public ActionResult DownloadAllCompletedTranscriptionInformation() { //var username = Request.QueryString["username"].ToString(CultureInfo.InvariantCulture); var headers = new HeaderManager(Request); var id = Convert.ToInt32(Request.QueryString["id"]); var guid = Convert.ToString(Request.QueryString["guid"]); M2ESession session = TokenManager.getSessionInfo(guid); var clientTemplate = new ClientTemplateService(); var isValidToken = TokenManager.IsValidSession(guid); var fileName = "Transcription_" + session.UserName + "_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss"); if (isValidToken) { var CompletedTranscriptions = clientTemplate.GetAllCompletedTranscriptionInformation(session.UserName, id); var products = new System.Data.DataTable("teste"); var columnName = CompletedTranscriptions.Payload.options.Split(';'); foreach (var Column in columnName) { products.Columns.Add(Column, typeof(string)); } foreach (var userResponse in CompletedTranscriptions.Payload.data) { products.Rows.Add(); int count = 1; foreach (var item in userResponse.userResponseData) { products.Rows.Add(item); } products.Rows.Add(); products.Rows.Add("Transcription Image", userResponse.imageUrl); products.Rows.Add(); products.Rows.Add(); products.Rows.Add(); } var grid = new GridView(); grid.DataSource = products; grid.DataBind(); Response.ClearContent(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment; filename=" + fileName + ".xls"); Response.ContentType = "application/ms-excel"; Response.Charset = ""; StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); grid.RenderControl(htw); Response.Output.Write(sw.ToString()); Response.Flush(); Response.End(); return View("MyView"); } else { return null; } }
public JsonResult GetAllCompletedTranscriptionInformation() { //var username = Request.QueryString["username"].ToString(CultureInfo.InvariantCulture); var headers = new HeaderManager(Request); M2ESession session = TokenManager.getSessionInfo(headers.AuthToken, headers); var id = Convert.ToInt32(Request.QueryString["id"]); var clientTemplate = new ClientTemplateService(); var isValidToken = TokenManager.IsValidSession(headers.AuthToken); if (isValidToken) { return Json(clientTemplate.GetAllCompletedTranscriptionInformation(session.UserName, id)); } else { ResponseModel<string> response = new ResponseModel<string>(); response.Status = 401; response.Message = "Unauthorized"; return Json(response); } }