Ejemplo n.º 1
0
        public virtual IExceptionReportSender Clone()
        {
            IExceptionReportSender clone = CreateEmptyClone();

            clone.CopyFrom(this);
            return(clone);
        }
Ejemplo n.º 2
0
        void CheckReportToDevExpressFileNameSpecified(IExceptionReportSender rootSender)
        {
            const string apiKey     = "12345678FEE1DEADBEEF4B1DBABEFACE";
            const string serviceUrl = "https://logify.devexpress.com";
            EmptyBackgroundExceptionReportSender root = rootSender as EmptyBackgroundExceptionReportSender;

            Assert.AreEqual(true, root != null);
            Assert.AreEqual(apiKey, root.ApiKey);
            Assert.AreEqual(serviceUrl, root.ServiceUrl);

            CompositeExceptionReportSender composite = root.InnerSender as CompositeExceptionReportSender;

            Assert.AreEqual(true, composite != null);
            Assert.AreEqual(apiKey, composite.ApiKey);
            Assert.AreEqual(serviceUrl, composite.ServiceUrl);

            ExternalProcessExceptionReportSender externalSender = composite.Senders[0] as ExternalProcessExceptionReportSender;

            Assert.AreEqual(true, externalSender != null);
            Assert.AreEqual(apiKey, externalSender.ApiKey);
            Assert.AreEqual(serviceUrl, externalSender.ServiceUrl);

            WinFormsExceptionReportSender winFormsSender = composite.Senders[1] as WinFormsExceptionReportSender;

            Assert.AreEqual(true, winFormsSender != null);
            Assert.AreEqual(apiKey, winFormsSender.ApiKey);
            Assert.AreEqual(serviceUrl, winFormsSender.ServiceUrl);

            //FileExceptionReportSender file = composite.Senders[2] as FileExceptionReportSender;
            //Assert.AreEqual(true, file != null);
            //Assert.AreEqual(apiKey, file.ApiKey);
            //Assert.AreEqual(serviceUrl, file.ServiceUrl);
            //Assert.AreEqual("exception.log", file.FileName);
        }
Ejemplo n.º 3
0
 static void CheckSenderConsistency(LogifyClientBase client, IExceptionReportSender sender)
 {
     //Assert.AreEqual(client.MiniDumpServiceUrl, sender.MiniDumpServiceUrl);
     Assert.AreEqual(client.ServiceUrl, sender.ServiceUrl);
     Assert.AreEqual(client.ConfirmSendReport, sender.ConfirmSendReport);
     Assert.AreEqual(client.ApiKey, sender.ApiKey);
 }
