private void CreateColumInfoToWord(DbLoginFor _DbLoginFor, bool _isTable = true) { IFrameWorkDb _IFrameWorkDb = null; _IFrameWorkDb = FrameWorkDbFactory.CreateNewFrameWorkDb(_DbLoginFor.ConnString, _DbLoginFor.Db_Type); if (_IFrameWorkDb == null) { MsgBox.Warning("您选中的表或者视图节点数据类型存在问题,请前去确认......."); return; } List <DbTableInfo> _tableList = _IFrameWorkDb.GetTables();//获取所的表 Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); bool _isSqlite = _DbLoginFor.Db_Type == 1 ? true : false; if (_isTable)//生成表的数据字典 { CreateCellStyle(builder); for (int i = 0; i < _tableList.Count; i++) { CreateTitleCell(builder, _tableList[i].Name); List <ColumnInfo> _columList = _IFrameWorkDb.GetColumsFromTable(_tableList[i].Name); CreateCell(builder, _columList, _isSqlite); } } else//生成视图的数据字典 { //下面加载视图 List <DbTableInfo> _viewList = _IFrameWorkDb.GetViews();//获取所有的视图 CreateCellStyle(builder); for (int i = 0; i < _viewList.Count; i++) { CreateTitleCell(builder, _tableList[i].Name, 2); //获取视图的每列信息 List <ColumnInfo> _columList = _IFrameWorkDb.GetColumsFromView(_viewList[i].Name); CreateCell(builder, _columList, _isSqlite); } } string _name = DialogUnitity.DialogSaveWordFile(ConstKeyUnitity.CAPTIONTEXT); if (string.IsNullOrEmpty(_name)) { MsgBox.Warning("保存文件名不可以为空..."); return; } doc.Save(_name); MsgBox.Infor("数据字典导出完成...."); }
private void CreateCSFileOneByOne(DbLoginFor _DbLoginFor, CodeTemplet __CodeTemplet, string _FolderPath, int _tableType = 1) { //加载所有的表 IFrameWorkDb _IFrameWorkDb = null; List <DbTableInfo> _tableList = null; _IFrameWorkDb = FrameWorkDbFactory.CreateNewFrameWorkDb(_DbLoginFor.ConnString, _DbLoginFor.Db_Type); if (_IFrameWorkDb == null) { MsgBox.Warning("您配置的数据库节点存在问题....."); return; } if (_tableType == 1)//表 { //System.Diagnostics.Stopwatch _stp= System.Diagnostics.Stopwatch.StartNew(); //_stp.Start(); _tableList = _IFrameWorkDb.GetTables();//获取所的表 List <Task> _TaskList = new List <Task>(); for (int i = 0; i < _tableList.Count; i++) { _TaskList.Add(Task.Factory.StartNew(new Func <object, int>(it => { int val1 = (int)it; IFrameWorkDb _IFrameWorkDbTheard = null; _IFrameWorkDbTheard = FrameWorkDbFactory.CreateNewFrameWorkDb(_DbLoginFor.ConnString, _DbLoginFor.Db_Type); List <ColumnInfo> _columnList = _IFrameWorkDbTheard.GetColumsFromTable(_tableList[val1].Name); foreach (var item in _columnList) { if (CSDBDic.ContainsKey(item.TypeName.Trim().ToUpper())) { item.TypeName = CSDBDic[item.TypeName.ToUpper()]; } } string CodeString = CreareRazorString(__CodeTemplet.CTemplet_Context, _tableList[val1].Name, __CodeTemplet.CTemplet_NameSP, __CodeTemplet.CTemplet_DbType, _columnList); string _fileName = _FolderPath + @"\" + __CodeTemplet.CTemplet_CPrefix.Trim() + _tableList[val1].Name + ".cs"; FileUnitity.StringToNewFile(_fileName, CodeString, System.Text.Encoding.UTF8); return(1); }), i)); if (i % 5 == 0) { Task.WaitAll(_TaskList.ToArray()); } } //_stp.Stop(); MsgBox.Infor(_stp.ElapsedMilliseconds.ToString()); } else //视图 { _tableList = _IFrameWorkDb.GetViews();//获取所的视图 List <Task> _TaskList = new List <Task>(); for (int i = 0; i < _tableList.Count; i++) { _TaskList.Add(Task.Factory.StartNew(new Func <object, int>(it => { int val1 = (int)it; List <ColumnInfo> _columnList = _IFrameWorkDb.GetColumsFromView(_tableList[val1].Name); foreach (var item in _columnList) { if (CSDBDic.ContainsKey(item.TypeName.Trim().ToUpper())) { item.TypeName = CSDBDic[item.TypeName.ToUpper()]; } } string CodeString = CreareRazorString(__CodeTemplet.CTemplet_Context, _tableList[val1].Name, __CodeTemplet.CTemplet_NameSP, __CodeTemplet.CTemplet_DbType, _columnList); string _fileName = _FolderPath + @"\" + __CodeTemplet.CTemplet_CPrefix.Trim() + _tableList[val1].Name + ".cs"; FileUnitity.StringToNewFile(_fileName, CodeString, System.Text.Encoding.UTF8); return(1); }), i)); if (i % 5 == 0) { Task.WaitAll(_TaskList.ToArray()); } } } }