/// <summary> /// Execute polling /// </summary> /// restart public static void StartEventEngine(ActionEvent delegateEmbedded) { try { LogEngine.DirectEventViewerLog("Engine starting...", 4); var current = AppDomain.CurrentDomain; current.AssemblyResolve += HandleAssemblyResolve; LogEngine.Enabled = ConfigurationBag.Configuration.LoggingEngineEnabled; Debug.WriteLine("Load Engine configuration."); //****************************Check for updates //Check if need to update files received from partners Debug.WriteLine( $"Check Engine Syncronization {ConfigurationBag.Configuration.AutoSyncronizationEnabled}.", ConsoleColor.White); if (ConfigurationBag.Configuration.AutoSyncronizationEnabled) { EventsEngine.SyncronizePoint(); } //Set service states Debug.WriteLine("Initialize Engine Service states."); ServiceStates.RunPolling = ConfigurationBag.Configuration.RunInternalPolling; ServiceStates.RestartNeeded = false; Debug.WriteLine("Initialize Engine."); EventsEngine.InitializeEventEngine(delegateEmbedded); //Init Message ingestor MessageIngestor.InitSecondaryPersistProvider(); //Create the two sends layers Debug.WriteLine("Start Internal Event Engine Channel."); //in EventUpStream Debug.WriteLine("Start External Event Engine Channel."); //OnRamp start the OnRamp Engine var canStart = OffRampEngineSending.Init("MSP Device Component.dll (vNext)"); if (!canStart) { LogEngine.WriteLog( ConfigurationBag.EngineName, $"Error during engine service starting. Name: {ConfigurationBag.Configuration.ChannelName} - ID: {ConfigurationBag.Configuration.ChannelId}", Constant.LogLevelError, Constant.TaskCategoriesError, null, Constant.LogLevelError); Thread.Sleep(ConfigurationBag.Configuration.WaitTimeBeforeRestarting); Environment.Exit(0); } if (EventsEngine.HAEnabled) { Thread haCheck = new Thread(EventsEngine.HAPointsUpdate); haCheck.Start(); Thread haClean = new Thread(EventsEngine.HAPointsClean); haClean.Start(); } //*****************Event object stream area********************* //Load the global event and triggers dlls var numOfTriggers = 0; var numOfEvents = 0; var numOfComponents = 0; var triggersAndEventsLoaded = EventsEngine.LoadAssemblyComponents(ref numOfTriggers, ref numOfEvents, ref numOfComponents); if (triggersAndEventsLoaded) { Debug.WriteLine( $"Triggers loaded {numOfTriggers} - Events loaded {numOfEvents}", ConsoleColor.DarkCyan); } //Load the Active triggers and the active events EventsEngine.RefreshBubblingSetting(false); //Start triggers single instances EventsEngine.ExecuteBubblingTriggerConfigurationsSingleInstance(); //Start triggers polling instances if (ConfigurationBag.Configuration.EnginePollingTime > 0) { var treadPollingRun = new Thread(StartTriggerPolling); treadPollingRun.Start(); } else { LogEngine.WriteLog(ConfigurationBag.EngineName, $"Configuration.EnginePollingTime = {ConfigurationBag.Configuration.EnginePollingTime}, internal polling system disabled.", Constant.LogLevelError, Constant.TaskCategoriesError, null, Constant.LogLevelWarning); } //Start Engine Service Debug.WriteLine( "Asyncronous Threading Service state active.", ConsoleColor.DarkCyan); var treadEngineStates = new Thread(CheckServiceStates); treadEngineStates.Start(); Debug.WriteLine("Start On Ramp Engine.", ConsoleColor.Green); var onRampEngineReceiving = new OnRampEngineReceiving(); onRampEngineReceiving.Init("component.dll name"); // Configuration files watcher //****************************Start folder whatcher EventsEngine.StartFolderWatcherEngine(); //****************************Start folder whatcher LogEngine.WriteLog( ConfigurationBag.EngineName, $"Engine service initialization procedure terminated. Name: {ConfigurationBag.Configuration.ChannelName} - ID: {ConfigurationBag.Configuration.ChannelId}", Constant.LogLevelError, Constant.TaskCategoriesError, null, Constant.LogLevelInformation); LogEngine.DirectEventViewerLog("Engine started.", 4); } catch (Exception ex) { LogEngine.WriteLog( ConfigurationBag.EngineName, $"Error in {MethodBase.GetCurrentMethod().Name}", Constant.LogLevelError, Constant.TaskCategoriesError, ex, Constant.LogLevelError); } }