diff --git a/.vs/AIProofread/v17/.suo b/.vs/AIProofread/v17/.suo index 20001d6..ea79337 100644 Binary files a/.vs/AIProofread/v17/.suo and b/.vs/AIProofread/v17/.suo differ diff --git a/AIProofread.sln b/AIProofread.sln index 0e78899..eae8630 100644 --- a/AIProofread.sln +++ b/AIProofread.sln @@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestConsoleApp", "TestConso EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "util-lib", "util-lib\util-lib.csproj", "{FF204E99-82F8-405E-847B-88FC6DF07715}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "updater", "updater\updater.csproj", "{73AC658D-CD49-4731-8491-A7BDBC811559}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -34,6 +36,12 @@ Global {FF204E99-82F8-405E-847B-88FC6DF07715}.Release|Any CPU.Build.0 = Release|Any CPU {FF204E99-82F8-405E-847B-88FC6DF07715}.Test|Any CPU.ActiveCfg = Test|Any CPU {FF204E99-82F8-405E-847B-88FC6DF07715}.Test|Any CPU.Build.0 = Test|Any CPU + {73AC658D-CD49-4731-8491-A7BDBC811559}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {73AC658D-CD49-4731-8491-A7BDBC811559}.Debug|Any CPU.Build.0 = Debug|Any CPU + {73AC658D-CD49-4731-8491-A7BDBC811559}.Release|Any CPU.ActiveCfg = Release|Any CPU + {73AC658D-CD49-4731-8491-A7BDBC811559}.Release|Any CPU.Build.0 = Release|Any CPU + {73AC658D-CD49-4731-8491-A7BDBC811559}.Test|Any CPU.ActiveCfg = Debug|Any CPU + {73AC658D-CD49-4731-8491-A7BDBC811559}.Test|Any CPU.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/AIProofread/AIProofread.csproj b/AIProofread/AIProofread.csproj index 28355bf..2b55a17 100644 --- a/AIProofread/AIProofread.csproj +++ b/AIProofread/AIProofread.csproj @@ -125,6 +125,24 @@ --> + + ..\packages\BouncyCastle.Cryptography.2.3.1\lib\net461\BouncyCastle.Cryptography.dll + + + ..\packages\Enums.NET.4.0.1\lib\net45\Enums.NET.dll + + + ..\packages\ExtendedNumerics.BigDecimal.2025.1001.2.129\lib\net46\ExtendedNumerics.BigDecimal.dll + + + ..\packages\SharpZipLib.1.4.2\lib\netstandard2.0\ICSharpCode.SharpZipLib.dll + + + ..\packages\MathNet.Numerics.Signed.5.0.0\lib\net461\MathNet.Numerics.dll + + + ..\packages\Microsoft.IO.RecyclableMemoryStream.3.0.0\lib\netstandard2.0\Microsoft.IO.RecyclableMemoryStream.dll + ..\packages\Microsoft.Web.WebView2.1.0.2210.55\lib\net45\Microsoft.Web.WebView2.Core.dll @@ -137,15 +155,83 @@ ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll + + ..\packages\NPOI.2.7.1\lib\netstandard2.0\NPOI.Core.dll + + + ..\packages\NPOI.2.7.1\lib\netstandard2.0\NPOI.OOXML.dll + + + ..\packages\NPOI.2.7.1\lib\netstandard2.0\NPOI.OpenXml4Net.dll + + + ..\packages\NPOI.2.7.1\lib\netstandard2.0\NPOI.OpenXmlFormats.dll + + + ..\packages\SixLabors.Fonts.1.0.1\lib\netstandard2.0\SixLabors.Fonts.dll + + + ..\packages\SixLabors.ImageSharp.2.1.8\lib\netstandard2.0\SixLabors.ImageSharp.dll + + + ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + + + ..\packages\System.Configuration.ConfigurationManager.6.0.0\lib\net461\System.Configuration.ConfigurationManager.dll + + + + ..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll + + + + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll + + + + ..\packages\System.Security.AccessControl.6.0.0\lib\net461\System.Security.AccessControl.dll + + + ..\packages\System.Security.Cryptography.Pkcs.6.0.3\lib\net461\System.Security.Cryptography.Pkcs.dll + + + ..\packages\System.Security.Cryptography.Xml.6.0.1\lib\net461\System.Security.Cryptography.Xml.dll + + + ..\packages\System.Security.Permissions.6.0.0\lib\net461\System.Security.Permissions.dll + + + ..\packages\System.Security.Principal.Windows.5.0.0\lib\net461\System.Security.Principal.Windows.dll + + + + ..\packages\System.Text.Encoding.CodePages.5.0.0\lib\net461\System.Text.Encoding.CodePages.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll + + + + ..\packages\System.ValueTuple.4.4.0\lib\net461\System.ValueTuple.dll + True + True + + @@ -234,16 +320,22 @@ ProofreadMainControl.cs + + + + + Code + FormContact.cs @@ -304,6 +396,10 @@ + + {73ac658d-cd49-4731-8491-a7bdbc811559} + updater + {ff204e99-82f8-405e-847b-88fc6df07715} util-lib diff --git a/AIProofread/AIProofread.csproj.user b/AIProofread/AIProofread.csproj.user index 2b6bc73..5edd783 100644 --- a/AIProofread/AIProofread.csproj.user +++ b/AIProofread/AIProofread.csproj.user @@ -8,6 +8,6 @@ Project - C:\Soft\Kingsoft\WPS Office\12.1.0.16929\office6\wps.exe + C:\Soft\Kingsoft\WPS Office\12.1.0.17827\office6\wps.exe \ No newline at end of file diff --git a/AIProofread/Bridge.cs b/AIProofread/Bridge.cs index b75f266..039d3f4 100644 --- a/AIProofread/Bridge.cs +++ b/AIProofread/Bridge.cs @@ -1,4 +1,5 @@ using AIProofread.Controls; +using AIProofread.core; using AIProofread.Util; using Microsoft.Office.Interop.Word; using Microsoft.Office.Tools.Word; @@ -13,6 +14,7 @@ using System.IO; using System.Runtime.InteropServices; using System.Text.RegularExpressions; using System.Threading.Tasks; +using System.Windows.Forms; using UtilLib; using Document = Microsoft.Office.Interop.Word.Document; using Task = System.Threading.Tasks.Task; @@ -162,43 +164,11 @@ namespace AIProofread data.Add("fullName", doc.FullName); data.Add("wordsCount", doc.Words.Count); data.Add("charactersCount", doc.Characters.Count); + data.Add("content", Tools.GetAllText(doc)); - Application app = new Application(); - - object missing = System.Reflection.Missing.Value; - object saveOption = WdSaveOptions.wdDoNotSaveChanges; - // 创建临时文件 - string path = CreateTempDocumentFile(doc); - Document tmpDoc = app.Documents.Open(path, false, true, false); - data.Add("content", Tools.GetAllText(tmpDoc)); - // 关闭并释放对象 - tmpDoc.Close(ref saveOption, ref missing, ref missing); - Marshal.ReleaseComObject(tmpDoc); - app.Quit(ref saveOption,ref missing,ref missing); - Marshal.ReleaseComObject(app); - // 显式回收一下吧 - GC.Collect(); - File.Delete(path); return Tools.GetJSONString(data); } - private string CreateTempDocumentFile(Document doc) - { - // 先转成临时文件 - FileStream fs = new FileStream(doc.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); - // - var tmpFile = Path.GetTempFileName(); - byte[] bytes = new byte[fs.Length]; - fs.Read(bytes, 0, bytes.Length); - FileStream tmp = new FileStream(tmpFile, FileMode.OpenOrCreate,FileAccess.ReadWrite); - tmp.Write(bytes, 0, bytes.Length); - // 关闭吧 - tmp.Close(); - fs.Close(); - - return tmpFile; - } - public string getParagraphTextByRange(int start, int end) { @@ -244,7 +214,7 @@ namespace AIProofread } - public void getParagraphTextByRangeSync(int start,int end) + public void getParagraphTextByRangeSync(int start, int end) { //var list = Tools.GetTextListByParagraphRange(start, end); //return Tools.GetJSONString(list); @@ -309,33 +279,40 @@ namespace AIProofread public async static void InitWebEnvAsync(string name, WebView2 webView) { - webView.Name = name; - if (webViewDict.ContainsKey(webView.Name)) + try { - webViewDict[name] = webView; + webView.Name = name; + if (webViewDict.ContainsKey(webView.Name)) + { + webViewDict[name] = webView; + } + else + { + webViewDict.Add(name, webView); + } + + // 禁用web安全,允许跨域 否则需要web编译为umd加载模式 + var ops = new CoreWebView2EnvironmentOptions("--disable-web-security"); + var env = await CoreWebView2Environment.CreateAsync(null, Config.WEB_DATA_PATH, ops); + await webView.EnsureCoreWebView2Async(env); + //webView.CoreWebView2.Settings.AreDevToolsEnabled = false; + //webView.CoreWebView2.Settings.AreDefaultScriptDialogsEnabled = false; + //webView.CoreWebView2.Settings.AreHostObjectsAllowed = true; + // 添加 js与客户端代理 + + webView.CoreWebView2.AddHostObjectToScript("bridge", bridge); } - else + catch (Exception ex) { - webViewDict.Add(name, webView); + Logger.Log(ex); } - - // 禁用web安全,允许跨域 否则需要web编译为umd加载模式 - var ops = new CoreWebView2EnvironmentOptions("--disable-web-security"); - var env = await CoreWebView2Environment.CreateAsync(null, Config.WEB_DATA_PATH, ops); - await webView.EnsureCoreWebView2Async(env); - //webView.CoreWebView2.Settings.AreDevToolsEnabled = false; - //webView.CoreWebView2.Settings.AreDefaultScriptDialogsEnabled = false; - //webView.CoreWebView2.Settings.AreHostObjectsAllowed = true; - // 添加 js与客户端代理 - - webView.CoreWebView2.AddHostObjectToScript("bridge", bridge); } // 清除所有标记 public void clearAllProofreadMark() { - // 设置当前文档数据 + // 标记当前文档所有书签数据 Globals.ThisAddIn.ActiveCurrentDocumentMarks(); try { @@ -542,7 +519,7 @@ namespace AIProofread marks[proofreadId].Select(); //Globals.ThisAddIn.SendMessageToWeb("select", proofreadId); } - Globals.ThisAddIn.SendMessageToWeb("select_proofread", proofreadId); + Globals.ThisAddIn.SendMessageToWeb("select-proofread", proofreadId); } public void processMark(int proofreadId, int status) @@ -553,7 +530,17 @@ namespace AIProofread } } - public void InitContent(string content) + private Document _currentDocument; + public Document CurrentDocument + { + get => _currentDocument ?? Globals.ThisAddIn.Application.ActiveDocument; + set + { + _currentDocument = value; + } + } + + public string InitContent(string content) { try { @@ -564,25 +551,19 @@ namespace AIProofread //var app = Globals.ThisAddIn.Application; //var cur = app.Selection; // + List disabledList = new List(); foreach (var correct in list) { - //cur.TypeText(correct.Insert); - //var rng = cur.Range; if (correct.Diffs != null && correct.Diffs.Count > 0) { - //var diffs = correct.Diffs.OrderBy(it => - //{ - // if (it.tag != "i") return it.start; - // return it.start + correct.Insert_len; - //}).ToList(); int index = 0; foreach (var item in correct.Diffs) { - if (item.idx == 3330) + if(item.id == 187117) { Console.WriteLine("xx"); } - var mark = AddBookmark(item, index, correct.Sentence_offset, correct.Insert_len, correct.Paragraph_num); + var mark = FindRangeAndCreateBookmark(correct.Insert, item, index, correct.Sentence_offset, correct.Insert_len, correct.Paragraph_num); if (item.tag != "i") index++; if (mark != null) { @@ -590,6 +571,7 @@ namespace AIProofread } else { + disabledList.Add(item.id); var msg = new Dictionary{ {"message","没有找到标记对象" }, { "origin",item }, @@ -599,7 +581,6 @@ namespace AIProofread }; Logger.Log(JsonConvert.SerializeObject(msg)); } - } } } @@ -618,28 +599,37 @@ namespace AIProofread } } } + + + // 隐藏面板对应校对项 + MainPanelWebMessage.DisabledProofreadItem(disabledList); } catch (Exception ex) { Logger.Log("Initial Content error:" + ex.Message + "\n" + ex.StackTrace + "\n\n"); + return "false"; } + return "true"; + } + + void SendMessageToPanel() + { + } public string GetParagraph(int index) { - - var document = Globals.ThisAddIn.Application.ActiveDocument; try { - var paragraphs = document.Paragraphs; + var paragraphs = CurrentDocument.Paragraphs; var total = paragraphs.Count; // 判断索引是否超出范围 if (index > total) { return null; } - var paragraph = document.Paragraphs[index]; + var paragraph = CurrentDocument.Paragraphs[index]; return paragraph.Range.Text; } catch (Exception ex) @@ -648,12 +638,27 @@ namespace AIProofread } } - public Microsoft.Office.Tools.Word.Bookmark AddBookmark(CorrectedContent item, int findIndex, int offset, int length, int paragraphIndex) + /// + /// 新增校对项 查找时的偏移量 + /// + private static readonly int INSERT_FIND_OFFSET = 5; + + /// + /// 根据校对项查找文档对应的位置 并创建书签 + /// + /// 接口原始文档 + /// 校对项 + /// + /// + /// + /// + /// + public Microsoft.Office.Tools.Word.Bookmark FindRangeAndCreateBookmark(string originText, CorrectedContent item, int findIndex, int offset, int length, int paragraphIndex) { Microsoft.Office.Tools.Word.Bookmark bookmark = null; try { - var document = Globals.ThisAddIn.Application.ActiveDocument; + var document = CurrentDocument; ControlCollection controls = Globals.Factory.GetVstoObject(document).Controls; var markName = Config.BuildBookmarkName(item.id); @@ -669,27 +674,77 @@ namespace AIProofread Range findRange = null; if (paragraphIndex > document.Paragraphs.Count) return null; var paragraph = document.Paragraphs[paragraphIndex]; - var paragraphStart = paragraph.Range.Start; - offset += paragraphStart; + Range paragraphRange = paragraph.Range; + var paragraphStart = paragraphRange.Start; + //offset += paragraphStart; - var Start = offset; + var Start = paragraphStart + offset; var End = Start + length - 1; - if (End > paragraph.Range.End) + if (End > paragraphRange.End) { - End = paragraph.Range.End; + End = paragraphRange.End; } // 当前句子的选区 var fullRange = document.Range(Start, End); - string fullText = fullRange.Text ?? paragraph.Range.Text; - Start = offset + item.start; - End = offset + item.end; + // 如果选择有文本就用文本 + string fullText = fullRange.Text ?? paragraphRange.Text; + // 当前段落文本 + string paragraphText = paragraphRange.Text; + End = Start + item.end; + Start = Start + item.start; + + + // 如果是新增 则查找定位 + if (item.tag == "i") + { + // s1. 通过接口的位置 和 文档内容进行比对 + try + { + if (paragraphText.Substring(offset, length) == originText) + { + // 直接使用接口定位 + findRange = document.Range(Start, End); + } + } + catch (Exception exif) + { + Logger.Log(exif); + } + // s2. 位置不匹配 则采用搜索定位 + if (findRange == null) + { + // 找前缀 + var prefix = item.start > 2 ? ( + item.start > INSERT_FIND_OFFSET + ? originText.Substring(item.start - INSERT_FIND_OFFSET, INSERT_FIND_OFFSET) + : originText.Substring(0, item.start) + ) : null; + // 找后缀 + var suffix = prefix == null ? ( + item.end + INSERT_FIND_OFFSET < originText.Length + ? originText.Substring(item.start, INSERT_FIND_OFFSET) + : originText.Substring(item.start, originText.Length - item.start) + ) : null; + // 偏移量 + var start = prefix != null || suffix != null + ? paragraphText.IndexOf(prefix ?? suffix, offset) // item.start + + : -1; + if (start != -1) + { + var findOffset = paragraphStart + start + (prefix != null ? prefix.Length : 0); + findRange = document.Range(findOffset, findOffset); + } + } + } + else + { + findRange = document.Range(Start, End); + } - // 如果是新增 只能使用接口数据 - findRange = document.Range(Start, End); if (item.tag != "i" && findRange.Text != item.origin) { - findRange = DocumentUtil.FindRange(paragraphIndex, item.origin, item.start, item.end); + findRange = DocumentUtil.FindRange(paragraphIndex, offset, originText, item.origin, item.start, item.end); } if (findRange != null) diff --git a/AIProofread/Config.cs b/AIProofread/Config.cs index de34f5d..db4fa12 100644 --- a/AIProofread/Config.cs +++ b/AIProofread/Config.cs @@ -6,7 +6,7 @@ namespace AIProofread public class Config { public static readonly string APP_NAME = "AI校对王"; - public static readonly string APP_VERSION = "1.0.7"; + public static readonly string APP_VERSION = "1.0.11"; public static bool IS_WPS = false; public static readonly string CONFIG_FILE = AppDomain.CurrentDomain.BaseDirectory + "app.json"; diff --git a/AIProofread/Logger.cs b/AIProofread/Logger.cs index 4c42667..7a6069f 100644 --- a/AIProofread/Logger.cs +++ b/AIProofread/Logger.cs @@ -30,7 +30,10 @@ namespace AIProofread streamWriter.Close(); streamWriter.Dispose(); } - + public static void Log( Exception e) + { + Log(e.StackTrace); + } public static void Log(string tag, Exception e) { Log(tag + "\n" + e.StackTrace); diff --git a/AIProofread/ProofreadItem.cs b/AIProofread/ProofreadItem.cs index f15bdb0..fdeb7c4 100644 --- a/AIProofread/ProofreadItem.cs +++ b/AIProofread/ProofreadItem.cs @@ -38,7 +38,7 @@ namespace UtilLib originSize = bookmark.Range.Font.Size; originBackgroundColor = bookmark.Shading.BackgroundPatternColor; originColor = bookmark.Shading.ForegroundPatternColor; - mark.Selected += OnMarkSelected; + //mark.Selected += OnMarkSelected; } SetMarkName(); //InitBookMark(bookmark); diff --git a/AIProofread/Ribbon1.Designer.cs b/AIProofread/Ribbon1.Designer.cs index dd98b21..1b6ba24 100644 --- a/AIProofread/Ribbon1.Designer.cs +++ b/AIProofread/Ribbon1.Designer.cs @@ -51,8 +51,8 @@ namespace AIProofread this.grpDebug = this.Factory.CreateRibbonGroup(); this.btnShowPane = this.Factory.CreateRibbonButton(); this.btnHidePane = this.Factory.CreateRibbonButton(); - this.btnTestLocation = this.Factory.CreateRibbonButton(); this.btnSelectionPosition = this.Factory.CreateRibbonButton(); + this.BtnOpenLog = this.Factory.CreateRibbonButton(); this.button1 = this.Factory.CreateRibbonButton(); this.tabAIProofread.SuspendLayout(); this.group1.SuspendLayout(); @@ -170,8 +170,8 @@ namespace AIProofread // this.grpDebug.Items.Add(this.btnShowPane); this.grpDebug.Items.Add(this.btnHidePane); - this.grpDebug.Items.Add(this.btnTestLocation); this.grpDebug.Items.Add(this.btnSelectionPosition); + this.grpDebug.Items.Add(this.BtnOpenLog); this.grpDebug.Items.Add(this.button1); this.grpDebug.Label = "开发调试"; this.grpDebug.Name = "grpDebug"; @@ -189,23 +189,21 @@ namespace AIProofread this.btnHidePane.Name = "btnHidePane"; this.btnHidePane.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btnHidePane_Click); // - // btnTestLocation - // - this.btnTestLocation.Label = "文本位置"; - this.btnTestLocation.Name = "btnTestLocation"; - this.btnTestLocation.Visible = false; - this.btnTestLocation.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btnTestLocation_Click); - // // btnSelectionPosition // - this.btnSelectionPosition.Label = "选中位置"; + this.btnSelectionPosition.Label = "测试分段速度"; this.btnSelectionPosition.Name = "btnSelectionPosition"; - this.btnSelectionPosition.Visible = false; this.btnSelectionPosition.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btnSelectionPosition_Click); // + // BtnOpenLog + // + this.BtnOpenLog.Label = "打开日志目录"; + this.BtnOpenLog.Name = "BtnOpenLog"; + this.BtnOpenLog.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.BtnOpenLog_Click); + // // button1 // - this.button1.Label = "button1"; + this.button1.Label = "更新测试版本"; this.button1.Name = "button1"; this.button1.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.button1_Click); // @@ -242,8 +240,8 @@ namespace AIProofread internal Microsoft.Office.Tools.Ribbon.RibbonGroup grpDebug; internal Microsoft.Office.Tools.Ribbon.RibbonButton btnShowPane; internal Microsoft.Office.Tools.Ribbon.RibbonButton btnHidePane; - internal Microsoft.Office.Tools.Ribbon.RibbonButton btnTestLocation; internal Microsoft.Office.Tools.Ribbon.RibbonButton btnSelectionPosition; + internal Microsoft.Office.Tools.Ribbon.RibbonButton BtnOpenLog; internal Microsoft.Office.Tools.Ribbon.RibbonButton button1; } diff --git a/AIProofread/Ribbon1.cs b/AIProofread/Ribbon1.cs index 7bbf824..5daae1d 100644 --- a/AIProofread/Ribbon1.cs +++ b/AIProofread/Ribbon1.cs @@ -6,6 +6,15 @@ using UtilLib; using System.Drawing; using System.Security.Cryptography; using Microsoft.Office.Interop.Word; +using System.IO; +using System.Threading.Tasks; +using AIProofread.Util; +using Microsoft.Office.Tools.Word; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using AIProofread.core; +using System.Windows.Forms; namespace AIProofread { @@ -124,8 +133,12 @@ namespace AIProofread private void btnClear_Click(object sender, RibbonControlEventArgs e) { //DocumentUtil.ClearProofreadMarks(); - Bridge.bridge.clearAllProofreadMark(); - Globals.ThisAddIn.SendMessageToWeb("clear-tips", null); + var result = MessageBox.Show("请确认是否清除此文档的所有校对标注?", "提示", MessageBoxButtons.OKCancel); + if(result == DialogResult.OK) + { + Bridge.bridge.clearAllProofreadMark(); + Globals.ThisAddIn.SendMessageToWeb("clear-tips", null); + } } private void btnShowPane_Click(object sender, RibbonControlEventArgs e) @@ -138,93 +151,289 @@ namespace AIProofread Globals.ThisAddIn.HidePanel(); } - - void TestStr(int p, string str) - { - - var doc = Globals.ThisAddIn.Application.ActiveDocument; - var p1 = doc.Paragraphs[p]; - var text = p1.Range.Text; - var index = text.IndexOf(str); - var r = DocumentUtil.FindRange(p, str, index, index + str.Length); - - System.Windows.Forms.MessageBox.Show("段落:" + p + str + ":" + index + (r == null ? "" : r.Text)); - //var findRange = FindRange(p, findIndex, str, index, index + str.Length); - - } - private void btnTestLocation_Click(object sender, RibbonControlEventArgs e) - { - TestStr(2, "销"); - TestStr(3, "针"); - TestStr(22, "疏"); - } + private Microsoft.Office.Interop.Word.Document CurrentDocument; private void btnSelectionPosition_Click(object sender, RibbonControlEventArgs e) { - var doc = Globals.ThisAddIn.Application.ActiveDocument; - var sel = Globals.ThisAddIn.Application.Selection; - if (sel != null && sel.Range != null) + // 测试加快速度处理 段落 + //CurrentDocument = Globals.ThisAddIn.Application.ActiveDocument; + //var tables = CurrentDocument.Tables; + //var tableCount = tables.Count; + //System.Windows.Forms.MessageBox.Show("tables "+ tableCount); + + //var footNotes = CurrentDocument.Footnotes; + //System.Windows.Forms.MessageBox.Show("footNotes " + footNotes.Count); + //var endNotes = CurrentDocument.Endnotes; + //System.Windows.Forms.MessageBox.Show("endNotes " + endNotes.Count); + //Bridge.bridge.getDocumentData(); + CurrentDocument = Globals.ThisAddIn.Application.ActiveDocument; + + string path = Tools.GetReadDocumentFilePath(CurrentDocument); + Debug.WriteLine(path); + Logger.Log(path); + + System.Windows.Forms.MessageBox.Show("Test"); + } + + private void TestSplit() + { + //try + //{ + // this.CurrentDocument = Globals.ThisAddIn.Application.ActiveDocument; + + // string rangeText = GetRangeText(CurrentDocument.Content); + + + // // 获取所有数学公式吗 + // foreach (OMath oMath in CurrentDocument.OMaths) + // { + // Console.WriteLine("xx"); + // } + + // // 形状哟 + // int count = CurrentDocument.Shapes.Count; + // System.Windows.Forms.MessageBox.Show(string.Format("Shapes总计:{0}", count)); + // foreach (Microsoft.Office.Interop.Word.Shape shape in CurrentDocument.Shapes) + // { + // } + // int count2 = CurrentDocument.InlineShapes.Count; + // System.Windows.Forms.MessageBox.Show(string.Format("InlineShapes总计:{0}", count2)); + // foreach (InlineShape inlineShape in CurrentDocument.InlineShapes) + // { + // } + + // string text5 = rangeText; + // Logger.Log($"Removed unuseable section article: {text5}"); + // string text6 = HostHelper.ReplaceSpecialChars(rangeText, isReplaceMultSpaceLine: true); + // Logger.Log($"Removed unuseable section upload: {text6}"); + // int end = CurrentDocument.Content.End; + // // 分割 + // string[] separator = new string[5] { "\r\a", "\a", "\r", "\v", "\f" }; + // string[] array4 = text5.Split(separator, StringSplitOptions.None); + // string[] array5 = text6.Split('\n'); + + // object Start = 0; + // object End = 1; + // //int pagenumber = GetIndexPageNumber(CurrentDocument.Range(ref Start, ref End)); + + // int start = 0; + // int start2 = 0; + // int start3 = 0; + // string empty = string.Empty; + // string empty2 = string.Empty; + // string empty3 = string.Empty; + // Range lastRange = null; + + // for (int j = 0; j < array5.Length; j++) + // { + // empty3 = string.Empty; + // List characters = new List(); + // CorrectionFragmentAbstract correctionFragmentAbstract = null; + // //Logger.Instance.Info($"Handling {j + 1} upload part"); + // empty2 = array5[j]; + // if (string.IsNullOrEmpty(empty2)) + // { + // continue; + // } + // int num4 = start + empty2.Length + 1; + // for (; string.IsNullOrEmpty(HostHelper.RemoveInvisibleCharas(array4[i])); i++) + // { + // num4 += array4[i].Length + 1; + // } + // empty = array4[i]; + // //Logger.Instance.Info($"Upload part is {empty2}"); + // End = start; + // Start = num4; + + // Range range3 = CurrentDocument.Range(ref End, ref Start); + // string rangeText3 = GetRangeText(range3); + + // //Logger.Instance.Info($"Text is {rangeText3}"); + // StringBuilder stringBuilder = new StringBuilder(); + // string text7 = (string.IsNullOrEmpty(rangeText3) ? "" : rangeText3.Last().ToString()); + // if (HostHelper.RemoveInvisibleCharas(rangeText3) != empty2 || (text7 != "\r" && text7 != "\r\a" && text7 != "\a" && text7 != "\f" && text7 != "\v")) + // { + // int articleIndex = start; + + // Start = articleIndex; + // End = articleIndex + 1; + // Range range4 = CurrentDocument.Range(ref Start, ref End); + // text7 = GetRangeText(range4); + // bool flag = true; + // while ((text7 != "\r" && text7 != "\r\a" && text7 != "\a" && text7 != "\f" && text7 != "\v") || flag) + // { + // if (flag) + // { + // //Logger.Instance.Info(string.Format("Special text default logic.", rangeText3)); + // GetInvisibleCharacters(ref articleIndex, empty2, end, stringBuilder, characters, flag); + // } + // else + // { + // //Logger.Instance.Info(string.Format("Text not contains \\r.", rangeText3)); + // GetInvisibleCharacters(ref articleIndex, "\r", end, stringBuilder, characters, flag); + // } + // End = articleIndex; + // Start = articleIndex + 1; + // range4 = CurrentDocument.Range(ref End, ref Start); + // text7 = GetRangeText(range4); + // flag = false; + // } + // stringBuilder.Append(text7); + // string text8 = stringBuilder.ToString(); + // empty = text8.Replace("\a", ""); + // num4 = range4.End; + // //Logger./*Instance*/.Info($"Article part is {empty}"); + // if (empty.ToUpper().Contains("PAGEREF _TOC")) + // { + // start = num4; + // //Logger.Instance.Info("String Contains 'PAGEREF _TOC' Struct."); + // continue; + // } + // } + // else + // { + // empty = rangeText3.Replace("\a", ""); + // int tempIndex = start; + // empty.ToCharArray().ToList().ForEach(delegate (char x) + // { + // characters.Add(new CorrectionCharacter(x, _v: true, tempIndex)); + // tempIndex++; + // }); + // } + // } + + //} + //catch (Exception ex) + //{ + // System.Windows.Forms.MessageBox.Show("出现了异常:" + ex.Message); + //} + } + + + private string GetInvisibleCharacters(ref int articleIndex, string articlePart, int end, StringBuilder stringBuilder, List characters, bool isFirst = true) + { + int num = articleIndex; + if (!isFirst) { - Paragraphs paragraphs = doc.Paragraphs; - Range range = sel.Range; - Paragraph paragraph = range.Paragraphs.First; - int paragraphIndex = -1; - for (int i = 1; i <= paragraphs.Count; i++) + articlePart = HostHelper.RemoveInvisibleCharas(articlePart); + } + int num2 = ((articlePart.Length + articleIndex < end) ? articlePart.Length : (end - articleIndex)); + Range range = null; + string empty = string.Empty; + if (string.IsNullOrEmpty(articlePart)) + { + string[] source = new string[4] { "\r", "\r\a", "\v", "\f" }; + empty = string.Empty; + while (range == null || range.Text == null || !source.Contains(empty)) { - - var para = paragraphs[i]; - if (para.Range.Start >= paragraph.Range.Start && para.Range.End <= paragraph.Range.End) + if (!string.IsNullOrEmpty(empty)) { - paragraphIndex = i; - break; + stringBuilder.Append(empty); + num++; } + if (num >= end) + { + //Logger.Instance.Error($"Correction dictionary over length:{stringBuilder.ToString()}"); + throw new ArgumentOutOfRangeException($"Not pair character: \\r \\f \\v \\r\\a, position {articleIndex}"); + } + object Start = num; + object End = num + 1; + range = CurrentDocument.Range(ref Start, ref End); + empty = GetRangeText(range); + string text = empty; + string text2 = text; + if (text2 != null && (text2 == null || text2.Length != 0)) + { + if (text2 == "\u001e") + { + empty = "-"; + } + } + else + { + empty = "\n"; + } + characters.Add(new CorrectionCharacter(empty.First(), source.Contains(empty), range.Start)); } - int startInParagraph = range.Start - paragraph.Range.Start; - int endInParagraph = range.End - paragraph.Range.Start; - - System.Windows.Forms.MessageBox.Show($"Selected text in {paragraphIndex} starts at position {startInParagraph} and ends at position {endInParagraph} in the paragraph."); } else { - System.Windows.Forms.MessageBox.Show("No text selected."); + for (int i = 0; i < num2; i++) + { + string text3 = articlePart[i].ToString(); + empty = string.Empty; + while (range == null || range.Text == null || !empty.Contains(text3)) + { + if (num >= end) + { + //Logger.Instance.Error($"Correction dictionary over length:{stringBuilder.ToString()}"); + throw new ArgumentOutOfRangeException($"Not pair character: {text3}, position {articleIndex}"); + } + object End = num; + object Start = num + 1; + range = CurrentDocument.Range(ref End, ref Start); + empty = GetRangeText(range); + string text4 = empty; + string text5 = text4; + if (text5 != null && (text5 == null || text5.Length != 0)) + { + if (text5 == "\u001e") + { + empty = "-"; + } + } + else + { + empty = "\n"; + } + stringBuilder.Append(empty); + num++; + characters.Add(new CorrectionCharacter(empty.First(), empty.Contains(text3), range.Start)); + } + } } + articleIndex = num; + return stringBuilder.ToString(); } - //public bool IsParagraphInTableOfContents(Document doc, Paragraph para) + public static int GetIndexPageNumber(Range range) + { + int result = -1; + try + { + result = int.Parse(range.get_Information(WdInformation.wdActiveEndPageNumber).ToString()); + } + catch (Exception exception) + { + Logger.Log(exception); + } + return result; + } + + + protected string GetRangeText(Range range) + { + return string.IsNullOrEmpty(range.Text) ? "" : range.Text; + } + + //private async Task ProcessCorrectCut() //{ - // // 检查文档和段落是否为null - // if (doc == null || para == null) - // return false; - // // 获取文档中的目录范围 - // Range tocRange = null; - // foreach (Range range in .) - // { - // if (range.InlineShapes.Count > 0) // 假设目录包含字段代码 - // { - // tocRange = range; - // break; - // } - // } - // // 如果没有找到目录范围,则返回false - // if (tocRange == null) - // return false; - - // // 获取段落范围 - // Word.Range paraRange = para.Range; - - // // 检查段落是否在目录范围内 - // return paraRange.StoryLength > 0 && tocRange.StoryLength > 0 && - // paraRange.Start >= tocRange.Start && paraRange.End <= tocRange.End; //} + private void BtnOpenLog_Click(object sender, RibbonControlEventArgs e) + { + // 打开日志目录 + Process.Start(Config.APP_LOG_PATH); + } private void button1_Click(object sender, RibbonControlEventArgs e) { - var doc = Globals.ThisAddIn.Application.ActiveDocument; - var styles = doc.Styles["TOC Heading"]; - - Console.WriteLine(styles.Font.Name); + string applicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; + string path = "updater.exe"; + ProcessStartInfo processStartInfo = new ProcessStartInfo(Path.Combine(applicationBase, Path.GetFileName(path))); + processStartInfo.WorkingDirectory = applicationBase; + Process.Start(processStartInfo); } } } diff --git a/AIProofread/ThisAddIn.cs b/AIProofread/ThisAddIn.cs index ead53a9..e6e8831 100644 --- a/AIProofread/ThisAddIn.cs +++ b/AIProofread/ThisAddIn.cs @@ -295,11 +295,11 @@ namespace AIProofread (Application as ApplicationEvents4_Event).NewDocument += Application_NewDocument; //Application.DocumentChange += // 选区发生变化事件 - //this.Application.WindowSelectionChange += Application_WindowSelectionChange; + this.Application.WindowSelectionChange += Application_WindowSelectionChange; try { - if (Application.ActiveDocument != null) + if (Application.Documents.Count > 0 && Application.ActiveDocument != null) { // 默认直接打开文档 就直接创建panel ShowPanel(Application.ActiveDocument, false); @@ -326,7 +326,7 @@ namespace AIProofread if (s.Range.Start == s.Range.End) // 说明是点击呀 { var count = s.Bookmarks.Count; - if (s.Bookmarks.Count == 1) // 只有这一个 + if (s.Bookmarks.Count >= 1) // 只有这一个 { foreach (Microsoft.Office.Interop.Word.Bookmark item in s.Bookmarks) { diff --git a/AIProofread/core/BridgeResult.cs b/AIProofread/core/BridgeResult.cs new file mode 100644 index 0000000..7906324 --- /dev/null +++ b/AIProofread/core/BridgeResult.cs @@ -0,0 +1,9 @@ +namespace AIProofread.core +{ + public class BridgeResult + { + public T Data { get; set; } + public int Code { get; set; } + public string Message { get; set; } + } +} diff --git a/AIProofread/core/CorrectionCharacter.cs b/AIProofread/core/CorrectionCharacter.cs new file mode 100644 index 0000000..e92283c --- /dev/null +++ b/AIProofread/core/CorrectionCharacter.cs @@ -0,0 +1,63 @@ +namespace AIProofread.core +{ + public class CorrectionCharacter + { + private int position; + + private char c; + + private bool visible; + + public int Position + { + get + { + return position; + } + set + { + position = value; + } + } + + public char C + { + get + { + return c; + } + set + { + c = value; + } + } + + public bool Visible + { + get + { + return visible; + } + set + { + visible = value; + } + } + + public CorrectionCharacter() + { + } + + public CorrectionCharacter(char _c, bool _v, int _p) + { + C = _c; + Visible = _v; + Position = _p; + } + + public override string ToString() + { + return $"{Position}:{C}-{Visible}"; + } + } +} diff --git a/AIProofread/core/CorrectionFragmentAbstract.cs b/AIProofread/core/CorrectionFragmentAbstract.cs new file mode 100644 index 0000000..cef7bb2 --- /dev/null +++ b/AIProofread/core/CorrectionFragmentAbstract.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AIProofread.core +{ + public abstract class CorrectionFragmentAbstract + { + private List characters = new List(); + + public List Characters + { + get + { + return characters; + } + set + { + characters = value; + } + } + + public abstract CorrectionRangeAbstract UploadRange { get; set; } + + public abstract CorrectionRangeAbstract ArticleRange { get; set; } + + public abstract CorrectionRangeAbstract FormatRange { get; set; } + + public abstract void AddCorrectionRange(CorrectionRangeAbstract article, CorrectionRangeAbstract upload, CorrectionRangeAbstract format = null); + + public abstract void RemoveCorrectionRange(); + + public abstract int[] SetCorrectionRange(int[] article, int[] upload); + + public abstract int[] Relocate(string upload, int offset); + + public abstract void ClearAll(); + + public abstract int GetFirstStartPosition(bool containUnvisibleCharacter); + + public abstract int GetLastEndPosition(bool containUnvisibleCharacter); + } +} diff --git a/AIProofread/core/CorrectionRangeAbstract.cs b/AIProofread/core/CorrectionRangeAbstract.cs new file mode 100644 index 0000000..425688e --- /dev/null +++ b/AIProofread/core/CorrectionRangeAbstract.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AIProofread.core +{ + public abstract class CorrectionRangeAbstract + { + protected List chars = new List(); + + public abstract string Text { get; set; } + + public abstract int Start { get; set; } + + public abstract int End { get; set; } + + public abstract int Count { get; } + + public CorrectionRangeAbstract(string text, int _s, int _e = -1) + { + Start = _s; + End = _e; + } + + public CorrectionRangeAbstract() + { + } + + public abstract int GetStartPosition(bool containUnvisibleCharacter); + + public abstract int GetEndPosition(bool containUnvisibleCharacter); + + public override string ToString() + { + return $"{Text}|{Start},{End}"; + } + } +} + diff --git a/AIProofread/core/DocumentUtil.cs b/AIProofread/core/DocumentUtil.cs index 9d2d561..a4ec23b 100644 --- a/AIProofread/core/DocumentUtil.cs +++ b/AIProofread/core/DocumentUtil.cs @@ -9,6 +9,7 @@ using System.Collections.Generic; using Microsoft.Office.Tools.Word; using System; using System.Xml.Linq; +using Newtonsoft.Json; namespace AIProofread { @@ -159,20 +160,24 @@ namespace AIProofread return list; } + private static readonly int INSERT_FIND_OFFSET = 5; /// /// 查找对应段落的range /// /// 段落index,从第1开始计数 + /// 当前偏移量 /// 要查找字符串 /// 字符串原始起始位置 /// 字符串原始结束位置 /// - public static Range FindRange(int paragraphsIndex, string findText, int wordStart, int wordEnd) + public static Range FindRange(int paragraphsIndex,int offset,string originText, string findText, int wordStart, int wordEnd) { // 暂时接口无法支持 var document = Globals.ThisAddIn.Application.ActiveDocument; if (paragraphsIndex > document.Paragraphs.Count) return null; var paragraph = document.Paragraphs[paragraphsIndex]; + var range = paragraph.Range; + var paragraphText = range.Text; try { //int num = 0; @@ -183,12 +188,12 @@ namespace AIProofread object End = paragraph.Range.End; // 段落选区 - Range range = document.Range(ref Start, ref End); + //Range range = document.Range(ref Start, ref End); var activeDocument = document; // 查找对象位置 - End = range.Start + wordStart; - Start = range.Start + wordEnd; + End = range.Start + offset + wordStart; + Start = range.Start + offset + wordEnd; // 直接找到 var findRange = activeDocument.Range(ref End, ref Start); // 判断对应选区是否是要找的文本 @@ -196,81 +201,114 @@ namespace AIProofread { return findRange; } - else + // 找前缀 + var prefix = wordStart > 2 ? ( + wordStart > INSERT_FIND_OFFSET + ? originText.Substring(wordStart - INSERT_FIND_OFFSET, INSERT_FIND_OFFSET) + : originText.Substring(0, wordStart) + ) : null; + // 找后缀 + var suffix = prefix == null ? ( + wordEnd + INSERT_FIND_OFFSET < originText.Length + ? originText.Substring(wordStart, INSERT_FIND_OFFSET) + : originText.Substring(wordStart, originText.Length - wordStart) + ) : null; + var start = prefix != null || suffix != null + ? paragraphText.IndexOf(prefix ?? suffix, offset) // item.start + + : -1; + if (start != -1) { - // 查找 - range.Find.MatchByte = true; - // 使用选区查找功能 - Find find = range.Find; - // 节约变量 - End = findText; - Start = true; + var findOffset = range.Start + start + (prefix != null ? prefix.Length : 0); + findRange = document.Range(findOffset, findOffset + wordEnd - wordStart); + if(findRange.Text == findText) { return findRange; } + } + var msg = new Dictionary{ + {"message","后端接口位置不可用,开始执行查找" }, + { "origin_start",wordStart }, + { "origin_end",wordEnd }, + {"find_text",findRange.Text }, + {"origin_text", findText} + }; + Logger.Log(JsonConvert.SerializeObject(msg)); + // 查找 + range.Find.MatchByte = true; + // 使用选区查找功能 + Find find = range.Find; + // 节约变量 + End = findText; + Start = true; - object MatchWholeWord = Type.Missing; - object MatchWildcards = Type.Missing; - object MatchSoundsLike = Type.Missing; - object MatchAllWordForms = Type.Missing; - object Forward = Type.Missing; - object Wrap = Type.Missing; - object Format = Type.Missing; - object ReplaceWith = Type.Missing; - object Replace = Type.Missing; - object MatchKashida = Type.Missing; - object MatchDiacritics = Type.Missing; - object MatchAlefHamza = Type.Missing; - object MatchControl = Type.Missing; + object MatchWholeWord = Type.Missing; + object MatchWildcards = Type.Missing; + object MatchSoundsLike = Type.Missing; + object MatchAllWordForms = Type.Missing; + object Forward = Type.Missing; + object Wrap = Type.Missing; + object Format = Type.Missing; + object ReplaceWith = Type.Missing; + object Replace = Type.Missing; + object MatchKashida = Type.Missing; + object MatchDiacritics = Type.Missing; + object MatchAlefHamza = Type.Missing; + object MatchControl = Type.Missing; - // 没有找到则执行查询 - find.Execute( - ref End, ref Start, ref MatchWholeWord, - ref MatchWildcards, ref MatchSoundsLike, - ref MatchAllWordForms, ref Forward, ref Wrap, - ref Format, ref ReplaceWith, ref Replace, - ref MatchKashida, ref MatchDiacritics, - ref MatchAlefHamza, ref MatchControl - ); + // 没有找到则执行查询 + find.Execute( + ref End, ref Start, ref MatchWholeWord, + ref MatchWildcards, ref MatchSoundsLike, + ref MatchAllWordForms, ref Forward, ref Wrap, + ref Format, ref ReplaceWith, ref Replace, + ref MatchKashida, ref MatchDiacritics, + ref MatchAlefHamza, ref MatchControl + ); - while (range.Find.Found) + var msg1 = new Dictionary{ + {"message",range.Find.Found?"搜索到可用位置":"没有搜索到可用位置" }, + { "search_start",range.Start }, + { "search_end",range.End }, + { "search_text",range.Text } + }; + Logger.Log(JsonConvert.SerializeObject(msg1)); + while (range.Find.Found) + { + var obj4 = range.Document; + MatchControl = range.Start; + MatchAlefHamza = range.End; + var range2 = obj4.Range(ref MatchControl, ref MatchAlefHamza); + num3 = range2.End; + if (range2.Text == findText) { - var obj4 = range.Document; - MatchControl = range.Start; - MatchAlefHamza = range.End; - var range2 = obj4.Range(ref MatchControl, ref MatchAlefHamza); - num3 = range2.End; - if (range2.Text == findText) - { - return range2; - } - break; - //if (findIndex == num) - //{ + return range2; + } + break; + //if (findIndex == num) + //{ - //} - //num++; - //range.Find.MatchByte = true; - //Find find2 = range.Find; - //MatchAlefHamza = missword; - //MatchControl = true; - //MatchDiacritics = Type.Missing; - //MatchKashida = Type.Missing; - //Replace = Type.Missing; - //ReplaceWith = Type.Missing; - //Format = Type.Missing; - //Wrap = Type.Missing; - //Forward = Type.Missing; - //MatchAllWordForms = Type.Missing; - //MatchSoundsLike = Type.Missing; - //MatchWildcards = Type.Missing; - //MatchWholeWord = Type.Missing; - //Start = Type.Missing; - //End = Type.Missing; - //// 再次重复查找 - //find2.Execute(ref MatchAlefHamza, ref MatchControl, ref MatchDiacritics, ref MatchKashida, ref Replace, ref ReplaceWith, ref Format, ref Wrap, ref Forward, ref MatchAllWordForms, ref MatchSoundsLike, ref MatchWildcards, ref MatchWholeWord, ref Start, ref End); - } - if (num3 == 0) - { - return null; - } + //} + //num++; + //range.Find.MatchByte = true; + //Find find2 = range.Find; + //MatchAlefHamza = missword; + //MatchControl = true; + //MatchDiacritics = Type.Missing; + //MatchKashida = Type.Missing; + //Replace = Type.Missing; + //ReplaceWith = Type.Missing; + //Format = Type.Missing; + //Wrap = Type.Missing; + //Forward = Type.Missing; + //MatchAllWordForms = Type.Missing; + //MatchSoundsLike = Type.Missing; + //MatchWildcards = Type.Missing; + //MatchWholeWord = Type.Missing; + //Start = Type.Missing; + //End = Type.Missing; + //// 再次重复查找 + //find2.Execute(ref MatchAlefHamza, ref MatchControl, ref MatchDiacritics, ref MatchKashida, ref Replace, ref ReplaceWith, ref Format, ref Wrap, ref Forward, ref MatchAllWordForms, ref MatchSoundsLike, ref MatchWildcards, ref MatchWholeWord, ref Start, ref End); + } + if (num3 == 0) + { + return null; } } catch (Exception) diff --git a/AIProofread/core/MainPanelWebMessage.cs b/AIProofread/core/MainPanelWebMessage.cs new file mode 100644 index 0000000..f9b94f4 --- /dev/null +++ b/AIProofread/core/MainPanelWebMessage.cs @@ -0,0 +1,87 @@ +using Microsoft.Office.Tools.Word; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace AIProofread.core +{ + public class MessageActionEnum + { + public string Action { get; set; } + public MessageActionEnum(string action) + { + this.Action = action; + } + + /// + /// 开始校对 + /// + public static readonly MessageActionEnum StartProofread = new MessageActionEnum("start"); + + + /// + /// 插件升级 + /// + public static readonly MessageActionEnum Upgrade = new MessageActionEnum("upgrade"); + /// + /// 清除所有校对内容 + /// + public static readonly MessageActionEnum ClearTips = new MessageActionEnum("clear-tips"); + /// + /// 打开插件 + /// + public static readonly MessageActionEnum ShowSetting = new MessageActionEnum("show-setting"); + /// + /// 打开(显示)词库管理 + /// + public static readonly MessageActionEnum ShowLexicon = new MessageActionEnum("show-lexicon"); + /// + /// 选中校对项 + /// + public static readonly MessageActionEnum SelectProofreadItem = new MessageActionEnum("select-proofread"); + /// + /// 禁用(隐藏)校对项 + /// + public static readonly MessageActionEnum DisableProofreadItem = new MessageActionEnum("disabled-proofread"); + + /// + /// 注销登录 + /// + public static readonly MessageActionEnum Logout = new MessageActionEnum("logout"); + /// + /// 同步注销登录 + /// + public static readonly MessageActionEnum AsyncLogout = new MessageActionEnum("async-logout"); + /// + /// 同步登录成功 + /// + public static readonly MessageActionEnum AsyncLoginSuccess = new MessageActionEnum("async-login-success"); + + + } + public class MainPanelWebMessage + { + + public static void Send(MessageActionEnum action, object data) + { + Globals.ThisAddIn.SendMessageToWeb(action.Action, data); + } + public static void Send(MessageActionEnum action) + { + Globals.ThisAddIn.SendMessageToWeb(action.Action, null); + } + + public static void SelectProofreadItem(int proofreadItemId) + { + Globals.ThisAddIn.SendMessageToWeb(MessageActionEnum.SelectProofreadItem.Action, proofreadItemId); + } + public static void DisabledProofreadItem(List proofreadItemIdList) + { + Globals.ThisAddIn.SendMessageToWeb(MessageActionEnum.DisableProofreadItem.Action, proofreadItemIdList); + } + + } +} diff --git a/AIProofread/core/Tools.cs b/AIProofread/core/Tools.cs index 9b38d59..103b78f 100644 --- a/AIProofread/core/Tools.cs +++ b/AIProofread/core/Tools.cs @@ -1,16 +1,155 @@ using Microsoft.Office.Interop.Word; using Newtonsoft.Json; +using NPOI.XWPF.UserModel; using System; using System.Collections.Generic; using System.Diagnostics; +using System.IO; using System.Security.Cryptography; namespace AIProofread { public class Tools { - private static readonly string[] paragSplitor = new string[] { "\r", "\n", "\r\n" }; - public static Dictionary GetAllText(Document doc) + private static readonly string[] paragSplitor = new string[] { "\r\n", "\r\f", "\r", "\n", "\f" }; + + /// + /// 采用NPOI进行文本读取 + /// + /// + /// + /// + public static Dictionary GetAllText(Microsoft.Office.Interop.Word.Document doc) + { + string ext = doc.FullName.ToLower(); + // 如果是 + if (ext.EndsWith(".wps") || doc.Paragraphs.Count < 200 || doc.Tables.Count < 20) + { + // 如果段落数小于200或表格小于20 则直接使用vsto 获取数据 + return GetAllTextByVSTO(doc); + } + // 创建临时文件 方便数据读取 + string docPath = Tools.GetReadDocumentFilePath(doc); + + Debug.WriteLine("GetAllText Start ==>", DateTime.Now.ToLongTimeString()); + // 获取当前文档所有文本 + string allText = doc.Range().Text; + List list = new List(); + using (FileStream stream = new FileStream(docPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + { + XWPFDocument ndoc = new XWPFDocument(stream); + var paragraphs = ndoc.Paragraphs; + int paragraphNumber = 1; + foreach (var bodyElement in ndoc.BodyElements) + { + // normal paragraph + if (bodyElement is XWPFParagraph p) + { + // 处理普通段落 + list.Add(new DocumentText(p.ParagraphText.Replace("\u0002", ""), paragraphNumber)); + paragraphNumber++; + } + // table -- vsto对于每个单元格的分段也会有 + else if (bodyElement is XWPFTable table) + { + foreach (var row in table.Rows) + { + foreach (var cell in row.GetTableCells()) + { + foreach (var pc in cell.Paragraphs) + { + //list.Add(pc.ParagraphText); + paragraphNumber++; + } + } + //list.Add(string.Empty); + paragraphNumber++; + } + } + // 目录处理 + else if (bodyElement is XWPFSDT sdt) + { + string tocText = sdt.Content.Text; + + // 如果需要,可以进一步解析目录项// 例如,按换行符拆分目录内容 + var tocEntries = tocText.Split(new string[] { "\n", "\r", "\r\n", "\f" }, StringSplitOptions.None); + foreach (string entry in tocEntries) + { + + list.Add(new DocumentText(entry.Replace("\u0002", ""), paragraphNumber)); + paragraphNumber++; + } + } + } + } + + Debug.WriteLine("GetAllText End ==>", DateTime.Now.ToLongTimeString()); + var map = new Dictionary + { + { "list", list }, + { "text", allText } + }; + // 删除临时文件 + File.Delete(docPath); + return map; + } + + public static string GetReadDocumentFilePath(Microsoft.Office.Interop.Word.Document doc) + { + // + string docPath = doc.FullName; + string ext = Path.GetExtension(docPath); + string tmpFile = Path.GetTempFileName(); + + Debug.WriteLine("GetReadDocumentFilePath Start ==>", DateTime.Now.ToLongTimeString()); + Debug.WriteLine("GetReadDocumentFilePath =>{0}", docPath); + + // 先转成临时文件 + FileStream fs = new FileStream(docPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + byte[] bytes = new byte[fs.Length]; + fs.Read(bytes, 0, bytes.Length); + + FileStream fsWriter = new FileStream(tmpFile, FileMode.OpenOrCreate, FileAccess.ReadWrite); + fsWriter.Write(bytes, 0, bytes.Length); + // 关闭吧 + fsWriter.Close(); + fs.Close(); + + // 判断是否是doc格式 + if (ext.ToLower().EndsWith("doc")) + { + // doc格式文档 需要转换成docx + // + Application app = new Application(); + // 打开临时文件 + var tmpDoc = app.Documents.OpenNoRepairDialog( + FileName: tmpFile, + AddToRecentFiles: false, + ReadOnly: true, + Visible: false + ); + string newTmpFile = docPath + ".docx"; + // 将原始文档另存为docx格式文档 + tmpDoc.SaveAs2( + FileName: newTmpFile, + FileFormat: WdSaveFormat.wdFormatXMLDocument, + AddToRecentFiles: false + ); + // 释放资源 + object missing = System.Reflection.Missing.Value; + object saveOption = WdSaveOptions.wdDoNotSaveChanges; + tmpDoc.Close(ref saveOption, ref missing, ref missing); + app.Quit(ref saveOption, ref missing, ref missing); + // 删除copy文件 + File.Delete(tmpFile); + tmpFile = newTmpFile; + } + Debug.WriteLine("GetReadDocumentFilePath =>=>{0}", tmpFile); + Debug.WriteLine("GetReadDocumentFilePath End ==>", DateTime.Now.ToLongTimeString()); + return tmpFile; + } + + public static Dictionary GetAllTextByVSTO(Microsoft.Office.Interop.Word.Document doc) { // 获取当前文档所有文本 string allText = doc.Range().Text; diff --git a/AIProofread/obj/Debug/AIProofread.csproj.AssemblyReference.cache b/AIProofread/obj/Debug/AIProofread.csproj.AssemblyReference.cache index 7ce5048..73f621d 100644 Binary files a/AIProofread/obj/Debug/AIProofread.csproj.AssemblyReference.cache and b/AIProofread/obj/Debug/AIProofread.csproj.AssemblyReference.cache differ diff --git a/AIProofread/obj/Debug/AIProofread.csproj.CoreCompileInputs.cache b/AIProofread/obj/Debug/AIProofread.csproj.CoreCompileInputs.cache index b737a76..5c4b855 100644 --- a/AIProofread/obj/Debug/AIProofread.csproj.CoreCompileInputs.cache +++ b/AIProofread/obj/Debug/AIProofread.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -79ea390e4d68eda54ffacc73a1e70c811a130e7954fbba3a2df5692e3b3c6464 +fe1ae839bfb706b80f0b4718d7a4129a4057bf53be655076474daf866eae1d58 diff --git a/AIProofread/obj/Debug/AIProofread.csproj.FileListAbsolute.txt b/AIProofread/obj/Debug/AIProofread.csproj.FileListAbsolute.txt index 963d945..65d5258 100644 --- a/AIProofread/obj/Debug/AIProofread.csproj.FileListAbsolute.txt +++ b/AIProofread/obj/Debug/AIProofread.csproj.FileListAbsolute.txt @@ -41,6 +41,7 @@ C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Microsoft.We C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Microsoft.Web.WebView2.Wpf.xml C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.csproj.AssemblyReference.cache C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Controls.FormContact.resources +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Controls.FormLoading.resources C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Controls.FormLogin.resources C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Controls.FormMain.resources C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Controls.FormSetting.resources @@ -49,7 +50,159 @@ C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread. C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Ribbon1.resources C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.csproj.GenerateResource.cache C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.csproj.CoreCompileInputs.cache +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofr.8811D769.Up2Date C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.dll C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.pdb -C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofr.8811D769.Up2Date -C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Controls.FormLoading.resources +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\updater.exe +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.IO.Compression.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\updater.pdb +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\updater.exe.config +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Runtime.InteropServices.RuntimeInformation.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Microsoft.Win32.Primitives.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\netstandard.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.AppContext.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Collections.Concurrent.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Collections.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Collections.NonGeneric.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Collections.Specialized.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.ComponentModel.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.ComponentModel.EventBasedAsync.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.ComponentModel.Primitives.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.ComponentModel.TypeConverter.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Console.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Data.Common.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Diagnostics.Contracts.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Diagnostics.Debug.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Diagnostics.FileVersionInfo.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Diagnostics.Process.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Diagnostics.StackTrace.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Diagnostics.TextWriterTraceListener.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Diagnostics.Tools.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Diagnostics.TraceSource.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Diagnostics.Tracing.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Drawing.Primitives.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Dynamic.Runtime.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Globalization.Calendars.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Globalization.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Globalization.Extensions.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.IO.Compression.ZipFile.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.IO.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.IO.FileSystem.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.IO.FileSystem.DriveInfo.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.IO.FileSystem.Primitives.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.IO.FileSystem.Watcher.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.IO.IsolatedStorage.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.IO.MemoryMappedFiles.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.IO.Pipes.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.IO.UnmanagedMemoryStream.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Linq.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Linq.Expressions.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Linq.Parallel.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Linq.Queryable.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Net.Http.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Net.NameResolution.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Net.NetworkInformation.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Net.Ping.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Net.Primitives.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Net.Requests.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Net.Security.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Net.Sockets.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Net.WebHeaderCollection.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Net.WebSockets.Client.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Net.WebSockets.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.ObjectModel.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Reflection.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Reflection.Extensions.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Reflection.Primitives.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Resources.Reader.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Resources.ResourceManager.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Resources.Writer.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Runtime.CompilerServices.VisualC.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Runtime.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Runtime.Extensions.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Runtime.Handles.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Runtime.InteropServices.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Runtime.Numerics.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Runtime.Serialization.Formatters.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Runtime.Serialization.Json.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Runtime.Serialization.Primitives.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Runtime.Serialization.Xml.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Claims.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Cryptography.Algorithms.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Cryptography.Csp.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Cryptography.Encoding.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Cryptography.Primitives.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Cryptography.X509Certificates.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Principal.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.SecureString.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Text.Encoding.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Text.Encoding.Extensions.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Text.RegularExpressions.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Threading.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Threading.Overlapped.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Threading.Tasks.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Threading.Tasks.Parallel.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Threading.Thread.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Threading.ThreadPool.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Threading.Timer.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.ValueTuple.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Xml.ReaderWriter.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Xml.XDocument.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Xml.XmlDocument.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Xml.XmlSerializer.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Xml.XPath.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Xml.XPath.XDocument.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\BouncyCastle.Cryptography.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Enums.NET.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\ExtendedNumerics.BigDecimal.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\ICSharpCode.SharpZipLib.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\MathNet.Numerics.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Microsoft.IO.RecyclableMemoryStream.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\NPOI.Core.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\NPOI.OOXML.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\NPOI.OpenXml4Net.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\NPOI.OpenXmlFormats.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\SixLabors.Fonts.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\SixLabors.ImageSharp.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Buffers.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Configuration.ConfigurationManager.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Memory.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Numerics.Vectors.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Runtime.CompilerServices.Unsafe.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.AccessControl.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Cryptography.Pkcs.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Cryptography.Xml.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Permissions.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Principal.Windows.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Text.Encoding.CodePages.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Threading.Tasks.Extensions.dll +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\BouncyCastle.Cryptography.xml +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Enums.NET.pdb +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Enums.NET.xml +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\ExtendedNumerics.BigDecimal.xml +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\ICSharpCode.SharpZipLib.pdb +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\ICSharpCode.SharpZipLib.xml +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\MathNet.Numerics.xml +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Microsoft.IO.RecyclableMemoryStream.xml +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\NPOI.Core.pdb +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\NPOI.Core.xml +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\NPOI.OOXML.pdb +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\NPOI.OOXML.xml +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\NPOI.OpenXml4Net.pdb +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\NPOI.OpenXml4Net.xml +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\NPOI.OpenXmlFormats.pdb +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\NPOI.OpenXmlFormats.xml +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\SixLabors.Fonts.xml +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\SixLabors.ImageSharp.xml +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Buffers.xml +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Configuration.ConfigurationManager.xml +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Memory.xml +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Numerics.Vectors.xml +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Runtime.CompilerServices.Unsafe.xml +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.AccessControl.xml +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Cryptography.Pkcs.xml +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Cryptography.Xml.xml +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Permissions.xml +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Security.Principal.Windows.xml +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Text.Encoding.CodePages.xml +C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Threading.Tasks.Extensions.xml diff --git a/AIProofread/obj/Debug/AIProofread.csproj.GenerateResource.cache b/AIProofread/obj/Debug/AIProofread.csproj.GenerateResource.cache index 6b6164f..36cc48b 100644 Binary files a/AIProofread/obj/Debug/AIProofread.csproj.GenerateResource.cache and b/AIProofread/obj/Debug/AIProofread.csproj.GenerateResource.cache differ diff --git a/AIProofread/obj/Debug/AIProofread.dll b/AIProofread/obj/Debug/AIProofread.dll index db29289..f8461d5 100644 Binary files a/AIProofread/obj/Debug/AIProofread.dll and b/AIProofread/obj/Debug/AIProofread.dll differ diff --git a/AIProofread/obj/Debug/AIProofread.pdb b/AIProofread/obj/Debug/AIProofread.pdb index 05b0cec..b924169 100644 Binary files a/AIProofread/obj/Debug/AIProofread.pdb and b/AIProofread/obj/Debug/AIProofread.pdb differ diff --git a/AIProofread/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/AIProofread/obj/Debug/DesignTimeResolveAssemblyReferences.cache index 8f69875..2263c5b 100644 Binary files a/AIProofread/obj/Debug/DesignTimeResolveAssemblyReferences.cache and b/AIProofread/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ diff --git a/AIProofread/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/AIProofread/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index eba936e..86a0cb8 100644 Binary files a/AIProofread/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/AIProofread/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/AIProofread/packages.config b/AIProofread/packages.config index 53f4db0..dfc8c51 100644 --- a/AIProofread/packages.config +++ b/AIProofread/packages.config @@ -1,4 +1,26 @@  + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/util-lib/UpdateModel.cs b/util-lib/UpdateModel.cs new file mode 100644 index 0000000..d0a9eb8 --- /dev/null +++ b/util-lib/UpdateModel.cs @@ -0,0 +1,9 @@ +namespace UtilLib +{ + public class UpdateModel + { + public int Version { get; set; } + public string Log { get; set; } + public string UpdateFile { get; set; } + } +} diff --git a/util-lib/packages.config b/util-lib/packages.config new file mode 100644 index 0000000..ea29129 --- /dev/null +++ b/util-lib/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/util-lib/util-lib.csproj b/util-lib/util-lib.csproj index b4772b9..0706d47 100644 --- a/util-lib/util-lib.csproj +++ b/util-lib/util-lib.csproj @@ -40,6 +40,9 @@ prompt + + ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll + @@ -57,11 +60,15 @@ + + + + \ No newline at end of file