using System; using Microsoft.VisualBasic; using static iMESCore.Base.iMESComSubroutine; using static iMESCore.Base.iMESComXML; using static iMESCore.Base.iMESConst; using iMESCore.Settings; namespace wsSXS { public class wsWIP { private iMESCore.Settings.AppSettings objSetting = new iMESCore.Settings.AppSettings(); private System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); // 用以讀取Xml字串 private DateTime ArriveTime; // 送達時間 private string strIdentity; // Identity XML字串 private string strReturnValue; // ReturnValue XML字串 private string strException; // Exception XML字串 private string strResult; // Result XML字串 private string strMessage; // Message XML字串 private string strServiceName = "wsWIP_SXS"; // ServiceName private string strResourceDir = "Resources"; private kcSYS.clsSYSUserLog objSYS = new kcSYS.clsSYSUserLog(); // 宣告Sys的物件 public wsWIP() { try { strResourceDir = System.IO.Path.Combine("wsUpdateResource", objSetting["ResourceDir"].ToString()); } catch (Exception) { } } public string HelloWorld(string InXml) { return "HelloWorld"; } public string LoadOPMaterialState(string InXml) { string LoadOPMaterialStateRet = null; // 先給預設值,以判斷是否有傳入該參數 string OPNo = defString; string MaterialNo = defString; string MaterialLotNo = defString; string UnitNo = defString; string MaterialType = defString; ArriveTime = DateTime.Now; try { // 讀取InXml字串 xmlDoc.LoadXml(InXml); // 組Identity字串 strIdentity = CombineXMLIdentity(Environment.MachineName, GetXMLCurUserNo(xmlDoc), ArriveTime.ToString(defDateTimeFormat)); // 判斷是否有傳入OPNo,若有,表示要依OPNo查詢 if (xmlDoc.DocumentElement.GetElementsByTagName("opno").Count > 0) { if (xmlDoc.GetElementsByTagName("opno").Item(0).SelectNodes("value").Count > 0) { OPNo = xmlDoc.DocumentElement.GetElementsByTagName("opno").Item(0).SelectNodes("value").Item(0).InnerText; } } // 判斷是否有傳入MaterialNo,若有,表示要依MaterialNo查詢 if (xmlDoc.DocumentElement.GetElementsByTagName("materialno").Count > 0) { if (xmlDoc.GetElementsByTagName("materialno").Item(0).SelectNodes("value").Count > 0) { MaterialNo = xmlDoc.DocumentElement.GetElementsByTagName("materialno").Item(0).SelectNodes("value").Item(0).InnerText; } } // 判斷是否有傳入MaterialLotNo,若有,表示要依MaterialLotNo查詢 if (xmlDoc.DocumentElement.GetElementsByTagName("materiallotno").Count > 0) { if (xmlDoc.GetElementsByTagName("materiallotno").Item(0).SelectNodes("value").Count > 0) { MaterialLotNo = xmlDoc.DocumentElement.GetElementsByTagName("materiallotno").Item(0).SelectNodes("value").Item(0).InnerText; } } if (xmlDoc.DocumentElement.GetElementsByTagName("unitno").Count > 0) { if (xmlDoc.GetElementsByTagName("unitno").Item(0).SelectNodes("value").Count > 0) { UnitNo = xmlDoc.DocumentElement.GetElementsByTagName("unitno").Item(0).SelectNodes("value").Item(0).InnerText; } } if (xmlDoc.DocumentElement.GetElementsByTagName("materialtype").Count > 0) { if (xmlDoc.GetElementsByTagName("materialtype").Item(0).SelectNodes("value").Count > 0) { MaterialType = xmlDoc.DocumentElement.GetElementsByTagName("materialtype").Item(0).SelectNodes("value").Item(0).InnerText; } } // 呼叫Dll執行 // strReturnValue = objWIP.LoadOPMaterialState(OPNo, MaterialNo, MaterialLotNo, UnitNo, MaterialType); strException = ""; strResult = "success"; } catch (iMESException.MESException ex) { strReturnValue = ""; strException = CombineXMLException(ex.ErrorCode.ToString(), TranslateMsg(ex.Message, GetXMLLanguageMode(xmlDoc), strResourceDir), "Load OP Material State Fail!!", ex.StackTrace); strResult = "fail"; } catch (Exception ex) { strReturnValue = ""; strException = CombineXMLException(defWSErrCode, ex.Message, "Load OP Material State Fail!!", ex.StackTrace); strResult = "fail"; } finally { // 將各部份之XML字串組起來並傳出 LoadOPMaterialStateRet = CombineXMLResponse(strIdentity, strReturnValue, strException, strResult, ""); } return LoadOPMaterialStateRet; } } }