protected void btnSearch_Click(object sender, EventArgs e)
{
PageAsyncTask task = new PageAsyncTask(BeginGetrdgDetailsAsyncData, EndGetrdgDetailsAsyncData, null, null);
Page.RegisterAsyncTask(task);
}
IAsyncResult BeginGetrdgDetailsAsyncData(object src, EventArgs args, AsyncCallback cb, object state)
{
StringBuilder sb = new StringBuilder();
sb.Append("<SalesAnalysis>");
-----
-------
sb.Append("</SalesAnalysis>");
return pharma.BeginSales_Analysis(sb.ToString(), cb, state);
}
void EndGetrdgDetailsAsyncData(IAsyncResult ar)
{
try
{
String result = pharma.EndSales_Analysis(ar, out strerror);
if (strerror == "")
{
DataSet dsresult = new DataSet();
dsresult = JsonConvert.DeserializeObject<DataSet>(result);
DataView dv = new DataView(dsresult.Tables[2]);
DataTable distinctValues = dv.ToTable(true, "SCHEDULE_ID", "SCHEDULE_NAME");
for (int i = 0; i < distinctValues.Rows.Count; i++)
{
dsresult.Tables[1].Columns.Add(distinctValues.Rows[i]["SCHEDULE_NAME"].ToString());
DataRow[] drs = dsresult.Tables[1].Select("SCHEDULE_ID='" + distinctValues.Rows[i]["SCHEDULE_ID"].ToString() + "'");
if (drs.Length > 0)
{
//foreach (DataRow dr in drs)
//{
// //assigning usage col values under dynamically created col "EQ_DESC"
// dr[distinctValues.Rows[i]["SCHEDULE_NAME"].ToString()] = dr["Usage"].ToString();
// //usage += Convert.ToDecimal(dr["Usage"].ToString());
//}
}
}
rdgDetails.DataSource = dsresult.Tables[1];
rdgDetails.DataBind();
}
else
{
errormsg
}
}
catch (Exception ex)
{
}
}
--------------------------------------------------------------------------------
wcf
{
PageAsyncTask task = new PageAsyncTask(BeginGetrdgDetailsAsyncData, EndGetrdgDetailsAsyncData, null, null);
Page.RegisterAsyncTask(task);
}
IAsyncResult BeginGetrdgDetailsAsyncData(object src, EventArgs args, AsyncCallback cb, object state)
{
StringBuilder sb = new StringBuilder();
sb.Append("<SalesAnalysis>");
-----
-------
sb.Append("</SalesAnalysis>");
return pharma.BeginSales_Analysis(sb.ToString(), cb, state);
}
void EndGetrdgDetailsAsyncData(IAsyncResult ar)
{
try
{
String result = pharma.EndSales_Analysis(ar, out strerror);
if (strerror == "")
{
DataSet dsresult = new DataSet();
dsresult = JsonConvert.DeserializeObject<DataSet>(result);
DataView dv = new DataView(dsresult.Tables[2]);
DataTable distinctValues = dv.ToTable(true, "SCHEDULE_ID", "SCHEDULE_NAME");
for (int i = 0; i < distinctValues.Rows.Count; i++)
{
dsresult.Tables[1].Columns.Add(distinctValues.Rows[i]["SCHEDULE_NAME"].ToString());
DataRow[] drs = dsresult.Tables[1].Select("SCHEDULE_ID='" + distinctValues.Rows[i]["SCHEDULE_ID"].ToString() + "'");
if (drs.Length > 0)
{
//foreach (DataRow dr in drs)
//{
// //assigning usage col values under dynamically created col "EQ_DESC"
// dr[distinctValues.Rows[i]["SCHEDULE_NAME"].ToString()] = dr["Usage"].ToString();
// //usage += Convert.ToDecimal(dr["Usage"].ToString());
//}
}
}
rdgDetails.DataSource = dsresult.Tables[1];
rdgDetails.DataBind();
}
else
{
errormsg
}
}
catch (Exception ex)
{
}
}
--------------------------------------------------------------------------------
wcf
public String Sales_Analysis(String
strParameter, out string
error)
{
error = string.Empty;
XmlDocument
pdoc = new XmlDocument();
pdoc.LoadXml(strParameter);
DataSet
ds = new DataSet();
methodParameters = strParameter;
try
{
if
(dbclass.Connectdb(ConfigurationManager.ConnectionStrings["constr"].ConnectionString))
{
dbclass.cmd = new OracleCommand();
dbclass.cmd.CommandText = "Proc Name";
dbclass.cmd.CommandType = CommandType.StoredProcedure;
#region add parameters
//IN parameter..
//Out
parameter..
#endregion
ds =
dbclass.ExecuteCommandDataSet(dbclass.con, dbclass.cmd);
if
(ds.Tables[1].Rows.Count > 0)
{
return JsonConvert.SerializeObject(ds,
Newtonsoft.Json.Formatting.Indented);
}
else
{
return "[]";
}
}
}
catch
(Exception ex)
{
error = ex.Message;
}
return
JsonConvert.SerializeObject(ds,
Newtonsoft.Json.Formatting.Indented);
}