Пример #1
0
        private void btnCompare_Click(object sender, EventArgs e)
        {
            if (this.ddlOldDb.SelectedItem == null || this.ddlNewDb.SelectedItem == null)
            {
                MessageBox.Show("请选择数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.ddlOldDb.SelectedItem.ToString() == this.ddlNewDb.SelectedItem.ToString())
            {
                MessageBox.Show("新旧数据库不能重复", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            oldDataSource = sourceList.Values.FirstOrDefault(i => i.Key == this.ddlOldDb.SelectedItem.ToString());
            newDataSource = sourceList.Values.FirstOrDefault(i => i.Key == this.ddlNewDb.SelectedItem.ToString());


            newConn.ProviderName = newDataSource.ProviderName;
            oldConn.ProviderName = oldDataSource.ProviderName;


            if (cs.IsDebug)
            {
                Start();
            }
            else
            {
                StartTh();

                //使用Task替代线程 防止界面假死
                //Task.Factory.StartNew(() =>
                //{
                //    Start();
                //});
            }
        }
Пример #2
0
        public string GetShowConnectionString(DBDataSource dBDataSource)
        {
            if (dBDataSource.Type == DBDataSourceType.DataSourceFile)
            {
                return(dBDataSource.Key);
            }
            if (dBDataSource.Type == DBDataSourceType.MySql)
            {
                try
                {
                    string        val = dBDataSource.Value;
                    List <string> rel = new List <string>();
                    foreach (var item in dBDataSource.Value.Split(';'))
                    {
                        if (string.IsNullOrEmpty(item))
                        {
                            continue;
                        }

                        if (item.IndexOf("=") < 1)
                        {
                            rel.Add(item);
                            continue;
                        }

                        if (item.Split('=')[0].ToLower() == "pwd" || item.Split('=')[0].ToLower() == "password")
                        {
                            continue;
                        }
                        rel.Add(item);
                    }
                    return(string.Join(";", rel));
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(dBDataSource.Value);
        }