fixed 勘误表导出顺序问题;同一句新增导致后续定位错误
This commit is contained in:
parent
8ab9a209e5
commit
d132bbfa3a
Binary file not shown.
@ -365,6 +365,8 @@
|
||||
<Compile Include="Model\DocumentContent.cs" />
|
||||
<Compile Include="Model\DocumentInfo.cs" />
|
||||
<Compile Include="Model\DocumentList.cs" />
|
||||
<Compile Include="Model\ExportDataItem.cs" />
|
||||
<Compile Include="Model\InsertMarkData.cs" />
|
||||
<Compile Include="ProofreadItem.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
|
@ -52,33 +52,34 @@ namespace AIProofread
|
||||
|
||||
public void ShowUpgradeView()
|
||||
{
|
||||
if (CurrentUpgrade == null)
|
||||
{
|
||||
CheckPluginUpgrade();
|
||||
if (CurrentUpgrade == null)
|
||||
{
|
||||
showDialog("获取版本信息失败,请稍后再试");
|
||||
return;
|
||||
}
|
||||
}
|
||||
var needUpgrade = CurrentUpgrade.NeedUpgrade(Config.APP_VERSION);
|
||||
if (!needUpgrade)
|
||||
{
|
||||
showDialog("当前版本为最新版本,无需升级");
|
||||
return;
|
||||
}
|
||||
if (CurrentUpgrade.Ext == 1)
|
||||
{
|
||||
var ret = MessageBox.Show(CurrentUpgrade.Message, "是否确认更新", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);
|
||||
if (ret == DialogResult.Yes)
|
||||
{
|
||||
OpenUrlWithOsBrowser(CurrentUpgrade.DownloadUrl);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
StartUpgradeProcess();
|
||||
}
|
||||
// 统一使用更新程序
|
||||
StartUpgradeProcess();
|
||||
//if (CurrentUpgrade == null)
|
||||
//{
|
||||
// CheckPluginUpgrade();
|
||||
// if (CurrentUpgrade == null)
|
||||
// {
|
||||
// showDialog("获取版本信息失败,请稍后再试");
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
//var needUpgrade = CurrentUpgrade.NeedUpgrade(Config.APP_VERSION);
|
||||
//if (!needUpgrade)
|
||||
//{
|
||||
// showDialog("当前版本为最新版本,无需升级");
|
||||
// return;
|
||||
//}
|
||||
//if (CurrentUpgrade.Ext == 1)
|
||||
//{
|
||||
// var ret = MessageBox.Show(CurrentUpgrade.Message, "是否确认更新", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);
|
||||
// if (ret == DialogResult.Yes)
|
||||
// {
|
||||
// OpenUrlWithOsBrowser(CurrentUpgrade.DownloadUrl);
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
//}
|
||||
}
|
||||
|
||||
public bool ShouldUpgradeForced()
|
||||
@ -245,6 +246,10 @@ namespace AIProofread
|
||||
Globals.ThisAddIn.HidePanel();
|
||||
}
|
||||
|
||||
public void ShowLog(string message)
|
||||
{
|
||||
Logger.Log((Config.IS_WPS ? "WPS" : "WORD") + "-WEB", message);
|
||||
}
|
||||
|
||||
public void ShowLoginForm(string action)
|
||||
{
|
||||
@ -527,8 +532,12 @@ namespace AIProofread
|
||||
}
|
||||
public void ShowSettingForm()
|
||||
{
|
||||
FormSetting frm = new FormSetting();
|
||||
frm.Show();
|
||||
Globals.ThisAddIn.ActiveDocument.ShowSetting();
|
||||
}
|
||||
|
||||
public void ShowWebView(string url, int width, int height, bool dialog)
|
||||
{
|
||||
Globals.ThisAddIn.ActiveDocument.ShowWebView(url, width, height, dialog);
|
||||
}
|
||||
|
||||
public void MoveCursor(int pos)
|
||||
@ -606,6 +615,10 @@ namespace AIProofread
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出勘误表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string ExportProofreadResult()
|
||||
{
|
||||
try
|
||||
@ -641,6 +654,10 @@ namespace AIProofread
|
||||
public string SaveCache(int documentId, string cache, bool silent)
|
||||
{
|
||||
var document = Globals.ThisAddIn.GetDocumentById(documentId);
|
||||
if (document == null)
|
||||
{
|
||||
return BridgeResult.Success("ok");
|
||||
}
|
||||
if (!silent)
|
||||
{
|
||||
if (!document.CurrentDocument.Saved)
|
||||
@ -727,11 +744,28 @@ namespace AIProofread
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCurrentDocumentProofreadStatus(int documentId,bool status)
|
||||
public void SetCurrentDocumentProofreadStatus(int documentId, bool proofread, bool proofreading, bool checkIsActive = false)
|
||||
{
|
||||
|
||||
if (documentId < 1) return;
|
||||
var document = Globals.ThisAddIn.GetDocumentById(documentId);
|
||||
document.Proofreading = status;
|
||||
if (document != null)
|
||||
{
|
||||
document.Proofread = proofread;
|
||||
document.Proofreading = proofreading;
|
||||
if (checkIsActive && documentId != Globals.ThisAddIn.ActiveDocument.Id) return;
|
||||
document.CheckBtnStatus();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置当前文档的校对状态
|
||||
/// </summary>
|
||||
/// <param name="documentId"></param>
|
||||
/// <param name="proofread"></param>
|
||||
/// <param name="proofreading"></param>
|
||||
public void SetCurrentDocumentProofreadStatus(int documentId, bool proofread, bool proofreading)
|
||||
{
|
||||
SetCurrentDocumentProofreadStatus(documentId, proofread, proofreading, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,10 +12,10 @@ namespace AIProofread
|
||||
public class Config
|
||||
{
|
||||
public static readonly string APP_NAME = "AI校对王";
|
||||
public static readonly string APP_VERSION = "2.0.0";
|
||||
public static readonly string APP_VERSION = "2.0.1";
|
||||
public static bool IS_WPS = false;
|
||||
public static bool UpgradeForcedNotice = false;
|
||||
|
||||
public static readonly string APP_BASE_DIR = AppDomain.CurrentDomain.BaseDirectory;
|
||||
public static readonly string CONFIG_FILE = AppDomain.CurrentDomain.BaseDirectory + "app.json";
|
||||
/// <summary>
|
||||
/// 文本背景色
|
||||
@ -25,11 +25,11 @@ namespace AIProofread
|
||||
/// <summary>
|
||||
/// 网页访问地址
|
||||
/// </summary>
|
||||
public static string WEB_PATH = "http://192.168.10.100:5173/"; //192.168.0.231:5137 192.168.10.100:5173 gm2-plugin.zverse.group
|
||||
public static bool RUN_IN_DEBUG = false;
|
||||
public static AppEnvironment APP_ENV = AppEnvironment.Prod;
|
||||
public static string WEB_PATH = "https://pre-gm-plugin.gachafun.com/"; //pre-gm-plugin.gachafun.com 192.168.0.231:5137 192.168.10.100:5173 gm2-plugin.zverse.group
|
||||
public static bool RUN_IN_DEBUG = true;
|
||||
public static AppEnvironment APP_ENV = AppEnvironment.Dev;
|
||||
#else
|
||||
public static string WEB_PATH = "https://gm-plugin.gachafun.com/";
|
||||
public static string WEB_PATH = "https://pre-gm-plugin.gachafun.com/";
|
||||
public static bool RUN_IN_DEBUG = false;
|
||||
public static AppEnvironment APP_ENV = AppEnvironment.Prod;
|
||||
#endif
|
||||
|
4
AIProofread/Controls/FormMessage.Designer.cs
generated
4
AIProofread/Controls/FormMessage.Designer.cs
generated
@ -86,7 +86,7 @@
|
||||
//
|
||||
this.BtnClose.BackColor = System.Drawing.Color.White;
|
||||
this.BtnClose.BackgroundImage = global::AIProofread.Properties.Resources.button_default;
|
||||
this.BtnClose.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
|
||||
this.BtnClose.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.BtnClose.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.BtnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.BtnClose.FlatAppearance.BorderColor = System.Drawing.Color.Gainsboro;
|
||||
@ -107,7 +107,7 @@
|
||||
// BtnConfirm
|
||||
//
|
||||
this.BtnConfirm.BackgroundImage = global::AIProofread.Properties.Resources.button;
|
||||
this.BtnConfirm.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
|
||||
this.BtnConfirm.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.BtnConfirm.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.BtnConfirm.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.BtnConfirm.FlatAppearance.BorderSize = 0;
|
||||
|
@ -30,14 +30,18 @@ namespace AIProofread
|
||||
{
|
||||
Directory.CreateDirectory(Config.APP_LOG_PATH);
|
||||
}
|
||||
StreamWriter streamWriter = File.AppendText(path);
|
||||
streamWriter.WriteLine("***************************[" + tag + "]***************************");
|
||||
streamWriter.WriteLine("消息:" + message);
|
||||
streamWriter.WriteLine("时间:" + time);
|
||||
streamWriter.WriteLine();
|
||||
streamWriter.Flush();
|
||||
streamWriter.Close();
|
||||
streamWriter.Dispose();
|
||||
try
|
||||
{
|
||||
StreamWriter streamWriter = File.AppendText(path);
|
||||
streamWriter.WriteLine("***************************[" + tag + "]***************************");
|
||||
streamWriter.WriteLine("消息:" + message);
|
||||
streamWriter.WriteLine("时间:" + time);
|
||||
streamWriter.WriteLine();
|
||||
streamWriter.Flush();
|
||||
streamWriter.Close();
|
||||
streamWriter.Dispose();
|
||||
}
|
||||
catch (Exception e) { }
|
||||
}
|
||||
public static void Log(string msg)
|
||||
{
|
||||
|
@ -80,6 +80,13 @@ namespace AIProofread.Model
|
||||
public CustomTaskPane TaskPane { get; set; }
|
||||
public WdProtectionType ProtectionType { get { return CurrentDocument.ProtectionType; } }
|
||||
|
||||
/// <summary>
|
||||
/// 是否已校对
|
||||
/// </summary>
|
||||
public bool Proofread { get; set; }
|
||||
/// <summary>
|
||||
/// 是否校对中
|
||||
/// </summary>
|
||||
public bool Proofreading { get; set; }
|
||||
|
||||
// 初始化
|
||||
@ -119,11 +126,17 @@ namespace AIProofread.Model
|
||||
}));
|
||||
}
|
||||
|
||||
private void ShowDocumentStatus(string tag)
|
||||
{
|
||||
Logger.Log($"{fileName} {tag} PaneVisible is {PaneVisible} Poofread is {Proofread} Proofreading is {Proofreading}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 隐藏面板
|
||||
/// </summary>
|
||||
public void HidePane()
|
||||
{
|
||||
ShowDocumentStatus(" HidePane");
|
||||
if (null != TaskPane) TaskPane.Visible = PaneVisible = false;
|
||||
}
|
||||
|
||||
@ -132,8 +145,9 @@ namespace AIProofread.Model
|
||||
/// </summary>
|
||||
public void Active()
|
||||
{
|
||||
ShowDocumentStatus(" Active");
|
||||
IsActive = true;
|
||||
if (null != TaskPane && PaneVisible)
|
||||
if (Config.IS_WPS && null != TaskPane && PaneVisible)
|
||||
{
|
||||
TaskPane.Visible = true;
|
||||
}
|
||||
@ -141,11 +155,26 @@ namespace AIProofread.Model
|
||||
|
||||
public void Deactive()
|
||||
{
|
||||
ShowDocumentStatus(" Deactive");
|
||||
IsActive = false;
|
||||
if (null != TaskPane && PaneVisible)
|
||||
if (Config.IS_WPS)
|
||||
{
|
||||
TaskPane.Visible = false;
|
||||
if (PaneVisible)
|
||||
{
|
||||
// 异步等待一段时间 重新设置为true,防止面板关闭时,触发事件
|
||||
ThreadPool.QueueUserWorkItem(state =>
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
PaneVisible = true;
|
||||
});
|
||||
}
|
||||
if (null != TaskPane && PaneVisible)
|
||||
{
|
||||
TaskPane.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@ -219,7 +248,7 @@ namespace AIProofread.Model
|
||||
//
|
||||
if (Globals.ThisAddIn.ribbon != null)
|
||||
{
|
||||
Globals.ThisAddIn.ribbon.BtnShowPanel.Enabled = !PaneVisible && marks.Count > 0;
|
||||
Globals.ThisAddIn.ribbon.BtnShowPanel.Enabled = !PaneVisible && Proofread;
|
||||
Globals.ThisAddIn.ribbon.SetCommonBtnStatus(!Proofreading);
|
||||
}
|
||||
}
|
||||
@ -229,6 +258,7 @@ namespace AIProofread.Model
|
||||
// 如果已经隐藏 则记录隐藏用于(WPS)多面板的切换的处理
|
||||
PaneVisible = TaskPane.Visible;
|
||||
CheckBtnStatus();
|
||||
//Globals.ThisAddIn.ribbon.BtnShowPanel.Enabled = !TaskPane.Visible && Proofread;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
@ -548,9 +578,11 @@ namespace AIProofread.Model
|
||||
int prevOffset = 0;
|
||||
|
||||
List<int> disabledList = new List<int>();
|
||||
List<InsertMarkData> insertMarks = new List<InsertMarkData>();
|
||||
foreach (var correct in list)
|
||||
{
|
||||
Logger.Log(string.Format("correct content:", correct.Insert));
|
||||
int currentOffset = correct.SentenceOffset;
|
||||
if (correct.CorrectItems != null && correct.CorrectItems.Count > 0)
|
||||
{
|
||||
prevOffset = 0;
|
||||
@ -565,7 +597,7 @@ namespace AIProofread.Model
|
||||
// 防止调用方法中没有更新
|
||||
if (_prev >= prevOffset)
|
||||
{
|
||||
prevOffset = correct.SentenceOffset + item.Start;
|
||||
prevOffset = currentOffset + item.Start;
|
||||
}
|
||||
|
||||
if (item.Tag != "i") index++;
|
||||
@ -575,8 +607,12 @@ namespace AIProofread.Model
|
||||
try
|
||||
{
|
||||
if (item.Tag == "i")
|
||||
{ // 使用空格填充
|
||||
mark.Text = ToolUtil.GetBlankText(item.Text.Length);
|
||||
{
|
||||
insertMarks.Add(new InsertMarkData()
|
||||
{
|
||||
Mark = mark,
|
||||
InsertLength = item.Text.Length
|
||||
});
|
||||
}
|
||||
if (item.Color != null)
|
||||
{
|
||||
@ -614,6 +650,16 @@ namespace AIProofread.Model
|
||||
}
|
||||
}
|
||||
}
|
||||
// 为了避免影响其他文本定位,操作完成后才使用空格填充
|
||||
try
|
||||
{
|
||||
foreach (var item in insertMarks)
|
||||
{
|
||||
item.Mark.Text = ToolUtil.GetBlankText(item.InsertLength);
|
||||
}
|
||||
}
|
||||
catch (Exception) { }
|
||||
insertMarks.Clear();
|
||||
//foreach (var item in marks)
|
||||
//{
|
||||
// if (item.Value.mark != null)
|
||||
@ -759,7 +805,9 @@ namespace AIProofread.Model
|
||||
{
|
||||
try
|
||||
{
|
||||
// 清除标记内存数据
|
||||
marks.Clear();
|
||||
// 清除区域相关数据
|
||||
ranges.Clear();
|
||||
TaskPane.Dispose();
|
||||
}
|
||||
@ -802,7 +850,7 @@ namespace AIProofread.Model
|
||||
{
|
||||
if (!needUpgrade)
|
||||
{
|
||||
ShowDialog("当前版本为最新版本,无需升级","","");
|
||||
ShowDialog("当前版本为最新版本,无需升级", "", "");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -818,7 +866,7 @@ namespace AIProofread.Model
|
||||
}
|
||||
|
||||
Bridge.bridge.OpenUrlWithOsBrowser(upgradeData.DownloadUrl);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -827,5 +875,32 @@ namespace AIProofread.Model
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public void ShowSetting()
|
||||
{
|
||||
|
||||
TaskPane.Control.BeginInvoke(new Action(() =>
|
||||
{
|
||||
FormSetting frm = new FormSetting();
|
||||
frm.Show();
|
||||
}));
|
||||
}
|
||||
public void ShowWebView(string url, int width, int height, bool dialog)
|
||||
{
|
||||
TaskPane.Control.BeginInvoke(new Action(() =>
|
||||
{
|
||||
FormWebView view = new FormWebView(url, width, height);
|
||||
if (dialog)
|
||||
{
|
||||
view.StartPosition = FormStartPosition.CenterScreen;
|
||||
view.ShowDialog();
|
||||
}
|
||||
else
|
||||
{
|
||||
view.StartPosition = FormStartPosition.CenterParent;
|
||||
view.Show();
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -78,11 +78,11 @@ namespace AIProofread.Model
|
||||
}
|
||||
public bool Remove(Document originDocument)
|
||||
{
|
||||
if(Count > 0 && originDocument != null)
|
||||
if (Count > 0 && originDocument != null)
|
||||
{
|
||||
documentList.RemoveAll(x =>
|
||||
{
|
||||
if(x.CurrentDocument == originDocument)
|
||||
if (x.CurrentDocument == originDocument)
|
||||
{
|
||||
x.Close();
|
||||
return true;
|
||||
|
56
AIProofread/Model/ExportDataItem.cs
Normal file
56
AIProofread/Model/ExportDataItem.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using Microsoft.Office.Interop.Word;
|
||||
using System.Collections.Generic;
|
||||
using UtilLib;
|
||||
|
||||
namespace AIProofread.Model
|
||||
{
|
||||
public class ExportDataItem
|
||||
{
|
||||
public int PageNumber { get; set; }
|
||||
public int LineNumber { get; set; }
|
||||
public string OriginSentence { get; set; }
|
||||
public CorrectItem Item { get; set; }
|
||||
|
||||
public ExportDataItem(CorrectItem item, int pageNumber, int lineNumber,string originSentence = "")
|
||||
{
|
||||
Item = item;
|
||||
PageNumber = pageNumber;
|
||||
LineNumber = lineNumber;
|
||||
OriginSentence = originSentence;
|
||||
}
|
||||
|
||||
public static List<ExportDataItem> GetExportData(Dictionary<int, ProofreadItem> marks)
|
||||
{
|
||||
List<ExportDataItem> list = new List<ExportDataItem>();
|
||||
|
||||
foreach (var item in marks)
|
||||
{
|
||||
if (item.Value.mark == null) continue;
|
||||
var it = item.Value.content;
|
||||
var range = item.Value.mark.Range;
|
||||
|
||||
// 获取书签在文档的页码数
|
||||
var pageNumber = range.get_Information(WdInformation.wdActiveEndPageNumber);
|
||||
// 获取书签在当前页面的行数
|
||||
var lineNumber = range.get_Information(WdInformation.wdFirstCharacterLineNumber);
|
||||
list.Add(new ExportDataItem(it, pageNumber, lineNumber,item.Value.OriginSentence));
|
||||
}
|
||||
// 根据页码和行数排序
|
||||
list.Sort((x, y) =>
|
||||
{
|
||||
if (x.PageNumber == y.PageNumber)
|
||||
{
|
||||
if(x.LineNumber == y.LineNumber)
|
||||
{
|
||||
// 如果行数相同,则根据起始位置排序
|
||||
return x.Item.Start.CompareTo(y.Item.Start);
|
||||
}
|
||||
// 如果页码相同,则根据行数排序
|
||||
return x.LineNumber.CompareTo(y.LineNumber);
|
||||
}
|
||||
return x.PageNumber.CompareTo(y.PageNumber);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
10
AIProofread/Model/InsertMarkData.cs
Normal file
10
AIProofread/Model/InsertMarkData.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using Microsoft.Office.Tools.Word;
|
||||
|
||||
namespace AIProofread.Model
|
||||
{
|
||||
public class InsertMarkData
|
||||
{
|
||||
public Bookmark Mark { get; set; }
|
||||
public int InsertLength { get; set; }
|
||||
}
|
||||
}
|
@ -33,6 +33,6 @@ using System.Security;
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
|
||||
// 方法是按如下所示使用“*”: :
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.1")]
|
||||
[assembly: AssemblyFileVersion("1.1.0.1")]
|
||||
[assembly: AssemblyVersion("2.0")]
|
||||
[assembly: AssemblyFileVersion("2.0.1.0")]
|
||||
|
||||
|
4
AIProofread/Ribbon1.Designer.cs
generated
4
AIProofread/Ribbon1.Designer.cs
generated
@ -203,7 +203,7 @@ namespace AIProofread
|
||||
//
|
||||
this.ButtonSaveCache.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
|
||||
this.ButtonSaveCache.Image = global::AIProofread.Properties.Resources.icon_save;
|
||||
this.ButtonSaveCache.Label = "暂存文件\r\n";
|
||||
this.ButtonSaveCache.Label = "手动保存数据\r\n";
|
||||
this.ButtonSaveCache.Name = "ButtonSaveCache";
|
||||
this.ButtonSaveCache.ShowImage = true;
|
||||
this.ButtonSaveCache.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.ButtonSaveCache_Click);
|
||||
@ -212,7 +212,7 @@ namespace AIProofread
|
||||
//
|
||||
this.ButtonLoadCache.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
|
||||
this.ButtonLoadCache.Image = global::AIProofread.Properties.Resources.icon_history;
|
||||
this.ButtonLoadCache.Label = "加载文件\r\n";
|
||||
this.ButtonLoadCache.Label = "追踪历史数据\r\n";
|
||||
this.ButtonLoadCache.Name = "ButtonLoadCache";
|
||||
this.ButtonLoadCache.ShowImage = true;
|
||||
this.ButtonLoadCache.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.ButtonLoadCache_Click);
|
||||
|
@ -61,6 +61,8 @@ namespace AIProofread
|
||||
public bool IsWPS { get; set; }
|
||||
|
||||
public List<FormLogin> LoginFormList = new List<FormLogin>();
|
||||
public static bool AppRunning = true;
|
||||
private System.Timers.Timer _timer;
|
||||
|
||||
//public override void BeginInit()
|
||||
//{
|
||||
@ -89,12 +91,60 @@ namespace AIProofread
|
||||
// 选区发生变化事件
|
||||
this.Application.WindowSelectionChange += Application_WindowSelectionChange;
|
||||
//CheckPluginUpgradeInfo();
|
||||
// CheckDocumentClosedTick();
|
||||
|
||||
// 定时检测文档是否关闭
|
||||
_timer = new System.Timers.Timer(10000);
|
||||
_timer.Elapsed += CheckDocumentClosed;
|
||||
_timer.AutoReset = true;
|
||||
_timer.Enabled = true;
|
||||
}
|
||||
catch (Exception ex1)
|
||||
{
|
||||
Logger.Log("Startup", ex1.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void CheckDocumentClosed(object sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
var existsList = new List<string>();
|
||||
Logger.Log("检测文档是否关闭 ...");
|
||||
try
|
||||
{
|
||||
if (documentList.Count == 0 || CurrentWordApplication.Documents.Count == documentList.Count) return;
|
||||
|
||||
existsList.Clear();
|
||||
|
||||
foreach (Document item in CurrentWordApplication.Documents)
|
||||
{
|
||||
existsList.Add(item.FullName);
|
||||
}
|
||||
// 检测文档是否关闭
|
||||
foreach (var item in documentList.documentList)
|
||||
{
|
||||
if (!existsList.Contains(item.fileName))
|
||||
{
|
||||
Logger.Log("检测到文档关闭,已移除:" + item.fileName);
|
||||
documentList.Remove(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Log(ex);
|
||||
}
|
||||
//await System.Threading.Tasks.Task.Run(() =>
|
||||
// {
|
||||
//
|
||||
// while (AppRunning)
|
||||
// {
|
||||
// Thread.Sleep(10000); // 暂停10s
|
||||
|
||||
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
async void CheckPluginUpgradeInfo()
|
||||
{
|
||||
@ -152,6 +202,15 @@ namespace AIProofread
|
||||
Logger.Log("Init WPS Error " + ex.Message);
|
||||
}
|
||||
}
|
||||
string verTextFile = Config.APP_BASE_DIR + Path.GetFileName("app_version.txt");
|
||||
try
|
||||
{
|
||||
File.WriteAllText(verTextFile, Config.APP_VERSION);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Log("Write App Version Error " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void InitAppByConfig()
|
||||
@ -257,7 +316,6 @@ namespace AIProofread
|
||||
private void Application_DocumentBeforeClose(Document currentDoc, ref bool Cancel)
|
||||
{
|
||||
Logger.Log("DocumentBeforeClose", currentDoc.FullName);
|
||||
documentList.Remove(currentDoc);
|
||||
//if (allMarks.ContainsKey(currentDoc))
|
||||
//{
|
||||
// allMarks.Remove(currentDoc);
|
||||
@ -405,6 +463,10 @@ namespace AIProofread
|
||||
//this.proofreadPanel.Dispose();
|
||||
Logger.Log("shutdown");
|
||||
documentList.Clear();
|
||||
if(_timer != null)
|
||||
{
|
||||
_timer.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
public void SyncLogout()
|
||||
|
@ -13,6 +13,11 @@ using NPOI.XSSF.UserModel;
|
||||
using System.Windows.Forms;
|
||||
using NPOI.SS.UserModel;
|
||||
using System.IO;
|
||||
using SixLabors.Fonts.Tables.AdvancedTypographic;
|
||||
using MathNet.Numerics.LinearAlgebra.Factorization;
|
||||
using System.Linq;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using AIProofread.Model;
|
||||
|
||||
namespace AIProofread
|
||||
{
|
||||
@ -318,7 +323,7 @@ namespace AIProofread
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Log(ex);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
//if(bookmark == null)
|
||||
@ -378,6 +383,8 @@ namespace AIProofread
|
||||
|
||||
private static Range FindRangeByCorrect(CorrectContext c, CorrectItem item, Paragraph paragraph, Microsoft.Office.Interop.Word.Document document, int prevOffset)
|
||||
{
|
||||
|
||||
var originText = c.Insert;
|
||||
var paraRange = paragraph.Range;
|
||||
var paraText = paraRange.Text;
|
||||
var paraStart = paraRange.Start;
|
||||
@ -389,9 +396,9 @@ namespace AIProofread
|
||||
var sentence = paraRange.Sentences[c.SentenceNumber]; //paraText.Substring(c.SentenceOffset, c.InsertLength);
|
||||
c.SentenceOffset = sentence.Start;
|
||||
var offset = c.SentenceOffset;
|
||||
c.Insert = sentence.Text;
|
||||
originText = sentence.Text;
|
||||
|
||||
if (sentence.Text == c.Insert)
|
||||
if (c.Insert == originText)
|
||||
{
|
||||
if (item.Tag == "i")
|
||||
{
|
||||
@ -403,7 +410,7 @@ namespace AIProofread
|
||||
if (range.Text == item.Origin) return range;
|
||||
}
|
||||
|
||||
var originText = c.Insert;
|
||||
originText = c.Insert;
|
||||
// 如果是新增 则查找定位
|
||||
if (item.Tag == "i")
|
||||
{
|
||||
@ -430,6 +437,12 @@ namespace AIProofread
|
||||
}
|
||||
}
|
||||
|
||||
if (prevOffset >= paraText.Length)
|
||||
{
|
||||
// 查找位置已经超过了整段长度了
|
||||
Logger.Log("prevOffset:" + prevOffset + " paraText.Length:" + paraText.Length);
|
||||
return null;
|
||||
}
|
||||
// 执行查找
|
||||
int wordStart = item.Start;
|
||||
int wordEnd = item.End;
|
||||
@ -447,6 +460,7 @@ namespace AIProofread
|
||||
? originText.Substring(wordStart, INSERT_FIND_OFFSET)
|
||||
: originText.Substring(wordStart, originText.Length - wordStart)
|
||||
) : null;
|
||||
|
||||
var start = prefix != null || suffix != null
|
||||
? paraText.IndexOf(prefix ?? suffix, prevOffset) // item.start +
|
||||
: -1;
|
||||
@ -475,7 +489,20 @@ namespace AIProofread
|
||||
{
|
||||
return;
|
||||
}
|
||||
using (var fs = File.OpenWrite(sfd.FileName))
|
||||
try
|
||||
{
|
||||
ProcessExport(sfd.FileName);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Globals.ThisAddIn.ActiveDocument.ShowDialog("导出勘误表失败", null, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void ProcessExport(string fileName)
|
||||
{
|
||||
using (var fs = File.OpenWrite(fileName))
|
||||
{
|
||||
var book = new XSSFWorkbook();
|
||||
var sheet = book.CreateSheet("Sheet1");
|
||||
@ -504,20 +531,16 @@ namespace AIProofread
|
||||
|
||||
var cell = row.CreateCell(3);//
|
||||
// 设置宽度
|
||||
sheet.SetColumnWidth(3, 50 * 256);
|
||||
sheet.SetColumnWidth(3, 80 * 256); // 80 字符的宽度
|
||||
cell.SetCellValue("详细信息");
|
||||
|
||||
var cellExp = row.CreateCell(4);
|
||||
// 设置文字颜色为红色
|
||||
var expStyle = book.CreateCellStyle();
|
||||
var f1 = CreateBaseFont(book);
|
||||
f1.Color = NPOI.HSSF.Util.HSSFColor.Red.Index;
|
||||
expStyle.SetFont(f1);
|
||||
cellExp.CellStyle = expStyle;
|
||||
sheet.SetColumnWidth(4, 10 * 256);
|
||||
cellExp.SetCellValue("异常");
|
||||
|
||||
var suggestCell = row.CreateCell(5);//
|
||||
suggestCell.CellStyle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Red.Index;
|
||||
//suggestCell.CellStyle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Red.Index;
|
||||
sheet.SetColumnWidth(5, 10 * 256);
|
||||
suggestCell.SetCellValue("建议");
|
||||
|
||||
row.CreateCell(6).SetCellValue("处理状态");
|
||||
@ -526,61 +549,149 @@ namespace AIProofread
|
||||
blackFont.Color = NPOI.HSSF.Util.HSSFColor.Black.Index;
|
||||
var redFont = CreateBaseFont(book);
|
||||
redFont.Color = NPOI.HSSF.Util.HSSFColor.Red.Index;
|
||||
|
||||
// 字体加粗增大
|
||||
var strongFont = CreateBaseFont(book);
|
||||
// 字体加粗
|
||||
strongFont.IsBold = true;
|
||||
// 字体更大
|
||||
strongFont.FontHeightInPoints = 13;
|
||||
// 获取排序后的数据
|
||||
var list = ExportDataItem.GetExportData(Globals.ThisAddIn.ActiveDocument.marks);
|
||||
// 对 list 进行排序
|
||||
int id = 1;
|
||||
foreach (var item in Globals.ThisAddIn.ActiveDocument.marks)
|
||||
foreach (var item in list)
|
||||
{
|
||||
if (item.Value.mark == null) continue;
|
||||
var it = item.Value.content;
|
||||
var range = item.Value.mark.Range;
|
||||
try
|
||||
{
|
||||
var it = item.Item;
|
||||
row = sheet.CreateRow(id);
|
||||
row.CreateCell(0).SetCellValue(id);
|
||||
row.CreateCell(1).SetCellValue(item.PageNumber);
|
||||
row.CreateCell(2).SetCellValue(item.LineNumber);
|
||||
|
||||
// 获取书签在文档的页码数
|
||||
var pageNumber = range.get_Information(WdInformation.wdActiveEndPageNumber);
|
||||
// 获取书签在当前页面的行数
|
||||
var lineNumber = range.get_Information(WdInformation.wdFirstCharacterLineNumber);
|
||||
row = sheet.CreateRow(id);
|
||||
row.CreateCell(0).SetCellValue(id);
|
||||
row.CreateCell(1).SetCellValue(pageNumber);
|
||||
row.CreateCell(2).SetCellValue(lineNumber);
|
||||
string originSentence = item.OriginSentence;
|
||||
if (it.Tag == "i")
|
||||
{
|
||||
// ˽
|
||||
// 对查找内容引用红色
|
||||
try
|
||||
{
|
||||
originSentence = originSentence.Substring(0, it.Start) + GetInsertContentByLength(it.Text.Length) + originSentence.Substring(it.Start);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log(e);
|
||||
}
|
||||
}
|
||||
|
||||
XSSFRichTextString originText = new XSSFRichTextString(item.Value.OriginSentence);
|
||||
originText.ApplyFont(blackFont);
|
||||
var startIndex = item.Value.OriginSentence.IndexOf(it.Origin);
|
||||
// 对查找内容引用红色
|
||||
originText.ApplyFont(startIndex, startIndex + it.Origin.Length, redFont);
|
||||
row.CreateCell(3).SetCellValue(originText);
|
||||
XSSFRichTextString originText = new XSSFRichTextString(originSentence.TrimEnd());
|
||||
originText.ApplyFont(blackFont);
|
||||
var startIndex = it.Tag == "i" ? it.Start : originSentence.IndexOf(it.Origin);
|
||||
// 对查找内容引用红色
|
||||
originText.ApplyFont(it.Start, it.Start + (it.Tag == "i" ? it.Text.Length : it.Origin.Length), redFont);
|
||||
var oriCell = row.CreateCell(3);
|
||||
// 设置单元格内容自动换行
|
||||
oriCell.CellStyle.WrapText = true;
|
||||
oriCell.SetCellValue(originText);
|
||||
|
||||
row.CreateCell(4).SetCellValue(it.Origin);
|
||||
if(it.Tag == "r") {
|
||||
row.CreateCell(4).SetCellValue(it.Origin);
|
||||
var suggest = it.Text;
|
||||
if(it.Type == "sensitive")
|
||||
if (it.Tag == "r")
|
||||
{
|
||||
suggest += "(敏感词)";
|
||||
string tag = "";
|
||||
if (it.Type == "blacklist")
|
||||
{
|
||||
tag = "黑名单";
|
||||
XSSFRichTextString replaceText = new XSSFRichTextString(suggest + $" {tag}");
|
||||
replaceText.ApplyFont(blackFont);
|
||||
if (tag != "")
|
||||
{
|
||||
// 对查找内容引用红色
|
||||
replaceText.ApplyFont(suggest.Length + 1, suggest.Length + 1 + tag.Length, strongFont);
|
||||
}
|
||||
row.CreateCell(5).SetCellValue(replaceText);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO 后期优化
|
||||
// 易错词不标识
|
||||
if (it.Type == "confusion" || it.Type == "model" || it.Type == "other")
|
||||
{
|
||||
row.CreateCell(5).SetCellValue(suggest);
|
||||
}
|
||||
else if (it.Type == "first_choice")
|
||||
{
|
||||
row.CreateCell(5).SetCellValue(suggest + " 【提示】首选");
|
||||
}
|
||||
else if (it.Type == "now_called")
|
||||
{
|
||||
row.CreateCell(5).SetCellValue(suggest + " 【提示】现称");
|
||||
}
|
||||
else if (it.Type == "quoting_legal")
|
||||
{
|
||||
row.CreateCell(5).SetCellValue(suggest + " 【提示】法规");
|
||||
}
|
||||
else if (it.Type == "incorrect_expression")
|
||||
{
|
||||
row.CreateCell(5).SetCellValue(suggest + " 【提示】表述有误");
|
||||
}
|
||||
else
|
||||
{
|
||||
row.CreateCell(5).SetCellValue(suggest + (string.IsNullOrEmpty(it.Addition) ? "" : $" 【提示】{it.Addition}"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (it.Type == "blacklist")
|
||||
else
|
||||
{
|
||||
suggest += "(敏感词)";
|
||||
string tag = "";
|
||||
startIndex = 0;
|
||||
if (it.Type == "incorrect_expression")
|
||||
{
|
||||
tag = "表述有误";
|
||||
}
|
||||
else if (it.Type == "sensitive")
|
||||
{
|
||||
tag = "敏感词";
|
||||
}
|
||||
else if (it.Type == "blacklist")
|
||||
{
|
||||
tag = "黑名单";
|
||||
}
|
||||
else if (it.Tag == "i")
|
||||
{
|
||||
startIndex = it.Text.Length + 1;
|
||||
tag = it.Text + " 新增";
|
||||
}
|
||||
else if (it.Tag == "d")
|
||||
{
|
||||
tag = "删除";
|
||||
}
|
||||
XSSFRichTextString suggestText = new XSSFRichTextString(tag);
|
||||
suggestText.ApplyFont(blackFont);
|
||||
if (tag.Length > 0)
|
||||
{
|
||||
// 对查找内容引用红色
|
||||
suggestText.ApplyFont(startIndex, it.Tag == "i" ? startIndex + 2 : tag.Length, strongFont);
|
||||
row.CreateCell(5).SetCellValue(suggestText);
|
||||
}
|
||||
else
|
||||
{
|
||||
row.CreateCell(5).SetCellValue(suggest);
|
||||
}
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(it.Addition))
|
||||
{
|
||||
suggest += $"({it.Addition})";
|
||||
}
|
||||
row.CreateCell(5).SetCellValue(suggest);
|
||||
row.CreateCell(6).SetCellValue(StatusText(it.IsAccept));
|
||||
}
|
||||
else if(it.Tag == "i")
|
||||
catch (Exception ex)
|
||||
{
|
||||
row.CreateCell(5).SetCellValue("新增");
|
||||
Logger.Log(ex);
|
||||
}
|
||||
else if (it.Tag == "e")
|
||||
{
|
||||
row.CreateCell(5).SetCellValue("删除");
|
||||
}
|
||||
row.CreateCell(6).SetCellValue(StatusText(it.IsAccept));
|
||||
id++;
|
||||
}
|
||||
|
||||
// 保存到文件
|
||||
book.Write(fs);
|
||||
Globals.ThisAddIn.ActiveDocument.ShowDialog("导出成功", null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -606,11 +717,16 @@ namespace AIProofread
|
||||
|
||||
private static string StatusText(int status)
|
||||
{
|
||||
if (status == AcceptStatus.Accept) return "采纳";
|
||||
else if (status == AcceptStatus.Review) return "复核";
|
||||
else if (status == AcceptStatus.Ignore) return "忽略";
|
||||
if (status == AcceptStatus.Accept) return "已采纳";
|
||||
else if (status == AcceptStatus.Review) return "已复核";
|
||||
else if (status == AcceptStatus.Ignore) return "已忽略";
|
||||
|
||||
return "未处理";
|
||||
}
|
||||
|
||||
private static string GetInsertContentByLength(int length)
|
||||
{
|
||||
return new String('˽', length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
@ -1 +1 @@
|
||||
73697d8cfbb569cc987afc71aa3dff1fa36374eacaf0a7c7b55871ef5023996c
|
||||
8f0bfa7787b64c7e81e5cec3f2098ad425c0efe864d9c3506d226b26674a4392
|
||||
|
@ -194,10 +194,15 @@ C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Text.
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Threading.Tasks.Extensions.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.FormDialog.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.FormLogger.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.FormMask.resources
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Controls.FormMessage.resources
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Controls.FormSetting.resources
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Controls.FormWebView.resources
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Controls.ProofreadMainControl.resources
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Properties.Resources.resources
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Ribbon1.resources
|
||||
@ -206,8 +211,3 @@ C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.
|
||||
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\AIProofread.Controls.FormLogger.resources
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Controls.FormMessage.resources
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Controls.FormDialog.resources
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Controls.FormWebView.resources
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Controls.FormMask.resources
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
36
updater/Form1.Designer.cs
generated
36
updater/Form1.Designer.cs
generated
@ -32,15 +32,16 @@
|
||||
this.LabelLog = new System.Windows.Forms.Label();
|
||||
this.progressBar1 = new System.Windows.Forms.ProgressBar();
|
||||
this.ButtonProcess = new System.Windows.Forms.Button();
|
||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// LabelLog
|
||||
//
|
||||
this.LabelLog.BackColor = System.Drawing.SystemColors.ControlLight;
|
||||
this.LabelLog.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.LabelLog.Location = new System.Drawing.Point(52, 30);
|
||||
this.LabelLog.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.LabelLog.Location = new System.Drawing.Point(90, 10);
|
||||
this.LabelLog.Name = "LabelLog";
|
||||
this.LabelLog.Size = new System.Drawing.Size(340, 169);
|
||||
this.LabelLog.Size = new System.Drawing.Size(300, 93);
|
||||
this.LabelLog.TabIndex = 0;
|
||||
this.LabelLog.Text = "正在检测";
|
||||
this.LabelLog.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
@ -48,39 +49,53 @@
|
||||
//
|
||||
// progressBar1
|
||||
//
|
||||
this.progressBar1.Location = new System.Drawing.Point(52, 210);
|
||||
this.progressBar1.Location = new System.Drawing.Point(90, 118);
|
||||
this.progressBar1.Name = "progressBar1";
|
||||
this.progressBar1.Size = new System.Drawing.Size(340, 10);
|
||||
this.progressBar1.Size = new System.Drawing.Size(300, 14);
|
||||
this.progressBar1.TabIndex = 3;
|
||||
this.progressBar1.Visible = false;
|
||||
//
|
||||
// ButtonProcess
|
||||
//
|
||||
this.ButtonProcess.Location = new System.Drawing.Point(186, 228);
|
||||
this.ButtonProcess.Location = new System.Drawing.Point(141, 153);
|
||||
this.ButtonProcess.Name = "ButtonProcess";
|
||||
this.ButtonProcess.Size = new System.Drawing.Size(72, 33);
|
||||
this.ButtonProcess.Size = new System.Drawing.Size(136, 40);
|
||||
this.ButtonProcess.TabIndex = 4;
|
||||
this.ButtonProcess.Text = "继续";
|
||||
this.ButtonProcess.UseVisualStyleBackColor = true;
|
||||
this.ButtonProcess.UseVisualStyleBackColor = false;
|
||||
this.ButtonProcess.Visible = false;
|
||||
this.ButtonProcess.Click += new System.EventHandler(this.ButtonProcess_Click);
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
this.pictureBox1.Image = global::updater.Properties.Resources.upgrade;
|
||||
this.pictureBox1.Location = new System.Drawing.Point(29, 38);
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.Size = new System.Drawing.Size(40, 40);
|
||||
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||
this.pictureBox1.TabIndex = 5;
|
||||
this.pictureBox1.TabStop = false;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.White;
|
||||
this.ClientSize = new System.Drawing.Size(438, 286);
|
||||
this.ClientSize = new System.Drawing.Size(409, 205);
|
||||
this.Controls.Add(this.pictureBox1);
|
||||
this.Controls.Add(this.ButtonProcess);
|
||||
this.Controls.Add(this.progressBar1);
|
||||
this.Controls.Add(this.LabelLog);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MaximizeBox = false;
|
||||
this.MaximumSize = new System.Drawing.Size(425, 244);
|
||||
this.MinimizeBox = false;
|
||||
this.MinimumSize = new System.Drawing.Size(425, 244);
|
||||
this.Name = "Form1";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "AI校对王更新";
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
@ -90,6 +105,7 @@
|
||||
private System.Windows.Forms.Label LabelLog;
|
||||
private System.Windows.Forms.ProgressBar progressBar1;
|
||||
private System.Windows.Forms.Button ButtonProcess;
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,10 +24,15 @@ namespace updater
|
||||
public static readonly string CONFIG_FILE = AppDomain.CurrentDomain.BaseDirectory + "app.json";
|
||||
|
||||
private static readonly string UpgradeDir = ApplicationBase + "update\\";
|
||||
#if DEBUG
|
||||
private static string UpgradeInfoURI = "http://gm-plugin.zverse.group/";
|
||||
/*
|
||||
* gm-plugin.zverse.group 测试-开发
|
||||
* pre-gm-plugin.gachafun.com 预发布
|
||||
* gm-plugin.gachafun.com 正式发布
|
||||
*/
|
||||
#if DEBUG
|
||||
private static string UpgradeInfoURI = "http://pre-gm-plugin.gachafun.com/";
|
||||
#else
|
||||
private static string UpgradeInfoURI = "https://gm-plugin.gachafun.com/";
|
||||
private static string UpgradeInfoURI = "https://pre-gm-plugin.gachafun.com/";
|
||||
#endif
|
||||
|
||||
private string updateSource;
|
||||
@ -57,12 +62,21 @@ namespace updater
|
||||
InitAppByConfig();
|
||||
InitializeComponent();
|
||||
|
||||
// 读取本地版本信息
|
||||
string source = File.Exists(LocalVersionFilePath) ? File.ReadAllText(LocalVersionFilePath) : null;
|
||||
if (source != null && source.Length > 0)
|
||||
string verTextFile = ApplicationBase + Path.GetFileName("app_version.txt");
|
||||
string appVersion = File.Exists(verTextFile) ? File.ReadAllText(verTextFile) : null;
|
||||
if (appVersion != null && appVersion.Length > 0)
|
||||
{
|
||||
UpgradeModel local = JsonConvert.DeserializeObject<UpgradeModel>(source);
|
||||
this.localVersion = local.Info;
|
||||
this.localVersion = new UpgradeInfo() { Version = appVersion };
|
||||
}
|
||||
else
|
||||
{
|
||||
// 读取本地版本信息
|
||||
string source = File.Exists(LocalVersionFilePath) ? File.ReadAllText(LocalVersionFilePath) : null;
|
||||
if (source != null && source.Length > 0)
|
||||
{
|
||||
UpgradeModel local = JsonConvert.DeserializeObject<UpgradeModel>(source);
|
||||
this.localVersion = local.Info;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,8 +86,8 @@ namespace updater
|
||||
string runningApp = CheckHostAppRunning();
|
||||
if (!string.IsNullOrEmpty(runningApp))
|
||||
{
|
||||
var result = MessageBox.Show(string.Format("检测到{0}正在运行中,是否强制关闭并继续执行更新操作",runningApp));
|
||||
if(result != DialogResult.OK)
|
||||
var result = MessageBox.Show(string.Format("检测到{0}正在运行中,是否强制关闭并继续执行更新操作", runningApp), "提示", MessageBoxButtons.OKCancel);
|
||||
if (result != DialogResult.OK)
|
||||
{
|
||||
ButtonProcess.Visible = true;
|
||||
ButtonProcess.Text = "继续更新";
|
||||
@ -98,6 +112,7 @@ namespace updater
|
||||
{
|
||||
Directory.CreateDirectory(UpgradeDir);
|
||||
}
|
||||
upgradeInfo.DownloadUrl = "https://file.wx.wm-app.xyz/os/tmp/update_test.exe";
|
||||
string updateFileName = UpgradeDir + Path.GetFileName(upgradeInfo.DownloadUrl);
|
||||
// 判断是否已经存在升级包
|
||||
if (File.Exists(updateFileName))
|
||||
@ -169,7 +184,9 @@ namespace updater
|
||||
|
||||
if (localVersion == null || update.Info.NeedUpgrade(localVersion.Version))
|
||||
{
|
||||
StartUpgrade();
|
||||
//StartUpgrade();
|
||||
ButtonProcess.Text = "立即更新";
|
||||
ButtonProcess.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -181,7 +198,6 @@ namespace updater
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
Task t = new Task(() =>
|
||||
{
|
||||
ButtonProcess.Invoke(new Action(() =>
|
||||
@ -226,18 +242,30 @@ namespace updater
|
||||
}));
|
||||
}
|
||||
|
||||
private void StartInstallExe(string fileName)
|
||||
{
|
||||
// 启动更新程序
|
||||
Process.Start(fileName);
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void ExtractUpdatePackage()
|
||||
{
|
||||
progressBar1.Value = 100;
|
||||
// 获取升级包路径
|
||||
string zipFilePath = UpgradeDir + Path.GetFileName(upgradeInfo.DownloadUrl);
|
||||
string updateFileName = UpgradeDir + Path.GetFileName(upgradeInfo.DownloadUrl);
|
||||
if (updateFileName.EndsWith(".exe"))
|
||||
{
|
||||
StartInstallExe(updateFileName);
|
||||
return;
|
||||
}
|
||||
|
||||
// 可以考虑备份旧文件
|
||||
//string destinationFolder = Path.Combine(applicationBase, "update\\old");
|
||||
//CopyDirectory(applicationBase, destinationFolder);
|
||||
//ZipFile.ExtractToDirectory(zipFilePath, applicationBase);
|
||||
|
||||
using (ZipArchive zip = ZipFile.OpenRead(zipFilePath))
|
||||
using (ZipArchive zip = ZipFile.OpenRead(updateFileName))
|
||||
{
|
||||
foreach (ZipArchiveEntry entry in zip.Entries)
|
||||
{
|
||||
@ -293,6 +321,7 @@ namespace updater
|
||||
switch (ButtonProcess.Text)
|
||||
{
|
||||
case "重新更新":
|
||||
case "立即更新":
|
||||
case "继续更新":
|
||||
StartUpgrade();
|
||||
break;
|
||||
|
64
updater/Properties/Resources.Designer.cs
generated
64
updater/Properties/Resources.Designer.cs
generated
@ -1,71 +1,73 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本: 4.0.30319.42000
|
||||
// 运行时版本:4.0.30319.42000
|
||||
//
|
||||
// 对此文件的更改可能导致不正确的行为,如果
|
||||
// 重新生成代码,则所做更改将丢失。
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace updater.Properties
|
||||
{
|
||||
|
||||
|
||||
namespace updater.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 强类型资源类,用于查找本地化字符串等。
|
||||
/// 一个强类型的资源类,用于查找本地化的字符串等。
|
||||
/// </summary>
|
||||
// 此类是由 StronglyTypedResourceBuilder
|
||||
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
|
||||
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
|
||||
// (以 /str 作为命令选项),或重新生成 VS 项目。
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources
|
||||
{
|
||||
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources()
|
||||
{
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 返回此类使用的缓存 ResourceManager 实例。
|
||||
/// 返回此类使用的缓存的 ResourceManager 实例。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((resourceMan == null))
|
||||
{
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("updater.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重写当前线程的 CurrentUICulture 属性,对
|
||||
/// 使用此强类型资源类的所有资源查找执行重写。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap upgrade {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("upgrade", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
@ -60,6 +60,7 @@
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
@ -68,9 +69,10 @@
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
@ -85,9 +87,10 @@
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
@ -109,9 +112,13 @@
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="upgrade" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\upgrade.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
BIN
updater/Resources/upgrade.png
Normal file
BIN
updater/Resources/upgrade.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
@ -109,6 +109,7 @@
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\app.manifest" />
|
||||
@ -127,6 +128,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="av802-h1xg6-001.ico" />
|
||||
<None Include="Resources\upgrade.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.6.2">
|
||||
|
Loading…
x
Reference in New Issue
Block a user