Ejemplo n.º 4
0
        void ApplyRecursively <TSender>(IExceptionReportSender sender, Action <TSender> action) where TSender : class
        {
            if (sender == null)
            {
                return;
            }
            TSender typedSender = sender as TSender;

            if (typedSender != null)
            {
                action(typedSender);
            }

            IExceptionReportSenderWrapper wrapper = sender as IExceptionReportSenderWrapper;

            if (wrapper != null)
            {
                ApplyRecursively <TSender>(wrapper.InnerSender, action);
            }

            CompositeExceptionReportSender composite = sender as CompositeExceptionReportSender;

            if (composite != null)
            {
                if (composite.Senders != null && composite.Senders.Count > 0)
                {
                    int count = composite.Senders.Count;
                    for (int i = 0; i < count; i++)
                    {
                        ApplyRecursively <TSender>(composite.Senders[i], action);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        static void CheckDefaultStructureAndPredicate(LogifyAlert client, Predicate <IExceptionReportSender> predicate)
        {
            IExceptionReportSender sender = ExceptionLoggerFactory.Instance.PlatformReportSender;

            Assert.AreEqual(true, sender != null);
            Assert.AreEqual(typeof(EmptyBackgroundExceptionReportSender), sender.GetType());
            CheckSenderConsistency(client, sender);
            predicate(sender);

            sender = ((EmptyBackgroundExceptionReportSender)sender).InnerSender;
            Assert.AreEqual(true, sender != null);
            Assert.AreEqual(typeof(CompositeExceptionReportSender), sender.GetType());
            CheckSenderConsistency(client, sender);
            predicate(sender);

            CompositeExceptionReportSender compositeSender = (CompositeExceptionReportSender)sender;

            CheckSenderConsistency(client, compositeSender);
            predicate(compositeSender);
            Assert.AreEqual(true, compositeSender.Senders != null);
            Assert.AreEqual(2, compositeSender.Senders.Count);

            sender = compositeSender.Senders[0];
            Assert.AreEqual(true, sender != null);
            Assert.AreEqual(typeof(WebExceptionReportSender), sender.GetType());
            CheckSenderConsistency(client, sender);
            predicate(sender);

            sender = compositeSender.Senders[1];
            Assert.AreEqual(true, sender != null);
            Assert.AreEqual(typeof(OfflineDirectoryExceptionReportSender), sender.GetType());
            CheckSenderConsistency(client, sender);
            predicate(sender);
        }
Ejemplo n.º 6
0
        public void SendOfflineReports()
        {
            try {
                if (!OfflineReportsEnabled)
                {
                    return;
                }

                IExceptionReportSender innerSender = CreateConfiguredPlatformExceptionReportSender();
                if (innerSender == null)
                {
                    return;
                }

                innerSender.ConfirmSendReport = false;
//                innerSender.ProxyCredentials = this.proxyCredentials;
//#if NETSTANDARD
//                innerSender.Proxy = this.Proxy;
//#endif
//                innerSender.ApiKey = this.ApiKey;
//                innerSender.ServiceUrl = this.ServiceUrl;
                //innerSender.MiniDumpServiceUrl = this.MiniDumpServiceUrl;

                ISavedReportSender savedReportsSender = CreateSavedReportsSender();
                if (savedReportsSender == null)
                {
                    return;
                }

                savedReportsSender.Sender        = innerSender;
                savedReportsSender.DirectoryName = this.OfflineReportsDirectory;
                savedReportsSender.TrySendOfflineReports();
            } catch {
            }
        }
Ejemplo n.º 7
0
        //const string serviceInfo = "/RW+Wzq8wasJP6LuHZcAbT2ShAvheOdnptsr/RI8zeCCfF6a+zXeWOhG0STFbxoLDjpzWj49DMTp0KZXufp4gz45nsSUwhcnrJC280vWliI=";
        protected void ReportToDevExpressCore(string uniqueUserId, string lastExceptionReportFileName, Assembly asm, IDictionary <string, string> customData)
        {
            IExceptionReportSender sender = ExceptionLoggerFactory.Instance.PlatformReportSender;

            if (sender != null && sender.CanSendExceptionReport())
            {
                return;
            }

            IExceptionReportSender reportSender = CreateExceptionReportSender();

            CompositeExceptionReportSender compositeSender = reportSender as CompositeExceptionReportSender;

            if (compositeSender == null)
            {
                compositeSender = new CompositeExceptionReportSender();
                compositeSender.Senders.Add(reportSender);
            }

            /*if (!String.IsNullOrEmpty(lastExceptionReportFileName)) {
             *  FileExceptionReportSender fileSender = new FileExceptionReportSender();
             *  fileSender.FileName = lastExceptionReportFileName;
             *  compositeSender.Senders.Add(fileSender);
             * }*/
            string[] info = GetServiceInfo(asm);
            if (info != null && info.Length == 2)
            {
                this.ServiceUrl = info[0]; // "http://logify.devexpress.com";
                this.ApiKey     = info[1]; // "12345678FEE1DEADBEEF4B1DBABEFACE";
                //if (this.ServiceUrl.StartsWith("http://", StringComparison.InvariantCultureIgnoreCase)) {
                if (CultureInfo.InvariantCulture.CompareInfo.IsPrefix(this.ServiceUrl, "http://", CompareOptions.IgnoreCase))
                {
                    this.ServiceUrl = "https://" + this.ServiceUrl.Substring("http://".Length);
                }
            }
            //this.MiniDumpServiceUrl = "http://logifydump.devexpress.com/";
            compositeSender.ServiceUrl = this.ServiceUrl;
            //compositeSender.ApiKey = "dx$" + logId;
            compositeSender.ApiKey = this.ApiKey;
            //compositeSender.MiniDumpServiceUrl = this.MiniDumpServiceUrl;
            this.AppName                = "DevExpress Demo or Design Time";
            this.AppVersion             = DetectDevExpressVersion(asm);
            this.UserId                 = uniqueUserId;
            this.ConfirmSendReport      = false;
            this.CollectBreadcrumbsCore = false;
            if (customData != null)
            {
                this.customData = customData;
            }

            //TODO:
            Config.CollectMiniDump = true;

            //apply values to config

            ExceptionLoggerFactory.Instance.PlatformReportSender = CreateBackgroundExceptionReportSender(compositeSender);
        }
Ejemplo n.º 8
0
 protected override bool SendExceptionReportInBackground(IExceptionReportSender innerSender, LogifyClientExceptionReport report)
 {
     if (innerSender != null)
     {
         return(innerSender.SendExceptionReport(report));
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 9
0
 protected override async Task <bool> SendExceptionReportInBackgroundAsync(IExceptionReportSender innerSender, LogifyClientExceptionReport report)
 {
     if (innerSender != null)
     {
         return(await innerSender.SendExceptionReportAsync(report));
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 10
0
        public virtual void CopyFrom(IExceptionReportSender instance)
        {
            this.ServiceUrl        = instance.ServiceUrl;
            this.ApiKey            = instance.ApiKey;
            this.ConfirmSendReport = instance.ConfirmSendReport;
            this.ProxyCredentials  = instance.ProxyCredentials;
#if NETSTANDARD
            this.Proxy = instance.Proxy;
#endif
            //this.MiniDumpServiceUrl = instance.MiniDumpServiceUrl;
            //this.LogId = instance.LogId;
        }
Ejemplo n.º 11
0
        protected IExceptionReportSender CreateConfiguredPlatformExceptionReportSender()
        {
            IExceptionReportSender result = CreateEmptyPlatformExceptionReportSender();

            result.ConfirmSendReport = ConfirmSendReport;
            result.ProxyCredentials  = ProxyCredentials;
#if NETSTANDARD
            result.Proxy = this.Proxy;
#endif
            result.ApiKey     = this.ApiKey;
            result.ServiceUrl = this.ServiceUrl;
            return(result);
        }
Ejemplo n.º 12
0
        public override void CopyFrom(IExceptionReportSender instance)
        {
            base.CopyFrom(instance);
            FileExceptionReportSender other = instance as FileExceptionReportSender;

            if (other == null)
            {
                return;
            }

            this.FileName = other.FileName;
            this.Append   = other.Append;
            this.Encoding = other.Encoding;
        }
Ejemplo n.º 13
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));
        }
Ejemplo n.º 14
0
        public override void CopyFrom(IExceptionReportSender instance)
        {
            base.CopyFrom(instance);
            OfflineDirectoryExceptionReportSender other = instance as OfflineDirectoryExceptionReportSender;

            if (other == null)
            {
                return;
            }

            this.DirectoryName = other.DirectoryName;
            this.Encoding      = other.Encoding;
            this.ReportCount   = other.ReportCount;
            this.IsEnabled     = other.IsEnabled;
        }
Ejemplo n.º 15
0
        protected override IExceptionReportSender CreateExceptionReportSender()
        {
            IExceptionReportSender defaultSender = CreateConfiguredPlatformExceptionReportSender();

            if (ConfirmSendReport)
            {
                return(defaultSender);
            }

            CompositeExceptionReportSender sender = new CompositeExceptionReportSender();

            sender.StopWhenFirstSuccess = true;
            //sender.Senders.Add(new ExternalProcessExceptionReportSender());
            sender.Senders.Add(defaultSender);
            sender.Senders.Add(new OfflineDirectoryExceptionReportSender());
            return(sender);
        }
Ejemplo n.º 16
0
        LogifyAlertRemoteConfiguration GetRemoteConfiguration()
        {
            IExceptionReportSender sender = CreateEmptyPlatformExceptionReportSender();

            if (sender == null)
            {
                return(null);
            }

            IRemoteConfigurationProvider provider = sender as IRemoteConfigurationProvider;

            if (provider == null)
            {
                return(null);
            }

            return(provider.GetConfiguration(this.ServiceUrl, this.ApiKey));
        }
Ejemplo n.º 17
0
        protected internal void InitAfterConfigure()
        {
            IExceptionReportSender reportSender = CreateExceptionReportSender();

            reportSender.ServiceUrl        = this.ServiceUrl;
            reportSender.ApiKey            = this.ApiKey;
            reportSender.ConfirmSendReport = this.ConfirmSendReport;
            reportSender.ProxyCredentials  = this.ProxyCredentials;
#if NETSTANDARD
            reportSender.Proxy = this.Proxy;
#endif
            //reportSender.MiniDumpServiceUrl = this.MiniDumpServiceUrl;
            ApplyRecursively <IOfflineDirectoryExceptionReportSender>(reportSender, (s) => { s.IsEnabled = this.OfflineReportsEnabled; });
            ApplyRecursively <IOfflineDirectoryExceptionReportSender>(reportSender, (s) => { s.DirectoryName = this.OfflineReportsDirectory; });
            ApplyRecursively <IOfflineDirectoryExceptionReportSender>(reportSender, (s) => { s.ReportCount = this.OfflineReportsCount; });

            ExceptionLoggerFactory.Instance.PlatformReportSender = CreateBackgroundExceptionReportSender(reportSender);
            //ExceptionLoggerFactory.Instance.PlatformIgnoreDetection = CreateIgnoreDetection();
        }
Ejemplo n.º 18
0
        public override void CopyFrom(IExceptionReportSender instance)
        {
            base.CopyFrom(instance);


            CompositeExceptionReportSender other = instance as CompositeExceptionReportSender;

            if (other == null)
            {
                return;
            }

            for (int i = 0; i < other.Senders.Count; i++)
            {
                this.Senders.Add(other.Senders[i].Clone());
            }

            this.StopWhenFirstSuccess = other.StopWhenFirstSuccess;
        }
Ejemplo n.º 19
0
        internal static async Task <bool> ReportExceptionAsync(Exception ex, IInfoCollector collector)
        {
            IExceptionReportSender reportSender = ExceptionLoggerFactory.Instance.PlatformReportSender;

            if (reportSender == null)
            {
                return(false);
            }

            if (collector == null)
            {
                return(false);
            }

            reportSender = reportSender.Clone();

            ExceptionLogger logger = new ExceptionLogger();

            logger.ReportSender = reportSender;
            return(await logger.PerformReportExceptionAsync(ex, collector));
        }
Ejemplo n.º 20
0
 public BackgroundThreadExceptionReportSender(IExceptionReportSender innerSender)
     : base(innerSender)
 {
 }
Ejemplo n.º 21
0
 protected BackgroundExceptionReportSender(IExceptionReportSender innerSender)
 {
     this.innerSender = innerSender;
 }
Ejemplo n.º 22
0
 public EmptyBackgroundExceptionReportSender(IExceptionReportSender innerSender)
     : base(innerSender)
 {
 }
Ejemplo n.º 23
0
 protected abstract Task <bool> SendExceptionReportInBackgroundAsync(IExceptionReportSender innerSender, LogifyClientExceptionReport report);
Ejemplo n.º 24
0
 protected abstract bool SendExceptionReportInBackground(IExceptionReportSender innerSender, LogifyClientExceptionReport report);
Ejemplo n.º 25
0
 protected virtual BackgroundExceptionReportSender CreateBackgroundExceptionReportSender(IExceptionReportSender reportSender)
 {
     return(new EmptyBackgroundExceptionReportSender(reportSender));
 }