コード例 #1
0
 public void OnSetup(clsDatabaseConfig config = null)
 {
     if (config == null)
     {
         bgwSetupConnection.RunWorkerAsync(this._objDatabaseConfig);
     }
     else
     {
         bgwSetupConnection.RunWorkerAsync(config);
     }
 }
コード例 #2
0
 public void OnSetServer(clsDatabaseConfig config = null)
 {
     if (config == null)
     {
         bgwSetServer.RunWorkerAsync(this._objDatabaseConfig);
     }
     else
     {
         bgwSetServer.RunWorkerAsync(config);
     }
 }
コード例 #3
0
ファイル: ctrlSetServer.ascx.cs プロジェクト: kantorn/toacs
 protected void btnSetServer_Click(object sender, EventArgs e)
 {
     if (IsServerDetailsValid())
     {
         setServerStart();
         this._objDatabaseConfig = new clsDatabaseConfig();
         this.objDatabaseConfig.ServerName = !String.IsNullOrEmpty(drpServerName.Text.Trim())
                                            ? drpServerName.Text.Trim()
                                            : txtServerName.Text.Trim();
         this.objDatabaseConfig.IsIntegratedSecurity = chkWindowsAuth.Checked;
         this.objDatabaseConfig.UserName = txtUserName.Text.Trim();
         this.objDatabaseConfig.Password = txtPassword.Text.Trim();
         SessionHelper.dbCommon.OnSetServer(objDatabaseConfig);
     }
 }
コード例 #4
0
ファイル: Common.cs プロジェクト: kantorn/toacs
 public void OnSetup(clsDatabaseConfig config = null)
 {
     if (config == null)
     {
         bgwSetupConnection.RunWorkerAsync(this._objDatabaseConfig);
     }
     else
     {
         bgwSetupConnection.RunWorkerAsync(config);
     }
 }
コード例 #5
0
ファイル: Common.cs プロジェクト: kantorn/toacs
 public void OnSetServer(clsDatabaseConfig config = null)
 {
     if (config == null)
     {
         bgwSetServer.RunWorkerAsync(this._objDatabaseConfig);
     }
     else
     {
         bgwSetServer.RunWorkerAsync(config);
     }
 }
