static void SendException(HttpContext context, Exception ex, HttpStatusCode status) { context.Response.ClearContent(); context.Response.ClearHeaders(); context.Response.ContentType = "text/html"; context.Response.Charset = Encoding.UTF8.WebName; context.Response.Cache.SetCacheability(HttpCacheability.NoCache); context.Response.TrySkipIisCustomErrors = true; context.Response.StatusCode = (int)status; //xhr.status context.Response.StatusDescription = status.ToString(); //xhr.statusText VLException vlex = ex as VLException; Int32 refId = NextRefId(); if (vlex != null) { refId = vlex.ReferenceId; Logger.Error(string.Format("RefId={0}, RawUrl={1}", refId, context.Request.RawUrl), ex); } else { Logger.Error(string.Format("RefId={0}, RawUrl={1}", refId, context.Request.RawUrl), ex); } var sb = new StringBuilder(); sb.AppendFormat("<div class=\"requestWrapper\">Request: {0}</div>", context.Request.FilePath); if (ex != null) { sb.Append("<div class=\"errorContainer\">"); sb.AppendFormat("<span class=\"errorText\">Reference number = {0} (required for support).</span><br /><br />", refId); while (ex != null) { sb.AppendFormat("<span class=\"errorText\">{0}</span>", context.Server.HtmlEncode(ex.Message)); ex = ex.InnerException; } sb.Append("</div>"); } //context.Response.Write("<html><head></head><body>"); context.Response.Write(sb.ToString()); //context.Response.Write("</body></html>"); context.Response.Flush(); context.Response.End();//throws a ThreadAbortException //HttpContext.Current.ApplicationInstance.CompleteRequest(); }
public static void CreateExcelDocument(VLSurveyManager surveyManager, VLSurvey survey, Collection <VLSurveyQuestionEx> questions, Collection <VLResponseEx> responses, string excelFilename) { try { using (SpreadsheetDocument document = SpreadsheetDocument.Create(excelFilename, SpreadsheetDocumentType.Workbook)) { WriteExcelFile(surveyManager, survey, questions, responses, document); } } catch (VLException ex) { var message = string.Format("An exception occured while calling AllResponsesXlsExport.CreateExcelDocument(), AccessTokenId={0}, surveyId={1}, excelFilename={2}", surveyManager.AccessTokenId, survey, excelFilename); Logger.Error(string.Format("RefId={0}, {1}", ex.ReferenceId, message), ex); throw new VLException(ex.Message, ex.ReferenceId); } catch (Exception ex) { var message = string.Format("An exception occured while calling AllResponsesXlsExport.CreateExcelDocument(), AccessTokenId={0}, surveyId={1}, excelFilename={2}", surveyManager.AccessTokenId, survey, excelFilename); var nex = new VLException(message, ex); Logger.Error(string.Format("RefId={0}, {1}", nex.ReferenceId, message), ex); throw nex; } }