Version.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. namespace Welling_Motor_Debug_Tool
  13. {
  14. public partial class Version : Form
  15. {
  16. //修改记录
  17. string ChangeLog = "修改记录:\r\n" +
  18. "V" + mainForm.Version + "\r\n" +
  19. "1,优化修改配置模式时重复发送指令的问题。\r\n\r\n" +
  20. "V2.2.0\r\n" +
  21. "1,优化新增协议内容;\r\n" +
  22. "2,增加协议类型选择,支持CAN和UART;\r\n" +
  23. "3,针对UART控制器在量产测试过程中增加5S协议设定和联动装置盒波特率设定,以正确接收UART控制器数据和Boot版本信息;\r\n" +
  24. "4,基础功能测试控制电机启动由修改运行模式改为Walk模式;\r\n" +
  25. "5,量产功能测试增加MOS内阻校准环节,支持可选;\r\n" +
  26. "6,增加流水号记录。\r\n\r\n" +
  27. "V2.1.9\r\n" +
  28. "1,增加整车信息2、用户骑行参数界面,支持上位机读写;\r\n" +
  29. "2,增加车架ODO里程写入和读取;\r\n" +
  30. "3,增加产品标签写入,支持32位字符;\r\n" +
  31. "4,生成参数界面可选择HUB_FCT,支持仅导出到本地;\r\n" +
  32. "5,FCT治具测试账户登录后,测试路径自动改为HUB_FCT_Test;\r\n" +
  33. "6,增加删除指定配置文件和样机测试记录文件,支持文件夹递归删除。\r\n\r\n" +
  34. "V2.1.8\r\n" +
  35. "1,限制FCT治具测试账户需要联网使用;\r\n" +
  36. "2,量产测试和检验模式下,双击配置文件可删除选中的配置文件。\r\n\r\n" +
  37. "V2.1.7\r\n" +
  38. "1,解决系统显示缩放后,截图显示不完全的问题;\r\n" +
  39. "2,允许离线使用是关闭网络定时检测;\r\n" +
  40. "3,定时检测网络断开时不自动关闭,此时不允许使用,等待网络恢复;\r\n" +
  41. "4,启动登录密码错误时不自动关闭,重新进入登录;\r\n" +
  42. "5,部分提示框修改为自动关闭;\r\n" +
  43. "6,增加读取本机信息功能;\r\n" +
  44. "7,启动时自动上传登录日志,包含本机信息。\r\n\r\n" +
  45. "V2.1.6\r\n" +
  46. "1,修改控制器内阻校准指令,增加写入存储标志;\r\n" +
  47. "2,参数生成界面增加导入样机测试记录的文件功能;\r\n" +
  48. "3,参数生成界面增加锁,防止误触。\r\n"
  49. ;
  50. //存储路径文件
  51. LocalInfo localInfo = new LocalInfo();
  52. //服务器配置
  53. string IP, Port, User, PassWD;
  54. //FTP
  55. ftp myFtp = new ftp();
  56. public Version()
  57. {
  58. InitializeComponent();
  59. }
  60. private void Version_Load(object sender, EventArgs e)
  61. {
  62. //更新版本信息
  63. label_Ver.Text = "版本: V" + mainForm.Version;
  64. label_BT.Text = "编译时间:" + System.IO.File.GetLastWriteTime(this.GetType().Assembly.Location).ToString("yyyy-MM-dd HH:mm:ss");
  65. //修改日志
  66. richTextBox_Log.Text = "";
  67. richTextBox_Log.AppendText(ChangeLog);
  68. //导入网络配置
  69. if (System.IO.File.Exists(localInfo.LocalPath + localInfo.ConfigFileName)) //存在配置文件,导入配置信息
  70. {
  71. //打开文件
  72. StreamReader objReader = new StreamReader(localInfo.LocalPath + localInfo.ConfigFileName);
  73. string sLine = "";
  74. ArrayList array_CfgInfo = new ArrayList();
  75. array_CfgInfo.Clear();
  76. while (sLine != null)
  77. {
  78. sLine = objReader.ReadLine();
  79. array_CfgInfo.Add(sLine);
  80. }
  81. objReader.Close();
  82. //解析配置文件
  83. try
  84. {
  85. //Server Set IP, Port, User, PassWS, ModelPath;
  86. IP = array_CfgInfo[12].ToString().Split(':')[1];
  87. Port = array_CfgInfo[13].ToString().Split(':')[1];
  88. User = array_CfgInfo[14].ToString().Split(':')[1];
  89. PassWD = array_CfgInfo[15].ToString().Split(':')[1];
  90. myFtp.FtpOption(IP, Port, User, PassWD, "admin", "ttium_admin");
  91. }
  92. catch (System.Exception)
  93. {
  94. MessageBox.Show("参数格式错误,写入默认值!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  95. }
  96. }
  97. else
  98. {
  99. MessageBox.Show("参数文件丢失!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  100. this.Close();
  101. }
  102. }
  103. private void button_CheckVersion_Click(object sender, EventArgs e)
  104. {
  105. //检查网络状态
  106. if (myFtp.CheckFtp() == false)
  107. {
  108. MessageBox.Show("网络断开", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  109. return;
  110. }
  111. else
  112. {
  113. //检查本地文件删除
  114. if (System.IO.File.Exists(localInfo.LocalPath + "\\Version"))
  115. System.IO.File.Delete(localInfo.LocalPath + "\\Version");
  116. //读取最新版本号
  117. myFtp.DownloadFile("/Tools/Welling_Motor_Debug_Tool/Version", localInfo.LocalPath);
  118. StreamReader objReader = new StreamReader(localInfo.LocalPath + "\\Version");
  119. string sLine = "";
  120. ArrayList arrText = new ArrayList();//创建一个动态数组
  121. while (sLine != null)
  122. {
  123. sLine = objReader.ReadLine();
  124. arrText.Add(sLine);
  125. }
  126. objReader.Close();
  127. System.IO.File.Delete(localInfo.LocalPath + "\\Version");
  128. //检查是否有最新版本
  129. string[] VerOld = mainForm.Version.Trim().Split('.');
  130. string[] VerNew = arrText[0].ToString().Trim().Split('.');
  131. int VerOld_int = Convert.ToInt32(VerOld[0]) * 10000 + Convert.ToInt32(VerOld[1].PadLeft(2, '0')) * 100 + Convert.ToInt32(VerOld[2].PadLeft(2, '0'));
  132. int VerNew_int = Convert.ToInt32(VerNew[0]) * 10000 + Convert.ToInt32(VerNew[1].PadLeft(2, '0')) * 100 + Convert.ToInt32(VerNew[2].PadLeft(2, '0'));
  133. if (VerNew_int <= VerOld_int)
  134. {
  135. //版本已是最新,跳出
  136. MessageBox.Show("版本已是最新", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  137. return;
  138. }
  139. //下载最新版本
  140. string SavePath = Directory.GetCurrentDirectory();
  141. string[] FileList = myFtp.GetFileNameList("/Tools/Welling_Motor_Debug_Tool");
  142. foreach (string file in FileList)
  143. {
  144. if (file.Contains(".exe"))
  145. {
  146. myFtp.DownloadFile("/Tools/Welling_Motor_Debug_Tool/" + file, SavePath);
  147. MessageBox.Show("最新版本下载完成,请手动删除旧版本\r\n最新版本:" + file, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  148. System.Environment.Exit(0);
  149. }
  150. }
  151. }
  152. }
  153. }
  154. }