/// <summary> /// 获取Product表相关信息 /// </summary> /// <param name="line">line</param> /// <param name="editor">editor</param> /// <param name="station">station</param> /// <param name="customer">customer</param> /// <param name="customerSN">customer SN</param> public S_RowData_Product GetProduct(string line, string editor, string station, string customer,string customerSN) { logger.Debug("(_CombineCOAandDN)GetProduct start.customerSN:" + customerSN); string keyStr = ""; try { var currentProduct = CommonImpl.GetProductByInput(customerSN, CommonImpl.InputTypeEnum.CustSN); if (null == currentProduct) { List<string> errpara = new List<string>(); errpara.Add(customerSN); throw new FisException("SFC002", errpara); } if (!string.IsNullOrEmpty(currentProduct.CartonSN)) { string temp = "CartonSN:" + currentProduct.CartonSN.ToString(); List<string> errpara = new List<string>(); errpara.Add(temp); throw new FisException("CHK858", errpara); } if (!string.IsNullOrEmpty(currentProduct.DeliveryNo)) { string temp = "DeliveryNo:" + currentProduct.DeliveryNo.ToString(); List<string> errpara = new List<string>(); errpara.Add(temp); throw new FisException("CHK858", errpara); } if (!string.IsNullOrEmpty(currentProduct.PalletNo)) { string temp = "PalletNo:" + currentProduct.PalletNo.ToString(); List<string> errpara = new List<string>(); errpara.Add(temp); throw new FisException("CHK858", errpara); } if (!string.IsNullOrEmpty(currentProduct.PizzaID)) { string temp = "PizzaID:" + currentProduct.PizzaID.ToString(); List<string> errpara = new List<string>(); errpara.Add(temp); throw new FisException("CHK858", errpara); } if ( currentProduct.CartonWeight == (decimal)0.00) { } else { string temp = "CartonWeight:" + currentProduct.CartonWeight.ToString(); List<string> errpara = new List<string>(); errpara.Add(temp); throw new FisException("CHK858", errpara); } } catch (FisException e) { logger.Error(e.mErrmsg); throw e; } catch (Exception e) { logger.Error(e.Message); throw e; } try { string sessionKey = customerSN; keyStr = sessionKey; Session currentSession = new Session(sessionKey, SessionType, editor, station, line, customer); Dictionary<string, object> wfArguments = new Dictionary<string, object>(); wfArguments.Add("Key", sessionKey); wfArguments.Add("Station", station); wfArguments.Add("CurrentFlowSession", currentSession); wfArguments.Add("Editor", editor); wfArguments.Add("PdLine", line); wfArguments.Add("Customer", customer); wfArguments.Add("SessionType", SessionType); string wfName, rlName; RouteManagementUtils.GetWorkflow(station, "CombineCOAandDNBlock.xoml", "", out wfName, out rlName); WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments); currentSession.AddValue(Session.SessionKeys.CustSN, customerSN); currentSession.SetInstance(instance); if (!SessionManager.GetInstance.AddSession(currentSession)) { currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists."); } currentSession.WorkflowInstance.Start(); currentSession.SetHostWaitOne(); if (currentSession.Exception != null) { if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null) { currentSession.ResumeWorkFlow(); } throw currentSession.Exception; } string isBSaM = currentSession.GetValue(ExtendSession.SessionKeys.IsBSamModel) as string; S_RowData_Product ret = new S_RowData_Product(); ret.DN = ""; ret.Model = ""; ret.isBSaM = ""; ret.ProductID = ""; ret.isBT = "false"; ret.isCDSI = ""; ret.isFactoryPo = ""; ret.isWin8 = ""; IProduct temp = productRepository.GetProductByCustomSn(customerSN); if (null != temp) { ret.ProductID = temp.ProId; ret.isBT = temp.IsBT.ToString(); ret.Model = temp.Model; IList<IMES.FisObject.Common.Model.ModelInfo> isPO = modelRep.GetModelInfoByModelAndName(temp.Model, "PO"); foreach (IMES.FisObject.Common.Model.ModelInfo tmpPO in isPO) { if (tmpPO.Value == "Y") { ret.isCDSI = "true"; } else { IList<IMES.FisObject.Common.Model.ModelInfo> isATSNAV = modelRep.GetModelInfoByModelAndName(temp.Model, "ATSNAV"); foreach (IMES.FisObject.Common.Model.ModelInfo tmpATSNAV in isATSNAV) { if (tmpATSNAV.Value == null) { } else if (tmpATSNAV.Value != "") { ret.isCDSI = "true"; } break; } } break; } if (ret.isCDSI == "true") { CdsiastInfo condition = new CdsiastInfo(); condition.snoId = temp.ProId; condition.tp = "FactoryPO"; IList<CdsiastInfo> isCdsiastInfo = productRepository.GetCdsiastInfoList(condition); ret.isFactoryPo = ""; foreach (CdsiastInfo tmpCdsiastInfo in isCdsiastInfo) { ret.isFactoryPo = tmpCdsiastInfo.sno; break; } if (ret.isBT == "true" || ret.isBT == "True") { } else { if (ret.isFactoryPo == "" || ret.isFactoryPo == null) { throw new FisException("CHK882", new string[] { }); } } } //Vincent 2015-02-26 Mo 綁訂PoNo else if (temp.IsBindedPo) { ret.isCDSI = "true"; ret.isFactoryPo = temp.BindPoNo; } //Marked by Benson at 20130517 For CQ Mantis 24 // IList<MoBOMInfo> win8list = bomRepository.GetPnListByModelAndBomNodeTypeAndDescr(temp.Model, "P1", "ECOA"); // if (win8list != null && win8list.Count > 0) //Marked by Benson at 20130517 For CQ Mantis 24 bool bWIN8 = false; CommonImpl2 cm2 = new CommonImpl2(); IHierarchicalBOM bom = bomRepository.GetHierarchicalBOMByModel(temp.Model); bWIN8=cm2.CheckIsWIN8(bom); if(bWIN8) { // mantis 1574 IList<string> valueList = ipartRepository.GetValueFromSysSettingByName("Site"); if (valueList.Count == 0) { throw new Exception("Error:尚未設定Site..."); } string errMsg = ""; IList<string> typeList = new List<string>(); typeList.Add("P/N"); typeList.Add("Key"); if (valueList[0] == "ICC") { typeList.Add("COA"); } else { typeList.Add("Hash"); } IList<IMES.FisObject.FA.Product.ProductInfo> infoList = productRepository.GetProductInfoList(temp.ProId, typeList); if (infoList != null) { StringBuilder infoTypes = new StringBuilder(); foreach (var v in infoList) { if ((null != v.InfoValue) && !string.IsNullOrEmpty(v.InfoValue.Trim())) infoTypes.Append(v.InfoType).Append(","); } string win8Type = infoTypes.ToString(); foreach (string s in typeList) { if (!(win8Type.Contains(s))) errMsg += s+ "缺少 "; } } else { foreach (string s in typeList) errMsg += s + "缺少 "; } if (!string.IsNullOrEmpty(errMsg)) { throw new FisException("CHK969", new string[] { errMsg }); } ret.isWin8 = "true"; } if (!"Y".Equals(isBSaM)) { if (ret.isCDSI == "true") { DNQueryCondition conditionDN = new DNQueryCondition(); DateTime aTime = DateTime.Now; aTime = aTime.AddDays(-3); conditionDN.ShipDateFrom = new DateTime(aTime.Year, aTime.Month, aTime.Day, 0, 0, 0, 0); conditionDN.Model = ret.Model; if (conditionDN.Model != "") { IList<Srd4CoaAndDn> dnList = currentRepository.GetDNListByConditionForPerformanceWithSorting(conditionDN); foreach (Srd4CoaAndDn tmp in dnList) { if (ret.isFactoryPo != "") { if (ret.isFactoryPo != tmp.PoNo) { continue; } } ret.DN = tmp.DeliveryNO; break; } } } else { Delivery assignDelivery = null; int assignQty = 0; // modify for other model, ex: Jamestown in mantis 1945 //IList<Delivery> deliveryList = currentRepository.GetDeliveryListByModel(ret.Model,"PC",12,"00"); IList<Delivery> deliveryList = getDnByModel(ret.Model); //Vincent 2015-02-27 過濾綁訂PoDN IList<string> bindPoNoList = moRep.GetBindPoNoByModel(ret.Model); if (bindPoNoList != null && bindPoNoList.Count > 0) { deliveryList = deliveryList.Where(x => !bindPoNoList.Contains(x.PoNo)).ToList(); } if (deliveryList.Count == 0) { if (temp.IsBT) { } else { List<string> errpara = new List<string>(); errpara.Add(customerSN); throw new FisException("PAK101", errpara);//无此机型Delivery! } } //a) ShipDate 越早,越优先 //b) 散装优先于非散装 //c) 剩余未包装Product数量越少的越优先 bool assignNA = false; foreach (Delivery dvNode in deliveryList) { int curqty = productRepository.GetCombinedQtyByDN(dvNode.DeliveryNo); int tmpqty = dvNode.Qty - curqty; int curQty = productRepository.GetCombinedQtyByDN(dvNode.DeliveryNo); if (tmpqty > 0 ) { bool naflag = false; foreach (DeliveryPallet dpNode in dvNode.DnPalletList) { if (dpNode.PalletID.Substring(0, 2) == "NA") { naflag = true; break; } } if (assignDelivery == null) { assignDelivery = dvNode; assignQty = tmpqty; assignNA = naflag; continue; } if (DateTime.Compare(assignDelivery.ShipDate, dvNode.ShipDate) < 0) { continue; } if (!assignNA && naflag) { assignDelivery = dvNode; assignQty = tmpqty; assignNA = naflag; } else if (assignNA == naflag) { if (tmpqty < assignQty) { assignDelivery = dvNode; assignQty = tmpqty; assignNA = naflag; } } } } if (assignDelivery == null) { if (temp.IsBT) { } else { FisException fe = new FisException("PAK103", new string[] { }); //没找到可分配的delivery throw fe; } } else { ret.DN = assignDelivery.DeliveryNo; } } } else // isBSaM { //if (! ChkInDelivery(ret.Model)) //{ // List<string> errpara = new List<string>(); // errpara.Add(ret.Model); // throw new FisException("PAK174", errpara); //} if (ChkInCartonLoc(ret.ProductID)) { List<string> errpara = new List<string>(); errpara.Add(ret.ProductID); throw new FisException("PAK175", errpara); } ret.isBSaM = isBSaM; //Y } } return ret; } catch (FisException e) { logger.Error(e.mErrmsg); throw e; } catch (Exception e) { logger.Error(e.Message); throw e; } finally { Session sessionDelete = SessionManager.GetInstance.GetSession(keyStr, SessionType); ; if (sessionDelete != null) { SessionManager.GetInstance.RemoveSession(sessionDelete); } logger.Debug("(_CombineCOAandDN)GetProduct end, customerSN:" + customerSN); } }
/// <summary> /// 取ModelBOM 中Model 直接下阶中有BomNodeType 为'P1' 的Part /// </summary> /// <param name="custSN">custSN</param> public string CheckBOM(string custSN) { string ret = "NotFind"; try { IProduct product = productRepository.GetProductByCustomSn(custSN); if (product == null) { return ret; } string model = product.Model; // 取ModelBOM 中Model 直接下阶中有BomNodeType 为'P1' 的Part IBOMRepository ibomRepository = RepositoryFactory.GetInstance().GetRepository<IMES.FisObject.Common.FisBOM.IBOMRepository>(); IHierarchicalBOM sessionBOM = null; sessionBOM = ibomRepository.GetHierarchicalBOMByModel(product.Model); CommonImpl2 cm2 = new CommonImpl2(); string site = cm2.GetSite(); if (site == "ICC" && cm2.CheckIsWIN8(sessionBOM)) { return ret; } IList<IBOMNode> bomNodeLst = new List<IBOMNode>(); bomNodeLst = sessionBOM.FirstLevelNodes; if (bomNodeLst != null && bomNodeLst.Count > 0) { foreach (IBOMNode ibomnode in bomNodeLst) { IPart currentPart = ibomnode.Part; if (currentPart.BOMNodeType == "P1" && currentPart.Descr.IndexOf("COA") == 0) { return currentPart.PN; } } } return ret; } catch (Exception ee) { throw ee; } }
private bool CheckOA3Key(IHierarchicalBOM bom, IProduct p, string fkiPath, CredentialCache FKICredentialCache, string editor, UnitOfWork uow) { bool bWIN8 = false; IList<IBOMNode> P1BomNodeList = bom.GetFirstLevelNodesByNodeType("P1"); //foreach (IBOMNode bomNode in P1BomNodeList) //{ // if (bomNode.Part.Descr.StartsWith("ECOA")) // { // bWIN8 = true; // break; // } //} CommonImpl2 cm2 = new CommonImpl2(); bWIN8 = cm2.CheckIsWIN8(bom); if (!bWIN8) return true; if (fkiPath == "") return true; //Switch off checking by FKIServer. string thisURI = ""; if (fkiPath.EndsWith("/")) { thisURI = fkiPath + "UnitStatus"; } else { thisURI = fkiPath + "/UnitStatus"; } HttpWebRequest req = (HttpWebRequest)WebRequest.Create(thisURI); req.AllowAutoRedirect = true; req.CookieContainer = new CookieContainer(); req.ContentType = "application/plain; charset=utf-8"; req.Accept = "*/*"; req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"; req.KeepAlive = true; req.Method = "POST"; req.Credentials = FKICredentialCache.GetCredential(new Uri(fkiPath), "NTLM"); string XMLInputData = "<?xml version='1.0' encoding='utf-8' ?>"; XMLInputData += "<UnitStatusRequest xmlns='http://HP.ITTS.OA30/digitaldistribution/2011/08'>"; XMLInputData += "<HPSerialNumber>"; XMLInputData += p.CUSTSN; XMLInputData += "</HPSerialNumber>"; XMLInputData += "<ProductKeyID>"; XMLInputData += ""; XMLInputData += "</ProductKeyID>"; XMLInputData += "</UnitStatusRequest>"; Encoding encoding = Encoding.Default; byte[] buffer = encoding.GetBytes(XMLInputData); req.ContentLength = buffer.Length; req.GetRequestStream().Write(buffer, 0, buffer.Length); HttpWebResponse res = (HttpWebResponse)req.GetResponse(); XmlTextReader xmlr = new XmlTextReader(res.GetResponseStream()); string status = ""; string rc = ""; bool bError = false; bool bFound = false; StringBuilder str = new StringBuilder("Formatted Response:\n"); while (xmlr.Read()) { switch (xmlr.NodeType) { case XmlNodeType.Element: if (xmlr.IsEmptyElement) str.AppendFormat("<{0}/>", xmlr.Name); else str.AppendFormat("<{0}>", xmlr.Name); break; case XmlNodeType.Text: str.Append(xmlr.Value); break; case XmlNodeType.CDATA: str.AppendFormat("<![CDATA[{0}]]>", xmlr.Value); break; case XmlNodeType.ProcessingInstruction: str.AppendFormat("<?{0} {1}?>", xmlr.Name, xmlr.Value); break; case XmlNodeType.Comment: str.AppendFormat("<!--{0}-->", xmlr.Value); break; case XmlNodeType.XmlDeclaration: str.AppendFormat("<?xml version='1.0'?>"); break; case XmlNodeType.DocumentType: str.AppendFormat("<!DOCTYPE{0} [{1}]>", xmlr.Name, xmlr.Value); break; case XmlNodeType.EntityReference: str.Append(xmlr.Name); break; case XmlNodeType.EndElement: str.AppendFormat("</{0}>", xmlr.Name); break; case XmlNodeType.Whitespace: str.Append("\n"); break; } if (xmlr.NodeType == System.Xml.XmlNodeType.Element && xmlr.LocalName.Equals("ReturnCode")) { xmlr.Read(); str.Append(xmlr.Value); rc = xmlr.Value.Trim(); if (rc != "000") bError = true; continue; } if (xmlr.NodeType == System.Xml.XmlNodeType.Element && xmlr.LocalName.Equals("ReturnMessage")) { if (bError) { xmlr.Read(); str.Append(xmlr.Value); string msg = xmlr.Value; xmlr.Close(); throw new Exception("[" + rc + "]:" + msg); } } if (xmlr.NodeType == System.Xml.XmlNodeType.Element && xmlr.LocalName.Equals("ProductKeyStateName")) { xmlr.Read(); str.Append(xmlr.Value); status = xmlr.Value; // Marked this by Benson at 2013/3/8 // if (status == "NotifiedBound") if (status == "NotifiedBound" || status == "FKIErrorBound") { //只能有一行状态为"Bound"/"NotifiedBound"/"PendingBound" --OLD //只能有一行状态为"Bound"/"NotifiedBound"/"PendingBound/FKIErrorBound" --NEW add by Benson at 2013/3/8 if (bFound) { xmlr.Close(); return false; } bFound = true; continue; } if (status == "Bound" || status == "PendingBound") { //只能有一行状态为"Bound"/"NotifiedBound"/"PendingBound" if (bFound) { xmlr.Close(); return false; } bFound = true; //对于状态为Bound/PendingBound的Product需要记录到ProductInfo中 IMES.FisObject.FA.Product.ProductInfo item = new IMES.FisObject.FA.Product.ProductInfo(); item.ProductID = p.ProId; item.InfoType = "Win8KeyState"; item.InfoValue = status; item.Editor = editor; if (productRepository.CheckExistProductInfo(p.ProId, "Win8KeyState")) { IMES.FisObject.FA.Product.ProductInfo cond = new IMES.FisObject.FA.Product.ProductInfo(); cond.ProductID = p.ProId; cond.InfoType = "Win8KeyState"; productRepository.UpdateProductInfoDefered(uow, item, cond); } else { productRepository.InsertProductInfoDefered(uow, item); } continue; } //Returned 或PendingReturn或NotifiedReturned或FKIErrorReturn --Mantis0001691 // Marked this by Benson at 2013/3/8 // if (status != "Returned" && status != "NotifiedReturned" && status != "PendingReturn") if (status != "Returned" && status != "NotifiedReturned" && status != "PendingReturn" && status != "FKIErrorReturn") { xmlr.Close(); return false; } } } xmlr.Close(); Console.Write(str.ToString()); return bFound; }