软件升级相关代码
This commit is contained in:
1 parent
93e5e36dd3
commit
892d7e1f6c
20 files changed
+1697
-3
No files matched your search
@@ -25,6 +25,7 @@ namespace TemuKJD
|
||||
//安装客户端必备字体
|
||||
InstallFont(Application.StartupPath + @"\Fonts\STZHONGS.TTF");
|
||||
|
||||
StartUp.CheckUpdate();
|
||||
System.Threading.Tasks.Task.Run(() =>
|
||||
{
|
||||
new Initialization().Get();
|
||||
|
||||
@@ -504,5 +504,60 @@ namespace TemuKJD
|
||||
if (ViolateRuleParam.LstViolateRuleNameSelect != null)
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig<List<string>>("violate_rule_name_select", ViolateRuleParam.LstViolateRuleNameSelect);
|
||||
}
|
||||
|
||||
public static void CheckUpdate()
|
||||
{
|
||||
try
|
||||
{
|
||||
// while (true)
|
||||
{
|
||||
string updatefilepath = System.Environment.CurrentDirectory + "\\Update.exe";
|
||||
var url = BaseClass.BuildObjString("update/get_update");
|
||||
var data = UserLogin.GetSignaturex();
|
||||
var html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
return;
|
||||
|
||||
var updateExeChk = BaseRegex.GetStringJson(ref html, "exe_check").ParseToString();
|
||||
var updateExeAddress = BaseRegex.GetStringJson(ref html, "exe_address");
|
||||
var updateFileAddress = BaseRegex.GetStringJson(ref html, "file_address");
|
||||
var newVersion = BaseRegex.GetIntJson(ref html, "next_version").ParseToInt();
|
||||
|
||||
if (File.Exists(updatefilepath))
|
||||
{
|
||||
string fc = BaseClass.GetFileMd5(updatefilepath);
|
||||
if (fc != updateExeChk)
|
||||
{
|
||||
NaiBa.Util.Helper.HttpHelper.DownloadFile(updateExeAddress, updatefilepath);
|
||||
}
|
||||
}
|
||||
else // 如果自动更新exe文件不存在,则强制更新exe文件
|
||||
NaiBa.Util.Helper.HttpHelper.DownloadFile(updateExeAddress, updatefilepath);
|
||||
|
||||
if (newVersion > BaseClass.VersionCount)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(updatefilepath))
|
||||
{
|
||||
File.WriteAllText(System.Environment.CurrentDirectory + "\\UpdateConfig.ini",
|
||||
"TemuKJD.exe\r\n" +
|
||||
BaseClass.VersionCount + "\r\n" +
|
||||
newVersion + "\r\n" +
|
||||
updateFileAddress);
|
||||
|
||||
Process.Start(updatefilepath);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
BaseMsgForm.ShowError(ex.Message);
|
||||
}
|
||||
}
|
||||
//Thread.Sleep(1000 * 60 * 60);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { BaseMsgForm.ShowError(ex.Message); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,8 +40,17 @@ namespace TemuKJD.UserForm
|
||||
{
|
||||
GetUserList();
|
||||
#if DEBUG
|
||||
grpEnvironmentChoice.Visible = true;
|
||||
pnlShowRemember.Visible = true;
|
||||
if (File.Exists(System.Environment.CurrentDirectory + "\\TemuKJD.exe.choice.debug.tools"))
|
||||
{
|
||||
grpEnvironmentChoice.Visible = true;
|
||||
pnlShowRemember.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
grpEnvironmentChoice.Visible = false;
|
||||
pnlShowRemember.Visible = false;
|
||||
rbtPrd.Checked = true;
|
||||
}
|
||||
#else
|
||||
grpEnvironmentChoice.Visible = false;
|
||||
pnlShowRemember.Visible = false;
|
||||
|
||||
Reference in new issue
Block a user