public static UpdateSoftEnt GetEnt(string url) { UpdateSoftEnt c = new UpdateSoftEnt(); try { c.ProductVer = Program.ProductVer; IAASResponse reponse = IAASRequest.Reauest(url, RequestMethod.GET, "", "", ""); if (reponse.StatusCode == HttpStatusCode.OK) { if (reponse.Content.IndexOf("}") < 0) { reponse.Content = "{" + reponse.Content + "}"; } if (reponse.Content.IndexOf("srb_ver_info_s") > 0) { c.ProductVer = reponse.Content.Substring(reponse.Content.IndexOf("srb_ver_info_s"), reponse.Content.IndexOf("srb_ver_info_e") - reponse.Content.IndexOf("srb_ver_info_s")).Replace("=", "").Replace("srb_ver_info_s", ""); c.DownUrl = reponse.Content.Substring(reponse.Content.IndexOf("srb_down_info_s"), reponse.Content.IndexOf("srb_down_info_e") - reponse.Content.IndexOf("srb_down_info_s")).Replace("=", "").Replace("srb_down_info_s", ""); } else { c = JsonToObj <UpdateSoftEnt>(reponse.Content); } } } catch { } return(c); }
public static void UpdataSoft(bool flag = false) { try { UpdateSoftEnt data = ApiClient.GetEnt(Win.WinInput.ApiUrl); if (Program.ProductVer != data.ProductVer) { //下载最新版本 #region 实现升级 bool updataok = false; string du = data.DownUrl; ///下载 if (MessageBox.Show("有新版本,是否现在升级!\r\n", "速录宝-有新版本", MessageBoxButtons.YesNo) == DialogResult.Yes) { Win.Login info = new Win.Login(false, Core.Win.WinInput.Input, 0); info.TopMost = true; info.Show(); try { WebClient client = new WebClient(); client = new WebClient(); string filename = System.IO.Path.Combine(Win.WinInput.Input.AppPath, "updatesoft.zip"); client.DownloadFile(du, filename); Thread.Sleep(200); updataok = true; } catch { updataok = false; } } if (updataok) { //关闭速录软件,打开升级解压程序 System.Diagnostics.Process.Start(System.IO.Path.Combine(Win.WinInput.Input.AppPath, "update.exe")); Program.MIme.ExitSelect(null, null); } #endregion return; } else if (flag) { MessageBox.Show("没有检测到要更新的程序!"); return; } } catch (Exception ex) { string ss = ex.ToString(); } }