diff --git a/Update.md b/Update.md index 4944ea8..cf07872 100644 --- a/Update.md +++ b/Update.md @@ -1,4 +1,9 @@ ## 更新日志 +2018-11-01 + + + 添加终端窗口; + + 修正无法生成数据库文档的问题; + * 优化其他一些细节; 2018-08-31 diff --git a/src/Kalman.Studio/Kalman.Studio.csproj b/src/Kalman.Studio/Kalman.Studio.csproj index c0433df..ec3a783 100644 --- a/src/Kalman.Studio/Kalman.Studio.csproj +++ b/src/Kalman.Studio/Kalman.Studio.csproj @@ -114,8 +114,8 @@ ..\packages\ICSharpCode.TextEditor.3.2.1.6466\lib\Net20\ICSharpCode.TextEditor.dll - - ..\packages\iTextSharp.5.5.13\lib\itextsharp.dll + + ..\packages\RedGate.iTextSharp.4.1.6.16\lib\net40\itextsharp.dll ..\packages\LiteDB.4.1.4\lib\net40\LiteDB.dll diff --git a/src/Kalman.Studio/Library/Export.cs b/src/Kalman.Studio/Library/Export.cs index cdde3ac..217f954 100644 --- a/src/Kalman.Studio/Library/Export.cs +++ b/src/Kalman.Studio/Library/Export.cs @@ -1,16 +1,18 @@ -锘縰sing Aspose.Cells; +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; using iTextSharp.text; using iTextSharp.text.pdf; -using Kalman.Data; +using System.IO; +using Kalman.Command; +using ICSharpCode.TextEditor.Util; +using iTextSharp.text.rtf; +using iTextSharp.text.html; using Kalman.Data.SchemaObject; +using Kalman.Data; using Kalman.PdmParser; -using System; -using System.Collections.Generic; -using System.IO; -/// -/// 鐢变簬鍒犻櫎浜嗙増鏉僁LL锛屽鑷磋鍔熻兘鏃犳硶浣跨敤銆傚彲鍦≦Q缇わ細122161138涓笅杞絪ource_lib.zip -/// namespace Kalman.Studio { public class iTextExporter @@ -18,14 +20,14 @@ public class iTextExporter enum ExportTyep { PDF = 0, - RTF = 1 - //HTML = 2 + RTF = 1, + HTML = 2 } string fileName = string.Empty; - //Table t = null; + Table t = null; BaseFont baseFont = BaseFont.CreateFont("c:\\windows\\fonts\\STSONG.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); - iTextSharp.text.Font font; + Font font; public iTextExporter(string path) { @@ -38,17 +40,17 @@ public iTextExporter(string path) //BaseFont baseFont = BaseFont.CreateFont("C:\\WINDOWS\\FONTS\\SIMHEI.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); //BaseFont baseFont = BaseFont.CreateFont("c:\\windows\\fonts\\STSONG.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); - font = new iTextSharp.text.Font(baseFont,12); + font = new Font(baseFont, 12); } public void PDModel2Pdf(IList tableList, string title) { - Export(tableList,title, ExportTyep.PDF); + Export(tableList, title, ExportTyep.PDF); } public void PDModel2Rtf(IList tableList, string title) { - Export(tableList,title, ExportTyep.RTF); + Export(tableList, title, ExportTyep.RTF); } //public void PDModel2Html(PDModel m) @@ -56,7 +58,7 @@ public void PDModel2Rtf(IList tableList, string title) // Export(m, ExportTyep.HTML); //} - private void Export(IList tableList,string title, ExportTyep exportType) + private void Export(IList tableList, string title, ExportTyep exportType) { Document doc = new Document(PageSize.A4.Rotate(), 20, 20, 20, 20); DocWriter w; @@ -67,11 +69,11 @@ private void Export(IList tableList,string title, ExportTyep exportType w = PdfWriter.GetInstance(doc, new FileStream(fileName, FileMode.Create, FileAccess.Write)); break; case ExportTyep.RTF: - //w = RtfWriter2.GetInstance(doc, new FileStream(fileName, FileMode.Create, FileAccess.Write)); + w = RtfWriter2.GetInstance(doc, new FileStream(fileName, FileMode.Create, FileAccess.Write)); + break; + case ExportTyep.HTML: + w = HtmlWriter.GetInstance(doc, new FileStream(fileName, FileMode.Create, FileAccess.Write)); break; - //case ExportTyep.HTML: - // w = HtmlWriter.GetInstance(doc, new FileStream(fileName, FileMode.Create, FileAccess.Write)); - //break; default: break; } @@ -94,8 +96,7 @@ private void Export(IList tableList,string title, ExportTyep exportType foreach (PDTable table in tableList) { - //sec = cpt.AddSection(new Paragraph(string.Format("{0}[{1}]", table.Name, table.Code), font)); - sec = cpt.AddSection(new Paragraph(string.Format("{0}[{1}]", table.Name, table.Code))); + sec = cpt.AddSection(new Paragraph(string.Format("{0}[{1}]", table.Name, table.Code), font)); if (string.IsNullOrEmpty(table.Comment) == false) { @@ -103,76 +104,76 @@ private void Export(IList tableList,string title, ExportTyep exportType sec.Add(chunk); } - //t = new Table(9, table.ColumnList.Count); - - ////t.Border = 15; - ////t.BorderColor = Color.BLACK; - ////t.BorderWidth = 1.0f; - //t.AutoFillEmptyCells = true; - //t.CellsFitPage = true; - //t.TableFitsPage = true; - //t.Cellpadding = 3; - ////if (exportType == ExportTyep.PDF) t.Cellspacing = 2; - //t.DefaultVerticalAlignment = Element.ALIGN_MIDDLE; - - //t.SetWidths(new int[] { 200, 200, 150, 50, 50, 50, 50, 50, 300 }); - - //t.AddCell(BuildHeaderCell("鍚嶇О")); - //t.AddCell(BuildHeaderCell("浠g爜")); - //t.AddCell(BuildHeaderCell("鏁版嵁绫诲瀷")); - //t.AddCell(BuildHeaderCell("闀垮害")); - //t.AddCell(BuildHeaderCell("绮惧害")); - //t.AddCell(BuildHeaderCell("涓婚敭")); - //t.AddCell(BuildHeaderCell("澶栭敭")); - //t.AddCell(BuildHeaderCell("鍙┖")); - //t.AddCell(BuildHeaderCell("娉ㄩ噴")); - - //foreach (PDColumn column in table.ColumnList) - //{ - // t.AddCell(BuildCell(column.Name)); - // t.AddCell(BuildCell(column.Code)); - // t.AddCell(BuildCell(column.DataType)); - // t.AddCell(BuildCell(column.Length == 0 ? "" : column.Length.ToString())); - // t.AddCell(BuildCell(column.Precision == 0 ? "" : column.Precision.ToString())); - // t.AddCell(BuildCell(column.IsPK ? " 鈭" : "")); - // t.AddCell(BuildCell(column.IsFK ? " 鈭" : "")); - // t.AddCell(BuildCell(column.Mandatory ? "" : " 鈭")); - // t.AddCell(BuildCell(column.Comment)); - //} - - //sec.Add(t); + t = new Table(9, table.ColumnList.Count); + + //t.Border = 15; + //t.BorderColor = Color.BLACK; + //t.BorderWidth = 1.0f; + t.AutoFillEmptyCells = true; + t.CellsFitPage = true; + t.TableFitsPage = true; + t.Cellpadding = 3; + //if (exportType == ExportTyep.PDF) t.Cellspacing = 2; + t.DefaultVerticalAlignment = Element.ALIGN_MIDDLE; + + t.SetWidths(new int[] { 200, 200, 150, 50, 50, 50, 50, 50, 300 }); + + t.AddCell(BuildHeaderCell("鍚嶇О")); + t.AddCell(BuildHeaderCell("浠g爜")); + t.AddCell(BuildHeaderCell("鏁版嵁绫诲瀷")); + t.AddCell(BuildHeaderCell("闀垮害")); + t.AddCell(BuildHeaderCell("绮惧害")); + t.AddCell(BuildHeaderCell("涓婚敭")); + t.AddCell(BuildHeaderCell("澶栭敭")); + t.AddCell(BuildHeaderCell("鍙┖")); + t.AddCell(BuildHeaderCell("娉ㄩ噴")); + + foreach (PDColumn column in table.ColumnList) + { + t.AddCell(BuildCell(column.Name)); + t.AddCell(BuildCell(column.Code)); + t.AddCell(BuildCell(column.DataType)); + t.AddCell(BuildCell(column.Length == 0 ? "" : column.Length.ToString())); + t.AddCell(BuildCell(column.Precision == 0 ? "" : column.Precision.ToString())); + t.AddCell(BuildCell(column.IsPK ? " 鈭" : "")); + t.AddCell(BuildCell(column.IsFK ? " 鈭" : "")); + t.AddCell(BuildCell(column.Mandatory ? "" : " 鈭")); + t.AddCell(BuildCell(column.Comment)); + } + + sec.Add(t); } doc.Add(cpt); doc.Close(); } - //private Cell BuildHeaderCell(string title) - //{ - // Phrase phrase = new Phrase(title, font); - // Cell cell = new Cell(phrase); - // cell.Header = true; - // cell.BackgroundColor = Color.LIGHT_GRAY; - // cell.VerticalAlignment = Element.ALIGN_MIDDLE; - // cell.HorizontalAlignment = Element.ALIGN_LEFT; - // //cell.Border = 15; - // //cell.BorderWidth = 0.2f; - // //cell.BorderColor = Color.BLACK; - // return cell; - //} + private Cell BuildHeaderCell(string title) + { + Phrase phrase = new Phrase(title, font); + Cell cell = new Cell(phrase); + cell.Header = true; + cell.BackgroundColor = Color.LIGHT_GRAY; + cell.VerticalAlignment = Element.ALIGN_MIDDLE; + cell.HorizontalAlignment = Element.ALIGN_LEFT; + //cell.Border = 15; + //cell.BorderWidth = 0.2f; + //cell.BorderColor = Color.BLACK; + return cell; + } - //Cell BuildCell(string text) - //{ - // Phrase phrase = new Phrase(text, font); - // Cell cell = new Cell(phrase); - // cell.VerticalAlignment = Element.ALIGN_MIDDLE; - // cell.HorizontalAlignment = Element.ALIGN_LEFT; - // //cell.Border = 15; - // //cell.BorderWidth = 0.2f; - // //cell.BorderColor = Color.BLACK; - - // return cell; - //} + Cell BuildCell(string text) + { + Phrase phrase = new Phrase(text, font); + Cell cell = new Cell(phrase); + cell.VerticalAlignment = Element.ALIGN_MIDDLE; + cell.HorizontalAlignment = Element.ALIGN_LEFT; + //cell.Border = 15; + //cell.BorderWidth = 0.2f; + //cell.BorderColor = Color.BLACK; + + return cell; + } /// /// @@ -185,6 +186,11 @@ public void DbSchema2Pdf(DbSchema schema, SODatabase db, List tableList tableList = Export(schema, db, tableList, ExportTyep.PDF); } + public void DbSchema2Html(DbSchema schema, SODatabase db, List tableList) + { + tableList = Export(schema, db, tableList, ExportTyep.HTML); + } + public void DbSchema2Rtf(DbSchema schema, SODatabase db, List tableList) { tableList = Export(schema, db, tableList, ExportTyep.RTF); @@ -204,11 +210,11 @@ private List Export(DbSchema schema, SODatabase db, List table w = PdfWriter.GetInstance(doc, new FileStream(fileName, FileMode.Create, FileAccess.Write)); break; case ExportTyep.RTF: - //w = RtfWriter2.GetInstance(doc, new FileStream(fileName, FileMode.Create, FileAccess.Write)); + w = RtfWriter2.GetInstance(doc, new FileStream(fileName, FileMode.Create, FileAccess.Write)); + break; + case ExportTyep.HTML: + w = HtmlWriter.GetInstance(doc, new FileStream(fileName, FileMode.Create, FileAccess.Write)); break; - //case ExportTyep.HTML: - // w = HtmlWriter.GetInstance(doc, new FileStream(fileName, FileMode.Create, FileAccess.Write)); - //break; default: break; } @@ -220,17 +226,19 @@ private List Export(DbSchema schema, SODatabase db, List table Chapter cpt = new Chapter(db.Name, 1); Section sec; - - doc.AddTitle(db.Name); - doc.AddAuthor("Kalman"); - doc.AddCreationDate(); - doc.AddCreator("Kalman"); - doc.AddSubject("鏁版嵁搴撴枃妗"); + #region + if (exportType != ExportTyep.HTML) + { + doc.AddTitle(db.Name); + doc.AddAuthor("Kalman"); + doc.AddCreationDate(); + doc.AddCreator("Kalman"); + doc.AddSubject("鏁版嵁搴撴枃妗"); + } foreach (SOTable table in tableList) { - //sec = cpt.AddSection(new Paragraph(table.Name, font)); - sec = cpt.AddSection(new Paragraph(table.Name)); + sec = cpt.AddSection(new Paragraph(table.Name, font)); if (string.IsNullOrEmpty(table.Comment) == false) { @@ -240,41 +248,42 @@ private List Export(DbSchema schema, SODatabase db, List table List columnList = schema.GetTableColumnList(table); - //t = new Table(7, columnList.Count); - - //t.AutoFillEmptyCells = true; - //t.CellsFitPage = true; - //t.TableFitsPage = true; - //t.Cellpadding = 3; - ////if (exportType == ExportTyep.PDF) t.Cellspacing = 2; - //t.DefaultVerticalAlignment = Element.ALIGN_MIDDLE; - - //t.SetWidths(new int[] { 200, 150, 50, 50, 50, 100, 300 }); - - //t.AddCell(BuildHeaderCell("鍚嶇О")); - //t.AddCell(BuildHeaderCell("鏁版嵁绫诲瀷")); - //t.AddCell(BuildHeaderCell("涓婚敭")); - //t.AddCell(BuildHeaderCell("鏍囧織")); - //t.AddCell(BuildHeaderCell("鍙┖")); - //t.AddCell(BuildHeaderCell("榛樿鍊")); - //t.AddCell(BuildHeaderCell("娉ㄩ噴")); - - //foreach (SOColumn column in columnList) - //{ - // t.AddCell(BuildCell(column.Name)); - // t.AddCell(BuildCell(GetDbColumnType(column))); - // t.AddCell(BuildCell(column.PrimaryKey ? " 鈭" : "")); - // t.AddCell(BuildCell(column.Identify ? " 鈭" : "")); - // t.AddCell(BuildCell(column.Nullable ? " 鈭" : "")); - // t.AddCell(BuildCell(column.DefaultValue == null ? "" : column.DefaultValue.ToString())); - // t.AddCell(BuildCell(column.Comment)); - //} - - //sec.Add(t); + t = new Table(7, columnList.Count); + + t.AutoFillEmptyCells = true; + t.CellsFitPage = true; + t.TableFitsPage = true; + t.Cellpadding = 3; + //if (exportType == ExportTyep.PDF) t.Cellspacing = 2; + t.DefaultVerticalAlignment = Element.ALIGN_MIDDLE; + + t.SetWidths(new int[] { 200, 150, 50, 50, 50, 100, 300 }); + + t.AddCell(BuildHeaderCell("鍚嶇О")); + t.AddCell(BuildHeaderCell("鏁版嵁绫诲瀷")); + t.AddCell(BuildHeaderCell("涓婚敭")); + t.AddCell(BuildHeaderCell("鏍囧織")); + t.AddCell(BuildHeaderCell("鍙┖")); + t.AddCell(BuildHeaderCell("榛樿鍊")); + t.AddCell(BuildHeaderCell("娉ㄩ噴")); + + foreach (SOColumn column in columnList) + { + t.AddCell(BuildCell(column.Name)); + t.AddCell(BuildCell(GetDbColumnType(column))); + t.AddCell(BuildCell(column.PrimaryKey ? " 鈭" : "")); + t.AddCell(BuildCell(column.Identify ? " 鈭" : "")); + t.AddCell(BuildCell(column.Nullable ? " 鈭" : "")); + t.AddCell(BuildCell(column.DefaultValue == null ? "" : column.DefaultValue.ToString())); + t.AddCell(BuildCell(column.Comment)); + } + + sec.Add(t); } doc.Add(cpt); doc.Close(); + #endregion return tableList; } diff --git a/src/Kalman.Studio/Properties/AssemblyInfo.cs b/src/Kalman.Studio/Properties/AssemblyInfo.cs index 681a48f..0914310 100644 --- a/src/Kalman.Studio/Properties/AssemblyInfo.cs +++ b/src/Kalman.Studio/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // 鍙互鎸囧畾鎵鏈夎繖浜涘硷紝涔熷彲浠ヤ娇鐢ㄢ滃唴閮ㄧ増鏈彿鈥濆拰鈥滀慨璁㈠彿鈥濈殑榛樿鍊硷紝 // 鏂规硶鏄寜濡備笅鎵绀轰娇鐢ㄢ*鈥: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.3.0.*")] -[assembly: AssemblyFileVersion("2.3.0")] +[assembly: AssemblyVersion("2.3.1.*")] +[assembly: AssemblyFileVersion("2.3.1")] diff --git a/src/Kalman.Studio/ToolForm/DbDocBuilder.cs b/src/Kalman.Studio/ToolForm/DbDocBuilder.cs index 7cd3916..e5022c3 100644 --- a/src/Kalman.Studio/ToolForm/DbDocBuilder.cs +++ b/src/Kalman.Studio/ToolForm/DbDocBuilder.cs @@ -238,6 +238,24 @@ private void btnOK_Click(object sender, EventArgs e) } } } + + if (rbtnHtml.Checked) + { + saveFileDialog1.Filter = "Html鏂囦欢(*.html)|*.html|鎵鏈夋枃浠(*.*)|*.*"; + saveFileDialog1.FileName = CurrentDatabase.Name; + if (saveFileDialog1.ShowDialog() == DialogResult.OK) + { + string fileName = saveFileDialog1.FileName; + + iTextExporter exporter = new iTextExporter(fileName); + exporter.DbSchema2Html(currentSchema, CurrentDatabase, list); + + if (MsgBox.ShowQuestionMessage("鏁版嵁搴撴枃妗g敓鎴愭垚鍔燂紝鏄惁鎵撳紑鏂囨。", "鎻愮ず淇℃伅") == DialogResult.Yes) + { + CmdHelper.Execute(fileName); + } + } + } } private void btnExit_Click(object sender, EventArgs e) diff --git a/src/Kalman.Studio/ToolForm/DbDocBuilder.designer.cs b/src/Kalman.Studio/ToolForm/DbDocBuilder.designer.cs index 3151400..a35b5ed 100644 --- a/src/Kalman.Studio/ToolForm/DbDocBuilder.designer.cs +++ b/src/Kalman.Studio/ToolForm/DbDocBuilder.designer.cs @@ -34,6 +34,7 @@ private void InitializeComponent() this.label1 = new System.Windows.Forms.Label(); this.cbConnectionStrings = new System.Windows.Forms.ComboBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.rbtnHtml = new System.Windows.Forms.RadioButton(); this.btnExit = new System.Windows.Forms.Button(); this.btnOK = new System.Windows.Forms.Button(); this.rbtnPdf = new System.Windows.Forms.RadioButton(); @@ -106,6 +107,7 @@ private void InitializeComponent() // // groupBox2 // + this.groupBox2.Controls.Add(this.rbtnHtml); this.groupBox2.Controls.Add(this.btnExit); this.groupBox2.Controls.Add(this.btnOK); this.groupBox2.Controls.Add(this.rbtnPdf); @@ -118,6 +120,17 @@ private void InitializeComponent() this.groupBox2.TabStop = false; this.groupBox2.Text = "閫夋嫨鏂囨。杈撳嚭鏍煎紡"; // + // rbtnHtml + // + this.rbtnHtml.AutoSize = true; + this.rbtnHtml.Location = new System.Drawing.Point(167, 23); + this.rbtnHtml.Name = "rbtnHtml"; + this.rbtnHtml.Size = new System.Drawing.Size(71, 16); + this.rbtnHtml.TabIndex = 6; + this.rbtnHtml.TabStop = true; + this.rbtnHtml.Text = "Html鏍煎紡"; + this.rbtnHtml.UseVisualStyleBackColor = true; + // // btnExit // this.btnExit.Location = new System.Drawing.Point(491, 20); @@ -153,7 +166,7 @@ private void InitializeComponent() // rbtnWord // this.rbtnWord.AutoSize = true; - this.rbtnWord.Location = new System.Drawing.Point(104, 23); + this.rbtnWord.Location = new System.Drawing.Point(89, 23); this.rbtnWord.Name = "rbtnWord"; this.rbtnWord.Size = new System.Drawing.Size(71, 16); this.rbtnWord.TabIndex = 0; @@ -294,5 +307,6 @@ private void InitializeComponent() private System.Windows.Forms.RadioButton rbtnPdf; private System.Windows.Forms.Button btnExit; private System.Windows.Forms.SaveFileDialog saveFileDialog1; + private System.Windows.Forms.RadioButton rbtnHtml; } } \ No newline at end of file diff --git a/src/Kalman.Studio/packages.config b/src/Kalman.Studio/packages.config index 21b3c01..d6e459c 100644 --- a/src/Kalman.Studio/packages.config +++ b/src/Kalman.Studio/packages.config @@ -8,7 +8,6 @@ - @@ -28,6 +27,7 @@ +