コード例 #6
0
        private void bgwSetupConnection_DoWork(object sender, DoWorkEventArgs e)
        {
            clsDatabaseConfig objdb           = (clsDatabaseConfig)e.Argument;
            string            errorMessage    = "";
            string            applicationPath = Path.GetDirectoryName(Application.ExecutablePath);

            //application
            if (applicationPath != null && applicationPath.IndexOf("bin") > -1)
            {
                applicationPath = applicationPath.Substring(0, applicationPath.IndexOf("bin")) + "DB";
            }
            //web server
            else
            {
                applicationPath = _currentContext.Server.MapPath("~/");
                DirectoryInfo appDirectory = new DirectoryInfo(applicationPath);
                applicationPath = appDirectory.Parent.FullName + "\\Utilities";
            }
            if (objdb.IsNewDatabase)
            {
                bgwSetupConnection.ReportProgress(10, "(1/6) Creating the database file...");
                errorMessage = objdb.CreateNewDatabase();
                if (errorMessage != ErrorStates.Success.ToString())
                {
                    bgwSetupConnection.ReportProgress(100, "Creating the database failed.");
                    e.Result = "Following error occured while creating the database:" + Environment.NewLine + errorMessage;
                    return;
                }

                bgwSetupConnection.ReportProgress(30, "(2/6) Verifying if database was attached...");
                errorMessage = objdb.IsNewDatabaseAttached();
                if (errorMessage == ErrorStates.Failure.ToString())
                {
                    bgwSetupConnection.ReportProgress(100, "Database was not attached to the server.");
                    e.Result = "Database was not attached to the server." + Environment.NewLine + "Try attaching it manually and rerun the configuration process";
                    return;
                }
                else if (errorMessage != ErrorStates.Success.ToString())
                {
                    bgwSetupConnection.ReportProgress(100, "Verifying the attached database failed.");
                    e.Result = "Following error occured while verifying the attached database:" + Environment.NewLine + errorMessage;
                    return;
                }

                bgwSetupConnection.ReportProgress(50, "(3/6) Installing schema onto the blank database...");
                errorMessage = objdb.InstallScriptFile(applicationPath + "\\Scripts\\InstallDatabaseSchema.sql");
                if (errorMessage != ErrorStates.Success.ToString())
                {
                    bgwSetupConnection.ReportProgress(100, "Installing schema to the database failed.");
                    e.Result = "Following error occured while installing schema to the database:" + Environment.NewLine + errorMessage;
                    return;
                }

                bgwSetupConnection.ReportProgress(70, "(4/6) Verifying the integrifty of database schema...");
                errorMessage = objdb.VerifySchema(applicationPath + "\\DB\\Scripts\\InstallDatabaseSchema.sql");
                if (errorMessage != ErrorStates.Success.ToString())
                {
                    bgwSetupConnection.ReportProgress(100, "Verifying integrity of the database schema failed.");
                    e.Result = "Following error occured while verifying integrity of the database schema:" + Environment.NewLine + errorMessage;
                    return;
                }

                bgwSetupConnection.ReportProgress(90, "(5/6) Fetching connection settings...");
                System.Threading.Thread.Sleep(500);
                e.Result = "|Success|" + objdb.GetConnectionString();

                bgwSetupConnection.ReportProgress(100, "(6/6) Database connection complete. Opening application...");
                System.Threading.Thread.Sleep(1000);
            }
            else
            {
                bgwSetupConnection.ReportProgress(10, "(1/5) Attaching the database file...");
                errorMessage = objdb.AttachExistingDatabase();
                if (errorMessage != ErrorStates.Success.ToString())
                {
                    bgwSetupConnection.ReportProgress(100, "Attaching the database failed.");
                    e.Result = "Following error occured while attaching the database:" + Environment.NewLine + errorMessage;
                    return;
                }

                bgwSetupConnection.ReportProgress(30, "(2/5) Verifying if database was attached...");
                errorMessage = objdb.IsExistingDatabaseAttached();
                if (errorMessage == ErrorStates.Failure.ToString())
                {
                    bgwSetupConnection.ReportProgress(100, "Database was not attached to the server.");
                    e.Result = "Database was not attached to the server." + Environment.NewLine + "Try attaching it manually and rerun the configuration process";
                    return;
                }
                else if (errorMessage != ErrorStates.Success.ToString())
                {
                    bgwSetupConnection.ReportProgress(100, "Verifying the attached database failed.");
                    e.Result = "Following error occured while verifying the attached database:" + Environment.NewLine + errorMessage;
                    return;
                }

                bgwSetupConnection.ReportProgress(50, "(3/5) Verifying the integrifty of database schema...");
                errorMessage = objdb.VerifySchema(applicationPath + "\\Scripts\\InstallDatabaseSchema.sql");
                if (errorMessage != ErrorStates.Success.ToString())
                {
                    bgwSetupConnection.ReportProgress(100, "Verifying integrity of the database schema failed.");
                    e.Result = "Following error occured while verifying integrity of the database schema:" + Environment.NewLine + errorMessage;
                    return;
                }

                bgwSetupConnection.ReportProgress(85, "(4/5) Fetching connection settings...");
                System.Threading.Thread.Sleep(500);
                e.Result = "|Success|" + objdb.GetConnectionString();

                bgwSetupConnection.ReportProgress(100, "(5/5) Database connection complete. Opening application...");
                System.Threading.Thread.Sleep(1000);
            }
        }
コード例 #7
0
        private void bgwSetServer_DoWork(object sender, DoWorkEventArgs e)
        {
            clsDatabaseConfig objdb = (clsDatabaseConfig)e.Argument;

            e.Result = objdb.IsServerNameValid();
        }