/// <summary> /// “获取包版本信息”按钮点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GetPackageVersion_Click(object sender, EventArgs e) { try { List <JoeySoftVersion> joeySoftVersions = PackageUpdateService.GetVersionInfo(); this.PackagelistBx.DataSource = joeySoftVersions; this.PackagelistBx.DisplayMember = nameof(JoeySoftVersion.Show); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <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("推包成功!"); } }