示例#1
0
        private void tsmiGenerateModel_Click(object sender, EventArgs e)
        {
            var tableInfoArr = this._tableList.Where(t => { return(t.ShowField); }).ToArray();

            if (tableInfoArr.Length == 0)
            {
                return;
            }

            var frm = new FModelInfo();

            if (frm.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            var para = new PartAsynWaitPara <Tuple <string, string, string, DBTableInfoEx[]>, object>();

            para.Caption      = "生成model结构";
            para.IsShowCancel = false;
            para.Para         = new Tuple <string, string, string, DBTableInfoEx[]>(frm.Namespace, frm.BaseClassName, frm.Dir, tableInfoArr);
            para.Function     = this.GenerateModel;

            para.Completed = (ret) =>
            {
                if (ret.Status == PartAsynExcuteStatus.Exception)
                {
                    Loger.Error(ret.Exception);
                }
            };

            PartAsynWaitHelper.Wait(para, this);
        }
示例#2
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            try
            {
                var dbConfig = DropdownBoxHelper.GetGenericFromComboBox <DatabaseConfig>(comboBoxDB);
                var para     = new PartAsynWaitPara <DatabaseConfig, object>();
                para.Caption      = "查询数据库结构";
                para.IsShowCancel = false;
                para.Para         = dbConfig;
                para.Function     = (p) =>
                {
                    p.AsynWait.Hint = $"正在查询数据库[{dbConfig.ConName}]结构,请稍候...";
                    IDBAccess dbAccess = DBAccessManager.GetDBAccessInstance(p.Para.DBID);
                    this._tableList = dbAccess.Database.GetTableInfoList(true).OrderBy(t => { return(t.Name); }).Select(t => { return(new DBTableInfoEx(t)); }).ToList();
                    if (p.AsynWait.InvokeRequired)
                    {
                        p.AsynWait.Invoke(new Action(() =>
                        {
                            this._tableBindingList.Clear();
                            this._tableBindingList.AddRange(this._tableList);
                        }));
                    }
                    else
                    {
                        this._tableBindingList.Clear();
                        this._tableBindingList.AddRange(this._tableList);
                    }

                    return(null);
                };

                para.Completed = (ret) =>
                {
                    if (ret.Status == PartAsynExcuteStatus.Exception)
                    {
                        Loger.Error(ret.Exception);
                    }
                };

                PartAsynWaitHelper.Wait(para, this);
            }
            catch (Exception ex)
            {
                Loger.Error(ex);
                MessageBox.Show(ex.Message);
            }
        }