public override bool SendExceptionReport(LogifyClientExceptionReport report) { if (ConfirmSendReport && !isFormShown && LogifyClientBase.Instance != null) { try { ReportConfirmationModel model = LogifyClientAccessor.CreateConfirmationModel(report, (r) => { return(base.SendExceptionReport(r)); }); if (model == null) { return(false); } isFormShown = true; if (ShowCustomConfirmSendForm(model)) { return(true); } return(ShowBuiltInConfirmSendForm(model)); } catch { return(false); } finally { isFormShown = false; } } else { return(base.SendExceptionReport(report)); } }
protected override bool SendExceptionReportCore(LogifyClientExceptionReport report) { try { if (!Directory.Exists(DirectoryName)) { Directory.CreateDirectory(DirectoryName); } if (!Directory.Exists(DirectoryName)) { return(false); } lock (typeof(OfflineDirectoryExceptionReportSender)) { EnsureHaveSpace(); string fileName = CreateTempFileName(DirectoryName); if (String.IsNullOrEmpty(fileName)) { return(false); } Encoding encoding = this.Encoding; if (encoding == null) { encoding = Encoding.UTF8; } File.WriteAllText(fileName, report.ReportString, encoding); return(true); } } catch { return(false); } }
async Task <bool> SendViaHttpWebRequestAsync(LogifyClientExceptionReport report) { WebRequest request = CreateAndSetupHttpWebRequest(report); HttpWebResponse response = await request.GetResponseAsync() as HttpWebResponse; return(response != null && response.StatusCode == HttpStatusCode.OK); }
public bool SendExceptionReport(string reportContent) { LogifyClientExceptionReport report = new LogifyClientExceptionReport(); report.ReportContent = new StringBuilder(reportContent); report.Data = new Dictionary <string, object>(); return(SendExceptionReport(report)); }
protected override async Task <bool> SendExceptionReportCoreAsync(LogifyClientExceptionReport report) { //Task task = Task.Factory.StartNew(() => { if (innerSender != null) { return(await SendExceptionReportInBackgroundAsync(innerSender, report)); } //}); return(true); }
protected override bool SendExceptionReportCore(LogifyClientExceptionReport report) { //Task task = Task.Factory.StartNew(() => { if (innerSender != null) { return(SendExceptionReportInBackground(innerSender, report)); } //}); return(true); }
bool ReportExceptionCore(Exception ex, IInfoCollector collector) { if (!ShouldSendExceptionReport()) { return(false); } LogifyClientExceptionReport report = CreateExceptionReport(ex, collector); return(SendExceptionReport(report)); }
async Task <bool> SendExceptionReportAsync(LogifyClientExceptionReport report) { if (ReportSender != null) { return(await ReportSender.SendExceptionReportAsync(report)); } else { return(true); } }
bool SendExceptionReport(LogifyClientExceptionReport report) { if (ReportSender != null) { return(ReportSender.SendExceptionReport(report)); } else { return(true); } }
async Task <bool> ReportExceptionCoreAsync(Exception ex, IInfoCollector collector) { if (!ShouldSendExceptionReport()) { return(false); } LogifyClientExceptionReport report = CreateExceptionReport(ex, collector); return(await SendExceptionReportAsync(report)); }
public static ReportConfirmationModel CreateConfirmationModel(LogifyClientExceptionReport report, Func <LogifyClientExceptionReport, bool> sendAction) { if (LogifyClientBase.Instance != null) { return(LogifyClientBase.Instance.CreateConfirmationModel(report, sendAction)); } else { return(null); } }
public virtual bool SendExceptionReport(LogifyClientExceptionReport report) { //TODO: maybe put report to disk, for further sending in case of unrecoverable error during send (no net or so on) for (int i = 0; i < RetryCount; i++) { try { if (SendExceptionReportCore(report)) { return(true); } } catch { } } return(false); }
public static LogifyClientExceptionReport CreateReportWithUserComments(LogifyClientExceptionReport originalReport, string userComments) { if (originalReport == null) { return(null); } LogifyClientExceptionReport report = originalReport; if (!String.IsNullOrEmpty(userComments)) { report = report.Clone(); AppendUserComments(report, userComments); } return(report); }
protected override bool SendExceptionReportCore(LogifyClientExceptionReport report) { bool result = false; int count = Senders.Count; for (int i = 0; i < count; i++) { try { if (Senders[i].CanSendExceptionReport()) { Senders[i].SendExceptionReport(report); result = true; } } catch { } } return(result); }
WebRequest CreateAndSetupHttpWebRequest(LogifyClientExceptionReport report) { WebRequest request = WebRequest.Create(CreateEndPointUrl(ServiceUrl, "api/report/newreport")); SetupProxy(request); request.Method = "POST"; request.Headers.Add("Authorization", "amx " + this.ApiKey); request.ContentType = "application/json"; byte[] buffer = Encoding.UTF8.GetBytes(report.ReportString); request.ContentLength = buffer.Length; using (Stream content = request.GetRequestStream()) { content.Write(buffer, 0, buffer.Length); content.Flush(); } return(request); }
static void AppendUserComments(LogifyClientExceptionReport report, string comments) { if (report == null || report.ReportContent == null) { return; } if (String.IsNullOrEmpty(comments)) { return; } comments = comments.Trim(); if (String.IsNullOrEmpty(comments)) { return; } StringBuilder reportContent = report.ReportContent; int lastBraceIndex = -1; for (int i = reportContent.Length - 1; i >= 0; i--) { if (reportContent[i] == '}') { lastBraceIndex = i; break; } } if (lastBraceIndex < 0) { return; } string commentsContent = GenerateCommentsContent(comments); if (String.IsNullOrEmpty(commentsContent)) { return; } report.ReportContent = reportContent.Insert(lastBraceIndex, commentsContent); report.ResetReportString(); }
LogifyClientExceptionReport CreateExceptionReport(Exception ex, IInfoCollector collector) { StringBuilder content = new StringBuilder(); StringWriter writer = new StringWriter(content); TextWriterLogger logger = new TextWriterLogger(writer); logger.BeginWriteObject(String.Empty); try { collector.Process(ex, logger); } finally { logger.EndWriteObject(String.Empty); } LogifyClientExceptionReport report = new LogifyClientExceptionReport(); report.ReportContent = content; report.Data = logger.Data; return(report); }
void TrySendSavedReport(string fileName) { try { FileInfo info = new FileInfo(fileName); if (info.Length > 1024 * 1024) // file size if more than 1Mb { File.Delete(fileName); return; } LogifyClientExceptionReport report = new LogifyClientExceptionReport(); StringBuilder content = new StringBuilder(File.ReadAllText(fileName)); report.ReportContent = content; if (Sender.SendExceptionReport(report)) { File.Delete(fileName); } } catch { } }
protected override async Task <bool> SendExceptionReportCoreAsync(LogifyClientExceptionReport report) { bool result = false; int count = Senders.Count; for (int i = 0; i < count; i++) { try { if (Senders[i].CanSendExceptionReport()) { bool success = await Senders[i].SendExceptionReportAsync(report); result = true; if (success && StopWhenFirstSuccess) { break; } } } catch { } } return(result); }
protected override bool SendExceptionReportCore(LogifyClientExceptionReport report) { try { string exePath = Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), "LogifySend.exe"); if (!File.Exists(exePath)) { return(false); } string reportPath = SaveReportToTemp(report.ReportString); if (String.IsNullOrEmpty(reportPath)) { return(false); } string configPath = SaveConfigToTemp(reportPath, report.Data); if (String.IsNullOrEmpty(configPath)) { return(false); } Process process = new Process(); process.StartInfo.FileName = exePath; process.StartInfo.Arguments = configPath; process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; //process.StartInfo.WindowStyle = ProcessWindowStyle.Normal; if (!process.Start()) { return(false); } if (process.WaitForExit(500) && process.HasExited) { return(process.ExitCode == 0); } return(true); } catch { return(false); } }
protected override bool SendExceptionReportCore(LogifyClientExceptionReport report) { try { Encoding encoding = this.Encoding; if (encoding == null) { encoding = Encoding.UTF8; } if (Append) { File.AppendAllText(FileName, report.ReportString, encoding); } else { File.WriteAllText(FileName, report.ReportString, encoding); } return(true); } catch { return(false); } }
protected override async Task <bool> SendExceptionReportInBackgroundAsync(IExceptionReportSender innerSender, LogifyClientExceptionReport report) { if (innerSender != null) { return(await innerSender.SendExceptionReportAsync(report)); } else { return(false); } }
protected override bool SendExceptionReportInBackground(IExceptionReportSender innerSender, LogifyClientExceptionReport report) { if (innerSender != null) { return(innerSender.SendExceptionReport(report)); } else { return(false); } }
protected override Task <bool> SendExceptionReportInBackgroundAsync(IExceptionReportSender innerSender, LogifyClientExceptionReport report) { Thread thread = new Thread(() => { if (innerSender != null) { innerSender.SendExceptionReport(report); } }); //thread.Priority = ThreadPriority.Highest; thread.Start(); //Thread.Sleep(3000); return(Task.FromResult(true)); }
protected abstract bool SendExceptionReportCore(LogifyClientExceptionReport report);
protected abstract Task <bool> SendExceptionReportCoreAsync(LogifyClientExceptionReport report);
protected override ReportConfirmationModel CreateConfirmationModel(LogifyClientExceptionReport report, Func <LogifyClientExceptionReport, bool> sendAction) { return(null); }
public override async Task <bool> SendExceptionReportAsync(LogifyClientExceptionReport report) { //no dialog in async version return(await base.SendExceptionReportAsync(report)); }
protected override bool SendExceptionReportCore(LogifyClientExceptionReport report) { return(SendViaHttpWebRequest(report)); }
protected override async Task <bool> SendExceptionReportCoreAsync(LogifyClientExceptionReport report) { return(await SendViaHttpWebRequestAsync(report)); }