public void StartCheckUpgrade() { //Task checkUpgradeCheckUpgrade = new Task(CheckUpgrade); //checkUpgradeCheckUpgrade.Start(); //checkUpgradeCheckUpgrade.ContinueWith((task) => { StartCheckUpgrade(); }); Task <UpgradeServiceEventArgs> checkUpgradeTask = new Task <UpgradeServiceEventArgs>(() => { string tempResponse = myHttp.SendData(string.Format(@"https://api.lulianqi.com/freehttp/UpdateCheck/v1.2?user={0}&dotnetrelease={1}", UserComputerInfo.GetComputerMac(), UserComputerInfo.GetDotNetRelease())); string isNeedUpdata = FreeHttp.AutoTest.ParameterizationPick.ParameterPickHelper.PickStrParameter("\"isNeedUpdata\":", ",", tempResponse); string url = FreeHttp.AutoTest.ParameterizationPick.ParameterPickHelper.PickStrParameter("\"url\":", ",", tempResponse); string message = FreeHttp.AutoTest.ParameterizationPick.ParameterPickHelper.PickStrParameter("\"message\":", ",", tempResponse); if (string.IsNullOrEmpty(isNeedUpdata)) { return(new UpgradeServiceEventArgs(false, null)); } if (isNeedUpdata == "true") { return(new UpgradeServiceEventArgs(true, url)); } return(null); }); checkUpgradeTask.Start(); checkUpgradeTask.ContinueWith((task) => { if (checkUpgradeTask.Result != null) { this.GetUpgradeMes(this, checkUpgradeTask.Result); } }); }
public void StartCheckUpgrade() { //Task checkUpgradeCheckUpgrade = new Task(CheckUpgrade); //checkUpgradeCheckUpgrade.Start(); //checkUpgradeCheckUpgrade.ContinueWith((task) => { StartCheckUpgrade(); }); Task <UpgradeServiceEventArgs> checkUpgradeTask = new Task <UpgradeServiceEventArgs>(() => { //string tempResponse = myHttp.SendData(string.Format(@"{0}freehttp/UpdateCheck/v{1}?dotnetrelease={2}&{3}", ConfigurationData.BaseUrl, System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(), UserComputerInfo.GetDotNetRelease(), UserComputerInfo.GetFreeHttpUser())); //string isNeedUpdata = FreeHttp.AutoTest.ParameterizationPick.ParameterPickHelper.PickStrParameter("\"isNeedUpdata\":", ",", tempResponse); //string isSilentUpgrade = FreeHttp.AutoTest.ParameterizationPick.ParameterPickHelper.PickStrParameter("\"isSilentUpgrade\":", ",", tempResponse); //string url = FreeHttp.AutoTest.ParameterizationPick.ParameterPickHelper.PickStrParameter("\"url\":\"", "\",", tempResponse); //string message = FreeHttp.AutoTest.ParameterizationPick.ParameterPickHelper.PickStrParameter("\"message\":\"", "\"", tempResponse); //if (string.IsNullOrEmpty(isNeedUpdata)) //{ // return new UpgradeServiceEventArgs(false, null); //} //if (isNeedUpdata == "true") //{ // if (isSilentUpgrade == "true") SilentUpgradeUrl = url; // return new UpgradeServiceEventArgs(true, url, null, isSilentUpgrade == "true"); //} //if (!string.IsNullOrEmpty(message)) //{ // return new UpgradeServiceEventArgs(true, null, message); //} //return null; try { HttpResponseMessage response = httpClient.GetAsync(string.Format(@"{0}freehttp/UpdateCheck/v{1}?dotnetrelease={2}&{3}", ConfigurationData.BaseUrl, UserComputerInfo.GetFreeHttpVersion(), UserComputerInfo.GetDotNetRelease(), UserComputerInfo.GetFreeHttpUser())).GetAwaiter().GetResult(); if (response.IsSuccessStatusCode) { UpdateInfo updateInfo = MyJsonHelper.JsonDataContractJsonSerializer.JsonStringToObject <UpdateInfo>(response.Content.ReadAsStringAsync().GetAwaiter().GetResult()); if (updateInfo == null) { _ = RemoteLogService.ReportLogAsync("JsonStringToObject fail that StartCheckUpgrade", RemoteLogService.RemoteLogOperation.CheckUpgrade, RemoteLogService.RemoteLogType.Error); return(new UpgradeServiceEventArgs(false, null)); } if (updateInfo.isNeedUpdata && updateInfo.isSilentUpgrade && !string.IsNullOrEmpty(updateInfo.url)) { SilentUpgradeUrl = updateInfo.url; } return(new UpgradeServiceEventArgs(true, updateInfo)); } else { _ = RemoteLogService.ReportLogAsync("StartCheckUpgrade get error response", RemoteLogService.RemoteLogOperation.CheckUpgrade, RemoteLogService.RemoteLogType.Error); return(new UpgradeServiceEventArgs(false, null)); } } catch (Exception ex) { _ = RemoteLogService.ReportLogAsync(ex.ToString(), RemoteLogService.RemoteLogOperation.Exception, RemoteLogService.RemoteLogType.Error); return(new UpgradeServiceEventArgs(false, null)); } }); checkUpgradeTask.Start(); checkUpgradeTask.ContinueWith((task) => { if (checkUpgradeTask.Result != null) { this.GetUpgradeMes(this, checkUpgradeTask.Result); } }); }
public void StartCheckUpgrade() { //Task checkUpgradeCheckUpgrade = new Task(CheckUpgrade); //checkUpgradeCheckUpgrade.Start(); //checkUpgradeCheckUpgrade.ContinueWith((task) => { StartCheckUpgrade(); }); Task <UpgradeServiceEventArgs> checkUpgradeTask = new Task <UpgradeServiceEventArgs>(() => { string tempResponse = myHttp.SendData(string.Format(@"{0}freehttp/UpdateCheck/v{1}?user={2}&dotnetrelease={3}", ConfigurationData.BaseUrl, System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(), UserComputerInfo.GetComputerMac(), UserComputerInfo.GetDotNetRelease())); string isNeedUpdata = FreeHttp.AutoTest.ParameterizationPick.ParameterPickHelper.PickStrParameter("\"isNeedUpdata\":", ",", tempResponse); string url = FreeHttp.AutoTest.ParameterizationPick.ParameterPickHelper.PickStrParameter("\"url\":", ",", tempResponse); string message = FreeHttp.AutoTest.ParameterizationPick.ParameterPickHelper.PickStrParameter("\"message\":", ",", tempResponse); if (string.IsNullOrEmpty(isNeedUpdata)) { return(new UpgradeServiceEventArgs(false, null)); } if (isNeedUpdata == "true") { return(new UpgradeServiceEventArgs(true, url)); } return(null); }); checkUpgradeTask.Start(); checkUpgradeTask.ContinueWith((task) => { if (checkUpgradeTask.Result != null) { this.GetUpgradeMes(this, checkUpgradeTask.Result); } }); }