/// <summary>
 /// Does the on shutdown.
 /// </summary>
 static internal void DoOnShutdown()
 {
     try
     {
         OnShutdown?.Invoke();
     }
     catch (Exception ex)
     {
         RIExceptionManager.Publish(ex, "Failed during: RIEventManager.DoOnShutdown()");
     }
 }
 /// <summary>
 /// Does the on created instance.
 /// </summary>
 /// <param name="ri">The ri.</param>
 static internal void DoOnCreatedInstance(ReflectInsight ri)
 {
     try
     {
         OnCreatedInstance?.Invoke(ri);
     }
     catch (Exception ex)
     {
         RIExceptionManager.Publish(ex, "Failed during: RIEventManager.DoOnCreatedInstance()");
     }
 }
 /// <summary>
 /// Does the on configuration change.
 /// </summary>
 static internal void DoOnConfigChange()
 {
     try
     {
         OnConfigChange?.Invoke();
     }
     catch (Exception ex)
     {
         RIExceptionManager.Publish(ex, "Failed during: RIEventManager.DoOnConfigChange()");
     }
 }
 /// <summary>
 /// Does the on configuration settings initialized.
 /// </summary>
 /// <param name="settings">The settings.</param>
 static internal void DoOnConfigSettingsInitialized(ReflectInsightConfig settings)
 {
     try
     {
         OnConfigSettingsInitialized?.Invoke(settings);
     }
     catch (Exception ex)
     {
         RIExceptionManager.Publish(ex, "Failed during: RIEventManager.DoOnConfigSettingsInitialized()");
     }
 }
 /// <summary>
 /// Called when [configuration file change].
 /// </summary>
 static internal void OnConfigFileChange()
 {
     try
     {
         TraceHtttpRequest = ReflectInsightConfig.Settings.GetBaseTraceHttpRequestAttribute("enabled", "false").ToLower() == "true";
     }
     catch (Exception ex)
     {
         RIExceptionManager.Publish(ex, "Failed during: static TraceMethod.OnConfigFileChange()");
     }
 }
 /// <summary>
 /// Does the on queue exception.
 /// </summary>
 /// <param name="ex">The ex.</param>
 static internal void DoOnQueueException(Exception ex)
 {
     try
     {
         OnQueueException?.Invoke(ex);
         OnAllExceptions?.Invoke(ex);
     }
     catch (Exception exc)
     {
         RIExceptionManager.Publish(exc, "Failed during: RIEventManager.DoOnQueueException()");
     }
 }
        private static ReflectInsightConfig ReadAndCreateConfigObject(string configFile)
        {
            var exception = (Exception)null;

            var attempts = 5;

            while (true)
            {
                try
                {
                    using (FileStream fs = new FileStream(configFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                        using (TextReader tr = new StreamReader(fs))
                        {
                            var xmlData = tr.ReadToEnd();
                            var doc     = new XmlDocument()
                            {
                                PreserveWhitespace = true
                            };
                            doc.LoadXml(xmlData);

                            return(new ReflectInsightConfig(doc.SelectSingleNode("configuration/insightSettings")));
                        }
                }
                catch (FileNotFoundException)
                {
                    break;
                }
                catch (IOException ex)
                {
                    attempts--;
                    if (attempts < 0)
                    {
                        exception = ex;
                        break;
                    }

                    Thread.Sleep(100);
                }
                catch (Exception ex)
                {
                    exception = ex;
                    break;
                }
            }

            if (exception != null)
            {
                RIExceptionManager.Publish(exception, string.Format("ReflectInsightConfig: Error opening file: {0}", configFile));
            }

            return(null);
        }
Example #8
0
 public static void Dispatch(ReflectInsightPackage package, Int32 destinationBindingGroupId)
 {
     try
     {
         MessageQueue.SendMessage(new BoundReflectInsightPackage()
         {
             BindingGroupId = destinationBindingGroupId, Package = package
         });
     }
     catch (Exception ex)
     {
         RIExceptionManager.PublishIfEvented(ex, "Failed during: ReflectInsightDispatcher.Dispatch()");
     }
 }
Example #9
0
 static internal void OnConfigFileChange()
 {
     try
     {
         lock (FInstances)
         {
             ObtainConfigInstances();
         }
     }
     catch (Exception ex)
     {
         RIExceptionManager.Publish(ex, "Failed during: static RILogManager.OnConfigFileChange()");
     }
 }
Example #10
0
 static internal void OnConfigFileChange()
 {
     try
     {
         lock (MessageColors)
         {
             LoadConfigColors();
         }
     }
     catch (Exception ex)
     {
         RIExceptionManager.Publish(ex, "Failed during: static RIMessageColors.OnConfigFileChange()");
     }
 }
Example #11
0
 static internal void OnConfigFileChange()
 {
     try
     {
         lock (FListenerGroups)
         {
             RemoveConfigListenerGroups();
             ObtainConfigListenerGroups();
         }
     }
     catch (Exception ex)
     {
         RIExceptionManager.Publish(ex, "Failed during: static RIListenerGroupManager.OnConfigFileChange()");
     }
 }
Example #12
0
 private void OnConfigChange()
 {
     try
     {
         lock (this)
         {
             ActiveStates states = new ActiveStates()
             {
                 RI = RILogManager.Get(FInstanceName) ?? RILogManager.Default
             };
             Name = states.RI.Category;
             CurrentActiveStates = states;
         }
     }
     catch (Exception ex)
     {
         RIExceptionManager.Publish(ex, String.Format("Failed during: RITraceListener.OnConfigChange() for extension: {0}", FInstanceName));
     }
 }
Example #13
0
        public static void Dispatch(IEnumerable <ReflectInsightPackage> packages, Int32 destinationBindingGroupId)
        {
            try
            {
                List <BoundReflectInsightPackage> boundPackages = new List <BoundReflectInsightPackage>();
                foreach (ReflectInsightPackage package in packages)
                {
                    boundPackages.Add(new BoundReflectInsightPackage()
                    {
                        BindingGroupId = destinationBindingGroupId, Package = package
                    });
                }

                MessageQueue.SendMessages(boundPackages);
            }
            catch (Exception ex)
            {
                RIExceptionManager.PublishIfEvented(ex, "Failed during: ReflectInsightDispatcher.Dispatch()");
            }
        }
        static ReflectInsightService()
        {
            try
            {
                DebugTextLoggerManager.OnStartup();

                FLockObject = new Object();
                ProcessId   = Process.GetCurrentProcess().Id;
                SessionId   = (uint)Guid.NewGuid().ToString().BKDRHash();

                OnStartup();

                AppDomain.CurrentDomain.ProcessExit += OnShutdown;
                RIEventManager.OnConfigChange       += OnConfigFileChange;
            }
            catch (Exception ex)
            {
                RIExceptionManager.Publish(ex, "Failed during: static ReflectInsightService.ctor()");
            }
        }
Example #15
0
        static private void ExecuteProcessMessages()
        {
            try
            {
                while (true)
                {
                    Thread.Sleep(FSleep);

                    ProcessMessages();

                    if (DebugManager.DebugMessageProcessEnabled)
                    {
                        continue;
                    }

                    lock (FLockObject)
                    {
                        if (!MessageQueue.HasMessages)
                        {
                            break;
                        }
                    }

                    Thread.Sleep(FSleep);
                }
            }
            catch (ThreadAbortException)
            {
            }
            catch (Exception ex)
            {
                RIExceptionManager.PublishIfEvented(new ReflectInsightException("MessageManager.ExecuteProcessMessages detected an unhandled exception. Please see inner exception for more details.", ex));
                RIEventManager.DoOnQueueException(ex);
            }
            finally
            {
                IsProcessing = false;
            }
        }
        static private void OnStartup()
        {
            try
            {
                RIExceptionManager.OnStartup();
                MessageQueue.OnStartup();
                MessageManager.OnStartup();
                RIListenerGroupManager.OnStartup();
                DebugManager.OnStartup();
                RILogManager.OnStartup();
                RIMessageColors.OnStartup();
                TraceMethod.OnStartup();
                ReflectInsight.OnStartup();
                RIEventManager.DoOnStartup();

                RITraceListener.OnStartup();
            }
            catch (Exception ex)
            {
                RIExceptionManager.Publish(ex, "Failed during: static ReflectInsightService.OnStartup()");
            }
        }
 static private void OnConfigFileChange()
 {
     try
     {
         lock (FLockObject)
         {
             RIExceptionManager.OnConfigFileChange();
             MessageQueue.OnConfigFileChange();
             MessageManager.OnConfigFileChange();
             RIListenerGroupManager.OnConfigFileChange();
             RILogManager.OnConfigFileChange();
             RIMessageColors.OnConfigFileChange();
             TraceMethod.OnConfigFileChange();
             ReflectInsight.OnConfigFileChange();
             RIEventManager.DoOnServiceConfigChange();
         }
     }
     catch (Exception ex)
     {
         RIExceptionManager.Publish(ex, "Failed during: static ReflectInsightService.OnConfigFileChange()");
     }
 }
Example #18
0
        static public void AddListenersByDetails(List <ListenerInfo> listeners, String details)
        {
            if (string.IsNullOrWhiteSpace(details))
            {
                return;
            }

            try
            {
                try
                {
                    ValidateCorrectUseOfBrackets(details, '(', ')');
                    ValidateCorrectUseOfBrackets(details, '"', '"');

                    details = MaskSpecialSymbols(details);
                    String[] subDetails = details.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                    foreach (String subDetail in subDetails)
                    {
                        ValidateCorrectUseOfBrackets(subDetail, '[', ']');

                        listeners.Add(CreateListenerInfo(EnsureNoSpacesForListenerName(subDetail), GetParameters(subDetail)));
                    }
                }
                catch (ReflectInsightException)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    throw new ReflectInsightException(String.Format("Invalid Listener Details Format: {0}", details), ex);
                }
            }
            catch (Exception ex)
            {
                RIExceptionManager.Publish(ex, "Failed during: DetailParser.AddListenersByDetails()");
            }
        }
Example #19
0
 private void OnWriterThreadException(Exception ex)
 {
     RIExceptionManager.PublishIfEvented(ex);
 }