protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (this.IsPostBack == false) { if (string.IsNullOrEmpty(Request.Params["surveyid"])) { throw new ArgumentNullException("surveyid"); } this.Surveyid = Int32.Parse(Request.Params["surveyid"]); if (Request.Params["textslanguage"] != null) { this.TextsLanguage = Int16.Parse(Request.Params["textslanguage"]); } if (Request.Params["viewId"] != null) { this.ViewId = Guid.Parse(Request.Params["viewId"]); } else { this.m_selectedView = SurveyManager.GetDefaultView(this.Surveyid); this.ViewId = this.SelectedView.ViewId; } } }
void SendFile(HttpRequest request, HttpResponse response, VLView view) { try { response.ClearHeaders(); response.Clear(); response.Cookies.Clear(); response.Cache.SetCacheability(HttpCacheability.NoCache); response.Charset = System.Text.UTF8Encoding.UTF8.WebName; String userAgent = HttpContext.Current.Request.Headers.Get("User-Agent"); if (userAgent.Contains("MSIE")) { response.AppendHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(view.PdfReportName.Replace(" ", "_"), System.Text.Encoding.UTF8)); } else { response.AppendHeader("Content-Disposition", "attachment; filename=" + view.PdfReportName.Replace(" ", "_")); } response.ContentType = "application/pdf"; SendFileFromFS(request, response, view); } catch (Exception ex) { Logger.Error(HttpContext.Current.Request.RawUrl, ex); throw; } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (this.IsPostBack == false) { if (Request.Params["viewId"] != null) { this.ViewId = Guid.Parse(Request.Params["viewId"]); } else { this.m_selectedView = SurveyManager.GetDefaultView(this.Surveyid); this.ViewId = this.SelectedView.ViewId; } } ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "JsSummaryArray", GetJsSummaryArray(this.ViewId), true); }
void SendFileFromFS(HttpRequest request, HttpResponse response, VLView view) { string acceptEncoding = request.Headers["Accept-Encoding"]; bool isGzipOutput = (!string.IsNullOrWhiteSpace(acceptEncoding) && acceptEncoding.Contains("gzip")); bool isDeflateOutput = (!string.IsNullOrWhiteSpace(acceptEncoding) && acceptEncoding.Contains("deflate")); Stream outputStream = null; bool disposeStream = false; try { string filepath = GetFilePath(view); string filename = view.PdfReportName; FileInfo fileInfo = new FileInfo(filepath); if (fileInfo.Exists) { int len = (int)fileInfo.Length; if (len <= TransmitFileUpperLimit) { response.TransmitFile(filepath); } else { StreamContent(request, response, len, System.IO.File.OpenRead(filepath)); } } } catch (Exception ex) { Logger.Error(HttpContext.Current.Request.RawUrl, ex); throw; } finally { if (outputStream != null && disposeStream) { ((IDisposable)outputStream).Dispose(); } } }
string GetFilePath(VLView view) { string rootDirectory = ValisSystem.Core.FileInventory.Path; return(Path.Combine(Path.Combine(rootDirectory, view.PdfReportPath), view.PdfReportName)); }