|
|
@@ -7,6 +7,7 @@ using System.Threading;
|
|
|
using System.Windows.Forms;
|
|
|
using System.Xml;
|
|
|
using UAS_AutoPass.ToolClass;
|
|
|
+using BenQGuru.eMES.DLLService;
|
|
|
|
|
|
namespace UAS_AutoPass
|
|
|
{
|
|
|
@@ -17,15 +18,21 @@ namespace UAS_AutoPass
|
|
|
|
|
|
DataTable dt;
|
|
|
|
|
|
+ MESHelper helper = new MESHelper();
|
|
|
+
|
|
|
+ string iusercode;
|
|
|
+
|
|
|
+ string isource;
|
|
|
+
|
|
|
Thread InitDB;
|
|
|
/// <summary>
|
|
|
/// 缓存的文件
|
|
|
/// </summary>
|
|
|
- string CachePath = Environment.GetEnvironmentVariable("windir").Substring(0, 1) + @":/UAS_MES/XmlAnalysor/Cache.xml";
|
|
|
+ public static string CachePath = Environment.GetEnvironmentVariable("windir").Substring(0, 1) + @":/UAS_MES/XmlAnalysor/Cache.xml";
|
|
|
/// <summary>
|
|
|
/// 缓存的文件夹
|
|
|
/// </summary>
|
|
|
- string CachePathFolder = Environment.GetEnvironmentVariable("windir").Substring(0, 1) + @":/UAS_MES/XmlAnalysor/";
|
|
|
+ public static string CachePathFolder = Environment.GetEnvironmentVariable("windir").Substring(0, 1) + @":/UAS_MES/XmlAnalysor/";
|
|
|
|
|
|
public AutoAnalysisXml()
|
|
|
{
|
|
|
@@ -33,6 +40,14 @@ namespace UAS_AutoPass
|
|
|
StartPosition = FormStartPosition.CenterScreen;
|
|
|
}
|
|
|
|
|
|
+ public AutoAnalysisXml(string iUserName, string iSource)
|
|
|
+ {
|
|
|
+ InitializeComponent();
|
|
|
+ iusercode = iUserName;
|
|
|
+ isource = iSource;
|
|
|
+ StartPosition = FormStartPosition.CenterScreen;
|
|
|
+ }
|
|
|
+
|
|
|
private void Form1_Load(object sender, EventArgs e)
|
|
|
{
|
|
|
CheckForIllegalCrossThreadCalls = false;
|
|
|
@@ -50,24 +65,12 @@ namespace UAS_AutoPass
|
|
|
Master.ValueMember = "ma_user";
|
|
|
try
|
|
|
{
|
|
|
- if (!Directory.Exists(CachePathFolder))
|
|
|
- Directory.CreateDirectory(CachePathFolder);
|
|
|
- XmlReader myReader = XmlReader.Create(CachePath);
|
|
|
- while (myReader.Read())
|
|
|
- {
|
|
|
- if (myReader.NodeType == XmlNodeType.Text)
|
|
|
- CacheInf.Add(myReader.Value);
|
|
|
- }
|
|
|
- myReader.Close();
|
|
|
- string[] Info = CacheInf.ToArray();
|
|
|
- FolderPath.Text = Info[0];
|
|
|
- BackUpFolderPath.Text = Info[1];
|
|
|
- Source.Text = Info[2];
|
|
|
- Master.Text = Info[3];
|
|
|
- AutoStart.Checked = (Info[4] == "True" ? true : false);
|
|
|
+ FolderPath.Text = BaseUtil.GetCacheData("FolderPath").ToString();
|
|
|
+ BackUpFolderPath.Text = BaseUtil.GetCacheData("BackUpFolderPath").ToString();
|
|
|
+ Master.Text = BaseUtil.GetCacheData("Master").ToString();
|
|
|
+ AutoStart.Checked = (bool)BaseUtil.GetCacheData("AutoStart");
|
|
|
}
|
|
|
- catch (Exception) { }
|
|
|
- StartWatch.PerformClick();
|
|
|
+ catch (Exception ex) { Console.WriteLine(ex.Message); }
|
|
|
}
|
|
|
|
|
|
private void ConnectDB()
|
|
|
@@ -108,35 +111,21 @@ namespace UAS_AutoPass
|
|
|
dh = new DataHelper();
|
|
|
}
|
|
|
}
|
|
|
- if (!dh.CheckExist("source", "sc_code='" + Source.Text + "' and sc_statuscode='AUDITED'"))
|
|
|
+ if (!dh.CheckExist("make", "ma_statuscode='STARTED' and ma_code='" + MakeCode.Text + "'"))
|
|
|
{
|
|
|
- OperateResult.AppendText("岗位资源错误或者未审核\n");
|
|
|
+ OperateResult.AppendText("工单不存在或者未下放\n");
|
|
|
return;
|
|
|
}
|
|
|
XmlWatcher.Path = FolderPath.Text;
|
|
|
XmlWatcher.Filter = "*.xml";
|
|
|
XmlWatcher.EnableRaisingEvents = true;
|
|
|
- try
|
|
|
- {
|
|
|
- File.Delete(CachePath);
|
|
|
- }
|
|
|
- catch (Exception) { }
|
|
|
- XmlDocument xmlDoc = new XmlDocument();
|
|
|
- //创建类型声明节点
|
|
|
- XmlNode node = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", "");
|
|
|
- xmlDoc.AppendChild(node);
|
|
|
- //创建根节点
|
|
|
- XmlElement xeRoot = xmlDoc.CreateElement("CacheInf");
|
|
|
- xmlDoc.AppendChild(xeRoot);
|
|
|
- CreateNode(xmlDoc, xeRoot, "FolderPath", FolderPath.Text);
|
|
|
- CreateNode(xmlDoc, xeRoot, "BackUpFolderPath", BackUpFolderPath.Text);
|
|
|
- CreateNode(xmlDoc, xeRoot, "Source", Source.Text);
|
|
|
- CreateNode(xmlDoc, xeRoot, "Master", Master.Text);
|
|
|
- CreateNode(xmlDoc, xeRoot, "AutoStart", AutoStart.Checked.ToString());
|
|
|
- xmlDoc.Save(CachePath);
|
|
|
- Source.Enabled = false;
|
|
|
+ BaseUtil.SetCacheData("FolderPath", FolderPath.Text);
|
|
|
+ BaseUtil.SetCacheData("BackUpFolderPath", BackUpFolderPath.Text);
|
|
|
+ BaseUtil.SetCacheData("Master", Master.Text);
|
|
|
+ BaseUtil.SetCacheData("AutoStart", AutoStart.Checked);
|
|
|
StartWatch.Enabled = false;
|
|
|
ChooseFolder.Enabled = false;
|
|
|
+ MakeCode.Enabled = false;
|
|
|
ChooseBackUpFolder.Enabled = false;
|
|
|
StopWatch.Enabled = true;
|
|
|
OperateResult.AppendText("开始执行监控\n");
|
|
|
@@ -188,8 +177,10 @@ namespace UAS_AutoPass
|
|
|
Console.WriteLine(ex.Message);
|
|
|
}
|
|
|
}
|
|
|
- string testDate = "";
|
|
|
- string testTime = "";
|
|
|
+ string test_date = "";
|
|
|
+ string test_result = "";
|
|
|
+ string test_sn = "";
|
|
|
+ string imageurl = "";
|
|
|
XmlReader myReader = XmlReader.Create(FolderPath.Text + @"\" + e.Name);
|
|
|
//获取文件名的序列号,如SA123456.xml
|
|
|
string sncode = e.Name.Split('.')[0];
|
|
|
@@ -203,10 +194,12 @@ namespace UAS_AutoPass
|
|
|
int name_or_result = 0;
|
|
|
while (myReader.Read())
|
|
|
{
|
|
|
- if (myReader.NodeType == XmlNodeType.Element && myReader.Name == "test")
|
|
|
+ if (myReader.NodeType == XmlNodeType.Element && myReader.Name == "test" && myReader.IsStartElement())
|
|
|
{
|
|
|
- testDate = myReader.GetAttribute(1);
|
|
|
- testTime = myReader.GetAttribute(0);
|
|
|
+ test_sn = myReader.GetAttribute("test_sn");
|
|
|
+ test_result = myReader.GetAttribute("test_result");
|
|
|
+ test_date = myReader.GetAttribute("test_date");
|
|
|
+ imageurl = myReader.GetAttribute("imgurl");
|
|
|
}
|
|
|
if (myReader.NodeType == XmlNodeType.Text)
|
|
|
{
|
|
|
@@ -222,13 +215,21 @@ namespace UAS_AutoPass
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- 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());
|
|
|
myReader.Close();
|
|
|
+ string ErrMessage = "";
|
|
|
+ if (helper.GoMo(MakeCode.Text, sncode, isource, out ErrMessage))
|
|
|
+ {
|
|
|
+ if (!helper.SetStepFinish(MakeCode.Text, isource, sncode, "自动过站采集", test_result, iusercode, "自动过站不良", out ErrMessage))
|
|
|
+ {
|
|
|
+ OperateResult.AppendText(ErrMessage + "\n");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ OperateResult.AppendText(ErrMessage + "\n");
|
|
|
+ return;
|
|
|
+ }
|
|
|
FileInfo file = new FileInfo(FolderPath.Text + @"\" + e.Name);
|
|
|
if (file.Exists)
|
|
|
{
|
|
|
@@ -260,8 +261,8 @@ namespace UAS_AutoPass
|
|
|
private void StopWatch_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
XmlWatcher.EnableRaisingEvents = false;
|
|
|
- Source.Enabled = true;
|
|
|
StartWatch.Enabled = true;
|
|
|
+ MakeCode.Enabled = true;
|
|
|
ChooseFolder.Enabled = true;
|
|
|
ChooseBackUpFolder.Enabled = true;
|
|
|
StopWatch.Enabled = false;
|
|
|
@@ -315,4 +316,4 @@ namespace UAS_AutoPass
|
|
|
SetAutoRun();
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
+}
|