|
@@ -975,30 +975,34 @@ namespace Welling_Motor_Debug_Tool
|
|
|
private void button_ExportParams_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
//检查
|
|
|
- if ((radioButton_MIGIC.Checked | radioButton_HUB.Checked) == false)
|
|
|
+ if ((radioButton_MIGIC.Checked | radioButton_HUB.Checked | radioButton_HUB_FCT.Checked) == false)
|
|
|
{
|
|
|
MessageBox.Show("请选择产品类型", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
return;
|
|
|
}
|
|
|
- foreach (Control c in groupBox1.Controls)
|
|
|
+ //不导出到本地时需填写完整订单信息
|
|
|
+ if (!checkBox_SyncFac.Checked)
|
|
|
{
|
|
|
- if (c is TextBox)
|
|
|
+ foreach (Control c in groupBox1.Controls)
|
|
|
{
|
|
|
- if (c.Text == "")
|
|
|
- {
|
|
|
- MessageBox.Show("信息填写不完整", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (c.Text.Contains('_'))
|
|
|
+ if (c is TextBox)
|
|
|
{
|
|
|
- if ((c.Name != "textBox_ProductTag")&& (c.Name != "textBox_SoftwareVer"))
|
|
|
+ if (c.Text == "")
|
|
|
{
|
|
|
- MessageBox.Show("\"" + c.Text + "\"" + "包含字符'_'", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
+ MessageBox.Show("信息填写不完整", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
return;
|
|
|
- }
|
|
|
+ }
|
|
|
+ if (c.Text.Contains('_'))
|
|
|
+ {
|
|
|
+ if ((c.Name != "textBox_ProductTag") && (c.Name != "textBox_SoftwareVer"))
|
|
|
+ {
|
|
|
+ MessageBox.Show("\"" + c.Text + "\"" + "包含字符'_'", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
//分割参数
|
|
|
string[] lines = richTextBox_AdvanceParams.Text.Split(new string[] { "\n" }, StringSplitOptions.None);
|
|
@@ -1142,91 +1146,142 @@ namespace Welling_Motor_Debug_Tool
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- //确定本地保存路径
|
|
|
- string Date = DateTime.Now.ToString("yyyy-MM-dd");
|
|
|
- string LocalPath = localInfo.LocalPath + "\\" + localInfo.CfgPathName + "\\" + Date;
|
|
|
- if (!Directory.Exists(LocalPath))
|
|
|
+ //不导出本地时,上传服务器
|
|
|
+ if (!checkBox_SyncFac.Checked)
|
|
|
{
|
|
|
- Directory.CreateDirectory(LocalPath);
|
|
|
- }
|
|
|
+ //确定本地保存路径
|
|
|
+ string Date = DateTime.Now.ToString("yyyy-MM-dd");
|
|
|
+ string LocalPath = localInfo.LocalPath + "\\" + localInfo.CfgPathName + "\\" + Date;
|
|
|
+ if (!Directory.Exists(LocalPath))
|
|
|
+ {
|
|
|
+ Directory.CreateDirectory(LocalPath);
|
|
|
+ }
|
|
|
|
|
|
- //确定远程保存路径
|
|
|
- string ServerPath = "";
|
|
|
- if (radioButton_HUB.Checked)
|
|
|
- {
|
|
|
- if (!myFtp.DirectoryExist("HUB_Control_TEST/cfg", Date))
|
|
|
- myFtp.MakeDir("HUB_Control_TEST/cfg" + "/" + Date);
|
|
|
- ServerPath = "HUB_Control_TEST/cfg" + "/" + Date;
|
|
|
- }
|
|
|
- else if (radioButton_MIGIC.Checked)
|
|
|
- {
|
|
|
- if (!myFtp.DirectoryExist("MIGIC_TEST/cfg", Date))
|
|
|
- myFtp.MakeDir("MIGIC_TEST/cfg" + "/" + Date);
|
|
|
- ServerPath = "MIGIC_TEST/cfg" + "/" + Date;
|
|
|
- }
|
|
|
-
|
|
|
- //确定文件名
|
|
|
- string fileName = "";
|
|
|
- fileName = textBox_ProductName.Text + "_" + textBox_MarkCode.Text + "-" + textBox_CustomerName.Text + "-" +
|
|
|
- textBox_MarkNum.Text + "_" + textBox_OtherInfo.Text + "_" + textBox_SoftwareVer.Text + "_" +
|
|
|
- DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss").Replace("/", "-").Replace(":", string.Empty).Replace(" ", "-");
|
|
|
-
|
|
|
- //保存.src文件
|
|
|
- System.IO.File.WriteAllText(LocalPath + "\\" + fileName + ".src", richTextBox_AdvanceParams.Text);
|
|
|
-
|
|
|
- //检查是否存在转换工具
|
|
|
- if (!Directory.Exists(localInfo.ToolsPath + "\\" + "GenerateParamsFile"))
|
|
|
- {
|
|
|
- Directory.CreateDirectory(localInfo.ToolsPath + "\\" + "GenerateParamsFile");
|
|
|
- myFtp.DownloadFile("Tools/GenerateParamsFile/ConsoleApp2.exe", localInfo.ToolsPath + "\\" + "GenerateParamsFile");
|
|
|
- myFtp.DownloadFile("Tools/GenerateParamsFile/Newtonsoft.Json.xml", localInfo.ToolsPath + "\\" + "GenerateParamsFile");
|
|
|
- myFtp.DownloadFile("Tools/GenerateParamsFile/Newtonsoft.Json.dll", localInfo.ToolsPath + "\\" + "GenerateParamsFile");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //程序使用最新版本
|
|
|
- if (System.IO.File.Exists(localInfo.ToolsPath + "\\" + "GenerateParamsFile" + "\\" + "ConsoleApp2.exe"))
|
|
|
- System.IO.File.Delete(localInfo.ToolsPath + "\\" + "GenerateParamsFile" + "\\" + "ConsoleApp2.exe");
|
|
|
- myFtp.DownloadFile("Tools/GenerateParamsFile/ConsoleApp2.exe", localInfo.ToolsPath + "\\" + "GenerateParamsFile");
|
|
|
- //库文件不更新
|
|
|
- if (!System.IO.File.Exists(localInfo.ToolsPath + "\\" + "GenerateParamsFile" + "\\" + "Newtonsoft.Json.xml"))
|
|
|
+ //确定远程保存路径
|
|
|
+ string ServerPath = "";
|
|
|
+ if (radioButton_HUB.Checked)
|
|
|
+ {
|
|
|
+ if (!myFtp.DirectoryExist("HUB_Control_TEST/cfg", Date))
|
|
|
+ myFtp.MakeDir("HUB_Control_TEST/cfg" + "/" + Date);
|
|
|
+ ServerPath = "HUB_Control_TEST/cfg" + "/" + Date;
|
|
|
+ }
|
|
|
+ else if (radioButton_MIGIC.Checked)
|
|
|
+ {
|
|
|
+ if (!myFtp.DirectoryExist("MIGIC_TEST/cfg", Date))
|
|
|
+ myFtp.MakeDir("MIGIC_TEST/cfg" + "/" + Date);
|
|
|
+ ServerPath = "MIGIC_TEST/cfg" + "/" + Date;
|
|
|
+ }
|
|
|
+ else if (radioButton_HUB_FCT.Checked)
|
|
|
+ {
|
|
|
+ if (!myFtp.DirectoryExist("HUB_Control_FCT/cfg", Date))
|
|
|
+ myFtp.MakeDir("HUB_Control_FCT/cfg" + "/" + Date);
|
|
|
+ ServerPath = "HUB_Control_FCT/cfg" + "/" + Date;
|
|
|
+ }
|
|
|
+
|
|
|
+ //确定文件名
|
|
|
+ string fileName = "";
|
|
|
+ fileName = textBox_ProductName.Text + "_" + textBox_MarkCode.Text + "-" + textBox_CustomerName.Text + "-" +
|
|
|
+ textBox_MarkNum.Text + "_" + textBox_OtherInfo.Text + "_" + textBox_SoftwareVer.Text + "_" +
|
|
|
+ DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss").Replace("/", "-").Replace(":", string.Empty).Replace(" ", "-");
|
|
|
+
|
|
|
+ //保存.src文件
|
|
|
+ System.IO.File.WriteAllText(LocalPath + "\\" + fileName + ".src", richTextBox_AdvanceParams.Text);
|
|
|
+
|
|
|
+ //检查是否存在转换工具
|
|
|
+ if (!Directory.Exists(localInfo.ToolsPath + "\\" + "GenerateParamsFile"))
|
|
|
+ {
|
|
|
+ Directory.CreateDirectory(localInfo.ToolsPath + "\\" + "GenerateParamsFile");
|
|
|
+ myFtp.DownloadFile("Tools/GenerateParamsFile/ConsoleApp2.exe", localInfo.ToolsPath + "\\" + "GenerateParamsFile");
|
|
|
myFtp.DownloadFile("Tools/GenerateParamsFile/Newtonsoft.Json.xml", localInfo.ToolsPath + "\\" + "GenerateParamsFile");
|
|
|
- if (!System.IO.File.Exists(localInfo.ToolsPath + "\\" + "GenerateParamsFile" + "\\" + "Newtonsoft.Json.dll"))
|
|
|
myFtp.DownloadFile("Tools/GenerateParamsFile/Newtonsoft.Json.dll", localInfo.ToolsPath + "\\" + "GenerateParamsFile");
|
|
|
- }
|
|
|
-
|
|
|
- //转换.ttcfg文件
|
|
|
- ProcessStartInfo startInfo = new ProcessStartInfo();
|
|
|
- startInfo.FileName = localInfo.ToolsPath + "\\" + "GenerateParamsFile" + "\\" + "ConsoleApp2.exe";
|
|
|
- startInfo.Arguments = "\"" + LocalPath + "\\" + fileName + ".src" + "\"";
|
|
|
- System.Diagnostics.Process.Start(startInfo);
|
|
|
- Thread.Sleep(1000);
|
|
|
-
|
|
|
- //保存页面
|
|
|
- Double scaleX = PrimaryScreen.ScaleX;
|
|
|
- Double scaleY = PrimaryScreen.ScaleY;
|
|
|
- Bitmap bit = new Bitmap((int)(this.Width * scaleX), (int)(this.Height * scaleY));//实例化一个和窗体一样大的bitmap
|
|
|
- Graphics g = Graphics.FromImage(bit);
|
|
|
- g.CopyFromScreen((int)(this.Left * scaleX), (int)(this.Top * scaleY), 0, 0, new Size((int)(this.Width * scaleX), (int)(this.Height * scaleY)));//保存整个窗体为图片
|
|
|
- bit.Save(LocalPath + "\\" + fileName + ".png");
|
|
|
-
|
|
|
- //生成pdf文件,上传服务器
|
|
|
- //...
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //程序使用最新版本
|
|
|
+ if (System.IO.File.Exists(localInfo.ToolsPath + "\\" + "GenerateParamsFile" + "\\" + "ConsoleApp2.exe"))
|
|
|
+ System.IO.File.Delete(localInfo.ToolsPath + "\\" + "GenerateParamsFile" + "\\" + "ConsoleApp2.exe");
|
|
|
+ myFtp.DownloadFile("Tools/GenerateParamsFile/ConsoleApp2.exe", localInfo.ToolsPath + "\\" + "GenerateParamsFile");
|
|
|
+ //库文件不更新
|
|
|
+ if (!System.IO.File.Exists(localInfo.ToolsPath + "\\" + "GenerateParamsFile" + "\\" + "Newtonsoft.Json.xml"))
|
|
|
+ myFtp.DownloadFile("Tools/GenerateParamsFile/Newtonsoft.Json.xml", localInfo.ToolsPath + "\\" + "GenerateParamsFile");
|
|
|
+ if (!System.IO.File.Exists(localInfo.ToolsPath + "\\" + "GenerateParamsFile" + "\\" + "Newtonsoft.Json.dll"))
|
|
|
+ myFtp.DownloadFile("Tools/GenerateParamsFile/Newtonsoft.Json.dll", localInfo.ToolsPath + "\\" + "GenerateParamsFile");
|
|
|
+ }
|
|
|
|
|
|
- //上传
|
|
|
- bool result1 = myFtp.UploadFile(LocalPath + "\\" + fileName + ".src", ServerPath);
|
|
|
- bool result2 = myFtp.UploadFile(LocalPath + "\\" + fileName + ".ttcfg", ServerPath);
|
|
|
- bool result3 = myFtp.UploadFile(LocalPath + "\\" + fileName + ".png", ServerPath);
|
|
|
- if (result1 & result2 & result3)
|
|
|
- {
|
|
|
- MessageBoxTimeOut.Show("上传成功", "提示", 1000, MessageBoxButtons.OK);
|
|
|
+ //转换.ttcfg文件
|
|
|
+ ProcessStartInfo startInfo = new ProcessStartInfo();
|
|
|
+ startInfo.FileName = localInfo.ToolsPath + "\\" + "GenerateParamsFile" + "\\" + "ConsoleApp2.exe";
|
|
|
+ startInfo.Arguments = "\"" + LocalPath + "\\" + fileName + ".src" + "\"";
|
|
|
+ System.Diagnostics.Process.Start(startInfo);
|
|
|
+ Thread.Sleep(1000);
|
|
|
+
|
|
|
+ //保存页面
|
|
|
+ Double scaleX = PrimaryScreen.ScaleX;
|
|
|
+ Double scaleY = PrimaryScreen.ScaleY;
|
|
|
+ Bitmap bit = new Bitmap((int)(this.Width * scaleX), (int)(this.Height * scaleY));//实例化一个和窗体一样大的bitmap
|
|
|
+ Graphics g = Graphics.FromImage(bit);
|
|
|
+ g.CopyFromScreen((int)(this.Left * scaleX), (int)(this.Top * scaleY), 0, 0, new Size((int)(this.Width * scaleX), (int)(this.Height * scaleY)));//保存整个窗体为图片
|
|
|
+ bit.Save(LocalPath + "\\" + fileName + ".png");
|
|
|
+
|
|
|
+ //生成pdf文件,上传服务器
|
|
|
+ //...
|
|
|
+
|
|
|
+ //上传
|
|
|
+ bool result1 = myFtp.UploadFile(LocalPath + "\\" + fileName + ".src", ServerPath);
|
|
|
+ bool result2 = myFtp.UploadFile(LocalPath + "\\" + fileName + ".ttcfg", ServerPath);
|
|
|
+ bool result3 = myFtp.UploadFile(LocalPath + "\\" + fileName + ".png", ServerPath);
|
|
|
+ if (result1 & result2 & result3)
|
|
|
+ {
|
|
|
+ MessageBoxTimeOut.Show("上传成功", "提示", 1000, MessageBoxButtons.OK);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MessageBox.Show("上传失败", "提示", MessageBoxButtons.OK);
|
|
|
+ }
|
|
|
}
|
|
|
+ //导出本地指定路径
|
|
|
else
|
|
|
{
|
|
|
- MessageBox.Show("上传失败", "提示", MessageBoxButtons.OK);
|
|
|
+ SaveFileDialog saveFileDialog = new SaveFileDialog();
|
|
|
+ saveFileDialog.Filter = "配置文件(*.ttcfg)|*.ttcfg";
|
|
|
+ DialogResult result = saveFileDialog.ShowDialog();
|
|
|
+ if (result == DialogResult.OK)
|
|
|
+ {
|
|
|
+ string filePath = saveFileDialog.FileName + "_" + DateTime.Now.ToString("yyyyMMddHHmmss");
|
|
|
+ //保存src文件
|
|
|
+ System.IO.File.WriteAllText(filePath + ".src", richTextBox_AdvanceParams.Text);
|
|
|
+ //检查是否存在转换工具
|
|
|
+ if (!Directory.Exists(localInfo.ToolsPath + "\\" + "GenerateParamsFile"))
|
|
|
+ {
|
|
|
+ Directory.CreateDirectory(localInfo.ToolsPath + "\\" + "GenerateParamsFile");
|
|
|
+ myFtp.DownloadFile("Tools/GenerateParamsFile/ConsoleApp2.exe", localInfo.ToolsPath + "\\" + "GenerateParamsFile");
|
|
|
+ myFtp.DownloadFile("Tools/GenerateParamsFile/Newtonsoft.Json.xml", localInfo.ToolsPath + "\\" + "GenerateParamsFile");
|
|
|
+ myFtp.DownloadFile("Tools/GenerateParamsFile/Newtonsoft.Json.dll", localInfo.ToolsPath + "\\" + "GenerateParamsFile");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //程序使用最新版本
|
|
|
+ if (System.IO.File.Exists(localInfo.ToolsPath + "\\" + "GenerateParamsFile" + "\\" + "ConsoleApp2.exe"))
|
|
|
+ System.IO.File.Delete(localInfo.ToolsPath + "\\" + "GenerateParamsFile" + "\\" + "ConsoleApp2.exe");
|
|
|
+ myFtp.DownloadFile("Tools/GenerateParamsFile/ConsoleApp2.exe", localInfo.ToolsPath + "\\" + "GenerateParamsFile");
|
|
|
+ //库文件不更新
|
|
|
+ if (!System.IO.File.Exists(localInfo.ToolsPath + "\\" + "GenerateParamsFile" + "\\" + "Newtonsoft.Json.xml"))
|
|
|
+ myFtp.DownloadFile("Tools/GenerateParamsFile/Newtonsoft.Json.xml", localInfo.ToolsPath + "\\" + "GenerateParamsFile");
|
|
|
+ if (!System.IO.File.Exists(localInfo.ToolsPath + "\\" + "GenerateParamsFile" + "\\" + "Newtonsoft.Json.dll"))
|
|
|
+ myFtp.DownloadFile("Tools/GenerateParamsFile/Newtonsoft.Json.dll", localInfo.ToolsPath + "\\" + "GenerateParamsFile");
|
|
|
+ }
|
|
|
+ //转换.ttcfg文件
|
|
|
+ ProcessStartInfo startInfo = new ProcessStartInfo();
|
|
|
+ startInfo.FileName = localInfo.ToolsPath + "\\" + "GenerateParamsFile" + "\\" + "ConsoleApp2.exe";
|
|
|
+ startInfo.Arguments = filePath + ".src";
|
|
|
+ System.Diagnostics.Process.Start(startInfo);
|
|
|
+ Thread.Sleep(1000);
|
|
|
+
|
|
|
+ MessageBoxTimeOut.Show("导出本地完成", "提示", 1000, MessageBoxButtons.OK);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-
|
|
|
}
|
|
|
|
|
|
}
|