protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); // Setup a connection with Active Directory. activeDirectory = new ActiveDirectory(HttpRuntime.AppDomainAppPath + CONFIG_ITEM_DIRECTORY, ACTIVE_DIRECTORY_CONFIGURATION_ITEM_NAME); // Get the connection string for the database. databaseConnectionString = (new ConfigurationItem(HttpRuntime.AppDomainAppPath + CONFIG_ITEM_DIRECTORY, DATABASE_CONNECTION_STRING_CONFIGURATION_ITEM_NAME, true)).Value; // Create a SQL Event log instance for logging application events. eventLog = new SqlEventLog(databaseConnectionString, typeof(MSStoredProcedure)); if (eventLog == null) { throw new ApplicationException("Unable to initialize event log."); } Log(new Event(EVENT_LOG_SOURCE_NAME, DateTime.Now, Event.SeverityLevels.Error, EVENT_LOG_CATEGORY_GENERAL, "Override web application started.")); // Read the application's configuration from it's configuration item. ReadApplicationConfig(); // Get the override payload template. string payloadFilePath = HttpRuntime.AppDomainAppPath + OVERRIDE_PAYLOAD_TEMPLATE_PATH; if (File.Exists(payloadFilePath)) { try { overridePayloadTemplate = File.ReadAllAsText(payloadFilePath); Log(new Event(EVENT_LOG_SOURCE_NAME, DateTime.Now, Event.SeverityLevels.Information, EVENT_LOG_CATEGORY_GENERAL, "Loaded override payload from " + payloadFilePath + " .")); } catch { Log(new Event(EVENT_LOG_SOURCE_NAME, DateTime.Now, Event.SeverityLevels.Error, EVENT_LOG_CATEGORY_GENERAL, "Unable to load override payload from " + payloadFilePath + " .")); throw new ApplicationException("Unable to load override paylod. Check log for more details."); } } }
/// <summary> /// Loads configuration data, and readies the service for execution. /// </summary> protected void InitializeService() { // Get the connection string for the database. databaseConnectionString = (new ConfigurationItem(AppDomain.CurrentDomain.BaseDirectory + CONFIG_ITEM_DIRECTORY, DATABASE_CONNECTION_STRING_CONFIGURATION_ITEM_NAME, true)).Value; // Create a SQL Event log instance for logging application events. eventLog = new SqlEventLog(databaseConnectionString, typeof(MSStoredProcedure)); if (eventLog == null) { throw new ApplicationException("Unable to initialize event log."); } eventLog.Log(new Event(EVENT_LOG_SOURCE_NAME, DateTime.Now, Event.SeverityLevels.Information, EVENT_LOG_CATEGORY_GENERAL, "Expiration service started.")); // Read the application's configuration from it's configuration item. ReadApplicationConfig(); // Get the override payload template. string payloadFilePath = AppDomain.CurrentDomain.BaseDirectory + OVERRIDE_PAYLOAD_TEMPLATE_PATH; if (File.Exists(payloadFilePath)) { try { unregisterPayloadTemplate = File.ReadAllAsText(payloadFilePath); eventLog.Log(new Event(EVENT_LOG_SOURCE_NAME, DateTime.Now, Event.SeverityLevels.Information, EVENT_LOG_CATEGORY_GENERAL, "Loaded unregister payload from " + payloadFilePath + " . ")); } catch { eventLog.Log(new Event(EVENT_LOG_SOURCE_NAME, DateTime.Now, Event.SeverityLevels.Error, EVENT_LOG_CATEGORY_GENERAL, "Unable to load unregister payload from " + payloadFilePath + " .")); throw new ApplicationException("Unable to load unregister paylod. Check log for more details."); } } }