private void OnRequest(object sender, EventArgs e) { var app = (HttpApplication)sender; if (!app.Request.Url.AbsoluteUri.ToLower().Contains("/onetrueerror/")) return; var reportId = app.Request.Form["reportId"]; if (string.IsNullOrEmpty(reportId)) return; var reportDTO = (ErrorReportDTO)TempData[reportId]; //Not allowed to upload report. if (app.Request.Form["Allowed"] != "true" && OneTrue.Configuration.UserInteraction.AskUserForPermission) { // accessor removes it. return; } if (reportDTO != null) OneTrue.UploadReport(reportDTO); var info = new UserSuppliedInformation(app.Request.Form["Description"], app.Request.Form["email"]); if (!string.IsNullOrEmpty(info.Description) || !string.IsNullOrEmpty(info.EmailAddress)) { OneTrue.LeaveFeedback(reportId, info); } app.Response.Redirect("~/"); app.Response.End(); }
// // Summary: // Upload an error report. // // Parameters: // dto: // Typically generated by OneTrueError.Client.OneTrue.GenerateReport(System.Exception). public static void UploadReport(ErrorReportDTO dto) { ExecuteRetryer retryer = new ExecuteRetryer(); retryer.Execute(() => { OneTrue.UploadReport(dto); }); }
private void OnError(object sender, EventArgs e) { var app = (HttpApplication)sender; if (!ConfigExtensions.CatchExceptions) return; var exception = app.Server.GetLastError(); var httpCodeIdentifier = new HttpCodeIdentifier(app, exception); var context = new HttpErrorReporterContext(this, exception) { HttpContext = app.Context, HttpStatusCode = httpCodeIdentifier.HttpCode, HttpStatusCodeName = httpCodeIdentifier.HttpCodeName, ErrorMessage = ExtractFirstLine(exception.Message) }; var dto = OneTrue.GenerateReport(context); var collection = dto.ContextCollections.FirstOrDefault( x => x.Name.Equals("ExceptionProperties", StringComparison.OrdinalIgnoreCase)); if (collection != null) { if (!collection.Properties.ContainsKey("HttpCode")) collection.Properties.Add("HttpCode", context.HttpStatusCode.ToString()); } if (OneTrue.Configuration.UserInteraction.AskUserForPermission) TempData[dto.ReportId] = dto; else OneTrue.UploadReport(dto); app.Response.StatusCode = context.HttpStatusCode; app.Response.StatusDescription = context.ErrorMessage; app.Response.TrySkipIisCustomErrors = true; app.Response.ContentEncoding = Encoding.UTF8; var pageContext = new PageGeneratorContext { Request = new HttpRequestWrapper(app.Request), Response = new HttpResponseWrapper(app.Response), ReporterContext = context, ReportId = dto.ReportId }; ConfigExtensions.ErrorPageGenerator.Generate(pageContext); app.Server.ClearError(); app.Response.End(); }
private void ReportToOneTrue() { var info = UserErrorDescription.UserDescription; var email = NotificationControl.Email; // only upload it if the flag is set, it have already been uploaded otherwise. if (AskForUserPermission) { OneTrue.UploadReport(_dto); } if (!string.IsNullOrEmpty(info) || !string.IsNullOrEmpty(email)) { OneTrue.LeaveFeedback(_dto.ReportId, new UserSuppliedInformation(info, email)); } }
private static void OnException(object sender, ThreadExceptionEventArgs e) { var context = new WinformsErrorReportContext(_instance, e.Exception); var dto = OneTrue.GenerateReport(context); if (!OneTrue.Configuration.UserInteraction.AskUserForPermission) { OneTrue.UploadReport(dto); } var ctx = new FormFactoryContext { Context = context, Report = dto }; var dialog = FormFactory(ctx); dialog.ShowDialog(); }
private void btnSubmit_Click_1(object sender, EventArgs e) { var info = errorDescription1.UserInfo; var email = notificationControl1.Email; // only upload it if the flag is set, it have already been uploaded otherwise. if (OneTrue.Configuration.UserInteraction.AskUserForPermission) { OneTrue.UploadReport(_dto); } if (!string.IsNullOrEmpty(info) || !string.IsNullOrEmpty(email)) { OneTrue.LeaveFeedback(_dto.ReportId, new UserSuppliedInformation(info, email)); } Close(); }
private static void OnException(object sender, DispatcherUnhandledExceptionEventArgs e) { var context = new WpfErrorReportContext(Instance, e.Exception); var dto = OneTrue.GenerateReport(context); if (!OneTrue.Configuration.UserInteraction.AskUserForPermission) { ActionWrapper.SafeActionExecution(() => OneTrue.UploadReport(dto)); } var ctx = new WindowFactoryContext { Context = context, Report = dto }; var dialog = WindowFactory(ctx); dialog.ShowDialog(); }
/// <summary> /// Do the OneTrueError collection pipeline. /// </summary> /// <param name="source">Thingy that detected the exception</param> /// <param name="exception">Exception that was caught</param> /// <param name="httpContext">Context currently executing</param> /// <param name="contextCollections">Extras</param> public static void ExecutePipeline(object source, Exception exception, HttpContextBase httpContext, params ContextCollectionDTO[] contextCollections) { if ( httpContext.Request.Url.AbsolutePath.IndexOf("/onetrueerror/submit", StringComparison.OrdinalIgnoreCase) != -1) { ProcessSubmit(httpContext); httpContext.Response.Redirect("~/"); return; } HttpApplication application = null; var module = source as ErrorHttpModule; if (module != null && module.Application != null) { application = module.Application; if (DisplayErrorPage) { module.Application.Response.Clear(); } } var httpCodeIdentifier = new HttpCodeIdentifier(application, exception); var reportingContext = new AspNetContext(application ?? source, exception, httpContext); var report = OneTrue.GenerateReport(reportingContext); if (contextCollections.Any()) { var newList = new List <ContextCollectionDTO>(report.ContextCollections); newList.AddRange(contextCollections); report.ContextCollections = newList.ToArray(); } // Add http code var exceptionCollection = report.ContextCollections.FirstOrDefault(x => x.Name == "ExceptionProperties"); if (exceptionCollection != null) { if (!exceptionCollection.Properties.ContainsKey("HttpCode")) { exceptionCollection.Properties["HttpCode"] = httpCodeIdentifier.HttpCode.ToString(); } } if (!DisplayErrorPage || !OneTrue.Configuration.UserInteraction.AskUserForPermission) { OneTrue.UploadReport(report); if (!DisplayErrorPage) { return; } } else { TempData[report.ReportId] = report; } var handler = new CustomControllerContext(exception, report.ReportId) { HttpCode = httpCodeIdentifier.HttpCode, HttpCodeName = httpCodeIdentifier.HttpCodeName }; var ctx = new HttpErrorReporterContext(source, exception, httpContext) { ErrorId = report.ReportId, HttpStatusCode = handler.HttpCode, HttpStatusCodeName = handler.HttpCodeName }; httpContext.Response.StatusCode = handler.HttpCode; httpContext.Response.StatusDescription = handler.HttpCodeName; handler.Execute(ctx); }