/// <summary> /// 重新获取 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsbRefresh_Click(object sender, EventArgs e) { FormUtils.ShowProcessing("正在查询表结构信息,请稍等......", this, arg => { DBUtils.Instance?.Info?.Refresh(); TxtSearchWords_TextChanged(sender, e); }, null); }
private void ExportToPdf() { string fileName = string.Empty; SaveFileDialog saveDia = new SaveFileDialog(); saveDia.Filter = "Text documents (.pdf)|*.pdf"; saveDia.Title = "另存文件为"; saveDia.CheckPathExists = true; saveDia.AddExtension = true; saveDia.AutoUpgradeEnabled = true; saveDia.DefaultExt = ".pdf"; saveDia.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); saveDia.OverwritePrompt = true; saveDia.ValidateNames = true; saveDia.FileName = DBUtils.Instance.Info.DBName + "表结构信息.pdf"; if (saveDia.ShowDialog(this) == DialogResult.OK) { //System.Diagnostics.Process process; //if (IsExistProcess(Path.GetFileName(saveDia.FileName), out process)) //{ // var dia = MessageBox.Show("文件已打开,导出前需关闭,是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); // if (dia == DialogResult.OK) // { // process.Kill(); // } //} FormUtils.ShowProcessing("正在导出数据字典PDF文档,请稍等......", this, arg => { try { // TODO 中文ttf字体库文件(微软雅黑) string baseFontPath = System.Windows.Forms.Application.StartupPath + "\\Fonts\\msyh.ttf"; System.Collections.Generic.List <TableDto> tableDtos = DBInstanceTransToDto(); TryOpenXml.Text.PdfUtils.ExportPdfByITextSharp(saveDia.FileName, baseFontPath, DBUtils.Instance.Info.DBName, tableDtos); if (MessageBox.Show("生成数据库字典PDF文档成功,是否打开?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { System.Diagnostics.Process.Start(saveDia.FileName); } } catch (Exception ex) { LogUtils.LogError("DBCHM执行出错", Developer.MJ, ex); } }, null); } }
private void BtnUpdateDisplayName_Click(object sender, EventArgs e) { if (DBUtils.Instance == null) { MessageBox.Show("更新批注,需连接数据库,请切换到要更新批注的数据库!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if (string.IsNullOrWhiteSpace(txtMulItem.Text)) { MessageBox.Show("请先选择批注数据文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } FormUtils.ShowProcessing("正在更新批注到数据库,请稍等......", this, arg => { string[] paths = txtMulItem.Text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); foreach (string ph in paths) { string extName = Path.GetExtension(ph).ToLower(); try { if (File.Exists(ph)) { if (extName == ".pdm") { UpdateCommentByPDM(ph); } else if (extName == ".xml") { UpdateCommentByXML(ph); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "出错", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } MessageBox.Show("更新表列批注完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); FormUtils.IsOK_Close = true; this.Close(); }, null); }
private void ExportToExcel() { string fileName = string.Empty; SaveFileDialog saveDia = new SaveFileDialog(); saveDia.Filter = "Excel files (*.xlsx)|*.xlsx"; saveDia.Title = "另存文件为"; saveDia.CheckPathExists = true; saveDia.AddExtension = true; saveDia.AutoUpgradeEnabled = true; saveDia.DefaultExt = ".xlsx"; saveDia.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); saveDia.OverwritePrompt = true; saveDia.ValidateNames = true; saveDia.FileName = DBUtils.Instance.Info.DBName + "表结构信息.xlsx"; if (saveDia.ShowDialog(this) == DialogResult.OK) { //System.Diagnostics.Process process; //if (IsExistProcess(Path.GetFileName(saveDia.FileName), out process)) //{ // var dia = MessageBox.Show("文件已打开,导出前需关闭,是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); // if (dia == DialogResult.OK) // { // process.Kill(); // } //} FormUtils.ShowProcessing("正在导出数据字典Excel文档,请稍等......", this, arg => { try { System.Collections.Generic.List <TableDto> tableDtos = DBInstanceTransToDto(); TryOpenXml.Text.ExcelUtils.ExportExcelByEpplus(saveDia.FileName, DBUtils.Instance.Info.DBName, tableDtos); if (MessageBox.Show("生成数据库字典Excel文档成功,是否打开?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { System.Diagnostics.Process.Start(saveDia.FileName); } } catch (Exception ex) { LogUtils.LogError("DBCHM执行出错", Developer.MJ, ex); } }, null); } }
private void ExportToMarkDown() { string fileName = string.Empty; SaveFileDialog saveDia = new SaveFileDialog(); saveDia.Filter = "markdown files (*.md)|*.md"; saveDia.Title = "另存文件为"; saveDia.CheckPathExists = true; saveDia.AddExtension = true; saveDia.AutoUpgradeEnabled = true; saveDia.DefaultExt = ".md"; saveDia.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); saveDia.OverwritePrompt = true; saveDia.ValidateNames = true; saveDia.FileName = DBUtils.Instance.Info.DBName + "表结构信息.md"; if (saveDia.ShowDialog(this) == DialogResult.OK) { FormUtils.ShowProcessing("正在导出数据字典markdown文档,请稍等......", this, arg => { try { System.Collections.Generic.List <TableDto> tableDtos = DBInstanceTransToDto(); TryOpenXml.Text.MarkDownUtils.Export(saveDia.FileName, DBUtils.Instance.Info.DBName, tableDtos); if (MessageBox.Show("生成数据库字典markdown文档成功,是否打开?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { System.Diagnostics.Process.Start(saveDia.FileName); } } catch (Exception ex) { LogUtils.LogError("DBCHM执行出错", Developer.MJ, ex); } }, null); } }
private void btnConnect_Click(object sender, EventArgs e) { if (GV_DBConfigs.SelectedRows.Count <= 0) { MessageBox.Show("请选择连接!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } int Id = Convert.ToInt32(GV_DBConfigs.SelectedRows[0].Cells[0].Value); DBCHMConfig config = ConfigUtils.Get(Id); if ((DBType)Enum.Parse(typeof(DBType), config.DBType) == DBType.SqlServer && !GV_DBConfigs.SelectedRows[0].Cells[6].Value.ToString().Equals("sa", StringComparison.OrdinalIgnoreCase)) { var dia = MessageBox.Show("非超级管理员的账号,可能因权限不足,查询不出表结构信息,确定要继续吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dia == DialogResult.Cancel) { return; } } FormUtils.ShowProcessing("正在查询表结构信息,请稍等......", this, arg => { try { DBUtils.Instance = DBMgr.UseDB((DBType)Enum.Parse(typeof(DBType), config.DBType), config.ConnString, 300); ConfigUtils.UpLastModified(Id); } catch (Exception ex) { LogUtils.LogError("连接数据库失败", Developer.SysDefault, ex, config); MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }, null); }
private void ExportToWord() { #region 引用Microsoft.Office.Interop.Word.dll导出word文档方法弃用,改为引用Aspose.Words.dll方法导出word文档 //FormUtils.ShowProcessing("正在导出数据字典Word文档,请稍等......", this, arg => //{ // try // { // System.Collections.Generic.List<TableDto> tableDtos = DBInstanceTransToDto(); // TryOpenXml.Text.WordUtils.ExportWordByMicrosoftOfficeInteropWord(DBUtils.Instance.Info.DBName, tableDtos); // MessageBox.Show("生成数据库字典Word文档成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); // } // catch (Exception ex) // { // LogUtils.LogError("DBCHM执行出错", Developer.MJ, ex); // } //}, null); #endregion string fileName = string.Empty; SaveFileDialog saveDia = new SaveFileDialog(); saveDia.Filter = "Word files (*.doc)|*.doc"; saveDia.Title = "另存文件为"; saveDia.CheckPathExists = true; saveDia.AddExtension = true; saveDia.AutoUpgradeEnabled = true; saveDia.DefaultExt = ".doc"; saveDia.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); saveDia.OverwritePrompt = true; saveDia.ValidateNames = true; saveDia.FileName = DBUtils.Instance.Info.DBName + "表结构信息.doc"; if (saveDia.ShowDialog(this) == DialogResult.OK) { //System.Diagnostics.Process process; //if (IsExistProcess(Path.GetFileName(saveDia.FileName), out process)) //{ // var dia = MessageBox.Show("文件已打开,导出前需关闭,是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); // if (dia == DialogResult.OK) // { // process.Kill(); // } //} FormUtils.ShowProcessing("正在导出数据字典Word文档,请稍等......", this, arg => { try { System.Collections.Generic.List <TableDto> tableDtos = DBInstanceTransToDto(); TryOpenXml.Text.WordUtils.ExportWordByAsposeWords(saveDia.FileName, DBUtils.Instance.Info.DBName, tableDtos); if (MessageBox.Show("生成数据库字典Word文档成功,是否打开?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { System.Diagnostics.Process.Start(saveDia.FileName); } } catch (Exception ex) { LogUtils.LogError("DBCHM执行出错", Developer.MJ, ex); } }, null); } }