예제 #1
0
        protected virtual void DatabaseSetupModule_BeginRequest(object sender, EventArgs e)
        {
            HttpApplication app = (HttpApplication)sender;

            if (!_isConnectionOK)
            {
                DataAccessHelper.SetUp(
                    GetConnectionString(),
                    ConfigurationManager.ConnectionStrings[StoreContext.ConnectionStringsTagName].ProviderName,
                    false,
                    true,
                    null,
                    WebConfiguration.SecretKey,
                    SystemConst.DefaultUrlCultureName,
                    HttpContext.Current.Server.MapPath(SystemConst.LicenseFilePath));

                string message;
                if (!TestConnection(out message) &&
                    !IsAtPage(app, "SystemError.aspx") &&
                    !IsAtPage(app, "GenericError.aspx") &&
                    !IsRequestingUnitTestPath(app.Request))
                {
                    string errorHeader = "Database Connection Error";
                    string errorText   = "There is an error while attempting to connect to the database. Please verify your connection string in the file";
                    WebUtilities.LogError(new Exception(errorHeader + "\n\n" + errorText + "\n" + message));
                    SystemErrorPage.RedirectToErrorPage(
                        errorHeader, "<p>" + errorText + "</p>");
                }

                PaymentModuleDatabaseConnected();

                _isConnectionOK = true;

                if (TestConfiguration())
                {
                    DataAccessContext.EnableConfigurations(true);
                    ConfigurationHelper.ApplyConfigurations();
                }
                else
                {
                    DataAccessContext.EnableConfigurations(false);
                }
            }
        }