/// <summary> /// 更新包版本 /// </summary> public static HttpResponseMessage UpdateVersionInfo(PutPackageVersion putPackageVersion) { Uri uri = new Uri(api + "/" + versionActionName + "/" + putPackageVersion.JoeySoftName); HttpResponseMessage httpResponseMessage = null; using (HttpClient httpClient = new HttpClient()) { httpResponseMessage = httpClient.PutAsync(uri, new StringContent(JsonConvert.SerializeObject(putPackageVersion), Encoding.UTF8, "application/json-patch+json")).Result; httpClient.Dispose(); } return(httpResponseMessage); }
/// <summary> /// 推包到服务器 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Pushbtn_Click(object sender, EventArgs e) { if (this.PackagelistBx.SelectedIndex == -1) { MessageBox.Show("请选择要打包的软件!"); return; } JoeySoftVersion joeySoftVersion = new JoeySoftVersion(); if (this.PackagelistBx.SelectedItem is JoeySoftVersion) { joeySoftVersion = this.PackagelistBx.SelectedItem as JoeySoftVersion; } string directoryPath = Directory.GetParent(this.PackageAdressCBX.Text).FullName; FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(this.PackageAdressCBX.Text); string zipAddress = Path.Combine(Directory.GetParent(directoryPath).FullName, joeySoftVersion.JoeySoftName + "V" + myFileVersionInfo.FileVersion + ".zip"); if (!File.Exists(zipAddress)) { MessageBox.Show("先打包后,再点推送!"); return; } //上传包 if (PackageUpdateService.UploadPackage(zipAddress) != System.Net.HttpStatusCode.OK) { MessageBox.Show("上传包错误,请检查网络!"); return; } PutPackageVersion putPackageVersion = new PutPackageVersion(); putPackageVersion.Version = myFileVersionInfo.FileVersion; putPackageVersion.JoeySoftName = joeySoftVersion.JoeySoftName; if (PackageUpdateService.UpdateVersionInfo(putPackageVersion).StatusCode != System.Net.HttpStatusCode.OK) { MessageBox.Show("推包报错!"); } else { MessageBox.Show("推包成功!"); } }