Example #1
0
 /// <summary>
 ///     Send local shared dll for the sync to the partner request
 /// </summary>
 /// <param name="Partner">Partner request to send</param>
 public static void SyncSendLocalDLLList(string DestinationPartner)
 {
     try
     {
         EventsEngine.UpdateAssemblyEventListShared();
         foreach (var jitgAssemblyEvent in EventsEngine.AssemblyEventListShared)
         {
             LogEngine.ConsoleWriteLine(
                 string.Format("SENT EVENT - {0} to {1}", jitgAssemblyEvent.FileName, DestinationPartner),
                 ConsoleColor.Green);
             OffRampEngineSending.SendMessageOnRamp(jitgAssemblyEvent, Configuration.MessageDataProperty.SyncSendLocalDLL,
                                                    DestinationPartner, null);
         }
     }
     catch (InvalidOperationException eoe)
     {
         LogEngine.ConsoleWriteLine(
             string.Format("Syncronization and Dictionaries rebuilded, Excpetion controlled - {0}", eoe.HResult),
             ConsoleColor.DarkRed);
     }
     catch (Exception ex)
     {
         LogEngine.WriteLog(Configuration.General_Source,
                            string.Format("Error in {0}", MethodBase.GetCurrentMethod().Name),
                            Constant.Error_EventID_High_Critical_,
                            Constant.TaskCategories_,
                            ex,
                            EventLogEntryType.Error);
     }
 }
Example #2
0
 /// <summary>
 ///     Send local shared dll for the sync to the partner request
 /// </summary>
 /// <param name="Partner">Partner request to send</param>
 public static void SyncSendLocalDLL(AssemblyEvent jitgAssemblyEvent, string DestinationPartner)
 {
     try
     {
         EventsEngine.UpdateAssemblyEventListShared();
         LogEngine.ConsoleWriteLine(
             string.Format("SENT EVENT - {0} to {1}", jitgAssemblyEvent.FileName, DestinationPartner),
             ConsoleColor.Green);
         OffRampEngineSending.SendMessageOnRamp(jitgAssemblyEvent, Configuration.MessageDataProperty.SyncSendLocalDLL,
                                                DestinationPartner, null);
     }
     catch (Exception ex)
     {
         LogEngine.WriteLog(Configuration.General_Source,
                            string.Format("Error in {0}", MethodBase.GetCurrentMethod().Name),
                            Constant.Error_EventID_High_Critical_,
                            Constant.TaskCategories_,
                            ex,
                            EventLogEntryType.Error);
     }
 }
