| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using ReleaseHelper.Services;
- using ReleaseHelper.Variables;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace ReleaseHelper
- {
- public partial class FormMain : Form
- {
- public FormMain()
- {
- InitializeComponent();
- textBoxLocalFile.Text = Const.TOBE_UPLOAD_LOCAL_FILE;
- textBoxOssPath.Text = Const.OSS_PATH;
- Task.Run(async () =>
- {
- var info = await Services.Release.GetLatestVersionInfo(Variables.Const.HTTP_UPDATE_FILE);
- BeginInvoke(new Action(() =>
- {
- textBoxNowVersion.Text = textBoxLatestVersion.Text = info.Version.ToString();
- }));
- });
- }
- private void button1_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(textBoxNowVersion.Text) || string.IsNullOrEmpty(textBoxUsername.Text) || string.IsNullOrEmpty(textBoxPassword.Text))
- {
- MessageBox.Show("信息不全");
- }
- else
- {
- try
- {
- Task.Run(async () =>
- {
- string res = await Release.ReleaseApplication(
- textBoxUsername.Text,
- textBoxPassword.Text,
- Convert.ToDouble(textBoxNowVersion.Text.Trim()),
- Const.TOBE_UPLOAD_LOCAL_FILE,
- Const.OSS_PATH,
- setProgressBar
- );
- if (string.IsNullOrEmpty(res))
- {
- res = "更新成功!";
- }
- MessageBox.Show(res);
- });
- }
- catch
- {
- }
- }
- }
- private void setProgressBar(int max, int now)
- {
- Utils.ControlExts.FormInvoke(this, () => {
- toolStripProgressBarRelease.Maximum = max;
- toolStripProgressBarRelease.Minimum = 0;
- toolStripProgressBarRelease.Value = now;
- Console.WriteLine(now.ToString(), "/", max.ToString());
- });
- }
- }
- }
|