|
@@ -1,4 +1,5 @@
|
|
-using System;
|
|
|
|
|
|
+using Microsoft.Win32;
|
|
|
|
+using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.IO;
|
|
@@ -55,11 +56,36 @@ namespace UAS_XmlAnalysor
|
|
Properties.Settings.Default.BackUpFolderPath = BackUpFolderPath.Text;
|
|
Properties.Settings.Default.BackUpFolderPath = BackUpFolderPath.Text;
|
|
Properties.Settings.Default.Source = Source.Text;
|
|
Properties.Settings.Default.Source = Source.Text;
|
|
Properties.Settings.Default.Master = Master.Text;
|
|
Properties.Settings.Default.Master = Master.Text;
|
|
|
|
+ Properties.Settings.Default.AutoStart = AutoStart.Checked;
|
|
Properties.Settings.Default.Save();
|
|
Properties.Settings.Default.Save();
|
|
Source.Enabled = false;
|
|
Source.Enabled = false;
|
|
|
|
+ StartWatch.Enabled = false;
|
|
|
|
+ SetAutoRun();
|
|
OperateResult.AppendText("开始执行监控\n");
|
|
OperateResult.AppendText("开始执行监控\n");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void SetAutoRun()
|
|
|
|
+ {
|
|
|
|
+ if (AutoStart.Checked) //设置开机自启动
|
|
|
|
+ {
|
|
|
|
+ string path = Application.ExecutablePath;
|
|
|
|
+ RegistryKey rk = Registry.LocalMachine;
|
|
|
|
+ RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
|
|
|
|
+ rk2.SetValue("UAS_XML解析器.exe", path);
|
|
|
|
+ rk2.Close();
|
|
|
|
+ rk.Close();
|
|
|
|
+ }
|
|
|
|
+ else //取消开机自启动
|
|
|
|
+ {
|
|
|
|
+ string path = Application.ExecutablePath;
|
|
|
|
+ RegistryKey rk = Registry.LocalMachine;
|
|
|
|
+ RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
|
|
|
|
+ rk2.DeleteValue("UAS_XML解析器.exe", false);
|
|
|
|
+ rk2.Close();
|
|
|
|
+ rk.Close();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
private void XmlWatcher_Created(object sender, FileSystemEventArgs e)
|
|
private void XmlWatcher_Created(object sender, FileSystemEventArgs e)
|
|
{
|
|
{
|
|
while (true)
|
|
while (true)
|
|
@@ -73,18 +99,24 @@ namespace UAS_XmlAnalysor
|
|
}
|
|
}
|
|
System.Threading.Thread.Sleep(500);
|
|
System.Threading.Thread.Sleep(500);
|
|
}
|
|
}
|
|
- catch (Exception)
|
|
|
|
- {
|
|
|
|
- }
|
|
|
|
|
|
+ catch (Exception) { }
|
|
}
|
|
}
|
|
|
|
+ string testDate = "";
|
|
|
|
+ string testTime = "";
|
|
XmlReader myReader = XmlReader.Create(FolderPath.Text + @"\" + e.Name);
|
|
XmlReader myReader = XmlReader.Create(FolderPath.Text + @"\" + e.Name);
|
|
string sncode = e.Name.Split('.')[0];
|
|
string sncode = e.Name.Split('.')[0];
|
|
|
|
+ string iMakeCode = dh.getFieldDataByCondition("makeserial", "ms_makecode", "ms_sncode='" + sncode + "'").ToString();
|
|
OperateResult.AppendText("读取文件" + e.Name + "\n");
|
|
OperateResult.AppendText("读取文件" + e.Name + "\n");
|
|
List<string> name = new List<string>();
|
|
List<string> name = new List<string>();
|
|
List<string> result = new List<string>();
|
|
List<string> result = new List<string>();
|
|
int name_or_result = 0;
|
|
int name_or_result = 0;
|
|
while (myReader.Read())
|
|
while (myReader.Read())
|
|
{
|
|
{
|
|
|
|
+ if (myReader.NodeType == XmlNodeType.Element && myReader.Name == "test")
|
|
|
|
+ {
|
|
|
|
+ testDate = myReader.GetAttribute(1);
|
|
|
|
+ testTime = myReader.GetAttribute(0);
|
|
|
|
+ }
|
|
if (myReader.NodeType == XmlNodeType.Text)
|
|
if (myReader.NodeType == XmlNodeType.Text)
|
|
{
|
|
{
|
|
if (name_or_result % 2 == 0)
|
|
if (name_or_result % 2 == 0)
|
|
@@ -99,7 +131,11 @@ namespace UAS_XmlAnalysor
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- string sql = "insert into STEPTESTDETAIL(std_id,std_sn,std_subclass1,std_testresult,std_date,std_rescode) values (STEPTESTDETAIL_seq.nextval,'" + sncode + "',:std_subclass1,:std_testresult,sysdate,'" + Source.Text + "')";
|
|
|
|
|
|
+ string date = testDate + " " + testTime;
|
|
|
|
+ string sql = "insert into STEPTESTDETAIL(std_id,std_makecode,std_sn,std_subclass1,std_testresult,std_indate,";
|
|
|
|
+ sql += "std_rescode,std_testdate,std_testtime,std_date) values(STEPTESTDETAIL_seq.nextval, '" + iMakeCode + "', ";
|
|
|
|
+ sql += "'" + sncode + "',:std_subclass1,:std_testresult, sysdate,'" + Source.Text + "',to_char(to_date('"+testDate+"','YYYY/MM/DD'), 'YYYYMMDD'),";
|
|
|
|
+ sql += "to_char(to_date('"+testTime+ "','hh24:mi:ss'), 'hh24miss'),to_date('"+ date + "','YYYY/MM/DD hh24:mi:ss'))";
|
|
dh.BatchInsert(sql, new string[] { "std_subclass1", "std_testresult" }, name.ToArray(), result.ToArray());
|
|
dh.BatchInsert(sql, new string[] { "std_subclass1", "std_testresult" }, name.ToArray(), result.ToArray());
|
|
myReader.Close();
|
|
myReader.Close();
|
|
FileInfo file = new FileInfo(FolderPath.Text + @"\" + e.Name);
|
|
FileInfo file = new FileInfo(FolderPath.Text + @"\" + e.Name);
|
|
@@ -111,7 +147,7 @@ namespace UAS_XmlAnalysor
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
{
|
|
{
|
|
- OperateResult.AppendText(e.Name + ex.Message+"\n");
|
|
|
|
|
|
+ OperateResult.AppendText(e.Name + ex.Message + "\n");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -120,6 +156,7 @@ namespace UAS_XmlAnalysor
|
|
{
|
|
{
|
|
XmlWatcher.EnableRaisingEvents = false;
|
|
XmlWatcher.EnableRaisingEvents = false;
|
|
Source.Enabled = true;
|
|
Source.Enabled = true;
|
|
|
|
+ StartWatch.Enabled = true;
|
|
OperateResult.AppendText("停止执行监控\n");
|
|
OperateResult.AppendText("停止执行监控\n");
|
|
}
|
|
}
|
|
|
|
|