private static void CreateExternConfigFileWatcher(string filePath)
        {
            lock (Lockobject)
            {
                DisposeExternConfigFileWatcher();

                FExternConfigFileWatcher = new FileSystemWatcher();
                try
                {
                    FExternConfigFileWatcher.BeginInit();
                    try
                    {
                        FExternConfigFileWatcher.Path                = Path.GetDirectoryName(filePath);
                        FExternConfigFileWatcher.Filter              = Path.GetFileName(filePath);
                        FExternConfigFileWatcher.NotifyFilter        = NotifyFilters.FileName | NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.CreationTime | NotifyFilters.Size;
                        FExternConfigFileWatcher.Changed            += OnConfigFileChanged;
                        FExternConfigFileWatcher.Created            += OnConfigFileChanged;
                        FExternConfigFileWatcher.Deleted            += OnConfigFileChanged;
                        FExternConfigFileWatcher.EnableRaisingEvents = true;
                    }
                    finally
                    {
                        FExternConfigFileWatcher.EndInit();
                    }
                }
                catch (Exception ex)
                {
                    DisposeExternConfigFileWatcher();
                    RIExceptionManager.Publish(ex, string.Format("ReflectInsightConfig: Cannot create FileSystemWatcher for file: {0}", filePath));
                }
            }
        }
        static private void OnShutdown()
        {
            try
            {
                AppDomain.CurrentDomain.ProcessExit -= OnShutdown;
                RIEventManager.OnConfigChange       -= OnConfigFileChange;

                RIEventManager.DoOnShutdown();
                ReflectInsight.OnShutdown();
                DebugManager.OnShutdown();
                RIMessageColors.OnShutdown();
                RILogManager.OnShutdown();
                RIListenerGroupManager.OnShutdown();
                ReflectInsightConfig.OnShutdown();
                TraceMethod.OnShutdown();

                RITraceListener.OnShutdown();
            }
            catch (Exception ex)
            {
                RIExceptionManager.Publish(ex, "Failed during: static ReflectInsightService.OnShutdown()");
            }
            finally
            {
                RIExceptionManager.OnShutdown();
                DebugTextLoggerManager.OnShutdown();
            }
        }
예제 #3
0
        static private void SendPackages(DestinationInfo[] destinations)
        {
            foreach (DestinationInfo dInfo in destinations)
            {
                try
                {
                    ReflectInsightPackage[] messages = dInfo.GetInterimMessages();
                    if (messages.Length > 0)
                    {
                        try
                        {
                            InvokeListeners.Receive(dInfo, dInfo.GetInterimMessages());
                        }
                        finally
                        {
                            dInfo.ClearInterimMessageQueue();
                            DebugManager.Sleep(0);
                        }
                    }
                }
                catch (ThreadAbortException)
                {
                }
                catch (Exception ex)
                {
                    if (RIExceptionManager.CanEvent(ex))
                    {
                        RIExceptionManager.Publish(new ReflectInsightException(String.Format("MessageManager.InvokeListeners: unhandled exception was detected in destination message loop for destination: {0}", dInfo.Name), ex));
                    }

                    RIEventManager.DoOnQueueException(ex);
                }
            }
        }
        private static void OnConfigFileChanged(object source, FileSystemEventArgs e)
        {
            try
            {
                var fileWatcher = (source as FileSystemWatcher);
                if (fileWatcher != null)
                {
                    fileWatcher.EnableRaisingEvents = false;
                }

                try
                {
                    var newFileTimestamp = File.GetLastWriteTime(e.FullPath);
                    if (newFileTimestamp != FLastFileChangeTimestamp)
                    {
                        FLastFileChangeTimestamp = newFileTimestamp;
                        DoOnConfigFileChanged(e);
                    }
                }
                finally
                {
                    if (fileWatcher != null)
                    {
                        fileWatcher.EnableRaisingEvents = true;
                    }
                }
            }
            catch (Exception ex)
            {
                RIExceptionManager.Publish(ex, "Failed during: static ReflectInsightConfig.OnConfigFileChanged()");
            }
        }
 /// <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 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>
 /// Does the on configuration change.
 /// </summary>
 static internal void DoOnConfigChange()
 {
     try
     {
         OnConfigChange?.Invoke();
     }
     catch (Exception ex)
     {
         RIExceptionManager.Publish(ex, "Failed during: RIEventManager.DoOnConfigChange()");
     }
 }
 /// <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 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 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);
        }
예제 #12
0
 static internal void OnConfigFileChange()
 {
     try
     {
         lock (MessageColors)
         {
             LoadConfigColors();
         }
     }
     catch (Exception ex)
     {
         RIExceptionManager.Publish(ex, "Failed during: static RIMessageColors.OnConfigFileChange()");
     }
 }
예제 #13
0
 static internal void OnConfigFileChange()
 {
     try
     {
         lock (FInstances)
         {
             ObtainConfigInstances();
         }
     }
     catch (Exception ex)
     {
         RIExceptionManager.Publish(ex, "Failed during: static RILogManager.OnConfigFileChange()");
     }
 }
예제 #14
0
 static internal void OnConfigFileChange()
 {
     try
     {
         lock (FListenerGroups)
         {
             RemoveConfigListenerGroups();
             ObtainConfigListenerGroups();
         }
     }
     catch (Exception ex)
     {
         RIExceptionManager.Publish(ex, "Failed during: static RIListenerGroupManager.OnConfigFileChange()");
     }
 }
예제 #15
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));
     }
 }
        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()");
            }
        }
 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()");
     }
 }
        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()");
            }
        }
예제 #19
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()");
            }
        }