private Delivery GetNextDelivery(Product curProduct) { IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); IDeliveryRepository deliveryRep = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>(); IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>(); IMORepository moRep = RepositoryFactory.GetInstance().GetRepository<IMORepository>(); Delivery assignDelivery = new Delivery(); CurrentSession.AddValue("HasDN", "N"); //CDSI 机器Assign Delivery的特殊要求 //IList<IMES.FisObject.Common.Model.ModelInfo> GetModelInfoByModelAndName(string model, string name); IList<IMES.FisObject.Common.Model.ModelInfo> infoList = modelRep.GetModelInfoByModelAndName(curProduct.Model, "PO"); Model model = modelRep.Find(curProduct.Model); string cdsi = ""; cdsi = model.GetAttribute("PO"); if (cdsi != "Y") { cdsi = ""; cdsi = model.GetAttribute("ATSNAV"); if (!string.IsNullOrEmpty(cdsi)) { cdsi = "cdsi"; } } else { cdsi = "cdsi"; } CurrentSession.AddValue("CDSI", cdsi); if (cdsi == "cdsi") { if (!string.IsNullOrEmpty(curProduct.DeliveryNo)) { assignDelivery = deliveryRep.Find(curProduct.DeliveryNo); CurrentSession.AddValue(Session.SessionKeys.Delivery, assignDelivery); return assignDelivery; } string factoryPo = ""; //获取Product 结合的Factory Po,对于CDSI 机器如果获取不到结合的Factory Po, //需要报告错误:“CDSI AST MISSING DATA!” //SELECT @FactoryPo = Sno FROM CDSIAST NOLOCK WHERE SnoId = @ProductId AND Tp = 'FactoryPO' CdsiastInfo conf = new CdsiastInfo(); conf.snoId = curProduct.ProId; conf.tp = "FactoryPO"; IList<CdsiastInfo> cdsiList = productRep.GetCdsiastInfoList(conf); /*if (cdsiList.Count == 0) { errpara.Add(this.Key); throw new FisException("PAK140", errpara);//“CDSI AST MISSING DATA!” }*/ factoryPo = cdsiList[0].sno; IList<Delivery> dnList = deliveryRep.GetDeliveryListByModelPrefix(factoryPo, "PC", 12, "00"); //IF @Delivery = '' SELECT 'CDSI 机器,无此PoNo: ' + @FactoryPo + ' 的Delivery!' if (dnList.Count == 0) { return null; } assignDelivery = dnList[0]; } else if (curProduct.IsBindedPo) { if (!string.IsNullOrEmpty(curProduct.DeliveryNo)) { assignDelivery = deliveryRep.Find(curProduct.DeliveryNo); CurrentSession.AddValue(Session.SessionKeys.Delivery, assignDelivery); return assignDelivery; } string factoryPo = curProduct.BindPoNo; IList<Delivery> dnList = deliveryRep.GetDeliveryListByModelPrefix(factoryPo, "PC", 12, "00"); if (dnList.Count == 0) { return null; } assignDelivery = dnList[0]; } else if (!curProduct.IsBT) { //a)选择的DN需要满足如下要求: //Delivery.ShipDate 大于3天前 (例如:当天为2011/9/13,那么获取的DN 的ShipDate 要大于2011/9/10) – 即ShipDate>=convert(char(10),getdate()-3,111) //Note: //ShipDate 需要转换为YYYY/MM/DD 格式显示 //Sample: 2009/05/11 //Delivery.Status = ‘00’ //Delivery.Model 长度为12 位 //Delivery.Model 前两码为’PC’ //系统自动分配另外一个DN(列表中满足条件的Delivery按照ShipDate,Qty,DeliveryNo 排序取第一个), DNQueryCondition condition = new DNQueryCondition(); DateTime temp = DateTime.Now; temp = temp.AddDays(-3); condition.ShipDateFrom = new DateTime(temp.Year, temp.Month, temp.Day, 0, 0, 0, 0); condition.Model = curProduct.Model; IList<DNForUI> dnList = deliveryRep.GetDNListByConditionWithSorting(condition); //Vincent 2015-02-27 過濾綁訂PoDN if (dnList != null && dnList.Count > 0) { IList<string> bindPoNoList = moRep.GetBindPoNoByModel(curProduct.Model); if (bindPoNoList != null && bindPoNoList.Count > 0) { dnList = dnList.Where(x => !bindPoNoList.Contains(x.PoNo)).ToList(); } } foreach (DNForUI tmp in dnList) { if (tmp.Status != "00") { continue; } if (!(tmp.ModelName.Length == 12 && tmp.ModelName.Substring(0, 2) == "PC")) { continue; } int qty = 0; int packedQty = 0; qty = tmp.Qty; IList<IProduct> productList = new List<IProduct>(); productList = productRep.GetProductListByDeliveryNo(tmp.DeliveryNo); packedQty = productList.Count; if (packedQty + 1 > qty) { continue; } assignDelivery = deliveryRep.Find(tmp.DeliveryNo); break; } if (assignDelivery == null) { return null; } } return assignDelivery; }
/// <summary> /// Check CDSI(shell机器),如果是,则从CDSIAST表中根据ProdID取得资产标签,进行结合,并打印 /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { Session session = CurrentSession; ActivityCommonImpl utl = ActivityCommonImpl.Instance; IProduct getProduct = utl.IsNull<IProduct>(session, Session.SessionKeys.Product); IList<IPart> needGenAstPartList =utl.IsNull<IList<IPart>>(session,Session.SessionKeys.NeedGenAstPartList); //Product getProduct = (Product)CurrentSession.GetValue(Session.SessionKeys.Product); //var ProdidOrCustsn = (string)CurrentSession.GetValue("ProdidOrCustsn"); string prodidOrCustsn = getProduct.ProId + "/" + getProduct.CUSTSN; //string descr = (string)session.GetValue("DESCR"); bool isCDSI = getProduct.IsCDSI; //session.AddValue(Session.SessionKeys.HasCDSI, isCDSI ? "Y":"N"); //2012-5-2 session.AddValue("ASTInfo", ""); if (isCDSI == true) { IPart part = null; if (needGenAstPartList.Count > 0) { part = needGenAstPartList.FirstOrDefault(); } if (part == null) { throw new FisException("CHK522", new List<string> { prodidOrCustsn }); } string atsnav = (string)getProduct.GetModelProperty("ATSNAV")??""; string checkItemType = string.IsNullOrEmpty(atsnav) ? "CNRS" : "CDSI"; string descr = part.Descr; string AST1 = ""; string AST2 = ""; var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); //Get AV Part No if (string.IsNullOrEmpty(atsnav)) { if (needGenAstPartList.Count == 1) { atsnav = needGenAstPartList[0].PN; } else { var cnrsPart = needGenAstPartList.Where(x => x.BOMNodeType == "AT" && x.Descr == "ATSN3").FirstOrDefault(); if (cnrsPart != null) { atsnav = cnrsPart.PN; } else { atsnav = needGenAstPartList[0].PN; } } } CdsiastInfo cdi = new CdsiastInfo(); cdi.tp = "ASSET_TAG"; cdi.snoId = getProduct.ProId; IList<CdsiastInfo> cdsiastInfoList = productRepository.GetCdsiastInfoList(cdi); if (cdsiastInfoList != null && cdsiastInfoList.Count > 0) { AST1 = cdsiastInfoList[0].sno; } CdsiastInfo cdi2 = new CdsiastInfo(); cdi2.tp = "ASSET_TAG2"; cdi2.snoId = getProduct.ProId; IList<CdsiastInfo> cdsiastInfoList2 = productRepository.GetCdsiastInfoList(cdi2); if (cdsiastInfoList2 != null && cdsiastInfoList2.Count > 0) { AST2 = cdsiastInfoList2[0].sno; } if (string.IsNullOrEmpty(AST1) && string.IsNullOrEmpty(AST2)) { throw new FisException("CHK203", new List<string> { prodidOrCustsn }); } else { //不为空则存入,保存product和Asset SN的绑定关系 //保存product和Asset SN的绑定关系 //Insert Product_Part values(@prdid,@partpn,@astsn1’’,’AT’,@user,getdate(),getdate()) //Insert Product_Part values(@prdid,@partpn,@astsn2’’,’AT’,@user,getdate(),getdate()) //注:@partpn 为PartNo in (bom中BomNodeType=’AT’ Descr=’ATSN1’ 对应的Pn) //IBOMRepository bomRep = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>(); // IList<IPart> needGenAstPartList = (IList < IPart >) session.GetValue(Session.SessionKeys.NeedGenAstPartList); //IHierarchicalBOM bom = bomRep.GetHierarchicalBOMByModel(getProduct.Model); //IList<IBOMNode> ATList = bom.GetNodesByNodeType("AT"); //if (ATList != null) //{ // /* ITC-1360-1363, Jessica Liu, 2012-3-10 // part = ATList.Where(at => at.Part.Descr == "ATSN3") // .Select(at => at.Part) // .FirstOrDefault<IPart>(); // */ // part = ATList.Where(at => at.Part.Descr == descr) // .Select(at => at.Part) // .FirstOrDefault<IPart>(); //} /* ITC-1360-0328,Jessica Liu, 2012-2-11 if(part ==null){ List<string> errpara = new List<string>(); errpara.Add(ProdidOrCustsn); throw new FisException("CHK203", errpara); } */ //ITC-1360-0496, Jessica Liu, 2012-2-28 if (!string.IsNullOrEmpty(AST1)) { IProductPart assetTag1 = new ProductPart(); assetTag1.BomNodeType = part.BOMNodeType; assetTag1.Iecpn = string.Empty; //part.PN; assetTag1.CustomerPn = atsnav; //string.Empty; //part.CustPn; assetTag1.ProductID = getProduct.ProId; assetTag1.PartID = (part == null) ? "" : part.PN; //part.PN; assetTag1.PartSn = AST1; assetTag1.PartType = descr; //"AT"; assetTag1.Station = Station; assetTag1.Editor = Editor; assetTag1.Cdt = DateTime.Now; assetTag1.Udt = DateTime.Now; assetTag1.CheckItemType = checkItemType; getProduct.AddPart(assetTag1); productRepository.Update(getProduct, CurrentSession.UnitOfWork); } if (!string.IsNullOrEmpty(AST2)) { IProductPart assetTag2 = new ProductPart(); assetTag2.BomNodeType = part.BOMNodeType; assetTag2.Iecpn = string.Empty; //part.PN; assetTag2.CustomerPn = atsnav; //part.CustPn; assetTag2.ProductID = getProduct.ProId; assetTag2.PartID = (part == null) ? "" : part.PN; //part.PN; assetTag2.PartSn = AST2; assetTag2.PartType = descr; //"AT"; assetTag2.Station = Station; assetTag2.Editor = Editor; assetTag2.Cdt = DateTime.Now; assetTag2.Udt = DateTime.Now; assetTag2.CheckItemType = checkItemType; getProduct.AddPart(assetTag2); productRepository.Update(getProduct, session.UnitOfWork); } session.AddValue("AST1", AST1); session.AddValue("AST2", AST2); //2012-5-2 string ASTinfo = ""; if (!string.IsNullOrEmpty(AST1) && !string.IsNullOrEmpty(AST2)) { ASTinfo += AST1 + ", " + AST2; } else if (!string.IsNullOrEmpty(AST1) && string.IsNullOrEmpty(AST2)) { ASTinfo = AST1; } else if (string.IsNullOrEmpty(AST1) && !string.IsNullOrEmpty(AST2)) { ASTinfo = AST2; } session.AddValue("ASTInfo", ASTinfo); } } return base.DoExecute(executionContext); }
/// <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 { 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; } S_RowData_Product ret = new S_RowData_Product(); ret.DN = ""; ret.Model = ""; 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[] { }); } } } IList<MoBOMInfo> win8list = bomRepository.GetPnListByModelAndBomNodeTypeAndDescr(temp.Model, "P1", "ECOA"); if (win8list != null && win8list.Count > 0) { IList<string> typeList = new List<string>(); typeList.Add("P/N"); typeList.Add("Key"); typeList.Add("Hash"); IList<IMES.FisObject.FA.Product.ProductInfo> infoList = productRepository.GetProductInfoList(temp.ProId, typeList); if (infoList == null || infoList.Count != 3) { throw new FisException("CHK885", new string[] { }); //ret.isWin8 = "true"; } else { ret.isWin8 = "true"; } } 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; IList<Delivery> deliveryList = currentRepository.GetDeliveryListByModel(ret.Model,"PC",12,"00"); 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; } } } 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> /// Delivery 分配原则 /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { List<string> errpara = new List<string>(); Product curProduct = (Product)CurrentSession.GetValue(Session.SessionKeys.Product); IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); IDeliveryRepository deliveryRep = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>(); IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>(); /*IList<ProductBTInfo> btList = productRep.GetProductBT(curProduct.ProId); if (btList.Count > 0 && Station.Trim() == "92") { return base.DoExecute(executionContext); } */ Delivery assignDelivery = new Delivery(); CurrentSession.AddValue("HasDN", "N"); //CDSI 机器Assign Delivery的特殊要求 //IList<IMES.FisObject.Common.Model.ModelInfo> GetModelInfoByModelAndName(string model, string name); IList<IMES.FisObject.Common.Model.ModelInfo> infoList = modelRep.GetModelInfoByModelAndName(curProduct.Model, "PO"); Model model = modelRep.Find(curProduct.Model); string cdsi = ""; cdsi= model.GetAttribute("PO"); if (cdsi != "Y") { cdsi = ""; cdsi = model.GetAttribute("ATSNAV"); if (!string.IsNullOrEmpty(cdsi)) { cdsi = "cdsi"; } } else { cdsi = "cdsi"; } CurrentSession.AddValue("CDSI", cdsi); if (cdsi == "cdsi") { if (!string.IsNullOrEmpty(curProduct.DeliveryNo)) { assignDelivery = deliveryRep.Find(curProduct.DeliveryNo); CurrentSession.AddValue(Session.SessionKeys.Delivery, assignDelivery); CurrentSession.AddValue("HasDN", "Y"); return base.DoExecute(executionContext); } string factoryPo = ""; //获取Product 结合的Factory Po,对于CDSI 机器如果获取不到结合的Factory Po, //需要报告错误:“CDSI AST MISSING DATA!” //SELECT @FactoryPo = Sno FROM CDSIAST NOLOCK WHERE SnoId = @ProductId AND Tp = 'FactoryPO' CdsiastInfo conf = new CdsiastInfo(); conf.snoId = curProduct.ProId; conf.tp = "FactoryPO"; IList<CdsiastInfo> cdsiList = productRep.GetCdsiastInfoList(conf); if (cdsiList.Count == 0) { errpara.Add(this.Key); throw new FisException("PAK140", errpara);//“CDSI AST MISSING DATA!” } factoryPo = cdsiList[0].sno; IList<Delivery> dnList = deliveryRep.GetDeliveryListByModelPrefix(factoryPo, "PC", 12, "00"); //IF @Delivery = '' SELECT 'CDSI 机器,无此PoNo: ' + @FactoryPo + ' 的Delivery!' if (dnList.Count == 0) { errpara.Add(factoryPo); throw new FisException("PAK141", errpara);//'CDSI 机器,无此PoNo: ' + @FactoryPo + ' 的Delivery!' } assignDelivery = dnList[0]; curProduct.DeliveryNo = assignDelivery.DeliveryNo; } else if (!curProduct.IsBT) { //a)选择的DN需要满足如下要求: //Delivery.ShipDate 大于3天前 (例如:当天为2011/9/13,那么获取的DN 的ShipDate 要大于2011/9/10) – 即ShipDate>=convert(char(10),getdate()-3,111) //Note: //ShipDate 需要转换为YYYY/MM/DD 格式显示 //Sample: 2009/05/11 //Delivery.Status = ‘00’ //Delivery.Model 长度为12 位 //Delivery.Model 前两码为’PC’ //系统自动分配另外一个DN(列表中满足条件的Delivery按照ShipDate,Qty,DeliveryNo 排序取第一个), DNQueryCondition condition = new DNQueryCondition(); DateTime temp = DateTime.Now; temp = temp.AddDays(-3); condition.ShipDateFrom = new DateTime(temp.Year, temp.Month, temp.Day, 0, 0, 0, 0); condition.Model = curProduct.Model; IList<DNForUI> dnList = deliveryRep.GetDNListByConditionWithSorting(condition); foreach (DNForUI tmp in dnList) { if (tmp.Status != "00") { continue; } if (!(tmp.ModelName.Length == 12 && tmp.ModelName.Substring(0, 2) == "PC")) { continue; } //tmp.Editor = deliveryRep.GetDeliveryInfoValue(tmp.DeliveryNo, "PartNo");//CustomerPN int qty = 0; int packedQty = 0; qty = tmp.Qty; IList<IProduct> productList = new List<IProduct>(); productList = productRep.GetProductListByDeliveryNo(tmp.DeliveryNo); packedQty = productList.Count; if (packedQty+1 > qty) { continue; } assignDelivery = deliveryRep.Find(tmp.DeliveryNo); break; } if (assignDelivery == null) { FisException fe = new FisException("PAK103", new string[] { }); //没找到可分配的delivery throw fe; } curProduct.DeliveryNo = assignDelivery.DeliveryNo; } CurrentSession.AddValue(Session.SessionKeys.Delivery, assignDelivery); return base.DoExecute(executionContext); }
private void combineCDSI(Session session,IProduct product, IPart part, string checkItemType, string avPartNo ) { var prodRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); string AST1 = ""; CdsiastInfo cdi = new CdsiastInfo(); cdi.tp = "ASSET_TAG"; cdi.snoId = product.ProId; IList<CdsiastInfo> cdsiastInfoList = prodRep.GetCdsiastInfoList(cdi); if (cdsiastInfoList != null && cdsiastInfoList.Count > 0) { AST1 = cdsiastInfoList[0].sno; } string AST2 = ""; CdsiastInfo cdi2 = new CdsiastInfo(); cdi2.tp = "ASSET_TAG2"; cdi2.snoId = product.ProId; IList<CdsiastInfo> cdsiastInfoList2 = prodRep.GetCdsiastInfoList(cdi2); if (cdsiastInfoList2 != null && cdsiastInfoList2.Count > 0) { AST2 = cdsiastInfoList2[0].sno; } if ((AST1 == "") && (AST2 == "")) { List<string> errpara = new List<string>(); throw new FisException("CHK203", errpara); } else { //不为空则存入 //保存product和Asset SN的绑定关系 if (AST1 != "") { IProductPart assetTag1 = new ProductPart(); assetTag1.ProductID = product.ProId; assetTag1.PartID = part.PN; assetTag1.PartType = part.Descr; assetTag1.Iecpn = ""; assetTag1.CustomerPn = avPartNo; assetTag1.PartSn = AST1; assetTag1.Station = this.Station; assetTag1.Editor = this.Editor; assetTag1.Cdt = DateTime.Now; assetTag1.Udt = DateTime.Now; assetTag1.BomNodeType = part.BOMNodeType; assetTag1.CheckItemType = checkItemType; product.AddPart(assetTag1); prodRep.Update(product, session.UnitOfWork); } if (AST2 != "") { IProductPart assetTag2 = new ProductPart(); assetTag2.ProductID = product.ProId; assetTag2.PartID = part.PN; assetTag2.PartType = part.Descr; assetTag2.Iecpn = ""; assetTag2.CustomerPn = avPartNo; assetTag2.PartSn = AST2; assetTag2.Station = this.Station; assetTag2.Editor = this.Editor; assetTag2.Cdt = DateTime.Now; assetTag2.Udt = DateTime.Now; assetTag2.BomNodeType = part.BOMNodeType; assetTag2.CheckItemType = checkItemType; product.AddPart(assetTag2); prodRep.Update(product, session.UnitOfWork); } session.AddValue("AST1", AST1); session.AddValue("AST2", AST2); //2012-5-2 string ASTinfo = ""; if (!string.IsNullOrEmpty(AST1) && !string.IsNullOrEmpty(AST2)) { ASTinfo += AST1 + ", " + AST2; } else if (!string.IsNullOrEmpty(AST1) && string.IsNullOrEmpty(AST2)) { ASTinfo = AST1; } else if (string.IsNullOrEmpty(AST1) && !string.IsNullOrEmpty(AST2)) { ASTinfo = AST2; } session.AddValue("ASTInfo", ASTinfo); } }
/// <summary> /// 获取Product表相关信息 /// </summary> /// <param name="customerSN">customer SN</param> public S_RowData_Product GetProductOnly(string customerSN) { logger.Debug("(_CombineCOAandDN)GetProductOnly start.customerSN:" + customerSN); try { S_RowData_Product ret = new S_RowData_Product(); ret.DN = ""; ret.Model = ""; ret.ProductID = ""; ret.isBT = "false"; ret.isCDSI = ""; ret.isFactoryPo = ""; 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[] { }); } } } } return ret; } catch (FisException e) { logger.Error(e.mErrmsg, e); throw new Exception(e.mErrmsg); } catch (Exception e) { logger.Error(e.Message, e); throw new SystemException(e.Message); } finally { logger.Debug("(_CombineCOAandDN)GetProductOnly end. customerSN:" + customerSN); } }
/// <summary> /// check product /// </summary> /// <param name="line">line</param> /// <param name="editor">editor</param> /// <param name="station">station</param> /// <param name="customer">customer</param> /// <param name="custSN">customer SN</param> public int CheckProduct(string line,string editor, string station, string customer,string custSN) { string keyStr = ""; try { string sessionKey = custSN; 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, "CombineDNPalletforBTBlock.xoml", "", out wfName, out rlName); WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments); currentSession.SetInstance(instance); if (!SessionManager.GetInstance.AddSession(currentSession)) { currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists."); FisException ex; List<string> erpara = new List<string>(); erpara.Add(sessionKey); ex = new FisException("CHK020", erpara); throw ex; } currentSession.WorkflowInstance.Start(); currentSession.SetHostWaitOne(); if (currentSession.Exception != null) { if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null) { currentSession.ResumeWorkFlow(); } throw currentSession.Exception; } IProduct product = null; product = productRepository.GetProductByCustomSn(custSN); if (null == product) { //no data return -10; } string isCDSI = ""; string isFactoryPo = ""; IList<IMES.FisObject.Common.Model.ModelInfo> isPO = modelRep.GetModelInfoByModelAndName(product.Model, "PO"); foreach (IMES.FisObject.Common.Model.ModelInfo tmpPO in isPO) { if (tmpPO.Value == "Y") { isCDSI = "true"; } else { IList<IMES.FisObject.Common.Model.ModelInfo> isATSNAV = modelRep.GetModelInfoByModelAndName(product.Model, "ATSNAV"); foreach (IMES.FisObject.Common.Model.ModelInfo tmpATSNAV in isATSNAV) { if (tmpATSNAV.Value == null) { } else if (tmpATSNAV.Value != "") { isCDSI = "true"; } break; } } break; } if (isCDSI == "true") { CdsiastInfo condition = new CdsiastInfo(); condition.snoId = product.ProId; condition.tp = "FactoryPO"; IList<CdsiastInfo> isCdsiastInfo = productRepository.GetCdsiastInfoList(condition); isFactoryPo = ""; foreach (CdsiastInfo tmpCdsiastInfo in isCdsiastInfo) { isFactoryPo = tmpCdsiastInfo.sno; break; } if (isFactoryPo == "" || isFactoryPo == null) { throw new FisException("CHK882", new string[] { }); } } if (!product.IsBT) { //非bt return -1; } bool checkCoa = false; // 取ModelBOM 中Model 直接下阶中有BomNodeType 为'P1' 的Part IPartRepository ipartRepository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>(); IBOMRepository ibomRepository = RepositoryFactory.GetInstance().GetRepository<IMES.FisObject.Common.FisBOM.IBOMRepository>(); IHierarchicalBOM sessionBOM = null; sessionBOM = ibomRepository.GetHierarchicalBOMByModel(product.Model); IList<IBOMNode> bomNodeLst = new List<IBOMNode>(); bomNodeLst = sessionBOM.FirstLevelNodes; IList<string> partNOList = new List<string>(); if (bomNodeLst != null && bomNodeLst.Count > 0) { foreach (IBOMNode ibomnode in bomNodeLst) { IPart currentPart = ibomnode.Part; if (currentPart.BOMNodeType == "P1" && currentPart.Descr.IndexOf("COA") != -1) { partNOList.Add(currentPart.PN); } } } else { //no data return -9; } foreach (IProductPart tmp in product.ProductParts) { if (tmp.PartSn != null && tmp.PartID != null) { if (partNOList.Contains(tmp.PartID)) { IList<COAStatus> reCoa = coaRepository.GetCOAStatusRange(tmp.PartSn, tmp.PartSn); foreach (COAStatus coaItem in reCoa) { checkCoa = true; if (coaItem.IECPN != tmp.PartID) { //COA not matches! return -2; } } } } } if (!checkCoa) { //success return 1; } //success return 2; } catch (FisException e) { logger.Error(e.mErrmsg, e); throw new Exception(e.mErrmsg); } catch (Exception e) { logger.Error(e.Message, e); throw new SystemException(e.Message); } finally { Session sessionDelete = SessionManager.GetInstance.GetSession(keyStr, SessionType); ; if (sessionDelete != null) { SessionManager.GetInstance.RemoveSession(sessionDelete); } logger.Debug("(_CombineDNPalletforBT)CheckProduct end"); } }
/// <summary> /// Delivery 分配原则 /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { List<string> errpara = new List<string>(); Product curProduct = (Product)CurrentSession.GetValue(Session.SessionKeys.Product); IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); IDeliveryRepository deliveryRep = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>(); IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>(); IList<ProductBTInfo> btList = productRep.GetProductBT(curProduct.ProId); if (btList.Count > 0 && Station.Trim() == "92") { return base.DoExecute(executionContext); } Delivery assignDelivery = null; CurrentSession.AddValue("HasDN", "N"); //CDSI 机器Assign Delivery的特殊要求 //IList<IMES.FisObject.Common.Model.ModelInfo> GetModelInfoByModelAndName(string model, string name); IList<IMES.FisObject.Common.Model.ModelInfo> infoList = modelRep.GetModelInfoByModelAndName(curProduct.Model, "PO"); Model model = modelRep.Find(curProduct.Model); string cdsi = ""; cdsi= model.GetAttribute("PO"); if (cdsi != "Y") { cdsi = ""; cdsi = model.GetAttribute("ATSNAV"); if (!string.IsNullOrEmpty(cdsi)) { cdsi = "cdsi"; } } else { cdsi = "cdsi"; } if (cdsi == "cdsi") { if (!string.IsNullOrEmpty(curProduct.DeliveryNo)) { assignDelivery = deliveryRep.Find(curProduct.DeliveryNo); CurrentSession.AddValue(Session.SessionKeys.Delivery, assignDelivery); CurrentSession.AddValue("HasDN", "Y"); return base.DoExecute(executionContext); } string factoryPo = ""; //获取Product 结合的Factory Po,对于CDSI 机器如果获取不到结合的Factory Po, //需要报告错误:“CDSI AST MISSING DATA!” //SELECT @FactoryPo = Sno FROM CDSIAST NOLOCK WHERE SnoId = @ProductId AND Tp = 'FactoryPO' CdsiastInfo conf = new CdsiastInfo(); conf.snoId = curProduct.ProId; conf.tp = "FactoryPO"; IList<CdsiastInfo> cdsiList = productRep.GetCdsiastInfoList(conf); if (cdsiList.Count == 0) { errpara.Add(this.Key); throw new FisException("PAK140", errpara);//“CDSI AST MISSING DATA!” } factoryPo = cdsiList[0].sno; IList<Delivery> dnList = deliveryRep.GetDeliveryListByModelPrefix(factoryPo, "PC", 12, "00"); //IF @Delivery = '' SELECT 'CDSI 机器,无此PoNo: ' + @FactoryPo + ' 的Delivery!' if (dnList.Count == 0) { errpara.Add(factoryPo); throw new FisException("PAK141", errpara);//'CDSI 机器,无此PoNo: ' + @FactoryPo + ' 的Delivery!' } assignDelivery = dnList[0]; } else { //a. 查找Delivery 出货时间(IMES_PAK..Delivery.ShipDate)大于两天前的, //状态为(IMES_PAK..Delivery.Status)'00' 的,Model(IMES_PAK..Delivery.Model) //与当前Product Model 相同的Deliveries,如果不存在,则报告错误:“无此机型Delivery!” DateTime beginCdt = DateTime.Now.AddDays(-2); String[] statusArray = { "00" }; int assignQty = 0; //如果此时Product 已经结合DN (IMES_FA..Product.DeliveryNo),则跳过Assign Delivery步骤,直接开始Assign Pallet if (!string.IsNullOrEmpty(curProduct.DeliveryNo)) { assignDelivery = deliveryRep.Find(curProduct.DeliveryNo); CurrentSession.AddValue(Session.SessionKeys.Delivery, assignDelivery); CurrentSession.AddValue("HasDN", "Y"); return base.DoExecute(executionContext); } //IList<Delivery> deliveryList = deliveryRep.GetDeliveryListByCdtAboveAndStatusesAndModel(beginCdt, statusArray, curProduct.Model); //SELECT DeliveryNo, ShipDate, Qty, '', 0 FROM Delivery NOLOCK //WHERE Model = @Model AND LEFT(Model, 2) = 'PC' //AND CONVERT(char(10), ShipDate, 111)>=CONVERT(char(10),GETDATE()-3,111) //AND LEN(Model) = 12 AND Status = '00' IList<Delivery> deliveryList = deliveryRep.GetDeliveryListByModel(curProduct.Model,"PC",12,"00"); if (deliveryList.Count == 0) { errpara.Add(this.Key); throw new FisException("PAK101", errpara);//无此机型Delivery! } //1. 按照Delivery.Model = @Model 选取Delivery //2. 选取的Delivery 还要求Delivery.Model 12位长,以'PC' 开头,CONVERT(char(10), ShipDate, 111)>=CONVERT(char(10),GETDATE()-3,111),Status = '00' //3. 满足上面条件的Delivery,按照如下顺序的排序规则,选取第一条;如果没有满足条件的Delivery,则需要报告错误。 //a) ShipDate 越早,越优先 //b) 散装优先于非散装 //c) 剩余未包装Product数量越少的越优先 bool assignNA = false; foreach (Delivery dvNode in deliveryList) { int curqty = productRep.GetCombinedQtyByDN(dvNode.DeliveryNo); int tmpqty = dvNode.Qty - curqty; //string tmpstr = (string)dvNode.GetExtendedProperty("Consolidated"); int curQty = productRep.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) { FisException fe = new FisException("PAK103", new string[] { }); //没找到可分配的delivery throw fe; } } curProduct.DeliveryNo = assignDelivery.DeliveryNo; //f.分配了Delivery 后,需要更新IMES_FA..Product.DeliveryNo,记录该Product 分配了的Delivery; //如果该Delivery 此时结合的Product 数量与Delivery定义的数量相等,则需要更新Delivery 的状态为'87'; //如果该Delivery 此时结合的Product 数量大于Delivery定义的数量, //则报告错误:“Delivery has over qty,请将此机器的船务Unpack后,再重新刷入!” //Lock The XXX: 2012.04.20 LiuDong //if (assignDelivery != null && !string.IsNullOrEmpty(assignDelivery.DeliveryNo)) //{ // Guid gUiD = Guid.Empty; // var identity = new ConcurrentLocksInfo(); // identity.clientAddr = "N/A"; // identity.customer = CurrentSession.Customer; // identity.descr = string.Format("ThreadID: {0}", System.Threading.Thread.CurrentThread.ManagedThreadId.ToString()); // identity.editor = CurrentSession.Editor; // identity.line = CurrentSession.Line; // identity.station = CurrentSession.Station; // identity.timeoutSpan4Hold = new TimeSpan(0, 0, 3).Ticks; // identity.timeoutSpan4Wait = new TimeSpan(0, 0, 5).Ticks; // gUiD = productRep.GrabLockByTransThread("Delivery", assignDelivery.DeliveryNo, identity); // CurrentSession.AddValue(Session.SessionKeys.lockToken_DN, gUiD); //} //Lock The XXX: 2012.04.20 LiuDong //assignDelivery.IsDNFull(int currentStationCombineQty); //2012.05.11 LD ////2012.05.09 LD ////int dvQty = productRep.GetCombinedQtyByDN(assignDelivery.DeliveryNo)+1; //int dvQty = productRep.GetCombinedQtyByDN_OnTrans(assignDelivery.DeliveryNo); int dvQty = productRep.GetCombinedQtyByDN(assignDelivery.DeliveryNo); ////2012.05.09 LD //2012.05.11 LD if (dvQty + 1 > assignDelivery.Qty) { FisException fe = new FisException("PAK104", new string[] { }); //Delivery has over qty,请将此机器的船务Unpack后,再重新刷入! throw fe; } IList<string> ProductIDList = new List<string>(); ProductIDList.Add(curProduct.ProId); productRep.BindDNDefered(CurrentSession.UnitOfWork, curProduct.DeliveryNo, ProductIDList, assignDelivery.Qty); if (dvQty + 1 == assignDelivery.Qty) { if (Station == "96") { assignDelivery.Status = "88"; } else { assignDelivery.Status = "87"; } deliveryRep.Update(assignDelivery, CurrentSession.UnitOfWork); } CurrentSession.AddValue(Session.SessionKeys.Delivery, assignDelivery); return base.DoExecute(executionContext); }
/// <summary> /// CheckProductAndDN /// </summary> /// <param name="custSN">customer SN</param> /// <param name="DN">DN</param> public string CheckProductAndDN(string custSN, string DN) { try { IProduct product = null; product = productRepository.GetProductByCustomSn(custSN); if (null == product) { List<string> errpara = new List<string>(); errpara.Add(custSN); throw new FisException("SFC002", errpara); } if (DN == "------------") { return product.Model; } Delivery CurrentDelivery = currentRepository.Find(DN); if (CurrentDelivery == null) { List<string> errpara = new List<string>(); errpara.Add(DN); throw new FisException("CHK107", errpara); } string isCDSI = ""; string isFactoryPo = ""; IList<IMES.FisObject.Common.Model.ModelInfo> isPO = modelRep.GetModelInfoByModelAndName(product.Model, "PO"); foreach (IMES.FisObject.Common.Model.ModelInfo tmpPO in isPO) { if (tmpPO.Value == "Y") { isCDSI = "true"; } else { IList<IMES.FisObject.Common.Model.ModelInfo> isATSNAV = modelRep.GetModelInfoByModelAndName(product.Model, "ATSNAV"); foreach (IMES.FisObject.Common.Model.ModelInfo tmpATSNAV in isATSNAV) { if (tmpATSNAV.Value == null) { } else if (tmpATSNAV.Value != "") { isCDSI = "true"; } break; } } break; } if (isCDSI == "true") { CdsiastInfo condition = new CdsiastInfo(); condition.snoId = product.ProId; condition.tp = "FactoryPO"; IList<CdsiastInfo> isCdsiastInfo = productRepository.GetCdsiastInfoList(condition); isFactoryPo = ""; foreach (CdsiastInfo tmpCdsiastInfo in isCdsiastInfo) { isFactoryPo = tmpCdsiastInfo.sno; break; } if (isFactoryPo == "" || isFactoryPo == null) { throw new FisException("CHK882", new string[] { }); } } else if (product.IsBindedPo) //Vincent add check bind PO case { isCDSI = "true"; isFactoryPo = product.BindPoNo; } if (product.Model != CurrentDelivery.ModelName) { if (isCDSI == "true") { return product.Model + "#@#" + isFactoryPo; } else { return product.Model; } } else { if (isCDSI == "true") { if (CurrentDelivery.PoNo == isFactoryPo) { return ""; } else { return product.Model + "#@#" + isFactoryPo; } } else //非bind Po case 即為 Normal case { //Vincent 檢查選中的PO 是否Bind PO if (! string.IsNullOrEmpty(CurrentDelivery.PoNo)) { IList<string> bindPoNoList = moRep.GetBindPoNoByModel(product.Model); if (bindPoNoList != null && bindPoNoList.Count > 0 && bindPoNoList.Contains(CurrentDelivery.PoNo)) { return product.Model; } } return ""; } } } catch (FisException e) { logger.Error(e.mErrmsg, e); throw new Exception(e.mErrmsg); } catch (Exception e) { logger.Error(e.Message, e); throw new SystemException(e.Message); } }
/// <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> /// Generate ATSN7 label /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); var partRepository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>(); Product curProduct = (Product)CurrentSession.GetValue(Session.SessionKeys.Product); IList<string> pnList = CurrentSession.GetValue("PnListOfATSN7") as IList<string>; bool bCDSI = (bool)CurrentSession.GetValue("bCDSI"); if (bCDSI == true) { string AST1 = ""; CdsiastInfo cdi = new CdsiastInfo(); cdi.tp = "ASSET_TAG"; cdi.snoId = curProduct.ProId; IList<CdsiastInfo> cdsiastInfoList = productRepository.GetCdsiastInfoList(cdi); if (cdsiastInfoList != null && cdsiastInfoList.Count > 0) { AST1 = cdsiastInfoList[0].sno; } string AST2 = ""; CdsiastInfo cdi2 = new CdsiastInfo(); cdi2.tp = "ASSET_TAG2"; cdi2.snoId = curProduct.ProId; IList<CdsiastInfo> cdsiastInfoList2 = productRepository.GetCdsiastInfoList(cdi2); if (cdsiastInfoList2 != null && cdsiastInfoList2.Count > 0) { AST2 = cdsiastInfoList2[0].sno; } if ((AST1 == "") && (AST2 == "")) { List<string> errpara = new List<string>(); throw new FisException("CHK203", errpara); } else { //不为空则存入 //保存product和Asset SN的绑定关系 foreach (string tmp in pnList) { if (AST1 != "") { IProductPart assetTag1 = new ProductPart(); assetTag1.ProductID = curProduct.ProId; assetTag1.PartID = tmp; assetTag1.PartType = "ATSN7"; assetTag1.Iecpn = ""; assetTag1.CustomerPn = ""; assetTag1.PartSn = AST1; assetTag1.Station = Station; assetTag1.Editor = Editor; assetTag1.Cdt = DateTime.Now; assetTag1.Udt = DateTime.Now; assetTag1.BomNodeType = "AT"; curProduct.AddPart(assetTag1); productRepository.Update(curProduct, CurrentSession.UnitOfWork); } if (AST2 != "") { IProductPart assetTag2 = new ProductPart(); assetTag2.ProductID = curProduct.ProId; assetTag2.PartID = tmp; assetTag2.PartType = "ATSN7"; assetTag2.Iecpn = ""; assetTag2.CustomerPn = ""; assetTag2.PartSn = AST2; assetTag2.Station = Station; assetTag2.Editor = Editor; assetTag2.Cdt = DateTime.Now; assetTag2.Udt = DateTime.Now; assetTag2.BomNodeType = "AT"; curProduct.AddPart(assetTag2); productRepository.Update(curProduct, CurrentSession.UnitOfWork); } } } } else //Not CDSI { string custNum = ""; string cust = curProduct.ModelObj.GetAttribute("Cust"); IList<AssetRangeInfo> assetRangeList = partRepository.GetAssetRangesByCode(cust); if (assetRangeList.Count == 0) //No AssetRange found { List<string> errpara = new List<string>(); throw new FisException("CHK200", errpara); } AssetRangeInfo assetRange = assetRangeList[0]; if (assetRange.begin.Length != assetRange.end.Length) //Length of Begin and End mismatch { List<string> errpara = new List<string>(); throw new FisException("CHK201", errpara); } try { SqlTransactionManager.Begin(); lock (_syncRoot_GetSeq) { INumControlRepository numCtrlRepository = RepositoryFactory.GetInstance().GetRepository<INumControlRepository, NumControl>(); string largestCustNum = numCtrlRepository.GetMaxAssetNumber("AST", cust, "HP"); if (string.IsNullOrEmpty(largestCustNum)) { custNum = assetRange.begin; //Save current custNum to numControl NumControl item = new NumControl(0, "AST", assetRange.code, custNum, "HP"); numCtrlRepository.SaveMaxAssetNumber(item, true); SqlTransactionManager.Commit(); } else { if (largestCustNum.Length != assetRange.begin.Length) //Length of largestCustNum and assetRange.begin mismatch { List<string> errpara = new List<string>(); throw new FisException("CHK201", errpara); } string prePartCur = ""; string numPartCur = ""; ParseAst(largestCustNum, out prePartCur, out numPartCur); if (numPartCur == "") { List<string> errpara = new List<string>(); throw new FisException("CHK201", errpara); } string prePartMax = ""; string numPartMax = ""; ParseAst(assetRange.end, out prePartMax, out numPartMax); if (numPartMax == "") { List<string> errpara = new List<string>(); throw new FisException("CHK201", errpara); } if (prePartCur != prePartMax) //Prefix of largestCustNum and assetRange.end mismatch { List<string> errpara = new List<string>(); throw new FisException("CHK201", errpara); } long numCur = long.Parse(numPartCur); long numMax = long.Parse(numPartMax); if (numCur >= numMax) { List<string> errpara = new List<string>(); throw new FisException("CHK201", errpara); } numCur++; custNum = prePartCur; int fillZeroCount = numPartCur.Length - numCur.ToString().Length; for (int i = 0; i < fillZeroCount; i++) { custNum += "0"; } custNum += numCur.ToString(); //Save current custNum to numControl NumControl item = new NumControl(0, "AST", assetRange.code, custNum, "HP"); numCtrlRepository.SaveMaxAssetNumber(item, false); SqlTransactionManager.Commit(); } } } catch (Exception e) { SqlTransactionManager.Rollback(); throw e; } finally { SqlTransactionManager.Dispose(); SqlTransactionManager.End(); } //Update custNum if (cust == "SCUSTA-1") { custNum = "000" + custNum.Trim() + "00"; } /* else if (cust == "CUSTW-1") { custNum = custNum.Trim() + " HQ P47"; } else if (cust == "CUSTW-2") { custNum = custNum.Trim() + " HQ P49"; } */ ConstValueInfo cond = new ConstValueInfo(); cond.type = "AST"; cond.name = cust; IList<ConstValueInfo> valList = partRepository.GetConstValueInfoList(cond); if (valList.Count > 0 && !String.IsNullOrEmpty(valList[0].value)) { custNum += valList[0].value.Trim(); } //保存product和Asset SN的绑定关系 foreach (string tmp in pnList) { IProductPart assetTag = new ProductPart(); assetTag.ProductID = curProduct.ProId; assetTag.PartID = tmp; assetTag.PartType = "ATSN7"; assetTag.Iecpn = ""; assetTag.CustomerPn = ""; assetTag.PartSn = custNum; assetTag.Station = Station; assetTag.Editor = Editor; assetTag.Cdt = DateTime.Now; assetTag.Udt = DateTime.Now; assetTag.BomNodeType = "AT"; curProduct.AddPart(assetTag); productRepository.Update(curProduct, CurrentSession.UnitOfWork); } } return base.DoExecute(executionContext); }
/// <summary> /// Generate ATSN7 label /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { Session session = CurrentSession; ActivityCommonImpl utl = ActivityCommonImpl.Instance; var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); var partRepository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>(); IProduct curProduct = utl.IsNull<IProduct>(session, Session.SessionKeys.Product); // Product curProduct = (Product)session.GetValue(Session.SessionKeys.Product); // IList<string> pnList = session.GetValue("PnListOfATSN7") as IList<string>; IList<string> pnList = utl.IsNull<IList<string>>(session, "PnListOfATSN7"); bool bCDSI = false; if (session.GetValue("bCDSI") != null) { bCDSI = (bool)session.GetValue("bCDSI"); } if (pnList.Count == 0) { throw new FisException("CQCHK1089", new List<string> { curProduct.ProId,"BOM", "ATSN7" }); } if (bCDSI == true) { string AST1 = ""; CdsiastInfo cdi = new CdsiastInfo(); cdi.tp = "ASSET_TAG"; cdi.snoId = curProduct.ProId; IList<CdsiastInfo> cdsiastInfoList = productRepository.GetCdsiastInfoList(cdi); if (cdsiastInfoList != null && cdsiastInfoList.Count > 0) { AST1 = cdsiastInfoList[0].sno; } string AST2 = ""; CdsiastInfo cdi2 = new CdsiastInfo(); cdi2.tp = "ASSET_TAG2"; cdi2.snoId = curProduct.ProId; IList<CdsiastInfo> cdsiastInfoList2 = productRepository.GetCdsiastInfoList(cdi2); if (cdsiastInfoList2 != null && cdsiastInfoList2.Count > 0) { AST2 = cdsiastInfoList2[0].sno; } if ((AST1 == "") && (AST2 == "")) { List<string> errpara = new List<string>(); throw new FisException("CHK203", errpara); } else { //不为空则存入 //保存product和Asset SN的绑定关系 foreach (string tmp in pnList) { if (AST1 != "") { IProductPart assetTag1 = new ProductPart(); assetTag1.ProductID = curProduct.ProId; assetTag1.PartID = tmp; assetTag1.PartType = "ATSN7"; assetTag1.Iecpn = ""; assetTag1.CustomerPn = ""; assetTag1.PartSn = AST1; assetTag1.Station = Station; assetTag1.Editor = Editor; assetTag1.Cdt = DateTime.Now; assetTag1.Udt = DateTime.Now; assetTag1.BomNodeType = "AT"; assetTag1.CheckItemType = "CDSI"; curProduct.AddPart(assetTag1); productRepository.Update(curProduct,session.UnitOfWork); } if (AST2 != "") { IProductPart assetTag2 = new ProductPart(); assetTag2.ProductID = curProduct.ProId; assetTag2.PartID = tmp; assetTag2.PartType = "ATSN7"; assetTag2.Iecpn = ""; assetTag2.CustomerPn = ""; assetTag2.PartSn = AST2; assetTag2.Station = Station; assetTag2.Editor = Editor; assetTag2.Cdt = DateTime.Now; assetTag2.Udt = DateTime.Now; assetTag2.BomNodeType = "AT"; assetTag2.CheckItemType = "CDSI"; curProduct.AddPart(assetTag2); productRepository.Update(curProduct, session.UnitOfWork); } } } } else //Not CDSI { #region 產生ATSN7 需要 string cust = curProduct.ModelObj.GetAttribute("Cust"); string custNum = ActivityCommonImpl.Instance.AstNum.CheckAndGetUsedAst(session, curProduct.ProId, cust, "AST", this.Station, this.Editor); if (custNum == null) { custNum = ActivityCommonImpl.Instance.AstNum.CheckAndSetReleaseAstNumber(curProduct.ProId, cust, "AST", this.Station, this.Editor); } if (string.IsNullOrEmpty(custNum)) { custNum = GenerateCodeNew(cust); //Update custNum //if (cust == "SCUSTA-1") //{ // custNum = "000" + custNum.Trim() + "00"; //} /* else if (cust == "CUSTW-1") { custNum = custNum.Trim() + " HQ P47"; } else if (cust == "CUSTW-2") { custNum = custNum.Trim() + " HQ P49"; } */ // Checksum custNum = ActivityCommonImpl.Instance.GetAstChecksum(cust, custNum); custNum = ActivityCommonImpl.Instance.CheckAndAddPreFixDateAst(cust, custNum); ConstValueInfo cond = new ConstValueInfo(); cond.type = "AST"; cond.name = cust; IList<ConstValueInfo> valList = partRepository.GetConstValueInfoList(cond); if (valList.Count > 0 && !String.IsNullOrEmpty(valList[0].value)) { custNum += valList[0].value.Trim(); } ActivityCommonImpl.Instance.AstNum.InsertCombinedAstNumber(curProduct.ProId, cust, "AST", custNum, this.Station, this.Editor); } //保存product和Asset SN的绑定关系 foreach (string tmp in pnList) { IProductPart assetTag = new ProductPart(); assetTag.ProductID = curProduct.ProId; assetTag.PartID = tmp; assetTag.PartType = "ATSN7"; assetTag.Iecpn = ""; assetTag.CustomerPn = ""; assetTag.PartSn = custNum; assetTag.Station = Station; assetTag.Editor = Editor; assetTag.Cdt = DateTime.Now; assetTag.Udt = DateTime.Now; assetTag.BomNodeType = "AT"; assetTag.CheckItemType = "GenASTSN"; curProduct.AddPart(assetTag); productRepository.Update(curProduct, session.UnitOfWork); } #endregion } return base.DoExecute(executionContext); }
/// <summary> /// Check CDSI(shell机器),如果是,则从CDSIAST表中根据ProdID取得资产标签,进行结合,并打印 /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { Product getProduct = (Product)CurrentSession.GetValue(Session.SessionKeys.Product); var ProdidOrCustsn = (string)CurrentSession.GetValue("ProdidOrCustsn"); string descr = (string)CurrentSession.GetValue("DESCR"); bool isCDSI = getProduct.IsCDSI; CurrentSession.AddValue("IsCDSI", isCDSI); //2012-5-2 CurrentSession.AddValue("ASTInfo", ""); if (isCDSI == true) { string AST1 = ""; string AST2 = ""; var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); CdsiastInfo cdi = new CdsiastInfo(); cdi.tp = "ASSET_TAG"; cdi.snoId = getProduct.ProId; IList<CdsiastInfo> cdsiastInfoList = productRepository.GetCdsiastInfoList(cdi); if (cdsiastInfoList != null && cdsiastInfoList.Count > 0) { AST1 = cdsiastInfoList[0].sno; } CdsiastInfo cdi2 = new CdsiastInfo(); cdi2.tp = "ASSET_TAG2"; cdi2.snoId = getProduct.ProId; IList<CdsiastInfo> cdsiastInfoList2 = productRepository.GetCdsiastInfoList(cdi2); if (cdsiastInfoList2 != null && cdsiastInfoList2.Count > 0) { AST2 = cdsiastInfoList2[0].sno; } if ((AST1 == "") && (AST2 == "")) { List<string> errpara = new List<string>(); errpara.Add(ProdidOrCustsn); throw new FisException("CHK203", errpara); } else { //不为空则存入,保存product和Asset SN的绑定关系 //保存product和Asset SN的绑定关系 //Insert Product_Part values(@prdid,@partpn,@astsn1’’,’AT’,@user,getdate(),getdate()) //Insert Product_Part values(@prdid,@partpn,@astsn2’’,’AT’,@user,getdate(),getdate()) //注:@partpn 为PartNo in (bom中BomNodeType=’AT’ Descr=’ATSN1’ 对应的Pn) IBOMRepository bomRep = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>(); IHierarchicalBOM bom = bomRep.GetHierarchicalBOMByModel(getProduct.Model); IList<IBOMNode> ATList = bom.GetNodesByNodeType("AT"); IPart part =null; if (ATList != null) { /* ITC-1360-1363, Jessica Liu, 2012-3-10 part = ATList.Where(at => at.Part.Descr == "ATSN3") .Select(at => at.Part) .FirstOrDefault<IPart>(); */ part = ATList.Where(at => at.Part.Descr == descr) .Select(at => at.Part) .FirstOrDefault<IPart>(); } /* ITC-1360-0328,Jessica Liu, 2012-2-11 if(part ==null){ List<string> errpara = new List<string>(); errpara.Add(ProdidOrCustsn); throw new FisException("CHK203", errpara); } */ if (part == null) { List<string> erpara = new List<string>(); erpara.Add(ProdidOrCustsn); throw new FisException("CHK205", erpara); } else { //ITC-1360-0496, Jessica Liu, 2012-2-28 if (!string.IsNullOrEmpty(AST1)) { IProductPart assetTag1 = new ProductPart(); assetTag1.BomNodeType = "AT"; assetTag1.Iecpn = string.Empty; //part.PN; assetTag1.CustomerPn = string.Empty; //part.CustPn; assetTag1.ProductID = getProduct.ProId; assetTag1.PartID = (part == null) ? "" : part.PN; //part.PN; assetTag1.PartSn = AST1; assetTag1.PartType = descr; //"AT"; assetTag1.Station = Station; assetTag1.Editor = Editor; assetTag1.Cdt = DateTime.Now; assetTag1.Udt = DateTime.Now; getProduct.AddPart(assetTag1); productRepository.Update(getProduct, CurrentSession.UnitOfWork); } if (!string.IsNullOrEmpty(AST2)) { IProductPart assetTag2 = new ProductPart(); assetTag2.BomNodeType = "AT"; assetTag2.Iecpn = string.Empty; //part.PN; assetTag2.CustomerPn = string.Empty; //part.CustPn; assetTag2.ProductID = getProduct.ProId; assetTag2.PartID = (part == null) ? "" : part.PN; //part.PN; assetTag2.PartSn = AST2; assetTag2.PartType = descr; //"AT"; assetTag2.Station = Station; assetTag2.Editor = Editor; assetTag2.Cdt = DateTime.Now; assetTag2.Udt = DateTime.Now; getProduct.AddPart(assetTag2); productRepository.Update(getProduct, CurrentSession.UnitOfWork); } CurrentSession.AddValue("AST1", AST1); CurrentSession.AddValue("AST2", AST2); //2012-5-2 string ASTinfo = ""; if (!string.IsNullOrEmpty(AST1) && !string.IsNullOrEmpty(AST2)) { ASTinfo += AST1 + ", " + AST2; } else if (!string.IsNullOrEmpty(AST1) && string.IsNullOrEmpty(AST2)) { ASTinfo = AST1; } else if (string.IsNullOrEmpty(AST1) && !string.IsNullOrEmpty(AST2)) { ASTinfo = AST2; } CurrentSession.AddValue("ASTInfo", ASTinfo); } } } return base.DoExecute(executionContext); }