private void UpgradeModule(EventMessage message)
 {
     try
     {
         string BusinessControllerClass = message.Attributes["BusinessControllerClass"];
         object objController = Framework.Reflection.CreateObject(BusinessControllerClass, "");
         Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController();
         Services.Log.EventLog.LogInfo objEventLogInfo;
         if (objController is IUpgradeable)
         {
             string[] UpgradeVersions = message.Attributes["UpgradeVersionsList"].ToString().Split(',');
             foreach (string Version in UpgradeVersions)
             {
                 string Results = ((IUpgradeable)objController).UpgradeModule(Version);
                 objEventLogInfo = new Services.Log.EventLog.LogInfo();
                 objEventLogInfo.AddProperty("Module Upgraded", BusinessControllerClass);
                 objEventLogInfo.AddProperty("Version", Version);
                 if (!string.IsNullOrEmpty(Results))
                 {
                     objEventLogInfo.AddProperty("Results", Results);
                 }
                 objEventLogInfo.LogTypeKey = Services.Log.EventLog.EventLogController.EventLogType.MODULE_UPDATED.ToString();
                 objEventLog.AddLog(objEventLogInfo);
             }
         }
         UpdateSupportedFeatures(objController, Convert.ToInt32(message.Attributes["DesktopModuleId"]));
     }
     catch (Exception exc)
     {
         Exceptions.LogException(exc);
     }
 }
 private static void CreateEventQueueMessage(ModuleInfo objModule, string strContent, string strVersion, int userID)
 {
     EventMessage oAppStartMessage = new EventMessage();
     oAppStartMessage.Priority = MessagePriority.High;
     oAppStartMessage.ExpirationDate = DateTime.Now.AddYears(-1);
     oAppStartMessage.SentDate = System.DateTime.Now;
     oAppStartMessage.Body = "";
     oAppStartMessage.ProcessorType = "CommonLibrary.Entities.Modules.EventMessageProcessor";
     oAppStartMessage.ProcessorCommand = "ImportModule";
     oAppStartMessage.Attributes.Add("BusinessControllerClass", objModule.DesktopModule.BusinessControllerClass);
     oAppStartMessage.Attributes.Add("ModuleId", objModule.ModuleID.ToString());
     oAppStartMessage.Attributes.Add("Content", strContent);
     oAppStartMessage.Attributes.Add("Version", strVersion);
     oAppStartMessage.Attributes.Add("UserID", userID.ToString());
     EventQueueController.SendMessage(oAppStartMessage, "Application_Start_FirstRequest");
 }
 private void ImportModule(EventMessage message)
 {
     try
     {
         string BusinessControllerClass = message.Attributes["BusinessControllerClass"];
         object objController = Framework.Reflection.CreateObject(BusinessControllerClass, "");
         if (objController is IPortable)
         {
             int ModuleId = Convert.ToInt32(message.Attributes["ModuleId"]);
             string Content = HttpContext.Current.Server.HtmlDecode(message.Attributes["Content"]);
             string Version = message.Attributes["Version"];
             int UserID = Convert.ToInt32(message.Attributes["UserId"]);
             ((IPortable)objController).ImportModule(ModuleId, Content, Version, UserID);
             ModuleController.SynchronizeModule(ModuleId);
         }
     }
     catch (Exception exc)
     {
         Exceptions.LogException(exc);
     }
 }
 private static EventMessage FillMessage(IDataReader dr, bool CheckForOpenDataReader)
 {
     EventMessage message;
     bool canContinue = true;
     if (CheckForOpenDataReader)
     {
         canContinue = false;
         if (dr.Read())
         {
             canContinue = true;
         }
     }
     if (canContinue)
     {
         message = new EventMessage();
         message.EventMessageID = Convert.ToInt32(Null.SetNull(dr["EventMessageID"], message.EventMessageID));
         message.Priority = (MessagePriority)Enum.Parse(typeof(MessagePriority), Convert.ToString(Null.SetNull(dr["Priority"], message.Priority)));
         message.ProcessorType = Convert.ToString(Null.SetNull(dr["ProcessorType"], message.ProcessorType));
         message.ProcessorCommand = Convert.ToString(Null.SetNull(dr["ProcessorCommand"], message.ProcessorCommand));
         message.Body = Convert.ToString(Null.SetNull(dr["Body"], message.Body));
         message.Sender = Convert.ToString(Null.SetNull(dr["Sender"], message.Sender));
         message.Subscribers = Convert.ToString(Null.SetNull(dr["Subscriber"], message.Subscribers));
         message.AuthorizedRoles = Convert.ToString(Null.SetNull(dr["AuthorizedRoles"], message.AuthorizedRoles));
         message.ExceptionMessage = Convert.ToString(Null.SetNull(dr["ExceptionMessage"], message.ExceptionMessage));
         message.SentDate = Convert.ToDateTime(Null.SetNull(dr["SentDate"], message.SentDate));
         message.ExpirationDate = Convert.ToDateTime(Null.SetNull(dr["ExpirationDate"], message.ExpirationDate));
         string xmlAttributes = Null.NullString;
         xmlAttributes = Convert.ToString(Null.SetNull(dr["Attributes"], xmlAttributes));
         message.DeserializeAttributes(xmlAttributes);
     }
     else
     {
         message = null;
     }
     return message;
 }
 public static bool SendMessage(EventMessage message, string eventName)
 {
     if (message.SentDate != null)
     {
         message.SentDate = DateTime.Now;
     }
     string[] subscribers = GetSubscribers(eventName);
     int intMessageID = Null.NullInteger;
     bool success = true;
     try
     {
         for (int indx = 0; indx <= subscribers.Length - 1; indx++)
         {
             intMessageID = DataProvider.Instance().AddEventMessage(eventName, (int)message.Priority, message.ProcessorType, message.ProcessorCommand, message.Body, message.Sender, subscribers[indx], message.AuthorizedRoles, message.ExceptionMessage, message.SentDate,
             message.ExpirationDate, message.SerializeAttributes());
         }
     }
     catch (Exception ex)
     {
         Exceptions.Exceptions.LogException(ex);
         success = Null.NullBoolean;
     }
     return success;
 }
 public abstract bool ProcessMessage(EventMessage message);
 public override bool ProcessMessage(EventMessage message)
 {
     try
     {
         switch (message.ProcessorCommand)
         {
             case "UpdateSupportedFeatures":
                 UpdateSupportedFeatures(message);
                 break;
             case "UpgradeModule":
                 UpgradeModule(message);
                 break;
             case "ImportModule":
                 ImportModule(message);
                 break;
             default:
                 break;
         }
     }
     catch (Exception ex)
     {
         message.ExceptionMessage = ex.Message;
         return false;
     }
     return true;
 }
 private void UpdateSupportedFeatures(EventMessage message)
 {
     string BusinessControllerClass = message.Attributes["BusinessControllerClass"];
     object objController = Framework.Reflection.CreateObject(BusinessControllerClass, "");
     UpdateSupportedFeatures(objController, Convert.ToInt32(message.Attributes["DesktopModuleId"]));
 }
 public void UpdateModuleInterfaces(ref DesktopModuleInfo desktopModuleInfo, string sender, bool forceAppRestart)
 {
     EventMessage oAppStartMessage = new EventMessage();
     oAppStartMessage.Sender = sender;
     oAppStartMessage.Priority = MessagePriority.High;
     oAppStartMessage.ExpirationDate = DateTime.Now.AddYears(-1);
     oAppStartMessage.SentDate = System.DateTime.Now;
     oAppStartMessage.Body = "";
     oAppStartMessage.ProcessorType = "CommonLibrary.Entities.Modules.EventMessageProcessor, CommonLibrary";
     oAppStartMessage.ProcessorCommand = "UpdateSupportedFeatures";
     oAppStartMessage.Attributes.Add("BusinessControllerClass", desktopModuleInfo.BusinessControllerClass);
     oAppStartMessage.Attributes.Add("DesktopModuleId", desktopModuleInfo.DesktopModuleID.ToString());
     EventQueueController.SendMessage(oAppStartMessage, "Application_Start");
     if ((forceAppRestart))
     {
         Config.Touch();
     }
 }
 public void Add(EventMessage message)
 {
     this.InnerList.Add(message);
 }