TestUpdateForm.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using Y.Test.Commons;
  11. using Y.Utils.DataUtils.JsonUtils;
  12. using Y.Utils.DelegateUtils;
  13. using Y.Utils.IOUtils.FileUtils;
  14. using Y.Utils.IOUtils.TxtUtils;
  15. using Y.Utils.UpdateUtils;
  16. namespace Y.Test.Views
  17. {
  18. public partial class TestUpdateForm : Form
  19. {
  20. public TestUpdateForm()
  21. {
  22. InitializeComponent();
  23. }
  24. private void TestUpdateForm_Load(object sender, EventArgs e)
  25. {
  26. FilePackageTool.Pack(@"D:\CoCo\Work\IMOS小助手\IMOS.Assistant\程序发布\1.0.0.0", @"D:\CoCo\Work\IMOS小助手\IMOS.Assistant\程序发布\所有版本打包\Assistant[1.0.0.0].udp");
  27. }
  28. private void button1_Click(object sender, EventArgs e)
  29. {
  30. Task.Factory.StartNew(() =>
  31. {
  32. //AppUpdateTool aut = new AppUpdateTool();
  33. //int updateCode = aut.Update("Oreo.NetMan", new Version(Application.ProductVersion),
  34. // "http://localhost:20001/Update/Get?name=lalala",
  35. // R.Paths.Temp, R.Paths.Relative,
  36. // UIDownProgress, null, UIUnpackProgress, null);
  37. //UIUpdateCode(updateCode);
  38. });
  39. }
  40. private void UIDownProgress(object sender, ProgressEventArgs e)
  41. {
  42. BeginInvoke(new Action(() =>
  43. {
  44. progressBar1.Value = (int)(e.Current * 100 / e.Total);
  45. label1.Text = string.Format("{0} / {1}", e.Current, e.Total);
  46. }));
  47. }
  48. private void UIUnpackProgress(object sender, ProgressEventArgs e)
  49. {
  50. BeginInvoke(new Action(() =>
  51. {
  52. progressBar2.Value = (int)(e.Current * 100 / e.Total);
  53. label2.Text = string.Format("{0} / {1}", e.Current, e.Total);
  54. }));
  55. }
  56. private void UIUpdateCode(int code)
  57. {
  58. BeginInvoke(new Action(() =>
  59. {
  60. label3.Text = code.ToString();
  61. }));
  62. }
  63. }
  64. }