Esempio n. 1
0
 private void Deserialize(string configXml)
 {
     if (!String.IsNullOrEmpty(configXml))
     {
         var xmlDoc = new XmlDocument {
             XmlResolver = null
         };
         xmlDoc.LoadXml(configXml);
         foreach (XmlElement xmlItem in xmlDoc.SelectNodes("/EventQueueConfig/PublishedEvents/Event"))
         {
             var oPublishedEvent = new PublishedEvent();
             oPublishedEvent.EventName   = xmlItem.SelectSingleNode("EventName").InnerText;
             oPublishedEvent.Subscribers = xmlItem.SelectSingleNode("Subscribers").InnerText;
             PublishedEvents.Add(oPublishedEvent.EventName, oPublishedEvent);
         }
         foreach (XmlElement xmlItem in xmlDoc.SelectNodes("/EventQueueConfig/EventQueueSubscribers/Subscriber"))
         {
             var oSubscriberInfo = new SubscriberInfo();
             oSubscriberInfo.ID          = xmlItem.SelectSingleNode("ID").InnerText;
             oSubscriberInfo.Name        = xmlItem.SelectSingleNode("Name").InnerText;
             oSubscriberInfo.Address     = xmlItem.SelectSingleNode("Address").InnerText;
             oSubscriberInfo.Description = xmlItem.SelectSingleNode("Description").InnerText;
             oSubscriberInfo.PrivateKey  = xmlItem.SelectSingleNode("PrivateKey").InnerText;
             EventQueueSubscribers.Add(oSubscriberInfo.ID, oSubscriberInfo);
         }
     }
 }
 private void Deserialize(string configXml)
 {
     if (!String.IsNullOrEmpty(configXml))
     {
         var xmlDoc = new XmlDocument();
         xmlDoc.LoadXml(configXml);
         foreach (XmlElement xmlItem in xmlDoc.SelectNodes("/EventQueueConfig/PublishedEvents/Event"))
         {
             var oPublishedEvent = new PublishedEvent();
             oPublishedEvent.EventName = xmlItem.SelectSingleNode("EventName").InnerText;
             oPublishedEvent.Subscribers = xmlItem.SelectSingleNode("Subscribers").InnerText;
             PublishedEvents.Add(oPublishedEvent.EventName, oPublishedEvent);
         }
         foreach (XmlElement xmlItem in xmlDoc.SelectNodes("/EventQueueConfig/EventQueueSubscribers/Subscriber"))
         {
             var oSubscriberInfo = new SubscriberInfo();
             oSubscriberInfo.ID = xmlItem.SelectSingleNode("ID").InnerText;
             oSubscriberInfo.Name = xmlItem.SelectSingleNode("Name").InnerText;
             oSubscriberInfo.Address = xmlItem.SelectSingleNode("Address").InnerText;
             oSubscriberInfo.Description = xmlItem.SelectSingleNode("Description").InnerText;
             oSubscriberInfo.PrivateKey = xmlItem.SelectSingleNode("PrivateKey").InnerText;
             EventQueueSubscribers.Add(oSubscriberInfo.ID, oSubscriberInfo);
         }
     }
 }
Esempio n. 3
0
        internal static EventQueueConfiguration GetConfig()
        {
            var config = (EventQueueConfiguration)DataCache.GetCache("EventQueueConfig");

            if ((config == null))
            {
                string filePath = Globals.HostMapPath + "EventQueue\\EventQueue.config";
                if (File.Exists(filePath))
                {
                    config = new EventQueueConfiguration();
                    //Deserialize into EventQueueConfiguration
                    config.Deserialize(FileSystemUtils.ReadFile(filePath));
                    //Set back into Cache
                    DataCache.SetCache("EventQueueConfig", config, new DNNCacheDependency(filePath));
                }
                else
                {
                    //make a default config file
                    config = new EventQueueConfiguration();
                    config.PublishedEvents       = new Dictionary <string, PublishedEvent>();
                    config.EventQueueSubscribers = new Dictionary <string, SubscriberInfo>();
                    var subscriber = new SubscriberInfo("DNN Core");
                    RegisterEventSubscription(config, "Application_Start", subscriber);
                    RegisterEventSubscription(config, "Application_Start_FirstRequest", subscriber);
                    SaveConfig(config, filePath);
                }
            }
            return(config);
        }
 public static void RegisterEventSubscription(EventQueueConfiguration config, string eventname, SubscriberInfo subscriber)
 {
     var e = new PublishedEvent();
     e.EventName = eventname;
     e.Subscribers = subscriber.ID;
     config.PublishedEvents.Add(e.EventName, e);
     if (!config.EventQueueSubscribers.ContainsKey(subscriber.ID))
     {
         config.EventQueueSubscribers.Add(subscriber.ID, subscriber);
     }
 }
        public static EventQueueConfiguration GetConfig()
        {
            EventQueueConfiguration config = (EventQueueConfiguration)DataCache.GetCache("EventQueueConfig");

            if (config == null)
            {
                string filePath = Globals.HostMapPath + "EventQueue\\EventQueue.config";
                if (File.Exists(filePath))
                {
                    config = new EventQueueConfiguration();
                    // Deserialize into EventQueueConfiguration
                    StreamReader oStreamReader = File.OpenText(filePath);
                    config.Deserialize(oStreamReader.ReadToEnd());
                    oStreamReader.Close();
                }
                else
                {
                    //make a default config file
                    SubscriberInfo si = new SubscriberInfo("DNN Core");
                    PublishedEvent e = new PublishedEvent();
                    e.EventName = "Application_Start";
                    e.Subscribers = si.ID.ToString();
                    config = new EventQueueConfiguration();
                    config.PublishedEvents = new PublishedEvents();
                    config.PublishedEvents.Add(e);
                    config.EventQueueSubscribers = new EventQueueSubscribers();
                    config.EventQueueSubscribers.Add(si);
                    StreamWriter oStream = File.CreateText(filePath);
                    oStream.WriteLine(config.Serialize());
                    oStream.Close();
                }
                if (File.Exists(filePath))
                {
                    // Create a dependency on the config file
                    CacheDependency dep = new CacheDependency(filePath);

                    // Set back into Cache
                    DataCache.SetCache("EventQueueConfig", config, dep);
                }
            }

            return config;
        }