Example #3
0
        /// <summary>
        ///     Execute polling
        /// </summary>
        /// restart
        public static void StartEventEngine(SetEventActionEvent delegateActionEventEmbedded)
        {
            try
            {
                var current = AppDomain.CurrentDomain;
                current.AssemblyResolve += HandleAssemblyResolve;

                LogEngine.Enabled = Configuration.LoggingEngineEnabled();
                LogEngine.ConsoleWriteLine("Load Engine configuration.", ConsoleColor.White);

                //****************************Check for updates
                //Check if need to update files received from partners
                LogEngine.ConsoleWriteLine("Check Engine Syncronization.", ConsoleColor.White);
                EventsEngine.CheckForFileToUpdate();
                //****************************Check for updates

                //Set service states
                LogEngine.ConsoleWriteLine("Initialize Engine Service states.", ConsoleColor.White);
                ServiceStates.RunPolling    = true;
                ServiceStates.RestartNeeded = false;

                LogEngine.ConsoleWriteLine("Initialize Engine.", ConsoleColor.Cyan);
                EventsEngine.InitializeEventEngine(delegateActionEventEmbedded);

                //Init Message ingestor
                MessageIngestor.Init();

                //Create the two sends layers
                // in EventsEngine
                if (!Configuration.DisableExternalEventsStreamEngine())
                {
                    LogEngine.ConsoleWriteLine("Start Internal Event Engine Channel.", ConsoleColor.Yellow);
                    var canStart = EventsEngine.CreateEventUpStream();

                    if (!canStart)
                    {
                        LogEngine.WriteLog(
                            Configuration.EngineName,
                            $"Error during engine service starting. Name: {Configuration.EngineName} - ID: {Configuration.ChannelId()}",
                            Constant.DefconOne,
                            Constant.TaskCategoriesError,
                            null,
                            EventLogEntryType.Error);
                        Thread.Sleep(Configuration.WaitTimeBeforeRestarting());
                        Environment.Exit(0);
                    }

                    //in EventUpStream
                    LogEngine.ConsoleWriteLine("Start External Event Engine Channel.", ConsoleColor.Yellow);
                    //OnRamp start the OnRamp Engine
                    canStart = OffRampEngineSending.Init("MSP Device Component.dll (vNext)");

                    if (!canStart)
                    {
                        LogEngine.WriteLog(
                            Configuration.EngineName,
                            $"Error during engine service starting. Name: {Configuration.ChannelName()} - ID: {Configuration.ChannelId()}",
                            Constant.DefconOne,
                            Constant.TaskCategoriesError,
                            null,
                            EventLogEntryType.Error);
                        Thread.Sleep(Configuration.WaitTimeBeforeRestarting());
                        Environment.Exit(0);
                    }
                }

                //*****************Event object stream area*********************
                //Load the global event and triggers dlls
                var numOfTriggers = 0;
                var numOfEvents   = 0;

                var triggersAndEventsLoaded = EventsEngine.LoadBubblingEventList(ref numOfTriggers, ref numOfEvents);
                if (triggersAndEventsLoaded)
                {
                    LogEngine.ConsoleWriteLine(
                        $"Triggers loaded {numOfTriggers} - Events loaded {numOfEvents}",
                        ConsoleColor.DarkCyan);
                }

                EventsEngine.UpdateAssemblyEventListShared();
                //Load the Active triggers and the active events
                EventsEngine.RefreshBubblingSetting();
                //Start triggers single instances
                EventsEngine.ExecuteBubblingTriggerConfigurationsSingleInstance();
                //Start triggers polling instances
                if (Configuration.EnginePollingTime() > 0)
                {
                    var treadPollingRun = new Thread(StartTriggerPolling);
                    treadPollingRun.Start();
                }
                else
                {
                    LogEngine.WriteLog(Configuration.EngineName,
                                       $"Configuration.EnginePollingTime = {Configuration.EnginePollingTime()}, internal polling system disabled.",
                                       Constant.DefconOne,
                                       Constant.TaskCategoriesError,
                                       null,
                                       EventLogEntryType.Warning);
                }

                //Start Engine Service
                LogEngine.ConsoleWriteLine(
                    "Asyncronous Threading Service state active.",
                    ConsoleColor.DarkCyan);
                var treadEngineStates = new Thread(CheckServiceStates);
                treadEngineStates.Start();

                if (!Configuration.DisableExternalEventsStreamEngine())
                {
                    LogEngine.ConsoleWriteLine("Start On Ramp Engine.", ConsoleColor.Green);
                    var onRampEngineReceiving = new OnRampEngineReceiving();
                    onRampEngineReceiving.Init("component.dll name");
                }
                // Configuration files watcher
                EventsEngine.StartConfigurationSyncEngine();

                LogEngine.WriteLog(
                    Configuration.EngineName,
                    $"Engine service initialization procedure terminated. Name: {Configuration.ChannelName()} - ID: {Configuration.ChannelId()}",
                    Constant.DefconOne,
                    Constant.TaskCategoriesError,
                    null,
                    EventLogEntryType.Information);
            }
            catch (Exception ex)
            {
                LogEngine.WriteLog(
                    Configuration.EngineName,
                    $"Error in {MethodBase.GetCurrentMethod().Name}",
                    Constant.DefconOne,
                    Constant.TaskCategoriesError,
                    ex,
                    EventLogEntryType.Error);
            }
        }