Пример #1
0
 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));
     }
 }
Пример #2
0
        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);
            }
        }
Пример #3
0
        async Task <bool> SendViaHttpWebRequestAsync(LogifyClientExceptionReport report)
        {
            WebRequest      request  = CreateAndSetupHttpWebRequest(report);
            HttpWebResponse response = await request.GetResponseAsync() as HttpWebResponse;

            return(response != null && response.StatusCode == HttpStatusCode.OK);
        }
Пример #4
0
        public bool SendExceptionReport(string reportContent)
        {
            LogifyClientExceptionReport report = new LogifyClientExceptionReport();

            report.ReportContent = new StringBuilder(reportContent);
            report.Data          = new Dictionary <string, object>();
            return(SendExceptionReport(report));
        }
Пример #5
0
 protected override async Task <bool> SendExceptionReportCoreAsync(LogifyClientExceptionReport report)
 {
     //Task task = Task.Factory.StartNew(() => {
     if (innerSender != null)
     {
         return(await SendExceptionReportInBackgroundAsync(innerSender, report));
     }
     //});
     return(true);
 }
Пример #6
0
 protected override bool SendExceptionReportCore(LogifyClientExceptionReport report)
 {
     //Task task = Task.Factory.StartNew(() => {
     if (innerSender != null)
     {
         return(SendExceptionReportInBackground(innerSender, report));
     }
     //});
     return(true);
 }
Пример #7
0
        bool ReportExceptionCore(Exception ex, IInfoCollector collector)
        {
            if (!ShouldSendExceptionReport())
            {
                return(false);
            }

            LogifyClientExceptionReport report = CreateExceptionReport(ex, collector);

            return(SendExceptionReport(report));
        }
Пример #8
0
 async Task <bool> SendExceptionReportAsync(LogifyClientExceptionReport report)
 {
     if (ReportSender != null)
     {
         return(await ReportSender.SendExceptionReportAsync(report));
     }
     else
     {
         return(true);
     }
 }
Пример #9
0
 bool SendExceptionReport(LogifyClientExceptionReport report)
 {
     if (ReportSender != null)
     {
         return(ReportSender.SendExceptionReport(report));
     }
     else
     {
         return(true);
     }
 }
Пример #10
0
        async Task <bool> ReportExceptionCoreAsync(Exception ex, IInfoCollector collector)
        {
            if (!ShouldSendExceptionReport())
            {
                return(false);
            }

            LogifyClientExceptionReport report = CreateExceptionReport(ex, collector);

            return(await SendExceptionReportAsync(report));
        }
Пример #11
0
 public static ReportConfirmationModel CreateConfirmationModel(LogifyClientExceptionReport report, Func <LogifyClientExceptionReport, bool> sendAction)
 {
     if (LogifyClientBase.Instance != null)
     {
         return(LogifyClientBase.Instance.CreateConfirmationModel(report, sendAction));
     }
     else
     {
         return(null);
     }
 }
Пример #12
0
 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);
 }
Пример #13
0
        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);
        }
Пример #14
0
        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);
        }
Пример #15
0
        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);
        }
Пример #16
0
        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();
        }
Пример #17
0
        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);
        }
Пример #18
0
        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 {
            }
        }
Пример #19
0
        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);
        }
Пример #20
0
        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);
            }
        }
Пример #21
0
        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);
            }
        }
Пример #22
0
 protected override async Task <bool> SendExceptionReportInBackgroundAsync(IExceptionReportSender innerSender, LogifyClientExceptionReport report)
 {
     if (innerSender != null)
     {
         return(await innerSender.SendExceptionReportAsync(report));
     }
     else
     {
         return(false);
     }
 }
Пример #23
0
 protected override bool SendExceptionReportInBackground(IExceptionReportSender innerSender, LogifyClientExceptionReport report)
 {
     if (innerSender != null)
     {
         return(innerSender.SendExceptionReport(report));
     }
     else
     {
         return(false);
     }
 }
Пример #24
0
        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));
        }
Пример #25
0
 protected abstract bool SendExceptionReportCore(LogifyClientExceptionReport report);
Пример #26
0
 protected abstract Task <bool> SendExceptionReportCoreAsync(LogifyClientExceptionReport report);
Пример #27
0
 protected override ReportConfirmationModel CreateConfirmationModel(LogifyClientExceptionReport report, Func <LogifyClientExceptionReport, bool> sendAction)
 {
     return(null);
 }
Пример #28
0
 public override async Task <bool> SendExceptionReportAsync(LogifyClientExceptionReport report)
 {
     //no dialog in async version
     return(await base.SendExceptionReportAsync(report));
 }
Пример #29
0
 protected override bool SendExceptionReportCore(LogifyClientExceptionReport report)
 {
     return(SendViaHttpWebRequest(report));
 }
Пример #30
0
 protected override async Task <bool> SendExceptionReportCoreAsync(LogifyClientExceptionReport report)
 {
     return(await SendViaHttpWebRequestAsync(report));
 }