public static DataSet ContentToString(HttpResponseMessage httpContent)
{
var readAsStringAsync = httpContent.Content.ReadAsAsync<DataSet>();
return readAsStringAsync.Result;
}
DataSet dsDownload = new DataSet();
//dsDownload = new Batch().DownloadBatch(Convert.ToInt32(ddlPractice.SelectedValue), ddlFileType.SelectedValue.ToString(), Session["ClientCode"].ToString(), System.DateTime.Now);
var userId = Convert.ToInt32(Session["Userid"]);
var client = new HttpClient();
client.Timeout = TimeSpan.FromMinutes(5);
// var authInfo = "admin" + ":" + "jasmine";
// authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", authInfo);
// var baseAddress = new Uri("http://localhost:56545/");
//var baseAddress = new Uri("http://173.201.28.153/WebAPI/");
var baseAddress = new Uri(System.Configuration.ConfigurationManager.AppSettings["APIPATH"]);
client.BaseAddress = baseAddress;
var response =
client.PostAsJsonAsync("api/Era/Download",
ff)
.Result;
//Response.Write(ContentToString(response));
dsDownload = ContentToString(response);
if (dsDownload.Tables[0].Rows[0]["ErrorCode"].ToString() == "0")
{
gvFiles.DataSource = dsDownload;
gvFiles.DataBind();
}
else
{
SetStatus(dsDownload.Tables[0].Rows[0]["ErrorMessage"].ToString());
}
No comments :
Post a Comment