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); } } }
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; }
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(PublishedEvent pe) { this.Add(pe.EventName, pe); }