Пример #1
0
        void ConnectCmd_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(txtServername.Text))
            {
                return;
            }
            if (string.IsNullOrEmpty(txtUsername.Text))
            {
                return;
            }

            LoginInfo_MySql info = new LoginInfo_MySql()
            {
                Server            = txtServername.Text,
                Database          = txtDbName.Text,
                Username          = txtUsername.Text,
                Pwd               = passwordBox1.Password,
                Port              = int.Parse(txtPort.Text),
                ConnectionTimeOut = 2000,
            };

            try
            {
                App.MainEngineer = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.MySql).X_Handler;
                App.MainEngineer.Open(info);
                if (App.MainEngineer.IsOpened)
                {
                    #region Save to Opened History Info
                    MySqlObjects mysqlItem = new MySqlObjects();
                    mysqlItem.ServerAddress = info.Server;
                    mysqlItem.Port          = info.Port;
                    mysqlItem.Username      = info.Username;

                    if (!SerializeClass.DatabaseHistoryInfo.MySqlHistory.IsContainSubValue(mysqlItem.ServerAddress))
                    {
                        HistoryObject oldObject = SerializeClass.DatabaseHistoryInfo;
                        oldObject.MySqlHistory.Add(mysqlItem);

                        SerializeClass.DatabaseHistoryInfo = oldObject;
                    }
                    #endregion
                    App.MainEngineer.CurDatabase = txtDbName.Text;
                    App.MainEngineer.CurPwd      = passwordBox1.Password;
                    RibbionIDE ide = new RibbionIDE();

                    ide.Title = info.Server;

                    ide.ShowDialog();
                }
            }
            catch (Exception ee)
            {
                //ee._获取我的异常详细信息().Show();
                App.ResetMainEngineer();
                ee.HandleMyException();
            }
        }
Пример #2
0
        private void InitDBs()
        {
            if (string.IsNullOrEmpty(txtServername.Text))
            {
                return;
            }
            if (string.IsNullOrEmpty(txtUsername.Text))
            {
                return;
            }


            LoginInfo_MySql info = new LoginInfo_MySql()
            {
                Server   = txtServername.Text,
                Username = txtUsername.Text,
                Pwd      = passwordBox1.Password,
                Port     = int.Parse(txtPort.Text),
            };

            try
            {
                App.MainEngineer = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.MySql).X_Handler;
                App.MainEngineer.Open(info);
                if (App.MainEngineer.IsOpened)
                {
                    List <string> dblist = App.MainEngineer.GetDatabaseList();
                    txtDbName.ItemsSource = null;

                    txtDbName.ItemsSource = dblist;
                    currentDbList.Clear();
                    currentDbList = dblist;
                }
            }
            catch (Exception ce)
            {
                ce.Message.Show();
            }
            finally
            {
                App.ResetMainEngineer();
            }
        }
Пример #3
0
        void CreateCmd_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if ("CreateDatabaseNotifyMsg".GetFromResourece().Confirm())
            {
                //Should notice there we didn't specify database name
                LoginInfo_MySql info = new LoginInfo_MySql()
                {
                    Server   = txtServername.Text,
                    Username = txtUsername.Text,
                    Pwd      = passwordBox1.Password,
                    Port     = int.Parse(txtPort.Text),
                };


                App.MainEngineer = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.MySql).X_Handler;
                App.MainEngineer.Open(info);
                try
                {
                    if (App.MainEngineer.IsOpened)
                    {
                        App.MainEngineer.DoExecuteNonQuery(
                            string.Format("Create database {0} CHARACTER SET {1}",
                                          txtDbName.Text,
                                          txtCharset.Text));

                        "CreateDatabaseOkMsg".GetFromResourece().Show();
                    }
                }
                catch (Exception ee)
                {
                    ee.Message.Show();
                }
                finally
                {
                    App.ResetMainEngineer();
                }

                InitDBs();
            }
        }
Пример #4
0
        public sealed override void Open(BaseLoginInfo pInfo)
        {
            //Record to base class (Vital)
            baseLoginInfo = pInfo;

            LoginInfo_MySql         myInfo  = pInfo as LoginInfo_MySql;
            LoginInfo_ForAllDbTypes allInfo = pInfo as LoginInfo_ForAllDbTypes;

            if ((myInfo == null) && (allInfo == null))
            {
                throw new ArgumentException("Only Support MySql login info and AllDBTypes Info");
            }

            if (IsOpened)
            {
                return;
            }

            try
            {
                string myConnString = string.Empty;
                if (allInfo != null)
                {
                    myInfo          = new LoginInfo_MySql();
                    myInfo.Database = allInfo.Database;
                    myInfo.Pwd      = allInfo.Pwd;
                    myInfo.Server   = allInfo.Server;
                    myInfo.Username = allInfo.Username;
                    myInfo.Port     = allInfo.Port;
                }

                myConnString = DbConnectionString.MySql.GetMySqlConnectionString(
                    myInfo.Server,
                    myInfo.Username,
                    myInfo.Pwd,
                    myInfo.Port,
                    myInfo.Database,
                    myInfo.ConnectionTimeOut,
                    50,
                    myInfo.IsPolling
                    );

                baseConn = new MySqlConnection(myConnString);
                baseConn.Open();

                Debug.WriteLine("Connection Timeout is " + baseConn.ConnectionTimeout);

                invalidator = new InvalidatorForMySql();
                //Set Current Opened Database
                base.CurDatabase = myInfo.Database;
                base.CurPwd      = myInfo.Pwd;

                if (string.IsNullOrEmpty(myInfo.Database))
                {
                    DoExecuteNonQuery("use mysql;");
                }
                else
                {
                    DoExecuteNonQuery("use " + myInfo.Database + ";");
                }
            }
            catch (Exception ee)
            {
                throw ee;
            }
        }