示例#1
0
        private void btnTestConnection_Click(object sender, EventArgs e)
        {
            try
            {
                AMTLogger.WriteToLog("Inside test connection");
                if (ValidateSQLServerSettings())
                {
                    DBProfileInfo dbprofileInfo = new DBProfileInfo();

                    dbprofileInfo.AuthenticationType = rdbSQLAuthentication.Checked ? EnumHelper.Authentication.SQLAuthentication : EnumHelper.Authentication.Windows;
                    dbprofileInfo.DatabaseType       = rdbSQLCE.Checked ? EnumHelper.Databases.SQLServerCE : EnumHelper.Databases.SQLServer;
                    dbprofileInfo.ServerName         = txtServerName.Text;
                    dbprofileInfo.UserName           = txtUserName.Text;

                    dbprofileInfo.HashSalt = Utility.HashPassword(txtPassword.Text);
                    dbprofileInfo.Password = Utility.Encrypt(txtPassword.Text, dbprofileInfo.HashSalt);


                    if (new AMT.Manager.InitailizeApp().CheckDatabaseConnection(Utility.GetConnectionInfoFromProfile(dbprofileInfo)))
                    {
                        MessageBox.Show("Connected Sucessfully.");
                    }
                    else
                    {
                        MessageBox.Show("Unable to connect");
                    }
                }
            }
            catch (Exception ex)
            {
                AMTLogger.WriteToLog(ex.Message, MethodBase.GetCurrentMethod().Name, 0, AMTLogger.LogInfo.Error);
            }
        }
示例#2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidateSQLServerSettings())
                {
                    DBProfileInfo dbprofileInfo = new DBProfileInfo();

                    dbprofileInfo.AuthenticationType = rdbSQLAuthentication.Checked ? EnumHelper.Authentication.SQLAuthentication : EnumHelper.Authentication.Windows;
                    dbprofileInfo.DatabaseType       = rdbSQLCE.Checked ? EnumHelper.Databases.SQLServerCE : EnumHelper.Databases.SQLServer;
                    dbprofileInfo.ServerName         = txtServerName.Text;
                    dbprofileInfo.UserName           = txtUserName.Text;

                    dbprofileInfo.HashSalt = Utility.HashPassword(txtPassword.Text);

                    dbprofileInfo.Password = Utility.Encrypt(txtPassword.Text, dbprofileInfo.HashSalt);

                    XMLSerializer <DBProfileInfo> .SerializeInputs <DBProfileInfo>(ApplicationInfo.DBProfileName, dbprofileInfo);



                    new AMT.Manager.InitailizeApp().CreateDatabases(Utility.LoadDbConnectionInfo());
                    //new Common.CommonUIInfo().InitApplication();

                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                AMTLogger.WriteToLog(ex.Message, MethodBase.GetCurrentMethod().Name, 0, AMTLogger.LogInfo.Error);
            }
        }
示例#3
0
        public static DBConnectionInfo LoadDbConnectionInfo()
        {
            DBConnectionInfo connectioninfo = new DBConnectionInfo();

            try
            {
                DBProfileInfo dbProfileInfo = new DBProfileInfo();


                if (File.Exists(ApplicationInfo.DBProfileName))
                {
                    XMLSerializer <DBProfileInfo> .DeSerializeInputs <DBProfileInfo>(ApplicationInfo.DBProfileName, ref dbProfileInfo);

                    connectioninfo.AuthenticationType = dbProfileInfo.AuthenticationType;
                    connectioninfo.DatabaseName       = ApplicationInfo.DatabaseName;
                    connectioninfo.DatabaseType       = dbProfileInfo.DatabaseType;
                    connectioninfo.DBPath             = ApplicationInfo.ApplicationDocumentPath;
                    connectioninfo.Password           = dbProfileInfo.Password;
                    connectioninfo.UserName           = dbProfileInfo.UserName;
                    connectioninfo.ServerName         = dbProfileInfo.ServerName;
                }
            }
            catch (Exception ex)
            {
                AMTLogger.WriteToLog(ex.Message, MethodBase.GetCurrentMethod().Name, 0, AMTLogger.LogInfo.Error);
            }
            return(connectioninfo);
        }
示例#4
0
        public static DBProfileInfo GetDBProfileInfo()
        {
            DBProfileInfo dbProfileInfo = new DBProfileInfo();

            try
            {
                if (File.Exists(ApplicationInfo.DBProfileName))
                {
                    XMLSerializer <DBProfileInfo> .DeSerializeInputs <DBProfileInfo>(ApplicationInfo.DBProfileName, ref dbProfileInfo);
                }
            }
            catch (Exception ex)
            {
                AMTLogger.WriteToLog(ex.Message, MethodBase.GetCurrentMethod().Name, 0, AMTLogger.LogInfo.Error);
            }
            return(dbProfileInfo);
        }
示例#5
0
        public static DBConnectionInfo GetConnectionInfoFromProfile(DBProfileInfo dbProfileInfo)
        {
            DBConnectionInfo connectioninfo = new DBConnectionInfo();

            try
            {
                connectioninfo.AuthenticationType = dbProfileInfo.AuthenticationType;
                connectioninfo.DatabaseName       = ApplicationInfo.DatabaseName;
                connectioninfo.DatabaseType       = dbProfileInfo.DatabaseType;
                connectioninfo.DBPath             = ApplicationInfo.ApplicationDocumentPath;
                connectioninfo.Password           = dbProfileInfo.Password;
                connectioninfo.UserName           = dbProfileInfo.UserName;
                connectioninfo.ServerName         = dbProfileInfo.ServerName;
            }
            catch (Exception ex)
            {
                AMTLogger.WriteToLog(ex.Message, MethodBase.GetCurrentMethod().Name, 0, AMTLogger.LogInfo.Error);
            }
            return(connectioninfo);
        }
示例#6
0
        private void LoadSettingsManager()
        {
            try
            {
                DBProfileInfo profileInfo = Utility.GetDBProfileInfo();

                if (profileInfo != null)
                {
                    rdbSQLCE.Checked = profileInfo.DatabaseType == EnumHelper.Databases.SQLServerCE ? true : false;
                    rdbSQL.Checked   = profileInfo.DatabaseType == EnumHelper.Databases.SQLServer ? true : false;

                    rdbSQLAuthentication.Checked = profileInfo.AuthenticationType == EnumHelper.Authentication.SQLAuthentication ?true :false;
                    rdbWinAuthentication.Checked = profileInfo.AuthenticationType == EnumHelper.Authentication.Windows? true :false;

                    txtUserName.Text   = profileInfo.UserName;
                    txtPassword.Text   = Utility.Decrypt(profileInfo.Password, profileInfo.HashSalt);
                    txtServerName.Text = profileInfo.ServerName;
                }
            }
            catch (Exception ex)
            {
                AMTLogger.WriteToLog(ex.Message, MethodBase.GetCurrentMethod().Name, 0, AMTLogger.LogInfo.Error);
            }
        }