/// <summary> /// Loads application wide cached data into the Application Object. This routine /// is called at startup, when the Application_Start event is thrown. /// </summary> public static void LoadApplicationObjectCacheData() { HttpContext currentHttpContext = HttpContext.Current; NameValueCollection appSettingsCollection = (NameValueCollection)ConfigurationManager.GetSection("appSettings"); // read data from web.config string defaultFromEmailAddress = appSettingsCollection["DefaultFromEmailAddress"].ToString(); string defaultToEmailAddress = appSettingsCollection["DefaultToEmailAddress"].ToString(); string emailPasswordSubject = appSettingsCollection["EmailPasswordSubject"].ToString(); string emailThreadNotificationSubject = appSettingsCollection["EmailThreadNotificationSubject"].ToString(); string siteName = appSettingsCollection["SiteName"].ToString(); string virtualRoot = appSettingsCollection["VirtualRoot"].ToString(); string ipBanComplainEmailAddress = appSettingsCollection["IPBanComplainEmailAddress"].ToString(); int maxAmountMessagesPerPage = Convert.ToInt32(appSettingsCollection["MaxAmountMessagesPerPage"]); string datafilesPath = currentHttpContext.Server.MapPath(appSettingsCollection["DatafilesPath"].ToString()); string ubbMessageTransformXSLPathFilename = appSettingsCollection["UBBMessageTransformXSLPathFilename"].ToString(); string ubbSignatureTransformXSLPathFilename = appSettingsCollection["UBBSignatureTransformXSLPathFilename"].ToString(); // Load XML -> HTML transformation XSL XslCompiledTransform messageStyle = new XslCompiledTransform(); XslCompiledTransform signatureStyle = new XslCompiledTransform(); messageStyle.Load(Path.Combine(datafilesPath, ubbMessageTransformXSLPathFilename)); signatureStyle.Load(Path.Combine(datafilesPath, ubbSignatureTransformXSLPathFilename)); Hashtable noiseWords = GuiHelper.LoadNoiseWordsIntoHashtable(datafilesPath); string registrationReplyMailTemplate = File.ReadAllText(Path.Combine(datafilesPath, "RegistrationReplyMail.template")); string threadUpdatedNotificationTemplate = File.ReadAllText(Path.Combine(datafilesPath, "ThreadUpdatedNotification.template")); // add other email templates here. // fetch all banned users and store them in the set of users to logout by force. DataView bannedNicknames = UserGuiHelper.GetAllBannedUserNicknamesAsDataView(); Hashtable usersToLogoutByForce = new Hashtable(); foreach (DataRowView row in bannedNicknames) { usersToLogoutByForce.Add(row["Nickname"].ToString(), null); } // store them into the application object. HttpApplicationState applicationState = currentHttpContext.Application; try { applicationState.Lock(); applicationState.Add("defaultFromEmailAddress", defaultFromEmailAddress); applicationState.Add("defaultToEmailAddress", defaultFromEmailAddress); applicationState.Add("siteName", siteName); applicationState.Add("virtualRoot", virtualRoot); applicationState.Add("datafilesMapPath", datafilesPath); applicationState.Add("emailPasswordSubject", emailPasswordSubject); applicationState.Add("emailThreadNotificationSubject", emailThreadNotificationSubject); applicationState.Add("messageStyle", messageStyle); applicationState.Add("signatureStyle", signatureStyle); applicationState.Add("noiseWords", noiseWords); applicationState.Add("maxAmountMessagesPerPage", maxAmountMessagesPerPage); applicationState.Add("IPBanComplainEmailAddress", ipBanComplainEmailAddress); applicationState.Add("cacheFlags", new Hashtable()); applicationState.Add("usersToLogoutByForce", usersToLogoutByForce); applicationState.Add("registrationReplyMailTemplate", registrationReplyMailTemplate); applicationState.Add("threadUpdatedNotificationTemplate", threadUpdatedNotificationTemplate); } finally { applicationState.UnLock(); } }