コード例 #1
0
        private void QuickConnectItems_Click(object sender, RibbonControlEventArgs e)
        {
            string hostName = e.Control.Id;
            string address, port, user, password, defaultSchema;

            ConnectionStatus.xmlPath = Environment.GetFolderPath(
                Environment.SpecialFolder.Personal) + "\\SEMC_SQL_For_Excel.xml";
            XmlDocument dbInfo = new XmlDocument();

            dbInfo.Load(ConnectionStatus.xmlPath);
            XmlNode root = dbInfo.DocumentElement;

            address = root.SelectSingleNode("//DBInfo/DB[@HostName='" +
                                            hostName + "']/Address").InnerText;
            port = root.SelectSingleNode("//DBInfo/DB[@HostName='" +
                                         hostName + "']/Port").InnerText;
            user = root.SelectSingleNode("//DBInfo/DB[@HostName='" +
                                         hostName + "']/Account").InnerText;
            password = root.SelectSingleNode("//DBInfo/DB[@HostName='" +
                                             hostName + "']/PWD").InnerText;
            defaultSchema = root.SelectSingleNode("//DBInfo/DB[@HostName='" +
                                                  hostName + "']/DefaultSchema").InnerText;
            password = AESModel.AESHelper.AESDecryptWithVector(
                password, "SEMCWangsese8586", "SEMCWangVector00");
            MySQLOperation mySQLOperation = new MySQLOperation();

            if (mySQLOperation.MakeConnection(
                    hostName, address, user, password, port, defaultSchema))
            {
                System.Windows.Forms.MessageBox.Show("连接成功");
                ConnectionStatus.alive                        = true;
                ConnectionStatus.connectionName               = hostName;
                Globals.Ribbons.Ribbon1.Disconnect.Enabled    = true;
                Globals.Ribbons.Ribbon1.ExportFromSQL.Enabled = true;
                Globals.Ribbons.Ribbon1.ImportInDB.Enabled    = true;
            }
            else
            {
                System.Windows.Forms.MessageBox.Show(
                    "连接失败,请检查服务器或网络是否正常!");
            }
        }
コード例 #2
0
        private void ConnectionManagerButtonOK_Click(object sender, EventArgs e)
        {
            string hostName, hostAddress, port, userName, password, defaultSchema;

            hostName      = HostNameComboBox.Text;
            hostAddress   = HostAddressTextBox.Text;
            port          = PortTextBox.Text;
            userName      = UserNameTextBox.Text;
            password      = PasswordTextBox.Text;
            defaultSchema = DefaultSchemaTextBox.Text;
            MySQLOperation newOperation = new MySQLOperation();

            if (hostName != "" && hostAddress != "" && port != "" &&
                userName != "" && password != "")
            {
                if (newOperation.MakeConnection(hostName, hostAddress, userName,
                                                password, port, defaultSchema))
                {
                    ActiveForm.Close();
                    MessageBox.Show("连接成功!");
                    ConnectionStatus.alive                        = true;
                    ConnectionStatus.connectionName               = hostName;
                    Globals.Ribbons.Ribbon1.Disconnect.Enabled    = true;
                    Globals.Ribbons.Ribbon1.ExportFromSQL.Enabled = true;
                    Globals.Ribbons.Ribbon1.ImportInDB.Enabled    = true;
                    password = AESModel.AESHelper.AESEncryptWithVector(password,
                                                                       "SEMCWangsese8586", "SEMCWangVector00");
                    if (newOperation.NewConnection(hostName, hostAddress, userName,
                                                   password, port, defaultSchema))
                    {
                        MessageBox.Show("新连接已存储!");
                    }
                }
                else
                {
                    MessageBox.Show("连接失败,请检查填写是否有误,网络状态或服务器是否正常!");
                }
            }
            return;
        }
コード例 #3
0
 private void QuickConnectItems_Click(object sender, RibbonControlEventArgs e)
 {
     string hostName = e.Control.Id;
     string address, port, user, password, defaultSchema;
     ConnectionStatus.xmlPath = Environment.GetFolderPath(
     Environment.SpecialFolder.Personal) + "\\SEMC_SQL_For_Excel.xml";
     XmlDocument dbInfo = new XmlDocument();
     dbInfo.Load(ConnectionStatus.xmlPath);
     XmlNode root = dbInfo.DocumentElement;
     address = root.SelectSingleNode("//DBInfo/DB[@HostName='" +
         hostName + "']/Address").InnerText;
     port = root.SelectSingleNode("//DBInfo/DB[@HostName='" +
         hostName + "']/Port").InnerText;
     user = root.SelectSingleNode("//DBInfo/DB[@HostName='" +
         hostName + "']/Account").InnerText;
     password = root.SelectSingleNode("//DBInfo/DB[@HostName='" +
         hostName + "']/PWD").InnerText;
     defaultSchema = root.SelectSingleNode("//DBInfo/DB[@HostName='" +
         hostName + "']/DefaultSchema").InnerText;
     password = AESModel.AESHelper.AESDecryptWithVector(
         password, "SEMCWangsese8586", "SEMCWangVector00");
     MySQLOperation mySQLOperation = new MySQLOperation();
     if(mySQLOperation.MakeConnection(
         hostName, address, user, password, port, defaultSchema))
     {
         System.Windows.Forms.MessageBox.Show("连接成功");
         ConnectionStatus.alive = true;
         ConnectionStatus.connectionName = hostName;
         Globals.Ribbons.Ribbon1.Disconnect.Enabled = true;
         Globals.Ribbons.Ribbon1.ExportFromSQL.Enabled = true;
         Globals.Ribbons.Ribbon1.ImportInDB.Enabled = true;
     }
     else
     {
         System.Windows.Forms.MessageBox.Show(
             "连接失败,请检查服务器或网络是否正常!");
     }
 }
コード例 #4
0
 private void ConnectionManagerButtonOK_Click(object sender, EventArgs e)
 {
     string hostName, hostAddress, port, userName, password, defaultSchema;
     hostName = HostNameComboBox.Text;
     hostAddress = HostAddressTextBox.Text;
     port = PortTextBox.Text;
     userName = UserNameTextBox.Text;
     password = PasswordTextBox.Text;
     defaultSchema = DefaultSchemaTextBox.Text;
     MySQLOperation newOperation = new MySQLOperation();
     if (hostName != "" && hostAddress != "" &&port != "" &&
         userName != "" && password != "")
     {
         if (newOperation.MakeConnection(hostName, hostAddress, userName,
             password,port,defaultSchema))
         {
             ActiveForm.Close();
             MessageBox.Show("连接成功!");
             ConnectionStatus.alive = true;
             ConnectionStatus.connectionName = hostName;
             Globals.Ribbons.Ribbon1.Disconnect.Enabled = true;
             Globals.Ribbons.Ribbon1.ExportFromSQL.Enabled = true;
             Globals.Ribbons.Ribbon1.ImportInDB.Enabled = true;
             password = AESModel.AESHelper.AESEncryptWithVector(password,
                 "SEMCWangsese8586", "SEMCWangVector00");
             if(newOperation.NewConnection(hostName, hostAddress, userName,
                 password, port, defaultSchema))
             {
                 MessageBox.Show("新连接已存储!");
             }
         }
         else
         {
             MessageBox.Show("连接失败,请检查填写是否有误,网络状态或服务器是否正常!");
         }
     }
     return;
 }