fixed ssl获取数据异常
This commit is contained in:
parent
99e0792772
commit
f744ba9926
@ -15,6 +15,10 @@ namespace AIProofread.Util
|
||||
|
||||
public static string GetHttpSource(string url)
|
||||
{
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3
|
||||
| SecurityProtocolType.Tls
|
||||
| SecurityProtocolType.Tls11
|
||||
| SecurityProtocolType.Tls12;
|
||||
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
|
||||
using (HttpWebResponse resp = (HttpWebResponse)httpWebRequest.GetResponse())
|
||||
{
|
||||
|
65
updater/Form1.Designer.cs
generated
65
updater/Form1.Designer.cs
generated
@ -30,71 +30,40 @@
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
|
||||
this.LabelLog = new System.Windows.Forms.Label();
|
||||
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.ButtonProcess = new System.Windows.Forms.Button();
|
||||
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, 52);
|
||||
this.LabelLog.Location = new System.Drawing.Point(52, 30);
|
||||
this.LabelLog.Name = "LabelLog";
|
||||
this.LabelLog.Size = new System.Drawing.Size(340, 100);
|
||||
this.LabelLog.Size = new System.Drawing.Size(340, 169);
|
||||
this.LabelLog.TabIndex = 0;
|
||||
this.LabelLog.Text = "正在检测";
|
||||
this.LabelLog.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.LabelLog.Click += new System.EventHandler(this.LabelLog_Click);
|
||||
//
|
||||
// ButtonUpdate
|
||||
//
|
||||
this.ButtonUpdate.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(100)))), ((int)(((byte)(215)))));
|
||||
this.ButtonUpdate.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(100)))), ((int)(((byte)(215)))));
|
||||
this.ButtonUpdate.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Blue;
|
||||
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(228, 198);
|
||||
this.ButtonUpdate.Name = "ButtonUpdate";
|
||||
this.ButtonUpdate.Size = new System.Drawing.Size(78, 31);
|
||||
this.ButtonUpdate.TabIndex = 1;
|
||||
this.ButtonUpdate.Text = "立即更新";
|
||||
this.ButtonUpdate.UseVisualStyleBackColor = false;
|
||||
this.ButtonUpdate.Click += new System.EventHandler(this.ButtonUpdate_Click);
|
||||
//
|
||||
// LabelLocalVersion
|
||||
//
|
||||
this.LabelLocalVersion.Location = new System.Drawing.Point(172, 232);
|
||||
this.LabelLocalVersion.Name = "LabelLocalVersion";
|
||||
this.LabelLocalVersion.Size = new System.Drawing.Size(100, 23);
|
||||
this.LabelLocalVersion.TabIndex = 2;
|
||||
this.LabelLocalVersion.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// progressBar1
|
||||
//
|
||||
this.progressBar1.Location = new System.Drawing.Point(52, 159);
|
||||
this.progressBar1.Location = new System.Drawing.Point(52, 210);
|
||||
this.progressBar1.Name = "progressBar1";
|
||||
this.progressBar1.Size = new System.Drawing.Size(340, 10);
|
||||
this.progressBar1.TabIndex = 3;
|
||||
this.progressBar1.Visible = false;
|
||||
//
|
||||
// BtnCancel
|
||||
// ButtonProcess
|
||||
//
|
||||
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);
|
||||
this.ButtonProcess.Location = new System.Drawing.Point(186, 228);
|
||||
this.ButtonProcess.Name = "ButtonProcess";
|
||||
this.ButtonProcess.Size = new System.Drawing.Size(72, 33);
|
||||
this.ButtonProcess.TabIndex = 4;
|
||||
this.ButtonProcess.Text = "继续";
|
||||
this.ButtonProcess.UseVisualStyleBackColor = true;
|
||||
this.ButtonProcess.Visible = false;
|
||||
this.ButtonProcess.Click += new System.EventHandler(this.ButtonProcess_Click);
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
@ -102,10 +71,8 @@
|
||||
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.ButtonProcess);
|
||||
this.Controls.Add(this.progressBar1);
|
||||
this.Controls.Add(this.LabelLocalVersion);
|
||||
this.Controls.Add(this.ButtonUpdate);
|
||||
this.Controls.Add(this.LabelLog);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MaximizeBox = false;
|
||||
@ -121,10 +88,8 @@
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label LabelLog;
|
||||
private System.Windows.Forms.Button ButtonUpdate;
|
||||
private System.Windows.Forms.Label LabelLocalVersion;
|
||||
private System.Windows.Forms.ProgressBar progressBar1;
|
||||
private System.Windows.Forms.Button BtnCancel;
|
||||
private System.Windows.Forms.Button ButtonProcess;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,8 @@ using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.UI.Design.WebControls;
|
||||
using System.Windows.Forms;
|
||||
|
||||
@ -61,17 +63,21 @@ namespace updater
|
||||
{
|
||||
UpgradeModel local = JsonConvert.DeserializeObject<UpgradeModel>(source);
|
||||
this.localVersion = local.Info;
|
||||
LabelLocalVersion.Text = localVersion.Version;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void ButtonUpdate_Click(object sender, System.EventArgs e)
|
||||
private void StartUpgrade()
|
||||
{
|
||||
if (CheckHostAppRunning())
|
||||
string runningApp = CheckHostAppRunning();
|
||||
if (!string.IsNullOrEmpty(runningApp))
|
||||
{
|
||||
MessageBox.Show(string.Format("检测到{0}正在运行中,请关闭{0}后继续执行更新操作",runningApp));
|
||||
ButtonProcess.Visible = true;
|
||||
ButtonProcess.Text = "继续更新";
|
||||
return;
|
||||
}
|
||||
ButtonProcess.Visible = false;
|
||||
progressBar1.Visible = true;
|
||||
if (!Directory.Exists(UpgradeDir))
|
||||
{
|
||||
@ -87,23 +93,21 @@ namespace updater
|
||||
DownLoadFile(upgradeInfo.DownloadUrl, updateFileName);
|
||||
}
|
||||
|
||||
public bool CheckHostAppRunning()
|
||||
public string CheckHostAppRunning()
|
||||
{
|
||||
Process[] array = Process.GetProcesses();
|
||||
foreach (Process item2 in array)
|
||||
{
|
||||
if (item2.ProcessName.Equals("wps"))
|
||||
{
|
||||
MessageBox.Show("检测到 WPS 正在运行中,请关闭后再执行更新操作");
|
||||
return true;
|
||||
return "WPS";
|
||||
}
|
||||
else if (item2.ProcessName.Equals("WINWORD"))
|
||||
{
|
||||
MessageBox.Show("检测到 Word 正在运行中,请关闭后再执行更新操作");
|
||||
return true;
|
||||
return "Word";
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
private void LabelLog_Click(object sender, System.EventArgs e)
|
||||
@ -115,6 +119,7 @@ namespace updater
|
||||
{
|
||||
try
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(UpgradeInfoURI + "api/v1/common/download/version");
|
||||
HttpWebResponse resp = (HttpWebResponse)httpWebRequest.GetResponse();
|
||||
// 获取响应内容
|
||||
@ -146,21 +151,27 @@ namespace updater
|
||||
|
||||
if (localVersion == null || update.Info.NeedUpgrade(localVersion.Version))
|
||||
{
|
||||
ButtonUpdate.Enabled = true;
|
||||
StartUpgrade();
|
||||
}
|
||||
else
|
||||
{
|
||||
ButtonUpdate.Visible = false;
|
||||
BtnCancel.Visible = false;
|
||||
LabelLocalVersion.Text = "当前是最新版本";
|
||||
LabelLog.Text = "当前是最新版本";
|
||||
ButtonProcess.Text = "关闭";
|
||||
ButtonProcess.Visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
ButtonUpdate.Enabled = false;
|
||||
CheckUpdate();
|
||||
|
||||
|
||||
Task t = new Task(() =>
|
||||
{
|
||||
ButtonProcess.Invoke(new Action(() =>
|
||||
{
|
||||
CheckUpdate();
|
||||
}));
|
||||
});
|
||||
t.Start();
|
||||
}
|
||||
|
||||
public void DownLoadFile(string url, string filename)
|
||||
@ -176,6 +187,8 @@ namespace updater
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ButtonProcess.Visible = true;
|
||||
ButtonProcess.Text = "重新更新";
|
||||
MessageBox.Show(e.Message);
|
||||
}
|
||||
}
|
||||
@ -221,7 +234,7 @@ namespace updater
|
||||
}
|
||||
}
|
||||
}
|
||||
MessageBox.Show("更新完成");
|
||||
MessageBox.Show("更新完成, 您可以打开文档继续校对");
|
||||
// 保存最新版本日志
|
||||
File.WriteAllText(LocalVersionFilePath, updateSource);
|
||||
this.Close();
|
||||
@ -256,5 +269,20 @@ namespace updater
|
||||
this.Close();
|
||||
Application.Exit();
|
||||
}
|
||||
|
||||
private void ButtonProcess_Click(object sender, EventArgs e)
|
||||
{
|
||||
switch (ButtonProcess.Text)
|
||||
{
|
||||
case "重新更新":
|
||||
case "继续更新":
|
||||
StartUpgrade();
|
||||
break;
|
||||
case "关闭":
|
||||
this.Close();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
如果你的应用程序需要此虚拟化来实现向后兼容性,则移除此
|
||||
元素。
|
||||
-->
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||
</requestedPrivileges>
|
||||
<applicationRequestMinimum>
|
||||
<defaultAssemblyRequest permissionSetReference="Custom" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user