/// <summary>
        /// 同步模型中的表字段
        /// </summary>
        /// <param name="_vt"></param>
        /// <returns></returns>
        private bool CMD_ViewTableColumnSync(MD_ViewTable _vt)
        {
            IList <MD_ViewTableColumn> _vtc = _vt.Columns;

            using (MetaDataServiceClient _mdc = new MetaDataServiceClient())
            {
                IList <MD_TableColumn> _tcolumns = _mdc.GetColumnsOfTable(_vt.TableID);

                IList <MD_ViewTableColumn> _newvtColumns          = new List <MD_ViewTableColumn>();
                IDictionary <string, MD_ViewTableColumn> _vtcDict = new Dictionary <string, MD_ViewTableColumn>();
                foreach (MD_ViewTableColumn _vtColumn in _vtc)
                {
                    _vtcDict.Add(_vtColumn.TableColumn.ColumnName, _vtColumn);
                }


                IDictionary <string, MD_TableColumn> _tcDict = new Dictionary <string, MD_TableColumn>();
                foreach (MD_TableColumn _tbcol in _tcolumns)
                {
                    _tcDict.Add(_tbcol.ColumnName, _tbcol);
                }

                ArrayList _delkeys = new ArrayList();
                foreach (string _key in _vtcDict.Keys)
                {
                    if (_tcDict.ContainsKey(_key))
                    {
                        _newvtColumns.Add(_vtcDict[_key]);
                    }
                }

                foreach (string _key in _tcDict.Keys)
                {
                    if (!_vtcDict.ContainsKey(_key))
                    {
                        MD_TableColumn     _thistc = _tcDict[_key];
                        MD_ViewTableColumn _newvtc = new MD_ViewTableColumn(
                            _mdc.GetNewID(),
                            _vt.ViewTableID,
                            _thistc.ColumnID,
                            true,
                            true,
                            true,
                            false,
                            false,
                            _thistc.DWDM,
                            0,
                            0);
                        _newvtc.TableColumn = _thistc;

                        _newvtColumns.Add(_newvtc);
                    }
                }
                _vt.Columns = _newvtColumns;
                this.gridControl1.DataSource = _vt.Columns;
                this._haveChange             = true;
                RaiseDataChanged();
                return(true);
            }
        }
Ejemplo n.º 2
0
        private IList <MD_TableColumn> CurrentDBColumns(IList <DB_ColumnMeta> _dbColumnList, IList <MD_TableColumn> _oldList)
        {
            using (MetaDataServiceClient _mdc = new MetaDataServiceClient())
            {
                IList <MD_TableColumn> _retList = new List <MD_TableColumn>();

                foreach (DB_ColumnMeta _dbc in _dbColumnList)
                {
                    MD_TableColumn _mtc = FindInOldList(_dbc.ColumnName, _oldList);
                    if (_mtc == null)
                    {
                        //添加新字段
                        string _displayName = MatchStringFromComment2(_dbc.Comments, MD_ConstDefine.RegExStrFN);
                        _displayName = (_displayName == "") ? _dbc.ColumnName : _displayName;
                        MD_TableColumn _newtc = new MD_TableColumn(_mdc.GetNewID(), this._tableDefine.TID, _dbc.ColumnName, _dbc.Nullable,
                                                                   _dbc.DataType, _dbc.DataPrecision, 0, _dbc.DataLength, "", "", 0, _displayName, "", 1, 1, 0, true, 1, "", "", "");
                        _retList.Add(_newtc);
                    }
                    else
                    {
                        //添加旧字段
                        _retList.Add(_mtc);
                    }
                }

                return(_retList);
            }
        }
