diff --git a/.vs/AIProofread/v17/.suo b/.vs/AIProofread/v17/.suo
index 4d3c30c..e4d56aa 100644
Binary files a/.vs/AIProofread/v17/.suo and b/.vs/AIProofread/v17/.suo differ
diff --git a/AIProofread/AIProofread.csproj b/AIProofread/AIProofread.csproj
index 2b55a17..dc01c19 100644
--- a/AIProofread/AIProofread.csproj
+++ b/AIProofread/AIProofread.csproj
@@ -336,6 +336,7 @@
Code
+
FormContact.cs
diff --git a/AIProofread/AIProofread.csproj.user b/AIProofread/AIProofread.csproj.user
index 5edd783..7760902 100644
--- a/AIProofread/AIProofread.csproj.user
+++ b/AIProofread/AIProofread.csproj.user
@@ -7,7 +7,7 @@
- Project
+ Program
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 f195d39..b337f5e 100644
--- a/AIProofread/Bridge.cs
+++ b/AIProofread/Bridge.cs
@@ -13,7 +13,6 @@ using System.Drawing;
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;
@@ -45,11 +44,68 @@ namespace AIProofread
private static object missing = System.Reflection.Missing.Value;
+ private static UpgradeData CurrentUpgrade = null;
+
+ public void ShowUpgradeView()
+ {
+ var needUpgrade = CurrentUpgrade.NeedUpgrade(Config.APP_VERSION);
+ if (CurrentUpgrade.Ext == 1)
+ {
+ if (!needUpgrade)
+ {
+ showDialog("当前版本为最新版本,无需升级");
+ }
+ else
+ {
+ 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();
+ }
+ }
+
+ public bool ShouldUpgradeForced()
+ {
+ return CurrentUpgrade != null && CurrentUpgrade.NeedUpgrade(Config.APP_VERSION) && CurrentUpgrade.UpgradeType == 1;
+ }
+
+ public void InitPluginUpgrade()
+ {
+ try
+ {
+ string source = HttpUtil.GetHttpSource(Config.WEB_PATH + "api/v1/common/download/version");
+ if (source == null) return;
+
+ UpgradeSource data = JsonConvert.DeserializeObject(source);
+ if (data == null || data.Code != 0) return;
+ CurrentUpgrade = data.Data;
+
+ // 是否需要强制升级
+ //if (ShouldUpgradeForced())
+ //{
+ // // 显示升级框
+ // ShowUpgradeView();
+ //}
+ }
+ catch (Exception ex)
+ {
+ Logger.Log(ex);
+ }
+ }
+
public string GetAppVersion()
{
return Config.APP_VERSION;
}
+
+
public void showDialog(string message)
{
System.Windows.Forms.MessageBox.Show(message);
@@ -133,6 +189,25 @@ namespace AIProofread
}
}
+ public static void StartUpgradeProcess()
+ {
+ try
+ {
+ string applicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
+ string path = "updater.exe";
+ ProcessStartInfo processStartInfo = new ProcessStartInfo(Path.Combine(applicationBase, Path.GetFileName(path)))
+ {
+ WorkingDirectory = applicationBase,
+ };
+ Process.Start(processStartInfo);
+ }
+ catch (Exception e)
+ {
+ Logger.Log(e);
+ MessageBox.Show("启动升级程序失败,请重试");
+ }
+ }
+
public void StartProofread()
{
Globals.ThisAddIn.SendMessageToWeb("start", "login");
@@ -183,15 +258,36 @@ namespace AIProofread
}
public string getDocumentData()
{
+
Dictionary data = new Dictionary();
var doc = Globals.ThisAddIn.Application.ActiveDocument;
- data.Add("name", doc.Name);
- data.Add("fullName", doc.FullName);
- //data.Add("documentId", GeIdBytDocument(doc));
- data.Add("wordsCount", doc.Words.Count);
- data.Add("charactersCount", doc.Characters.Count);
- data.Add("content", Tools.GetAllText(doc));
+ if (!doc.Saved)
+ {
+ data.Add("code", 1);
+ data.Add("message", "请保存文档后再进行校对");
+ }
+ else if (ShouldUpgradeForced())
+ {
+ data.Add("code", 2);
+ data.Add("message", "请升级插件后再进行校对");
+ }
+ else if (doc.ProtectionType != WdProtectionType.wdNoProtection)
+ {
+ data.Add("code", 3);
+ data.Add("message", "文档受保护,无法编辑");
+ }
+ else
+ {
+ data.Add("code", 0);
+ data.Add("message", "success");
+ data.Add("name", doc.Name);
+ data.Add("fullName", doc.FullName);
+ //data.Add("documentId", GeIdBytDocument(doc));
+ data.Add("wordsCount", doc.Words.Count);
+ data.Add("charactersCount", doc.Characters.Count);
+ data.Add("content", Tools.GetAllText(doc));
+ }
return Tools.GetJSONString(data);
}
@@ -271,12 +367,27 @@ namespace AIProofread
public void ShowUpgrade(string data)
{
- var upgradeData = JsonConvert.DeserializeObject(data);
- var ret = System.Windows.Forms.MessageBox.Show(upgradeData.Message, "更新提示", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);
- if (ret == System.Windows.Forms.DialogResult.Yes)
- {
- OpenUrlWithOsBrowser(upgradeData.DownloadUrl);
- }
+ //var upgradeData = JsonConvert.DeserializeObject(data);
+ //var needUpgrade = upgradeData.NeedUpgrade(Config.APP_VERSION);
+ //if (upgradeData.Ext == 1)
+ //{
+ // if (!needUpgrade)
+ // {
+ // showDialog("当前版本为最新版本,无需升级");
+ // }
+ // else
+ // {
+ // var ret = MessageBox.Show(upgradeData.Message, "是否确认更新", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);
+ // if (ret == DialogResult.Yes)
+ // {
+ // OpenUrlWithOsBrowser(upgradeData.DownloadUrl);
+ // }
+ // }
+ //}
+ //else
+ //{
+ // StartUpgradeProcess();
+ //}
}
public void noticeOtherWeb(string json, string targetWebName)
@@ -335,6 +446,10 @@ namespace AIProofread
}
+ public void clearAllProofreadMarkById(int documentId)
+ {
+ clearAllProofreadMark(GetDocumentById(documentId));
+ }
// 清除所有标记
public void clearAllProofreadMark(Document document)
{
@@ -496,7 +611,7 @@ namespace AIProofread
rng.Select();
}
- public void SelectMarkById(int proofreadId,int documentId)
+ public void SelectMarkById(int proofreadId, int documentId)
{
var doc = documentId < 1 ? Globals.ThisAddIn.Application.ActiveDocument : GetDocumentById(documentId);
//
@@ -566,13 +681,13 @@ namespace AIProofread
}
}
- public string InitContent(string content,int documentId)
+ public string InitContent(string content, int documentId)
{
try
{
// 根据文档编号 获取当前文档避免数据混乱
CurrentDocument = GetDocumentById(documentId);
- if(CurrentDocument == null)
+ if (CurrentDocument == null)
{
throw new Exception("没有找到校对文档对象");
}
@@ -594,23 +709,19 @@ namespace AIProofread
int index = 0;
foreach (var item in correct.Diffs)
{
- if (item.id == 187095)
- {
- Console.WriteLine("xx");
- }
int _prev = prevOffset;
// 查找对应区域并再该区域添加书签
- var mark = FindRangeAndCreateBookmark(item, correct,ref prevOffset);
+ var mark = DocumentUtil.FindRangeAndCreateBookmark(item, correct, CurrentDocument, ref prevOffset);
// 防止调用方法中没有更新
if (_prev >= prevOffset)
{
- prevOffset = correct.SentenceOffset + item.end;
+ prevOffset = correct.SentenceOffset + item.start;
}
-
+
if (item.tag != "i") index++;
if (mark != null)
{
- marks.Add(item.id, new ProofreadItem(item, mark,documentId));
+ marks.Add(item.id, new ProofreadItem(item, mark, documentId));
}
else
{
@@ -637,8 +748,16 @@ namespace AIProofread
}
if (item.Value.content.color != null)
{
- // 给选区添加背景颜色
- item.Value.mark.Shading.BackgroundPatternColor = (WdColor)ColorTranslator.ToOle(Colors.FromHex(item.Value.content.color));
+ try
+ {
+ var color = (WdColor)ColorTranslator.ToOle(Colors.FromHex(item.Value.content.color));
+ // 给选区添加背景颜色
+ item.Value.mark.Shading.BackgroundPatternColor = color;
+ }
+ catch (Exception)
+ {
+ //item.Value.mark.Shading.BackgroundPatternColor = WdColor.wdColorLightOrange;
+ }
}
}
}
@@ -693,7 +812,7 @@ namespace AIProofread
/// 校对
///
///
- public Microsoft.Office.Tools.Word.Bookmark FindRangeAndCreateBookmark(CorrectedContent correct, DocumentCorrectItem sentense,ref int prevOffset)
+ public Microsoft.Office.Tools.Word.Bookmark FindRangeAndCreateBookmark1(CorrectedContent correct, DocumentCorrectItem sentense, ref int prevOffset)
{
Microsoft.Office.Tools.Word.Bookmark bookmark = null;
try
@@ -793,7 +912,7 @@ namespace AIProofread
if (correct.tag != "i" && findRange.Text != correct.origin)
{
// 查找
- findRange = DocumentUtil.FindRange(correct,sentense,ref prevOffset,CurrentDocument, paragraphRange);
+ findRange = DocumentUtil.FindRange(correct, sentense, ref prevOffset, CurrentDocument, paragraphRange);
}
// 能够找到对应的区域 则再对应区域添加书签
@@ -853,6 +972,7 @@ namespace AIProofread
return bookmark;
}
+
///
///
///
diff --git a/AIProofread/Logger.cs b/AIProofread/Logger.cs
index 7a6069f..ae9a6d1 100644
--- a/AIProofread/Logger.cs
+++ b/AIProofread/Logger.cs
@@ -32,7 +32,7 @@ namespace AIProofread
}
public static void Log( Exception e)
{
- Log(e.StackTrace);
+ Log(e.Message + "\n" + e.StackTrace);
}
public static void Log(string tag, Exception e)
{
diff --git a/AIProofread/ProofreadItem.cs b/AIProofread/ProofreadItem.cs
index b2a617c..f36b5c8 100644
--- a/AIProofread/ProofreadItem.cs
+++ b/AIProofread/ProofreadItem.cs
@@ -84,16 +84,30 @@ namespace UtilLib
}
public void UnSelect()
{
- if (mark == null) return;
- mark.Range.Font.Size = originSize; // 还原
- mark.Shading.ForegroundPatternColor = originColor;
+ try
+ {
+ if (mark == null) return;
+ mark.Range.Font.Size = originSize; // 还原
+ mark.Shading.ForegroundPatternColor = originColor;
+ }
+ catch (Exception e)
+ {
+ Logger.Log(e);
+ }
}
private void SetMarkStyle()
{
- if (mark == null) return;
+ try
+ {
+ if (mark == null) return;
//mark.Range.Underline = Microsoft.Office.Interop.Word.WdUnderline.wdUnderlineThick;
mark.Shading.BackgroundPatternColor = (WdColor)ColorTranslator.ToOle(Colors.FromHex(content.color));
+ }
+ catch (Exception e)
+ {
+ Logger.Log(e);
+ }
}
public void ResetMarkStyle()
@@ -108,7 +122,10 @@ namespace UtilLib
mark.Shading.ForegroundPatternColor = originColor;
mark.Range.Shading.BackgroundPatternColor = originColor;// Microsoft.Office.Interop.Word.WdColor.wdColorAutomatic;
}
- catch (Exception) { }
+ catch (Exception e)
+ {
+ Logger.Log(e);
+ }
}
public void Process(int status)
diff --git a/AIProofread/Ribbon1.cs b/AIProofread/Ribbon1.cs
index 61d546f..fa7b9ff 100644
--- a/AIProofread/Ribbon1.cs
+++ b/AIProofread/Ribbon1.cs
@@ -124,7 +124,8 @@ namespace AIProofread
private void BtnUpdate_Click(object sender, RibbonControlEventArgs e)
{
//System.Windows.Forms.MessageBox.Show("当前插件是最新版本");
- Globals.ThisAddIn.SendMessageToWeb("upgrade", Config.APP_VERSION);
+ //Globals.ThisAddIn.SendMessageToWeb("upgrade", Config.APP_VERSION);
+ Bridge.bridge.ShowUpgradeView();
}
private void BtnProofreadAll_Click(object sender, RibbonControlEventArgs e)
@@ -396,12 +397,6 @@ namespace AIProofread
{
return string.IsNullOrEmpty(range.Text) ? "" : range.Text;
}
-
- //private async Task ProcessCorrectCut()
- //{
-
-
- //}
private void BtnOpenLog_Click(object sender, RibbonControlEventArgs e)
{
// 打开日志目录
@@ -410,11 +405,7 @@ namespace AIProofread
private void button1_Click(object sender, RibbonControlEventArgs e)
{
- 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);
+ Bridge.StartUpgradeProcess();
}
}
}
diff --git a/AIProofread/ThisAddIn.cs b/AIProofread/ThisAddIn.cs
index f65f80c..da91451 100644
--- a/AIProofread/ThisAddIn.cs
+++ b/AIProofread/ThisAddIn.cs
@@ -303,6 +303,8 @@ namespace AIProofread
//Application.DocumentChange +=
// 选区发生变化事件
this.Application.WindowSelectionChange += Application_WindowSelectionChange;
+ // 检测升级信息
+ Bridge.bridge.InitPluginUpgrade();
try
{
diff --git a/AIProofread/Util/HttpUtil.cs b/AIProofread/Util/HttpUtil.cs
new file mode 100644
index 0000000..d37ded7
--- /dev/null
+++ b/AIProofread/Util/HttpUtil.cs
@@ -0,0 +1,36 @@
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+using updater;
+
+namespace AIProofread.Util
+{
+ public class HttpUtil
+ {
+
+ public static string GetHttpSource(string url)
+ {
+ HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
+ using (HttpWebResponse resp = (HttpWebResponse)httpWebRequest.GetResponse())
+ {
+ // 获取响应内容
+ if (resp.StatusCode == HttpStatusCode.OK)
+ {
+ using (Stream receiveStream = resp.GetResponseStream())
+ {
+ using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8))
+ {
+ return readStream.ReadToEnd();
+ }
+ }
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/AIProofread/core/DocumentUtil.cs b/AIProofread/core/DocumentUtil.cs
index d1a280e..5898766 100644
--- a/AIProofread/core/DocumentUtil.cs
+++ b/AIProofread/core/DocumentUtil.cs
@@ -1,15 +1,14 @@
//using Microsoft.Office.Interop.Word;
-using Section = Microsoft.Office.Interop.Word.Section;
-using WdColor = Microsoft.Office.Interop.Word.WdColor;
using System.Drawing;
using UtilLib;
-using Microsoft.Office.Interop.Word;
-using Bookmark = Microsoft.Office.Tools.Word.Bookmark;
using System.Collections.Generic;
-using Microsoft.Office.Tools.Word;
using System;
-using System.Xml.Linq;
using Newtonsoft.Json;
+using Microsoft.Office.Interop.Word;
+using Microsoft.Office.Tools.Word;
+using Bookmark = Microsoft.Office.Tools.Word.Bookmark;
+using Section = Microsoft.Office.Interop.Word.Section;
+using WdColor = Microsoft.Office.Interop.Word.WdColor;
namespace AIProofread
{
@@ -291,5 +290,124 @@ namespace AIProofread
return null;
}
+
+
+
+ public static Bookmark FindRangeAndCreateBookmark(CorrectedContent correct, DocumentCorrectItem sentense, Microsoft.Office.Interop.Word.Document document, ref int prevOffset)
+ {
+ Bookmark bookmark = null;
+ try
+ {
+ ControlCollection controls = Globals.Factory.GetVstoObject(document).Controls;
+ var markName = Config.BuildBookmarkName(correct.id);
+
+ // 判断是否已经存在
+ if (controls.Contains(markName))
+ {
+ try
+ {
+ controls.Remove(markName);
+ }
+ catch (Exception) { }
+ }
+ // 判断段落是否存在
+ if (sentense.ParagraphNumber > document.Paragraphs.Count) return null;
+
+ var paragraph = document.Paragraphs[sentense.ParagraphNumber];
+
+ var findRange = FindRangeByCorrect(sentense, correct, paragraph, document, prevOffset);
+ if (findRange != null)
+ {
+ // 更新查找的结束位置
+ //prevOffset = findRange.End - paragraphStart;
+ bookmark = controls.AddBookmark(findRange, markName);
+ bookmark.Tag = "ai_proofread";
+ }
+ }
+ catch (Exception ex)
+ {
+ Logger.Log("create mark error:" + ex.Message + "\n" + ex.StackTrace + "\n\n");
+ }
+ return bookmark;
+ }
+
+ private static Range FindRangeByCorrect(DocumentCorrectItem c, CorrectedContent item, Paragraph paragraph, Microsoft.Office.Interop.Word.Document document, int prevOffset)
+ {
+ var paraRange = paragraph.Range;
+ var paraText = paraRange.Text;
+ var paraStart = paraRange.Start;
+
+ // 定位句子的其实位置
+ var offset = paraStart + c.SentenceOffset;
+ //var cutLength = Math.Min(c.InsertLen, paraText.Length - offset);
+ var sentence = paraText.Substring(c.SentenceOffset, c.InsertLength);
+ if (sentence == c.Insert)
+ { // 比对原始内容与校对原文是否一致
+ var range = document.Range(offset + item.start, offset + item.end);
+ //
+ if (range.Text == item.origin) return range;
+ }
+
+ var originText = c.Insert;
+ // 如果是新增 则查找定位
+ if (item.tag == "i")
+ {
+ // 找前缀
+ var prefix1 = 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 suffix1 = prefix1 == 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 start1 = prefix1 != null || suffix1 != null
+ ? paraText.IndexOf(prefix1 ?? suffix1, prevOffset)
+ : -1;
+ if (start1 != -1)
+ {
+ var findOffset = paraStart + start1 + (prefix1 != null ? prefix1.Length : 0);
+ return document.Range(findOffset, findOffset);
+ }
+ }
+
+ // 执行查找
+ int wordStart = item.start;
+ int wordEnd = item.end;
+
+ // 找前缀
+ 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
+ ? paraText.IndexOf(prefix ?? suffix, prevOffset) // item.start +
+ : -1;
+ if (start != -1)
+ {
+ var findOffset = paraRange.Start + start + (prefix != null ? prefix.Length : 0);
+ var range = document.Range(findOffset, findOffset + wordEnd - wordStart);
+ if (range.Text == item.origin) { return range; }
+ }
+ // 直接定位查找
+ start = paraText.IndexOf(item.origin, prevOffset);
+ if (start == -1) return null;
+ // 定位整体开始位置
+ start = paraStart + start;
+ return document.Range(start, start + item.origin.Length);
+ }
+
}
}
diff --git a/AIProofread/obj/Debug/AIProofread.csproj.AssemblyReference.cache b/AIProofread/obj/Debug/AIProofread.csproj.AssemblyReference.cache
index d11fd72..9e931da 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 5c4b855..4141863 100644
--- a/AIProofread/obj/Debug/AIProofread.csproj.CoreCompileInputs.cache
+++ b/AIProofread/obj/Debug/AIProofread.csproj.CoreCompileInputs.cache
@@ -1 +1 @@
-fe1ae839bfb706b80f0b4718d7a4129a4057bf53be655076474daf866eae1d58
+4c1c6aa096bd384197619062b3689b9a218de9da2c1b7adc250936855349c9f3
diff --git a/AIProofread/obj/Debug/AIProofread.csproj.FileListAbsolute.txt b/AIProofread/obj/Debug/AIProofread.csproj.FileListAbsolute.txt
index 65d5258..f2c0d2a 100644
--- a/AIProofread/obj/Debug/AIProofread.csproj.FileListAbsolute.txt
+++ b/AIProofread/obj/Debug/AIProofread.csproj.FileListAbsolute.txt
@@ -29,34 +29,6 @@ C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\AIProofread.
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\AIProofread.pdb
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\AIProofread.dll.manifest
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\AIProofread.vsto
-C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Microsoft.Office.Tools.Common.v4.0.Utilities.dll
-C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Microsoft.Web.WebView2.Core.dll
-C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Microsoft.Web.WebView2.WinForms.dll
-C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Microsoft.Web.WebView2.Wpf.dll
-C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Newtonsoft.Json.dll
-C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\util-lib.dll
-C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\util-lib.pdb
-C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Microsoft.Web.WebView2.Core.xml
-C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Microsoft.Web.WebView2.WinForms.xml
-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
-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
-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\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
@@ -85,6 +57,7 @@ C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Dynam
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.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
@@ -158,6 +131,11 @@ C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\ExtendedNume
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\Microsoft.Office.Tools.Common.v4.0.Utilities.dll
+C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Microsoft.Web.WebView2.Core.dll
+C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Microsoft.Web.WebView2.WinForms.dll
+C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Microsoft.Web.WebView2.Wpf.dll
+C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Newtonsoft.Json.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
@@ -176,6 +154,11 @@ C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Secur
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\updater.exe
+C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\util-lib.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\util-lib.pdb
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
@@ -184,6 +167,9 @@ C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\ICSharpCode.
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\Microsoft.Web.WebView2.Core.xml
+C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Microsoft.Web.WebView2.WinForms.xml
+C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Microsoft.Web.WebView2.Wpf.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
@@ -206,3 +192,17 @@ C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\System.Secur
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
+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
+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
+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
diff --git a/AIProofread/obj/Debug/AIProofread.csproj.GenerateResource.cache b/AIProofread/obj/Debug/AIProofread.csproj.GenerateResource.cache
index 739a2f9..4263b0e 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 fad082e..b1d6128 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 987a942..620aff6 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 82225bc..ed38d85 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 741e8f9..86a0cb8 100644
Binary files a/AIProofread/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/AIProofread/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ
diff --git a/updater/AppConfig.cs b/updater/AppConfig.cs
new file mode 100644
index 0000000..9251ced
--- /dev/null
+++ b/updater/AppConfig.cs
@@ -0,0 +1,12 @@
+namespace updater
+{
+ public class AppConfig
+ {
+ public string AppUrl { get; set; }
+ public bool AppRunInDebug { get; set; }
+ ///
+ /// dev | test | product
+ ///
+ public string Environment { get; set; }
+ }
+}
diff --git a/updater/Form1.Designer.cs b/updater/Form1.Designer.cs
index 220bc48..5ef2e1d 100644
--- a/updater/Form1.Designer.cs
+++ b/updater/Form1.Designer.cs
@@ -33,6 +33,7 @@
this.ButtonUpdate = new System.Windows.Forms.Button();
this.LabelLocalVersion = new System.Windows.Forms.Label();
this.progressBar1 = new System.Windows.Forms.ProgressBar();
+ this.BtnCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// LabelLog
@@ -55,7 +56,7 @@
this.ButtonUpdate.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(100)))), ((int)(((byte)(215)))));
this.ButtonUpdate.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.ButtonUpdate.ForeColor = System.Drawing.Color.White;
- this.ButtonUpdate.Location = new System.Drawing.Point(183, 198);
+ this.ButtonUpdate.Location = new System.Drawing.Point(228, 198);
this.ButtonUpdate.Name = "ButtonUpdate";
this.ButtonUpdate.Size = new System.Drawing.Size(78, 31);
this.ButtonUpdate.TabIndex = 1;
@@ -79,12 +80,29 @@
this.progressBar1.TabIndex = 3;
this.progressBar1.Visible = false;
//
+ // BtnCancel
+ //
+ this.BtnCancel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(100)))), ((int)(((byte)(215)))));
+ this.BtnCancel.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(100)))), ((int)(((byte)(215)))));
+ this.BtnCancel.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Blue;
+ this.BtnCancel.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(100)))), ((int)(((byte)(215)))));
+ this.BtnCancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
+ this.BtnCancel.ForeColor = System.Drawing.Color.White;
+ this.BtnCancel.Location = new System.Drawing.Point(144, 198);
+ this.BtnCancel.Name = "BtnCancel";
+ this.BtnCancel.Size = new System.Drawing.Size(78, 31);
+ this.BtnCancel.TabIndex = 4;
+ this.BtnCancel.Text = "取消更新";
+ this.BtnCancel.UseVisualStyleBackColor = false;
+ this.BtnCancel.Click += new System.EventHandler(this.BtnCancel_Click);
+ //
// 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.Controls.Add(this.BtnCancel);
this.Controls.Add(this.progressBar1);
this.Controls.Add(this.LabelLocalVersion);
this.Controls.Add(this.ButtonUpdate);
@@ -106,6 +124,7 @@
private System.Windows.Forms.Button ButtonUpdate;
private System.Windows.Forms.Label LabelLocalVersion;
private System.Windows.Forms.ProgressBar progressBar1;
+ private System.Windows.Forms.Button BtnCancel;
}
}
diff --git a/updater/Form1.cs b/updater/Form1.cs
index 93286d9..82d8125 100644
--- a/updater/Form1.cs
+++ b/updater/Form1.cs
@@ -15,23 +15,53 @@ namespace updater
{
public partial class Form1 : Form
{
- private int localVersionCode = 0;
- private UpdateModel model;
- private static string applicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
- private string versionFilePath = applicationBase + Path.GetFileName("version.json");
- private string updateDir = applicationBase + "update\\";
- private string updateInfoUri = "https://file.wx.wm-app.xyz/jdw/latest.json";
+ private UpgradeInfo localVersion;
+ private UpgradeInfo upgradeInfo;
+ private static readonly string ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
+ private static readonly string LocalVersionFilePath = ApplicationBase + Path.GetFileName("version.json");
+ 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/";
+#else
+ private static string UpgradeInfoURI = "https://gm-plugin.gachafun.com/";
+#endif
+
private string updateSource;
+ private void InitAppByConfig()
+ {
+ try
+ {
+ if (File.Exists(CONFIG_FILE))
+ {
+ string content = File.ReadAllText(CONFIG_FILE);
+ if (content == null || content.Length == 0) return;
+ AppConfig config = JsonConvert.DeserializeObject(content);
+
+ // 插件网址
+ if (!string.IsNullOrEmpty(config.AppUrl))
+ {
+ UpgradeInfoURI = config.AppUrl;
+ }
+ }
+ }
+ catch (Exception) { }
+ }
+
public Form1()
{
+ InitAppByConfig();
InitializeComponent();
- string source = File.Exists(versionFilePath) ? File.ReadAllText(versionFilePath) : null;
+
+ // 读取本地版本信息
+ string source = File.Exists(LocalVersionFilePath) ? File.ReadAllText(LocalVersionFilePath) : null;
if (source != null && source.Length > 0)
{
- UpdateModel update = JsonConvert.DeserializeObject(source);
- this.localVersionCode = update.VersionCode;
- LabelLocalVersion.Text = update.Version;
+ UpgradeModel local = JsonConvert.DeserializeObject(source);
+ this.localVersion = local.Info;
+ LabelLocalVersion.Text = localVersion.Version;
}
}
@@ -43,18 +73,18 @@ namespace updater
return;
}
progressBar1.Visible = true;
- if (!Directory.Exists(updateDir))
+ if (!Directory.Exists(UpgradeDir))
{
- Directory.CreateDirectory(updateDir);
+ Directory.CreateDirectory(UpgradeDir);
}
- string updateFileName = updateDir + Path.GetFileName(model.UpdateFile);
+ string updateFileName = UpgradeDir + Path.GetFileName(upgradeInfo.DownloadUrl);
// 判断是否已经存在升级包
if (File.Exists(updateFileName))
{
ExtractUpdatePackage();
return;
}
- DownLoadFile(model.UpdateFile, updateFileName);
+ DownLoadFile(upgradeInfo.DownloadUrl, updateFileName);
}
public bool CheckHostAppRunning()
@@ -70,6 +100,7 @@ namespace updater
else if (item2.ProcessName.Equals("WINWORD"))
{
MessageBox.Show("检测到 Word 正在运行中,请关闭后再执行更新操作");
+ return true;
}
}
return false;
@@ -82,36 +113,45 @@ namespace updater
public void CheckUpdate()
{
- HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(updateInfoUri);
- HttpWebResponse resp = (HttpWebResponse)httpWebRequest.GetResponse();
- // 获取响应内容
- if (resp.StatusCode == HttpStatusCode.OK)
+ try
{
- Stream receiveStream = resp.GetResponseStream();
- StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
- updateSource = readStream.ReadToEnd();
- if (updateSource == null && updateSource.Length == 0)
+ HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(UpgradeInfoURI + "api/v1/common/download/version");
+ HttpWebResponse resp = (HttpWebResponse)httpWebRequest.GetResponse();
+ // 获取响应内容
+ if (resp.StatusCode == HttpStatusCode.OK)
{
- LabelLog.Text = "获取更新信息失败";
- return;
+ Stream receiveStream = resp.GetResponseStream();
+ StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
+ updateSource = readStream.ReadToEnd();
+ if (updateSource == null && updateSource.Length == 0)
+ {
+ LabelLog.Text = "获取更新信息失败,请稍后重试";
+ return;
+ }
+ resp.Close();
+ UpgradeModel update = JsonConvert.DeserializeObject(updateSource);
+ ProcessUpdate(update);
}
- resp.Close();
- UpdateModel update = JsonConvert.DeserializeObject(updateSource);
- ProcessUpdate(update);
+ }
+ catch (Exception)
+ {
+ LabelLog.Text = "获取更新信息失败,请稍后重试";
}
}
- private void ProcessUpdate(UpdateModel update)
+ private void ProcessUpdate(UpgradeModel update)
{
- LabelLog.Text = update.Log;
- this.model = update;
- if (update.VersionCode > this.localVersionCode)
+ this.upgradeInfo = update.Info;
+ LabelLog.Text = update.Info.Message;
+
+ if (localVersion == null || update.Info.NeedUpgrade(localVersion.Version))
{
ButtonUpdate.Enabled = true;
}
else
{
ButtonUpdate.Visible = false;
+ BtnCancel.Visible = false;
LabelLocalVersion.Text = "当前是最新版本";
}
}
@@ -158,22 +198,32 @@ namespace updater
private void ExtractUpdatePackage()
{
progressBar1.Value = 100;
- string zipFilePath = updateDir + Path.GetFileName(model.UpdateFile);
+ // 获取升级包路径
+ string zipFilePath = UpgradeDir + Path.GetFileName(upgradeInfo.DownloadUrl);
+
// 可以考虑备份旧文件
//string destinationFolder = Path.Combine(applicationBase, "update\\old");
//CopyDirectory(applicationBase, destinationFolder);
//ZipFile.ExtractToDirectory(zipFilePath, applicationBase);
+
using (ZipArchive zip = ZipFile.OpenRead(zipFilePath))
{
foreach (ZipArchiveEntry entry in zip.Entries)
{
// 采用覆盖模式进行解压
- entry.ExtractToFile(Path.Combine(applicationBase, entry.FullName), true);
+ try
+ {
+ entry.ExtractToFile(Path.Combine(ApplicationBase, entry.FullName), true);
+ }
+ catch (Exception)
+ {
+
+ }
}
}
MessageBox.Show("更新完成");
- // 保存日志
- File.WriteAllText(versionFilePath, updateSource);
+ // 保存最新版本日志
+ File.WriteAllText(LocalVersionFilePath, updateSource);
this.Close();
}
public static void CopyDirectory(string sourceFolder, string destinationFolder)
@@ -200,5 +250,11 @@ namespace updater
}
}
}
+
+ private void BtnCancel_Click(object sender, EventArgs e)
+ {
+ this.Close();
+ Application.Exit();
+ }
}
}
diff --git a/updater/Properties/app.manifest b/updater/Properties/app.manifest
index 5a95963..303298c 100644
--- a/updater/Properties/app.manifest
+++ b/updater/Properties/app.manifest
@@ -9,14 +9,13 @@
以下节点之一替换 requestedExecutionLevel 节点。
-
指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化。
如果你的应用程序需要此虚拟化来实现向后兼容性,则移除此
元素。
-->
-
+
diff --git a/updater/UpdateModel.cs b/updater/UpdateModel.cs
deleted file mode 100644
index 163393d..0000000
--- a/updater/UpdateModel.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace updater
-{
- public class UpdateModel
- {
- public int VersionCode { get; set; }
- public string Version { get; set; }
- public string Log { get; set; }
- public string UpdateFile { get; set; }
- }
-}
diff --git a/updater/UpgradeModel.cs b/updater/UpgradeModel.cs
new file mode 100644
index 0000000..9f5b021
--- /dev/null
+++ b/updater/UpgradeModel.cs
@@ -0,0 +1,49 @@
+using Newtonsoft.Json;
+using System;
+using System.Security.Permissions;
+
+namespace updater
+{
+ public class UpgradeInfo
+ {
+ public int Id { get; set; }
+ public int PublishType { get; set; }
+ public string Version { get; set; }
+ [JsonProperty("download_url")]
+ public string DownloadUrl { get; set; }
+ public string Message { get; set; }
+
+ ///
+ /// 1强制升级
+ /// 2强制提示
+ /// 3弱提示
+ ///
+ [JsonProperty("upgrade_type")]
+ public int UpgradeType { get; set; }
+
+ ///
+ /// 是否显示弹框 1:显示2:不显示
+ ///
+ [JsonProperty("is_show_pop")]
+ public int ShowPop { get; set; }
+
+ //public int VersionCode { get; set; }
+ //public string Log { get; set; }
+ //public string UpdateFile { get; set; }
+
+ public bool NeedUpgrade(string currentVersion)
+ {
+ var remoteVer = new Version(Version);
+ var currentVer = new Version(currentVersion);
+ return remoteVer > currentVer;
+ }
+ }
+ public class UpgradeModel
+ {
+ [JsonProperty("msg")]
+ public string Message { get; set; }
+ public int Code { get; set; }
+ [JsonProperty("data")]
+ public UpgradeInfo Info { get; set; }
+ }
+}
diff --git a/updater/updater.csproj b/updater/updater.csproj
index 3cd409a..c38dda3 100644
--- a/updater/updater.csproj
+++ b/updater/updater.csproj
@@ -22,6 +22,7 @@
DEBUG;TRACE
prompt
4
+ true
AnyCPU
@@ -71,6 +72,7 @@
+
Form
@@ -83,7 +85,7 @@
-
+
Form1.cs
diff --git a/util-lib/UpgradeData.cs b/util-lib/UpgradeData.cs
index 92c8ffd..28254f8 100644
--- a/util-lib/UpgradeData.cs
+++ b/util-lib/UpgradeData.cs
@@ -1,21 +1,34 @@
-using System;
+using Newtonsoft.Json;
+using System;
+using System.Security.Principal;
namespace UtilLib
{
+ public class UpgradeSource
+ {
+ public int Code { get; set; }
+ [JsonProperty("msg")]
+ public string Message { get; set; }
+ public UpgradeData Data { get; set; }
+ }
+
public class UpgradeData
{
public int Id { get; set; }
///
/// APP名称
///
+ [JsonProperty("app_name")]
public string AppName { get; set; }
///
/// 客户端类型 1ios 2安卓 3window插件 4 5
///
+ [JsonProperty("client_type")]
public int ClientType { get; set; }
///
/// 发布类型
///
+ [JsonProperty("publish_type")]
public int PublishType { get; set; }
///
/// 发布的版本号
@@ -24,19 +37,26 @@ namespace UtilLib
///
/// 升级类型(1强制升级 2强制提示 3弱提示)
///
+ [JsonProperty("upgrade_type")]
public int UpgradeType { get; set; }
+ [JsonProperty("download_url")]
public string DownloadUrl { get; set; }
///
/// 发布时间
///
+ [JsonProperty("publish_time")]
public int PublishTime { get; set; }
///
/// 发布的信息
///
public string Message { get; set; }
+ [JsonProperty("compatible_version_id")]
public int CompatibleVersionId { get; set; }
+ [JsonProperty("is_show_pop")]
public int IsShowPop { get; set; }
+ public int Ext { get; set; }
+
public bool NeedUpgrade(string currentVersion)
{
var remoteVer = new Version(Version);