123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace Welling_Motor_Debug_Tool
- {
- public partial class Version : Form
- {
- //修改记录
- string ChangeLog = "修改记录:\r\n" +
- "V2.1.6\r\n" +
- "1,修改控制器内阻校准指令,增加写入存储标志;\r\n" +
- "2,参数生成界面增加导入样机测试记录的文件功能;\r\n" +
- "3,参数生成界面增加锁,防止误触。\r\n\r\n" +
- "V2.1.7\r\n" +
- "1,解决系统显示缩放后,截图显示不完全的问题;\r\n" +
- "2,允许离线使用是关闭网络定时检测;\r\n" +
- "3,定时检测网络断开时不自动关闭,此时不允许使用,等待网络恢复;\r\n" +
- "4,启动登录密码错误时不自动关闭,重新进入登录;\r\n" +
- "5,部分提示框修改为自动关闭;\r\n" +
- "6,增加读取本机信息功能;\r\n" +
- "7,启动时自动上传登录日志,包含本机信息。\r\n\r\n" +
- "V2.1.8\r\n" +
- "1,限制FCT治具测试账户需要联网使用;\r\n" +
- "2,量产测试和检验模式下,双击配置文件可删除选中的配置文件。\r\n\r\n" +
- "V" + mainForm.Version + "\r\n" +
- "\r\n"
- ;
- //存储路径文件
- LocalInfo localInfo = new LocalInfo();
- //服务器配置
- string IP, Port, User, PassWD;
- //FTP
- ftp myFtp = new ftp();
- public Version()
- {
- InitializeComponent();
- }
- private void Version_Load(object sender, EventArgs e)
- {
- //更新版本信息
- label_Ver.Text = "版本: V" + mainForm.Version;
- label_BT.Text = "编译时间:" + System.IO.File.GetLastWriteTime(this.GetType().Assembly.Location).ToString("yyyy-MM-dd HH:mm:ss");
- //修改日志
- richTextBox_Log.Text = "";
- richTextBox_Log.AppendText(ChangeLog);
- //导入网络配置
- if (System.IO.File.Exists(localInfo.LocalPath + localInfo.ConfigFileName)) //存在配置文件,导入配置信息
- {
- //打开文件
- StreamReader objReader = new StreamReader(localInfo.LocalPath + localInfo.ConfigFileName);
- string sLine = "";
- ArrayList array_CfgInfo = new ArrayList();
- array_CfgInfo.Clear();
- while (sLine != null)
- {
- sLine = objReader.ReadLine();
- array_CfgInfo.Add(sLine);
- }
- objReader.Close();
- //解析配置文件
- try
- {
- //Server Set IP, Port, User, PassWS, ModelPath;
- IP = array_CfgInfo[12].ToString().Split(':')[1];
- Port = array_CfgInfo[13].ToString().Split(':')[1];
- User = array_CfgInfo[14].ToString().Split(':')[1];
- PassWD = array_CfgInfo[15].ToString().Split(':')[1];
- myFtp.FtpOption(IP, Port, User, PassWD, "admin", "ttium_admin");
- }
- catch (System.Exception)
- {
- MessageBox.Show("参数格式错误,写入默认值!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- else
- {
- MessageBox.Show("参数文件丢失!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.Close();
- }
- }
- private void button_CheckVersion_Click(object sender, EventArgs e)
- {
- //检查网络状态
- if (myFtp.CheckFtp() == false)
- {
- MessageBox.Show("网络断开", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- else
- {
- //检查本地文件删除
- if (System.IO.File.Exists(localInfo.LocalPath + "\\Version"))
- System.IO.File.Delete(localInfo.LocalPath + "\\Version");
- //读取最新版本号
- myFtp.DownloadFile("/Tools/Welling_Motor_Debug_Tool/Version", localInfo.LocalPath);
- StreamReader objReader = new StreamReader(localInfo.LocalPath + "\\Version");
- string sLine = "";
- ArrayList arrText = new ArrayList();//创建一个动态数组
- while (sLine != null)
- {
- sLine = objReader.ReadLine();
- arrText.Add(sLine);
- }
- objReader.Close();
- System.IO.File.Delete(localInfo.LocalPath + "\\Version");
- //检查是否有最新版本
- string[] VerOld = mainForm.Version.Trim().Split('.');
- string[] VerNew = arrText[0].ToString().Trim().Split('.');
- if (Convert.ToInt16(VerNew[0]) <= Convert.ToInt16(VerOld[0]))
- {
- if (Convert.ToInt16(VerNew[1]) <= Convert.ToInt16(VerOld[1]))
- {
- if (Convert.ToInt16(VerNew[2]) <= Convert.ToInt16(VerOld[2]))
- {
- MessageBox.Show("版本已是最新", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- }
- //下载最新版本
- string SavePath = Directory.GetCurrentDirectory();
- string[] FileList = myFtp.GetFileNameList("/Tools/Welling_Motor_Debug_Tool");
- foreach (string file in FileList)
- {
- if (file.Contains(".exe"))
- {
- myFtp.DownloadFile("/Tools/Welling_Motor_Debug_Tool/" + file, SavePath);
- MessageBox.Show("最新版本下载完成,请手动删除旧版本\r\n最新版本:" + file, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- }
- }
- }
- }
|