/// <summary> /// 检查Model1,Model2是否满足ChangeModel条件 /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { IPartRepository MyPartRepository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>(); string ChangeModelCheckItem = ""; IList<string> ChangeModelCheckItemList = MyPartRepository.GetValueFromSysSettingByName("ChangeModelCheckItem"); if (ChangeModelCheckItemList != null && ChangeModelCheckItemList.Count > 0) { ChangeModelCheckItem = ChangeModelCheckItemList[0]; } if (!string.IsNullOrEmpty(ChangeModelCheckItem)) { string[] CheckItems = ChangeModelCheckItem.Split(new string[] { "~" }, System.StringSplitOptions.RemoveEmptyEntries); ModelBomMatch MatchManager = new ModelBomMatch(); string model1 = CurrentSession.GetValue(Session.SessionKeys.Model1) as string; string model2 = CurrentSession.GetValue(Session.SessionKeys.Model2) as string; IBOMRepository MyBomRepository = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>(); IHierarchicalBOM model1Bom = MyBomRepository.GetHierarchicalBOMByModel(model1); IHierarchicalBOM model2Bom = MyBomRepository.GetHierarchicalBOMByModel(model2); IList<PNQty> model1PNQtyList; IList<PNQty> model2PNQtyList; foreach (string CheckItem in CheckItems) { model1PNQtyList = MatchManager.GetPNQty(CheckItem, model1Bom); model2PNQtyList = MatchManager.GetPNQty(CheckItem, model2Bom); //var query = from model1PnQty in model1PNQtyList // join model2PnQty in model2PNQtyList on model1PnQty.Pn equals model2PnQty.Pn into match // from result in match.DefaultIfEmpty() // where model1PnQty.Qty != result.Qty // select new PNQty(model1PnQty.Pn, result == null ? -1 : result.Qty); foreach (PNQty tempModel1 in model1PNQtyList) { bool match = false; foreach (PNQty tempModel2 in model2PNQtyList) { if (tempModel2.Pn == tempModel1.Pn) { if (tempModel2.Qty == tempModel1.Qty) { match = true; break; } else { throw new FisException("CHM003", new string[] { model1, model2 }); } } } if (!match) { throw new FisException("CHM002", new string[] { model1, model2 }); } } } CurrentSession.AddValue(Session.SessionKeys.ChangeModelCheckItem, CheckItems); } return base.DoExecute(executionContext); }
/// <summary> /// 检查是否满足条件 /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { IPartRepository MyPartRepository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>(); string KittingInputCheckItem = ""; IList<string> KittingInputCheckItemList = MyPartRepository.GetValueFromSysSettingByName("FAKittingCheckItem"); if (KittingInputCheckItemList != null && KittingInputCheckItemList.Count > 0) { KittingInputCheckItem = KittingInputCheckItemList[0]; } //KittingInputCheckItem = "WWAN~WL~HDD~DDR~CPU~LCM~BAT"; if (!string.IsNullOrEmpty(KittingInputCheckItem)) { string[] CheckItems = KittingInputCheckItem.Split(new string[] { "~" }, System.StringSplitOptions.RemoveEmptyEntries); ModelBomMatch MatchManager = new ModelBomMatch(); Product currentProduct = ((Product)CurrentSession.GetValue(Session.SessionKeys.Product)); string model = currentProduct.Model; IBOMRepository bomRep = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>(); IHierarchicalBOM modelBom = bomRep.GetHierarchicalBOMByModel(model); IList<PNQty> modelPNQtyList; foreach (string CheckItem in CheckItems) { modelPNQtyList = MatchManager.GetPNQty(CheckItem, modelBom); IList<string> _PartNo_list = (IList<string>)CurrentSession.GetValue("_PartNo_list"); bool flag = false; for (int ii = 0; ii < modelPNQtyList.Count; ii++) { flag = false; for (int i = 0; i < _PartNo_list.Count; i++) { if (modelPNQtyList[ii].Pn == _PartNo_list[i]) { flag = true; break; } } if (flag == false) { List<string> erpara = new List<string>(); erpara.Add(CheckItem); FisException ex; ex = new FisException("CHK285", erpara); throw ex; } } } } return base.DoExecute(executionContext); }