コード例 #1
0
        /// <summary>
        ///     Sync the local DLL trigger and events to the table storage
        /// </summary>
        public static void SyncLocalDLL(AssemblyEvent jitgAssemblyEvent)
        {
            try
            {
                var BubblingDirectory = Configuration.DirectoryOperativeRoot_ExeName();

                var assemblyFile = Path.Combine(BubblingDirectory, string.Concat(jitgAssemblyEvent.Type, "s"),
                                                jitgAssemblyEvent.FileName);
                //Set the primary key, if equal then check the assembly version
                if (!File.Exists(assemblyFile))
                {
                    LogEngine.ConsoleWriteLine("-NEW EVENT RECEIVED-", ConsoleColor.Green);
                    File.WriteAllBytes(assemblyFile, jitgAssemblyEvent.AssemblyContent);
                    LogEngine.ConsoleWriteLine("-NEW EVENT CREATED-", ConsoleColor.Green);
                }
                else
                {
                    //To avoid the lock
                    //Before delete all clones
                    LogEngine.ConsoleWriteLine("-SYNC EVENT-", ConsoleColor.Green);

                    var assembly = Assembly.LoadFile(assemblyFile);

                    var versionOnLocal   = assembly.GetName().Version;
                    var versionOnStorage = new Version(jitgAssemblyEvent.Version);

                    if (versionOnStorage.CompareTo(versionOnLocal) > 0)
                    {
                        LogEngine.ConsoleWriteLine(
                            string.Format("-SYNC EVENT TO DO- Local V.{0} Remote V. {1}", versionOnLocal,
                                          versionOnStorage), ConsoleColor.Green);
                        var assemblyUpdate = Path.ChangeExtension(assemblyFile, Configuration.General_UpdateFile);
                        File.WriteAllBytes(assemblyUpdate, jitgAssemblyEvent.AssemblyContent);
                        LogEngine.ConsoleWriteLine("-SYNC EVENT DONE-", ConsoleColor.Green);
                    }
                    assembly = null;
                }
            }
            catch (IOException ioException)
            {
                LogEngine.ConsoleWriteLine("-SYNC EVENT -", ConsoleColor.Red);
            }
            catch (UnauthorizedAccessException unauthorizedAccessException)
            {
                LogEngine.ConsoleWriteLine("-SYNC EVENT -", ConsoleColor.Red);
            }

            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);
            }
        }
コード例 #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);
     }
 }