Esempio n. 6
0
        public static EventQueueConfiguration GetConfig()
        {
            EventQueueConfiguration config = (EventQueueConfiguration)DataCache.GetCache("EventQueueConfig");

            if (config == null)
            {
                string filePath = Globals.HostMapPath + "EventQueue\\EventQueue.config";
                if (File.Exists(filePath))
                {
                    config = new EventQueueConfiguration();
                    // Deserialize into EventQueueConfiguration
                    StreamReader oStreamReader = File.OpenText(filePath);
                    config.Deserialize(oStreamReader.ReadToEnd());
                    oStreamReader.Close();
                }
                else
                {
                    //make a default config file
                    SubscriberInfo si = new SubscriberInfo("DNN Core");
                    PublishedEvent e  = new PublishedEvent();
                    e.EventName            = "Application_Start";
                    e.Subscribers          = si.ID.ToString();
                    config                 = new EventQueueConfiguration();
                    config.PublishedEvents = new PublishedEvents();
                    config.PublishedEvents.Add(e);
                    config.EventQueueSubscribers = new EventQueueSubscribers();
                    config.EventQueueSubscribers.Add(si);
                    StreamWriter oStream = File.CreateText(filePath);
                    oStream.WriteLine(config.Serialize());
                    oStream.Close();
                }
                if (File.Exists(filePath))
                {
                    // Create a dependency on the config file
                    CacheDependency dep = new CacheDependency(filePath);

                    // Set back into Cache
                    DataCache.SetCache("EventQueueConfig", config, dep);
                }
            }

            return(config);
        }
 public void Add(SubscriberInfo es)
 {
     this.Add(es.ID, es);
 }
Esempio n. 8
0
        public static void RegisterEventSubscription(EventQueueConfiguration config, string eventname, SubscriberInfo subscriber)
        {
            var e = new PublishedEvent();

            e.EventName   = eventname;
            e.Subscribers = subscriber.ID;
            config.PublishedEvents.Add(e.EventName, e);
            if (!config.EventQueueSubscribers.ContainsKey(subscriber.ID))
            {
                config.EventQueueSubscribers.Add(subscriber.ID, subscriber);
            }
        }
        internal static EventQueueConfiguration GetConfig()
        {
            var config = (EventQueueConfiguration) DataCache.GetCache("EventQueueConfig");
            if ((config == null))
            {
                string filePath = Globals.HostMapPath + "EventQueue\\EventQueue.config";
                if (File.Exists(filePath))
                {
                    config = new EventQueueConfiguration();
                    //Deserialize into EventQueueConfiguration
                    config.Deserialize(FileSystemUtils.ReadFile(filePath));
                    //Set back into Cache
                    DataCache.SetCache("EventQueueConfig", config, new DNNCacheDependency(filePath));
                }
                else
                {
					//make a default config file
                    config = new EventQueueConfiguration();
                    config.PublishedEvents = new Dictionary<string, PublishedEvent>();
                    config.EventQueueSubscribers = new Dictionary<string, SubscriberInfo>();
                    var subscriber = new SubscriberInfo("DNN Core");
                    RegisterEventSubscription(config, "Application_Start", subscriber);
                    RegisterEventSubscription(config, "Application_Start_FirstRequest", subscriber);
                    SaveConfig(config, filePath);
                }
            }
            return config;
        }
Esempio n. 10
0
 public void Add(SubscriberInfo es)
 {
     this.Add(es.ID, es);
 }