internal static void SaveConfig(EventQueueConfiguration config, string filePath) { StreamWriter oStream = File.CreateText(filePath); oStream.WriteLine(config.Serialize()); oStream.Close(); //Set back into Cache DataCache.SetCache("EventQueueConfig", config, new DNNCacheDependency(filePath)); }
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; }