Пример #1
0
 private void WriteTableDefine_New(MD_Namespace _ns)
 {
     using (MetaDataServiceClient _mdc = new MetaDataServiceClient())
     {
         foreach (MD_Table _table in _ns.TableList)
         {
             try
             {
                 this.label2.Text = string.Format("写入表{0}的定义 ....", _table.TableName);
                 Application.DoEvents();
                 string _newid = GetNewID(_table.TID, "MD_TABLE", "TID", _mdc);
                 string _oldid = _table.TID;
                 IDTable.Add(_oldid, _newid);
                 _table.TID           = _newid;
                 _table.NamespaceName = _ns.NameSpace;
                 _table.DWDM          = _ns.DWDM;
                 foreach (MD_TableColumn _tc in _table.Columns)
                 {
                     string _newcolumnid = GetNewID(_tc.ColumnID, "MD_TABLECOLUMN", "TCID", _mdc);
                     IDTable.Add(_tc.ColumnID, _newcolumnid);
                     _tc.ColumnID = _newcolumnid;
                     _tc.DWDM     = _ns.DWDM;
                     _tc.TID      = _table.TID;
                 }
                 _mdc.ImportTableDefine(_table);
             }
             catch (Exception ex)
             {
                 XtraMessageBox.Show(string.Format("导入表{0}时失败!{1}", _table.TableName, ex.Message), "系统提示");
                 break;
             }
         }
     }
 }
Пример #2
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);
                }
            }
        }