Ejemplo n.º 3
0
        private IList <MD_TableColumn> CreateNewColumns(IList <DB_ColumnMeta> _dbColumnList)
        {
            using (MetaDataServiceClient _mdc = new MetaDataServiceClient())
            {
                IList <MD_TableColumn> _cols = new List <MD_TableColumn>();

                foreach (DB_ColumnMeta _dbc in _dbColumnList)
                {
                    string _displayName = MatchStringFromComment2(_dbc.Comments, MD_ConstDefine.RegExStrFN);
                    _displayName = (_displayName == "") ? _dbc.ColumnName : _displayName;
                    MD_TableColumn _newtc = new MD_TableColumn(_mdc.GetNewID(), this._tableDefine.TID, _dbc.ColumnName, _dbc.Nullable,
                                                               _dbc.DataType, _dbc.DataPrecision, 0, _dbc.DataLength, "", "", 0, _displayName, "", 1, 1, 0, true, 1, "", "", "");
                    _cols.Add(_newtc);
                }
                return(_cols);
            }
        }
Ejemplo n.º 4
0
        private void WriteTableDefine(string _oldNameSpace, MD_Namespace _ns, DataSet _ds)
        {
            using (MetaDataServiceClient _mdc = new MetaDataServiceClient())
            {
                DataRow[] _TableDefineRows = _ds.Tables["MD_TABLE"].Select(string.Format("NAMESPACE='{0}'", _oldNameSpace));
                foreach (DataRow _dr in _TableDefineRows)
                {
                    DB_TableMeta _tm = new DB_TableMeta();
                    _tm.TableName    = _dr["TABLENAME"].ToString();
                    _tm.TableComment = _dr["DESCRIPTION"].ToString();
                    _tm.TableType    = _dr["TABLETYPE"].ToString();

                    string _oldid = _dr["TID"].ToString();
                    string _newid = GetNewID(_oldid, "MD_TABLE", "TID", _mdc);

                    this.IDTable.Add(_oldid, _newid);

                    MD_Table _tableDefine = new MD_Table(
                        _newid,
                        _ns.NameSpace,
                        _tm.TableName,
                        _tm.TableType,
                        _tm.TableComment,
                        _dr.IsNull("DISPLAYNAME") ? "" : _dr["DISPLAYNAME"].ToString(),
                        _dr.IsNull("MAINKEY") ? "" : _dr["MAINKEY"].ToString(),
                        _ns.DWDM,
                        _dr.IsNull("SECRETFUN") ? "" : _dr["SECRETFUN"].ToString(),
                        _dr.IsNull("EXTSECRET") ? "" : _dr["EXTSECRET"].ToString()
                        );

                    _tableDefine.Columns = new List <MD_TableColumn>();
                    DataRow[] _columnRow = _ds.Tables["MD_TABLECOLUMN"].Select(string.Format("TID={0}", _dr["TID"]));
                    foreach (DataRow _dcrow in _columnRow)
                    {
                        string _oldTCid = _dcrow["TCID"].ToString();
                        string _newTCid = GetNewID(_oldTCid, "MD_TABLECOLUMN", "TCID", _mdc);
                        try
                        {
                            this.IDTable.Add(_oldTCid, _newTCid);
                        }
                        catch (Exception e)
                        {
                            throw e;
                        }

                        MD_TableColumn _tc = new MD_TableColumn(
                            _newTCid,
                            _newid,
                            _dcrow["COLUMNNAME"].ToString(),
                            (_dcrow["ISNULLABLE"].ToString() == "Y"),
                            _dcrow["TYPE"].ToString(),
                            _dcrow.IsNull("PRECISION") ? 1 : Convert.ToInt32(_dcrow["PRECISION"]),
                            _dcrow.IsNull("SCALE") ? 1 : Convert.ToInt32(_dcrow["SCALE"]),
                            _dcrow.IsNull("LENGTH") ? 1 : Convert.ToInt32(_dcrow["LENGTH"]),
                            _dcrow.IsNull("REFDMB") ? "" : _dcrow["REFDMB"].ToString(),
                            _dcrow.IsNull("DMBLEVELFORMAT") ? "" : _dcrow["DMBLEVELFORMAT"].ToString(),
                            _dcrow.IsNull("SECRETLEVEL") ? 0 : Convert.ToInt32(_dcrow["SECRETLEVEL"]),
                            _dcrow.IsNull("DISPLAYTITLE") ? "" : _dcrow["DISPLAYTITLE"].ToString(),
                            _dcrow.IsNull("DISPLAYFORMAT") ? "" : _dcrow["DISPLAYFORMAT"].ToString(),
                            _dcrow.IsNull("DISPLAYLENGTH") ? 1 : Convert.ToInt32(_dcrow["DISPLAYLENGTH"]),
                            _dcrow.IsNull("DISPLAYHEIGHT") ? 1 : Convert.ToInt32(_dcrow["DISPLAYHEIGHT"]),
                            _dcrow.IsNull("DISPLAYORDER") ? 0 : Convert.ToInt32(_dcrow["DISPLAYORDER"]),
                            _dcrow.IsNull("CANDISPLAY") ? true : ((decimal)_dcrow["CANDISPLAY"] > 0),
                            _dcrow.IsNull("COLWIDTH") ? 1 : Convert.ToInt32(_dcrow["COLWIDTH"]),
                            _ns.DWDM,
                            _dcrow.IsNull("CTAG") ? "" : _dcrow["CTAG"].ToString(),
                            ""
                            );
                        _tableDefine.Columns.Add(_tc);
                    }
                    _mdc.ImportTableDefine(_tableDefine);
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 插入列定义
        /// </summary>
        /// <param name="_table"></param>
        /// <param name="_tc"></param>
        public static void InsertColumnDefine(MD_Table _table, MD_TableColumn _tc)
        {
            try
            {
                StringBuilder _sb_insert = new StringBuilder();
                _sb_insert.Append(" insert into md_tablecolumn (TCID,TID,COLUMNNAME,");
                _sb_insert.Append(" ISNULLABLE,TYPE,`PRECISION`,SCALE,");
                _sb_insert.Append(" LENGTH,REFDMB,DMBLEVELFORMAT,SECRETLEVEL,");
                _sb_insert.Append(" DISPLAYTITLE,DISPLAYFORMAT,DISPLAYLENGTH,DISPLAYHEIGHT,");
                _sb_insert.Append(" DISPLAYORDER,CANDISPLAY,COLWIDTH,DWDM,");
                _sb_insert.Append(" CTAG,REFWORDTB ) values ");
                _sb_insert.Append(" (@TCID,@TID,@COLUMNNAME,");
                _sb_insert.Append(" @ISNULLABLE,@TYPE,@PRECISION,@SCALE,");
                _sb_insert.Append(" @LENGTH,@REFDMB,@DMBLEVELFORMAT,@SECRETLEVEL,");
                _sb_insert.Append(" @DISPLAYTITLE,@DISPLAYFORMAT,@DISPLAYLENGTH,@DISPLAYHEIGHT,");
                _sb_insert.Append(" @DISPLAYORDER,@CANDISPLAY,@COLWIDTH,@DWDM,");
                _sb_insert.Append(" @CTAG,@REFWORDTB)  ");

                MySqlParameter[] _param3 =
                {
                    new MySqlParameter("@TCID",           MySqlDbType.Int64),
                    new MySqlParameter("@TID",            MySqlDbType.Int64),
                    new MySqlParameter("@COLUMNNAME",     MySqlDbType.VarChar,  50),
                    new MySqlParameter("@ISNULLABLE",     MySqlDbType.VarChar, 100),
                    new MySqlParameter("@TYPE",           MySqlDbType.VarChar,  20),
                    new MySqlParameter("@PRECISION",      MySqlDbType.Int32),
                    new MySqlParameter("@SCALE",          MySqlDbType.Int32),
                    new MySqlParameter("@LENGTH",         MySqlDbType.Int32),
                    new MySqlParameter("@REFDMB",         MySqlDbType.VarChar,  50),
                    new MySqlParameter("@DMBLEVELFORMAT", MySqlDbType.VarChar,  20),
                    new MySqlParameter("@SECRETLEVEL",    MySqlDbType.Int32),
                    new MySqlParameter("@DISPLAYTITLE",   MySqlDbType.VarChar,  50),
                    new MySqlParameter("@DISPLAYFORMAT",  MySqlDbType.VarChar,  50),
                    new MySqlParameter("@DISPLAYLENGTH",  MySqlDbType.Int32),
                    new MySqlParameter("@DISPLAYHEIGHT",  MySqlDbType.Int32),
                    new MySqlParameter("@DISPLAYORDER",   MySqlDbType.Int32),
                    new MySqlParameter("@CANDISPLAY",     MySqlDbType.Int32),
                    new MySqlParameter("@COLWIDTH",       MySqlDbType.Int32),
                    new MySqlParameter("@DWDM",           MySqlDbType.VarChar,  20),
                    new MySqlParameter("@CTAG",           MySqlDbType.VarChar, 500),
                    new MySqlParameter("@REFWORDTB",      MySqlDbType.VarChar, 50)
                };
                _param3[0].Value = Convert.ToInt64(_tc.ColumnID);
                _param3[1].Value = Convert.ToInt64(_table.TID);
                _param3[2].Value = _tc.ColumnName;
                _param3[3].Value = _tc.IsNullable ? "Y" : "N";
                _param3[4].Value = _tc.ColumnType;
                _param3[5].Value = Convert.ToInt32(_tc.Precision);
                _param3[6].Value = Convert.ToInt32(_tc.Scale);
                _param3[7].Value = Convert.ToInt32(_tc.Length);
                _param3[8].Value = _tc.RefDMB;
                _param3[9].Value = _tc.DMBLevelFormat;

                _param3[10].Value = Convert.ToInt32(_tc.SecretLevel);
                _param3[11].Value = _tc.DisplayTitle;
                _param3[12].Value = _tc.DisplayFormat;
                _param3[13].Value = Convert.ToInt32(_tc.DisplayLength);
                _param3[14].Value = Convert.ToInt32(_tc.DisplayHeight);
                _param3[15].Value = Convert.ToInt32(_tc.DisplayOrder);
                _param3[16].Value = _tc.CanDisplay ? 1 : 0;
                _param3[17].Value = Convert.ToInt32(_tc.ColWidth);
                _param3[18].Value = _tc.DWDM;
                _param3[19].Value = _tc.CTag;
                _param3[20].Value = _tc.RefWordTableName;


                MysqlDBHelper.ExecuteNonQuery(MysqlDBHelper.conf, CommandType.Text, _sb_insert.ToString(), _param3);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                Debug.WriteLine(ex.StackTrace);
            }
            MyDA_MetaDataQuery.ModelLib.Clear();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 更新列定义
        /// </summary>
        /// <param name="_table"></param>
        /// <param name="_tc"></param>
        public static void UpdateColumnDefine(MD_Table _table, MD_TableColumn _tc)
        {
            StringBuilder _sb = new StringBuilder();

            _sb.Append(" update md_tablecolumn  set TID=@TID,COLUMNNAME=@COLUMNNAME,");
            _sb.Append(" ISNULLABLE=@ISNULLABLE,TYPE=@TYPE,`PRECISION`=@PRECISION,SCALE=@SCALE,");
            _sb.Append(" LENGTH=@LENGTH,REFDMB=@REFDMB,DMBLEVELFORMAT=@DMBLEVELFORMAT,SECRETLEVEL=@SECRETLEVEL,");
            _sb.Append(" DISPLAYTITLE=@DISPLAYTITLE,DISPLAYFORMAT=@DISPLAYFORMAT,DISPLAYLENGTH=@DISPLAYLENGTH,DISPLAYHEIGHT=@DISPLAYHEIGHT,");
            _sb.Append(" DISPLAYORDER=@DISPLAYORDER,CANDISPLAY=@CANDISPLAY,COLWIDTH=@COLWIDTH,DWDM=@DWDM,");
            _sb.Append(" CTAG=@CTAG,REFWORDTB=@REFWORD ");
            _sb.Append(" WHERE TCID=@TCID");

            MySqlParameter[] _param3 =
            {
                new MySqlParameter("@TID",            MySqlDbType.Int64),
                new MySqlParameter("@COLUMNNAME",     MySqlDbType.VarChar,  50),
                new MySqlParameter("@ISNULLABLE",     MySqlDbType.VarChar, 100),
                new MySqlParameter("@TYPE",           MySqlDbType.VarChar,  20),
                new MySqlParameter("@PRECISION",      MySqlDbType.Int32),
                new MySqlParameter("@SCALE",          MySqlDbType.Int32),
                new MySqlParameter("@LENGTH",         MySqlDbType.Int32),
                new MySqlParameter("@REFDMB",         MySqlDbType.VarChar,  50),
                new MySqlParameter("@DMBLEVELFORMAT", MySqlDbType.VarChar,  20),
                new MySqlParameter("@SECRETLEVEL",    MySqlDbType.Int32),
                new MySqlParameter("@DISPLAYTITLE",   MySqlDbType.VarChar,  50),
                new MySqlParameter("@DISPLAYFORMAT",  MySqlDbType.VarChar,  50),
                new MySqlParameter("@DISPLAYLENGTH",  MySqlDbType.Int32),
                new MySqlParameter("@DISPLAYHEIGHT",  MySqlDbType.Int32),
                new MySqlParameter("@DISPLAYORDER",   MySqlDbType.Int32),
                new MySqlParameter("@CANDISPLAY",     MySqlDbType.Int32),
                new MySqlParameter("@COLWIDTH",       MySqlDbType.Int32),
                new MySqlParameter("@DWDM",           MySqlDbType.VarChar,  20),
                new MySqlParameter("@CTAG",           MySqlDbType.VarChar, 500),
                new MySqlParameter("@REFWORD",        MySqlDbType.VarChar,  50),
                new MySqlParameter("@TCID",           MySqlDbType.Int64)
            };

            _param3[0].Value = Convert.ToInt64(_table.TID);
            _param3[1].Value = _tc.ColumnName;
            _param3[2].Value = _tc.IsNullable ? "Y" : "N";
            _param3[3].Value = _tc.ColumnType;
            _param3[4].Value = Convert.ToInt32(_tc.Precision);
            _param3[5].Value = Convert.ToInt32(_tc.Scale);
            _param3[6].Value = Convert.ToInt32(_tc.Length);
            _param3[7].Value = _tc.RefDMB;
            _param3[8].Value = _tc.DMBLevelFormat;

            _param3[9].Value  = Convert.ToInt32(_tc.SecretLevel);
            _param3[10].Value = _tc.DisplayTitle;
            _param3[11].Value = _tc.DisplayFormat;
            _param3[12].Value = Convert.ToInt32(_tc.DisplayLength);
            _param3[13].Value = Convert.ToInt32(_tc.DisplayHeight);
            _param3[14].Value = Convert.ToInt32(_tc.DisplayOrder);
            _param3[15].Value = _tc.CanDisplay ? 1 : 0;
            _param3[16].Value = Convert.ToInt32(_tc.ColWidth);
            _param3[17].Value = _tc.DWDM;
            _param3[18].Value = _tc.CTag;
            _param3[19].Value = _tc.RefWordTableName;
            _param3[20].Value = Convert.ToInt64(_tc.ColumnID);

            MysqlDBHelper.ExecuteNonQuery(MysqlDBHelper.conf, CommandType.Text, _sb.ToString(), _param3);
            MyDA_MetaDataQuery.ModelLib.Clear();
        }