MainForm.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using Oreo.VersionUpdate.Commons;
  2. using Oreo.VersionUpdate.Models;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. using Y.Utils.DataUtils.Collections;
  13. namespace Oreo.VersionUpdate.Views
  14. {
  15. public partial class MainForm : Form
  16. {
  17. public MainForm()
  18. {
  19. InitializeComponent();
  20. }
  21. private void MainForm_Load(object sender, EventArgs e)
  22. {
  23. }
  24. private void StartUpdate()
  25. {
  26. Task.Factory.StartNew(() =>
  27. {
  28. //读取标准更新最新版本号 获取需要标准更新的配置
  29. StartUpdateStandard();
  30. //使用本地插件名称和版本号 获取需要更新插件的配置
  31. StartUpdatePlugin();
  32. });
  33. }
  34. private void StartUpdateStandard()
  35. {
  36. R.Log.i("读取标准更新版本号");
  37. string versionNumber = GetStandardVersionNumber();
  38. }
  39. private void StartUpdatePlugin()
  40. {
  41. R.Log.i("读取本地插件列表(名称、版本号)");
  42. List<PluginModel> pluginList = GetPluginList();
  43. if (ListTool.HasElements(pluginList))
  44. {
  45. R.Log.i("共读取到 " + pluginList.Count + " 个插件");
  46. pluginList.ForEach(x =>
  47. {
  48. R.Log.i("请求 " + x.Name + " / " + x.Version + " 插件的更新");
  49. VersionModel pluginNewVersion = GetPluginNewVersion(x);
  50. if (pluginNewVersion != null)
  51. {
  52. R.Log.i(x.Name + " / " + x.Version + " 插件有新版本 " + pluginNewVersion.VersionNumber + " 需要更新,准备更新");
  53. bool flag = Update(pluginNewVersion);
  54. if (flag)
  55. {
  56. R.Log.i(x.Name + " 更新成功,当前版本" + pluginNewVersion.VersionNumber);
  57. }
  58. else
  59. {
  60. R.Log.w(x.Name + " 更新失败");
  61. }
  62. }
  63. });
  64. }
  65. else
  66. {
  67. R.Log.w("本地插件列表为空");
  68. }
  69. R.Log.i("本地插件更新操作结束");
  70. }
  71. #region 读取本地数据操作
  72. private List<PluginModel> GetPluginList()
  73. {
  74. List<PluginModel> rs = null;
  75. return rs;
  76. }
  77. private string GetStandardVersionNumber()
  78. {
  79. string rs = "";
  80. return rs;
  81. }
  82. #endregion
  83. #region 读取网络数据操作
  84. private VersionModel GetPluginNewVersion(PluginModel pm)
  85. {
  86. VersionModel rs = null;
  87. return rs;
  88. }
  89. #endregion
  90. #region 更新操作
  91. private bool Update(VersionModel vm)
  92. {
  93. return false;
  94. }
  95. #endregion
  96. #region UI操作
  97. /// <summary>
  98. /// 退出程序
  99. /// </summary>
  100. void UIClose()
  101. {
  102. Invoke(new Action(() =>
  103. {
  104. Close();
  105. }));
  106. }
  107. #endregion
  108. }
  109. }