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);
                }
            }
        }
示例#2
0
    protected void uxExecuteButton_Click(object sender, EventArgs e)
    {
        try
        {
            if (uxExecuteText.Text != "")
            {
                AdminUtilities.RemoveAllCacheInMemory();

                DatabaseConverter databaseConverter = new DatabaseConverter();

                databaseConverter.OnScriptExecuting();
                DataAccess.ExecuteNonQueryNoParameter(uxExecuteText.Text.Trim());
                databaseConverter.OnScriptExecuted();

                // Update configurations
                DataAccessContext.ClearConfigurationCache();
                ConfigurationHelper.ApplyConfigurations();

                databaseConverter.Convert();

                AdminUtilities.RemoveAllCacheInMemory();

                // Set up PaymentModule
                //      PaymentModuleSetup paymentModule = new PaymentModuleSetup();
                //      paymentModule.ProcessDatabaseConnected();

                uxMessageLabel.ForeColor = System.Drawing.Color.Green;
                uxMessageLabel.Text      = "<strong>Upgrade Completed</storng>";
            }
            else
            {
                DisplatError("No command to execute.");
            }
        }
        catch (Exception ex)
        {
            DisplatError(ex.Message);
        }
    }