// Added by Icyer 2006/12/15 // 检查产品 private Messages CheckProduct(object act, string runningCard) { // 查询产品信息 BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider domainProvider = null; if ((act as IDCTClient).DBConnection != null) { domainProvider = (act as IDCTClient).DBConnection as BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider; } else { domainProvider = Common.DomainDataProvider.DomainDataProviderManager.DomainDataProvider() as BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider; (act as IDCTClient).DBConnection = domainProvider; } try { //为改善性能 ((SQLDomainDataProvider)domainProvider).PersistBroker.AutoCloseConnection = false; ((SQLDomainDataProvider)domainProvider).PersistBroker.OpenConnection(); ActionOnLineHelper _helper = new ActionOnLineHelper(domainProvider); // Added by Icyer 2007/03/16 如果归属工单,则做归属工单检查,否则做序列号途程检查 UserControl.Messages msgProduct = _helper.GetIDInfo(runningCard); ProductInfo product = (ProductInfo)msgProduct.GetData().Values[0]; MO moWillGo = null; ActionGoToMO actionGoMO = new ActionGoToMO(domainProvider); Messages msgMo = actionGoMO.GetItemCodeFromGoMoRCard(((IDCTClient)act).ResourceCode, runningCard); if (msgMo.IsSuccess() == false) // 如果有错误,表示需要归属工单,但是解析工单或查询工单发生错误 { return(msgMo); } if (msgMo.GetData() != null) // 需要归属工单,做归属工单检查 { product.NowSimulation = new BenQGuru.eMES.Domain.DataCollect.Simulation(); UserControl.Message msgMoData = msgMo.GetData(); moWillGo = (MO)msgMoData.Values[0]; moCode = moWillGo.MOCode; ActionGoToMO goToMO = new ActionGoToMO(domainProvider); GoToMOActionEventArgs MOActionEventArgs = new GoToMOActionEventArgs( ActionType.DataCollectAction_GoMO, runningCard, ((IDCTClient)act).LoginedUser, ((IDCTClient)act).ResourceCode, product, moWillGo.MOCode); msgMo = goToMO.CheckIn(MOActionEventArgs); if (!MOActionEventArgs.PassCheck) { msgMo = _helper.CheckID(new CKeypartsActionEventArgs( ActionType.DataCollectAction_CollectINNO, runningCard, ((IDCTClient)act).LoginedUser, ((IDCTClient)act).ResourceCode, product, null, null)); } } else // 不需要归属工单,检查序列号途程 { if (product == null || product.LastSimulation == null) { msgProduct.ClearMessages(); msgProduct.Add(new UserControl.Message(MessageType.Error, "$NoSimulation")); return(msgProduct); } msgMo = _helper.CheckID(new CKeypartsActionEventArgs( ActionType.DataCollectAction_CollectINNO, runningCard, ((IDCTClient)act).LoginedUser, ((IDCTClient)act).ResourceCode, product, null, null)); } if (msgMo.IsSuccess() == false) { return(msgMo); } // Added end keypartsHT = new Hashtable(); keypartsHT.Add("ProdcutInfo", product); keypartsHT.Add("MOWillGo", moWillGo); IDCTClient client = act as IDCTClient; OPBOMFacade opBOMFacade = new OPBOMFacade(domainProvider); MOFacade moFacade = new MOFacade(domainProvider); object[] objBomDetail = null; Messages messages1 = new Messages(); if (moWillGo == null) { // 检查途程 messages1 = _helper.CheckID( new CKeypartsActionEventArgs( ActionType.DataCollectAction_CollectINNO, product.LastSimulation.RunningCard, client.LoginedUser, client.ResourceCode, product, null, null)); } if (messages1.IsSuccess() == true) { //objBomDetail = opBOMFacade.GetOPBOMDetails( // product.NowSimulation.MOCode, // product.NowSimulation.RouteCode, // product.NowSimulation.OPCode); //Miodified by Scott MO moNew = (MO)moFacade.GetMO(product.NowSimulation.MOCode); objBomDetail = opBOMFacade.QueryOPBOMDetail(product.NowSimulation.ItemCode, string.Empty, string.Empty, moNew.BOMVersion, product.NowSimulation.RouteCode, product.NowSimulation.OPCode, (int)MaterialType.CollectMaterial, int.MinValue, int.MaxValue, moNew.OrganizationID, true); if (objBomDetail == null) { messages1.Add(new UserControl.Message(MessageType.Error, "$CS_OPBOM_NotFound")); } } else { return(messages1); } //object mo = moFacade.GetMO( product.LastSimulation.MOCode ); object mo = moWillGo; if (moWillGo == null) { mo = moFacade.GetMO(product.LastSimulation.MOCode); } //OPBomKeyparts opBomKeyparts = new OPBomKeyparts(objBomDetail, Convert.ToInt32(((MO)mo).IDMergeRule), domainProvider); // 查询OPBOM if (objBomDetail == null) { msgProduct.Add(new Message(MessageType.Error, "$CS_NOOPBomInfo $CS_Param_MOCode=" + product.NowSimulation.MOCode + " $CS_Param_RouteCode=" + product.NowSimulation.RouteCode + " $CS_Param_OPCode =" + product.NowSimulation.OPCode)); return(msgProduct); } else { this.filterOpBomDetail(ref objBomDetail); if (objBomDetail == null || objBomDetail.Length <= 0) { msgProduct.Add(new Message(MessageType.Error, "$CS_OPBOM_NotFound")); return(msgProduct); } for (int i = 0; i < objBomDetail.Length; i++) { if (((OPBOMDetail)objBomDetail[i]).OPBOMItemControlType == "item_control_lot") { opBomDetailCount += 1; } else { opBomDetailCount += Convert.ToInt32(((OPBOMDetail)objBomDetail[i]).OPBOMItemQty); } } for (int i = 0; i < objBomDetail.Length; i++) { if (((OPBOMDetail)objBomDetail[i]).OPBOMItemControlType == "item_control_lot") { opBomDetailList.Add(objBomDetail[i]); } else { int number = Convert.ToInt32(((OPBOMDetail)objBomDetail[i]).OPBOMItemQty); for (int j = 0; j < number; j++) { opBomDetailList.Add(objBomDetail[i]); } } } if (((OPBOMDetail)objBomDetail[0]).OPBOMItemControlType == BOMItemControlType.ITEM_CONTROL_LOT) { msgProduct.Add(new UserControl.Message(MessageType.Normal, ">>$DCT_PLEASE_INPUT_Lot " + ((OPBOMDetail)objBomDetail[0]).OPBOMSourceItemCode)); } else { msgProduct.Add(new UserControl.Message(MessageType.Normal, ">>$DCT_PLEASE_INPUT_Keyparts " + ((OPBOMDetail)objBomDetail[0]).OPBOMSourceItemCode)); } // keypartsHT.Add("KeypartsInfo", opBomKeyparts); keypartsHT.Add("Opbomdetail", objBomDetail); } return(msgProduct); } catch (Exception ex) { throw ex; } finally { ((SQLDomainDataProvider)domainProvider).PersistBroker.CloseConnection(); ((SQLDomainDataProvider)domainProvider).PersistBroker.AutoCloseConnection = true; } }
// Added by Icyer 2006/12/15 // 检查产品 private Messages CheckProduct(object act, string runningCard) { // 查询产品信息 BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider domainProvider = null; if ((act as IDCTClient).DBConnection != null) { domainProvider = (act as IDCTClient).DBConnection as BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider; } else { domainProvider = Common.DomainDataProvider.DomainDataProviderManager.DomainDataProvider() as BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider; (act as IDCTClient).DBConnection = domainProvider; } ActionOnLineHelper _helper = new ActionOnLineHelper(domainProvider); /* Removed by Icyer 2007/03/16 * UserControl.Messages msgProduct = _helper.GetIDInfo( runningCard ) ; * ProductInfo product= (ProductInfo)msgProduct.GetData().Values[0]; * if (product == null || product.LastSimulation == null) * { * msgProduct.ClearMessages(); * msgProduct.Add(new UserControl.Message(MessageType.Error, "$NoSimulation")); * return msgProduct; * } */ // Added by Icyer 2007/03/16 如果归属工单,则做归属工单检查,否则做序列号途程检查 UserControl.Messages msgProduct = _helper.GetIDInfo(runningCard); ProductInfo product = (ProductInfo)msgProduct.GetData().Values[0]; MO moWillGo = null; ActionGoToMO actionGoMO = new ActionGoToMO(domainProvider); Messages msgMo = actionGoMO.GetItemCodeFromGoMoRCard(((IDCTClient)act).ResourceCode, runningCard); if (msgMo.IsSuccess() == false) // 如果有错误,表示需要归属工单,但是解析工单或查询工单发生错误 { return(msgMo); } if (msgMo.GetData() != null) // 需要归属工单,做归属工单检查 { product.NowSimulation = new BenQGuru.eMES.Domain.DataCollect.Simulation(); UserControl.Message msgMoData = msgMo.GetData(); moWillGo = (MO)msgMoData.Values[0]; ActionGoToMO goToMO = new ActionGoToMO(domainProvider); GoToMOActionEventArgs MOActionEventArgs = new GoToMOActionEventArgs( ActionType.DataCollectAction_GoMO, runningCard, ((IDCTClient)act).LoginedUser, ((IDCTClient)act).ResourceCode, product, moWillGo.MOCode); msgMo = goToMO.CheckIn(MOActionEventArgs); if (!MOActionEventArgs.PassCheck) { msgMo = _helper.CheckID(new CKeypartsActionEventArgs( ActionType.DataCollectAction_CollectKeyParts, runningCard, ((IDCTClient)act).LoginedUser, ((IDCTClient)act).ResourceCode, product, null, null)); } } else // 不需要归属工单,检查序列号途程 { if (product == null || product.LastSimulation == null) { msgProduct.ClearMessages(); msgProduct.Add(new UserControl.Message(MessageType.Error, "$NoSimulation")); return(msgProduct); } msgMo = _helper.CheckID(new CKeypartsActionEventArgs( ActionType.DataCollectAction_CollectKeyParts, runningCard, ((IDCTClient)act).LoginedUser, ((IDCTClient)act).ResourceCode, product, null, null)); } if (msgMo.IsSuccess() == false) { return(msgMo); } // Added end keypartsHT = new Hashtable(); keypartsHT.Add("ProdcutInfo", msgProduct); keypartsHT.Add("MOWillGo", moWillGo); IDCTClient client = act as IDCTClient; OPBOMFacade opBOMFacade = new OPBOMFacade(domainProvider); object[] objBomDetail = null; Messages messages1 = new Messages(); if (moWillGo == null) { // 检查途程 messages1 = _helper.CheckID( new CKeypartsActionEventArgs( ActionType.DataCollectAction_CollectKeyParts, product.LastSimulation.RunningCard, client.LoginedUser, client.ResourceCode, product, null, null)); } if (messages1.IsSuccess() == true) { objBomDetail = opBOMFacade.GetOPBOMDetails( product.NowSimulation.MOCode, product.NowSimulation.RouteCode, product.NowSimulation.OPCode); } else { return(messages1); } MOFacade moFacade = new MOFacade(domainProvider); //object mo = moFacade.GetMO( product.LastSimulation.MOCode ); object mo = moWillGo; if (moWillGo == null) { mo = moFacade.GetMO(product.LastSimulation.MOCode); } // 查询OPBOM OPBomKeyparts opBomKeyparts = new OPBomKeyparts(objBomDetail, Convert.ToInt32(((MO)mo).IDMergeRule), domainProvider); if (opBomKeyparts.Count == 0) { msgProduct.Add(new Message(MessageType.Error, "$CS_NOOPBomInfo $CS_Param_MOCode=" + product.NowSimulation.MOCode + " $CS_Param_RouteCode=" + product.NowSimulation.RouteCode + " $CS_Param_OPCode =" + product.NowSimulation.OPCode)); return(msgProduct); } else { this.OutMesssage = new UserControl.Message(MessageType.Normal, "$DCT_PLEASE_INPUT_Keyparts " + (opBomKeyparts.GetbomKeypartCount() + 1).ToString() + "/" + opBomKeyparts.Count.ToString()); keypartsHT.Add("KeypartsInfo", opBomKeyparts); } return(msgProduct); }
// Added end public override Messages Action(object act) { Messages msg = new Messages(); ActionOnLineHelper _helper = null; BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider domainProvider = null; if (act == null) { return(msg); } DataCollect.Action.ActionEventArgs args; if (ObjectState == null) { args = new BenQGuru.eMES.DataCollect.Action.ActionEventArgs(); args.RunningCard = act.ToString().ToUpper().Trim(); } else { args = ObjectState as DataCollect.Action.ActionEventArgs; } string data = act.ToString().ToUpper().Trim(); //Keyparts //Laws Lu,2006/06/03 添加 获取已有连接 if ((act as IDCTClient).DBConnection != null) { domainProvider = (act as IDCTClient).DBConnection as BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider; } else { domainProvider = Common.DomainDataProvider.DomainDataProviderManager.DomainDataProvider() as BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider; (act as IDCTClient).DBConnection = domainProvider; } msg = CheckData(data, domainProvider); if (keypartsHT == null) { // 按照逻辑,走到这个分支应该是错误的 string strFile = @"C:\DCT_EmptyMessage.txt"; string strLine = DateTime.Now.ToString("yyyy-MM-dd HH:mi:ss") + "\t" + "ActionCollectKeyParts" + "\t" + "Missing Product In Action, RunningCard:" + args.RunningCard + ",Input:" + data; System.IO.StreamWriter writer = new System.IO.StreamWriter(strFile, true); writer.WriteLine(strLine); writer.Close(); // if (msg.IsSuccess() && (keypartsHT == null || keypartsHT.ContainsKey("ProdcutInfo") == false)) { //检查序列号 _helper = new ActionOnLineHelper(domainProvider); msg = _helper.GetIDInfo(args.RunningCard); // Added by Icyer 2006/12/14 // 检查序列号 ProductInfo product = (ProductInfo)msg.GetData().Values[0]; if (product == null || product.LastSimulation == null) { msg.ClearMessages(); msg.Add(new Message(MessageType.Error, "$NoSimulation")); } // base.Action (act); // ActionCollectKeyparts actionCollectKeyparts = this; // this.NextAction = actionCollectKeyparts; // this.Status = ActionStatus.PrepareData; // return msg; // Added end } if (msg.IsSuccess() && (keypartsHT == null || keypartsHT.ContainsKey("KeypartsInfo") == false)) { try { keypartsHT = new Hashtable(); keypartsHT.Add("ProdcutInfo", msg); ProductInfo product = (ProductInfo)msg.GetData().Values[0]; /* Removed by Icyer 2006/12/14 * 如果序列号已在本上料工序,则GetMORouteNextOperation会取下一个工序,导致找不到OPBOM * 改变推导OPBOM的逻辑 * ItemFacade itemFacade = new ItemFacade(domainProvider); * object op = itemFacade.GetMORouteNextOperation( * product.LastSimulation.MOCode, * product.LastSimulation.RouteCode, * product.LastSimulation.OPCode); * * OPBOMFacade opBOMFacade=new OPBOMFacade( domainProvider); * object[] objBomDetail = opBOMFacade.GetOPBOMDetails( * product.LastSimulation.MOCode, * product.LastSimulation.RouteCode, * (op as ItemRoute2OP).OPCode); */ // Added by Icyer 2006/12/14 IDCTClient client = act as IDCTClient; OPBOMFacade opBOMFacade = new OPBOMFacade(domainProvider); object[] objBomDetail = null; DataCollect.ActionOnLineHelper onLine = new ActionOnLineHelper(domainProvider); Messages messages1 = onLine.CheckID( new CKeypartsActionEventArgs( ActionType.DataCollectAction_CollectKeyParts, product.LastSimulation.RunningCard, client.LoginedUser, client.ResourceCode, product, null, null)); if (messages1.IsSuccess() == true) { objBomDetail = opBOMFacade.GetOPBOMDetails( product.NowSimulation.MOCode, product.NowSimulation.RouteCode, product.NowSimulation.OPCode); } else { throw new Exception(messages1.OutPut()); } // Added end MOFacade moFacade = new MOFacade(domainProvider); object mo = moFacade.GetMO(product.LastSimulation.MOCode); OPBomKeyparts opBomKeyparts = new OPBomKeyparts(objBomDetail, Convert.ToInt32(((MO)mo).IDMergeRule), domainProvider); if (opBomKeyparts.Count == 0) { /* Removed by Icyer 2006/12/27 @ YHI * msg.Add(new Message(MessageType.Error, "$CS_NOOPBomInfo $CS_Param_MOCode="+product.LastSimulation.MOCode +" $CS_Param_RouteCode="+product.LastSimulation.RouteCode +" $CS_Param_OPCode ="+product.LastSimulation.OPCode)); * throw new Exception(msg.OutPut()); */ throw new Exception("$CS_NOOPBomInfo"); } else { //opBomKeyparts.AddKeyparts(data, product.LastSimulation.MOCode); // Removed by Icyer 2006/12/14 keypartsHT.Add("KeypartsInfo", opBomKeyparts); } } catch (Exception ex) { /* Removed by Icyer 2006/12/27 @ YHI * keypartsHT = null; * this.NeedCancel = true; * throw ex; */ // Added by Icyer 2006/12/27 @ YHI base.Action(act); ActionCollectKeyparts actionCollectKeyparts = this; this.NextAction = actionCollectKeyparts; this.Status = ActionStatus.PrepareData; msg.ClearMessages(); msg.Add(new UserControl.Message(MessageType.Error, ex.Message)); msg.Add(new UserControl.Message(MessageType.Normal, "$DCT_PLEASE_INPUT_Keyparts")); return(msg); // Added end } } } if (msg.IsSuccess()) { OPBomKeyparts opBomKeyparts = (OPBomKeyparts)keypartsHT["KeypartsInfo"]; msg = keypartsHT["ProdcutInfo"] as Messages; MO moWillGo = (MO)keypartsHT["MOWillGo"]; ProductInfo product = (ProductInfo)msg.GetData().Values[0]; Messages msgResult = new Messages(); if (opBomKeyparts.Count > opBomKeyparts.GetbomKeypartCount()) { try { //opBomKeyparts.AddKeyparts(data, product.LastSimulation.MOCode); if (moWillGo == null) { msgResult.AddMessages(opBomKeyparts.AddKeyparts(data, product.LastSimulation.MOCode)); } else { msgResult.AddMessages(opBomKeyparts.AddKeyparts(data, moWillGo.MOCode)); } } catch (Exception ex) { msgResult.Add(new UserControl.Message(MessageType.Error, ex.Message)); } keypartsHT["KeypartsInfo"] = opBomKeyparts; } if (msgResult.IsSuccess() == false || opBomKeyparts.Count > opBomKeyparts.GetbomKeypartCount()) { base.Action(act); ActionCollectKeyparts actionCollectKeyparts = this; this.NextAction = actionCollectKeyparts; this.Status = ActionStatus.PrepareData; this.OutMesssage = new UserControl.Message(MessageType.Normal, "$DCT_PLEASE_INPUT_Keyparts " + (opBomKeyparts.GetbomKeypartCount() + 1).ToString() + "/" + opBomKeyparts.Count.ToString()); if (msgResult.IsSuccess() == false) { //msgResult.Add(new UserControl.Message(MessageType.Normal, "$DCT_PLEASE_INPUT_Keyparts")); return(msgResult); } else { return(msg); } } //((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.OpenConnection(); domainProvider.BeginTransaction(); try { BenQGuru.eMES.BaseSetting.BaseModelFacade dataModel = new BenQGuru.eMES.BaseSetting.BaseModelFacade(domainProvider); Resource resource = (Resource)dataModel.GetResource(args.ResourceCode); _helper = new ActionOnLineHelper(domainProvider); DataCollectFacade dataCollect = new DataCollect.DataCollectFacade(domainProvider); ActionCheckStatus actionCheckStatus = new ActionCheckStatus(); actionCheckStatus.ProductInfo = product; actionCheckStatus.ProductInfo.Resource = resource; ExtendSimulation lastSimulation = actionCheckStatus.ProductInfo.LastSimulation; BenQGuru.eMES.Material.WarehouseFacade wfacade = null; if (System.Configuration.ConfigurationSettings.AppSettings["NeedMaterialModule"].Trim() == "1") { wfacade = new WarehouseFacade(domainProvider); } IDCTClient client = act as IDCTClient; msg.AddMessages(_helper.ActionWithTransaction( new CKeypartsActionEventArgs( ActionType.DataCollectAction_CollectKeyParts, product.NowSimulation.RunningCard, client.LoginedUser, client.ResourceCode, product, opBomKeyparts, wfacade), actionCheckStatus)); // Added by Icyer 2006/12/28 @ YHI 采集集成上料 bool bLoadedINNO = false; if (this.NeedCollectINNO == true && msg.IsSuccess() == true) { string strRCard = product.NowSimulation.RunningCard; UserControl.Messages msgProduct = _helper.GetIDInfo(strRCard); product = (ProductInfo)msgProduct.GetData().Values[0]; CINNOActionEventArgs argsInno = new CINNOActionEventArgs( ActionType.DataCollectAction_CollectINNO, strRCard, client.LoginedUser, client.ResourceCode, product, INNOCode, wfacade ); IAction action = new BenQGuru.eMES.DataCollect.Action.ActionFactory(domainProvider).CreateAction(ActionType.DataCollectAction_CollectINNO); msg.AddMessages(action.Execute(argsInno)); if (msg.IsSuccess() == true) { bLoadedINNO = true; msg.Add(new UserControl.Message(MessageType.Success, string.Format("$CS_INNO_CollectSuccess[" + this.INNOCode + "] $CS_Keyparts_CollectSuccess"))); } } // Added end if (msg.IsSuccess()) { if (System.Configuration.ConfigurationSettings.AppSettings["NeedMaterialModule"].Trim() == "1") { if (wfacade != null) { wfacade.ExecCacheSQL(); } } domainProvider.CommitTransaction(); if (bLoadedINNO == false) { msg.Add(new UserControl.Message(MessageType.Success, string.Format("$CS_Keyparts_CollectSuccess"))); } } else { domainProvider.RollbackTransaction(); } } catch (Exception ex) { domainProvider.RollbackTransaction(); msg.Add(new UserControl.Message(ex)); } finally { ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.CloseConnection(); } base.Action(act); ActionRCard actRcard1 = new ActionRCard(); actRcard1.OutMesssage = new UserControl.Message(MessageType.Normal, "$CS_Please_Input_RunningCard"); this.NextAction = actRcard1; this.ObjectState = null; this.keypartsHT = null; this.Status = ActionStatus.PrepareData; return(msg); } base.Action(act); //Web.Helper.ActionType acttype = new Web.Helper.ActionType(); // if(acttype.Items.Contains(args.RunningCard)) // { // (act as IDCTClient).CachedAction = null; // } ActionRCard actRcard = new ActionRCard(); actRcard.OutMesssage = new UserControl.Message(MessageType.Normal, "$CS_Please_Input_RunningCard"); this.NextAction = actRcard; // Added by Icyer 2006/12/14 this.ObjectState = null; this.keypartsHT = null; this.Status = ActionStatus.PrepareData; // Added end return(msg); }
public UserControl.Messages NGCollect(object[] parserObjs) { UserControl.Messages returnMsg = new UserControl.Messages(); UserControl.Messages messages = new UserControl.Messages(); try { foreach (object obj in parserObjs) { PIDAOIData aoiData = obj as PIDAOIData; if (aoiData.RESULT == "FAIL") { ActionOnLineHelper onLine = new ActionOnLineHelper(this._domainDataProvider); returnMsg.AddMessages(onLine.GetIDInfo(aoiData.RCARD.Trim().ToUpper())); try { if (returnMsg.IsSuccess()) { ProductInfo product = (ProductInfo)returnMsg.GetData().Values[0]; this._domainDataProvider.BeginTransaction(); // //归属工单采集 // IAction dataCollectMO = new ActionFactory(this._domainDataProvider).CreateAction(ActionType.DataCollectAction_GoMO); // messages.AddMessages(((IActionWithStatus)dataCollectMO).Execute( // new GoToMOActionEventArgs(ActionType.DataCollectAction_GoMO, // aoiData.RCARD.Trim().ToUpper(), // aoiData.USER.Trim().ToUpper(), // AgentHelp.getResCode(aoiData.RESOURCE.Trim().ToUpper()), // product,this.getMOCode(aoiData.RCARD.Trim().ToUpper())))); // // if(messages.IsSuccess()) // { // returnMsg.Add( new UserControl.Message(UserControl.MessageType.Succes,string.Format("{0} $CS_GOMO_CollectSuccess",aoiData.RCARD.ToUpper())) ); // // } // else // { // returnMsg.Add( new UserControl.Message(UserControl.MessageType.Error,AgentHelp.GetErrorMessage(messages))); // } // messages.ClearMessages(); //取不良信息 object[] errorinfor = GetErrorInfor(aoiData); messages = onLine.GetIDInfo(aoiData.RCARD.Trim().ToUpper()); product = (ProductInfo)messages.GetData().Values[0]; //NG采集 IAction dataCollectNG = new ActionFactory(this._domainDataProvider).CreateAction(ActionType.DataCollectAction_SMTNG); messages.AddMessages(((IActionWithStatus)dataCollectNG).Execute( new TSActionEventArgs(ActionType.DataCollectAction_SMTNG, aoiData.RCARD.Trim().ToUpper(), aoiData.USER.Trim().ToUpper(), AgentHelp.getResCode(aoiData.RESOURCE.Trim().ToUpper()), product, errorinfor, ""))); if (messages.IsSuccess()) { this._domainDataProvider.CommitTransaction(); returnMsg.Add(new UserControl.Message(UserControl.MessageType.Success, string.Format("{0} $CS_NGSUCCESS", aoiData.RCARD.ToUpper()))); returnMsg.Add(new UserControl.Message(" ")); BenQGuru.eMES.Common.Log.Info(string.Format("{0} $CS_NGSUCCESS: {1}", aoiData.RCARD.Trim().ToUpper(), "OK")); messages.Add(new UserControl.Message(MessageType.Success, string.Format("$CS_NGSUCCESS,$CS_Param_ID:{0}", aoiData.RCARD.ToUpper()))); } else { this._domainDataProvider.RollbackTransaction(); string errorMsg = string.Format("{0} $CS_NGFail : {1}", aoiData.RCARD.Trim().ToUpper(), AgentHelp.GetErrorMessage(messages)); returnMsg.Add(new UserControl.Message(UserControl.MessageType.Error, errorMsg)); returnMsg.Add(new UserControl.Message(" ")); BenQGuru.eMES.Common.Log.Info(errorMsg); } } } catch (Exception ex) { this._domainDataProvider.RollbackTransaction(); BenQGuru.eMES.Common.Log.Info(AgentHelp.GetErrorMessage(messages), ex); } finally { ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)_domainDataProvider).PersistBroker.CloseConnection(); } } } } catch {} return(returnMsg); }
// Added by Icyer 2006/12/15 // 检查产品 private Messages CheckProduct(object act, string runningCard) { // 查询产品信息 BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider domainProvider = null; if ((act as IDCTClient).DBConnection != null) { domainProvider = (act as IDCTClient).DBConnection as BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider; } else { domainProvider = Common.DomainDataProvider.DomainDataProviderManager.DomainDataProvider() as BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider; (act as IDCTClient).DBConnection = domainProvider; } ActionOnLineHelper _helper = new ActionOnLineHelper(domainProvider); UserControl.Messages msgProduct = _helper.GetIDInfo(runningCard); ProductInfo product = (ProductInfo)msgProduct.GetData().Values[0]; if (product == null || product.LastSimulation == null) { msgProduct.ClearMessages(); msgProduct.Add(new UserControl.Message(MessageType.Error, "$NoSimulation")); return(msgProduct); } mergeList = new Hashtable(); mergeList.Add("ProdcutInfo", msgProduct); // 转换比例 //this.IDMergeRule = Convert.ToInt32(product.LastSimulation.IDMergeRule); // 转换比例从工序中读 IDCTClient client = act as IDCTClient; OPBOMFacade opBOMFacade = new OPBOMFacade(domainProvider); // 检查途程 Messages messages1 = _helper.CheckID( new CKeypartsActionEventArgs( ActionType.DataCollectAction_Split, product.LastSimulation.RunningCard, client.LoginedUser, client.ResourceCode, product, null, null)); if (messages1.IsSuccess() == true) { object op = new ItemFacade(domainProvider).GetItemRoute2Operation( product.NowSimulation.ItemCode, product.NowSimulation.RouteCode, product.NowSimulation.OPCode); if (op == null) { messages1.Add(new UserControl.Message(MessageType.Error, "$Error_CS_Current_OP_Not_Exist")); return(messages1); } if (((ItemRoute2OP)op).OPControl[(int)BenQGuru.eMES.BaseSetting.OperationList.IDTranslation] != '1') { messages1.Add(new UserControl.Message(MessageType.Error, "$CS_OP_Not_SplitOP")); //当前工序不是序号转换工序 return(messages1); } // 转换比例 this.IDMergeRule = 1; if (((ItemRoute2OP)op).IDMergeType == IDMergeType.IDMERGETYPE_ROUTER) { this.IDMergeRule = (int)((ItemRoute2OP)op).IDMergeRule; } // 序号转换类型 mergeIdType = ((ItemRoute2OP)op).IDMergeType; ArrayList listId = new ArrayList(); mergeList.Add("MergeIdList", listId); } else { return(messages1); } return(msgProduct); }
private void txtRCard_TxtboxKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if (e.KeyChar == '\r') { UserControl.Messages msg = new UserControl.Messages(); string rcard = Web.Helper.FormatHelper.CleanString(txtRCard.Value.Trim().ToUpper()); //检查产品序列号格式 msg.AddMessages(MatchMo(rcard, CurrentSequence - 1)); if (!msg.IsSuccess()) { ucMessage.Add(msg); this.txtMoCode.TextFocus(false, true); return; } else { #region 业务处理 //如果为最后一次,则提交更新 if (CurrentSequence == dsMo.MultiMo.Rows.Count) { //更新RunningCard UpdateListRCard(CurrentSequence - 1); ActionOnLineHelper _helper = new ActionOnLineHelper(this.DataProvider); DataProvider.BeginTransaction(); try { #region 循环完成归属工单 foreach (DataRow dr in dsMo.MultiMo) { string runningCard = Convert.ToString(dr["产品序列号"]); string moCode = Convert.ToString(dr["工单"]); msg.AddMessages(_helper.GetIDInfo(runningCard)); if (msg.IsSuccess()) { ProductInfo product = (ProductInfo)msg.GetData().Values[0]; GoToMOActionEventArgs args = new GoToMOActionEventArgs( ActionType.DataCollectAction_GoMO, runningCard, ApplicationService.Current().UserCode, ApplicationService.Current().ResourceCode, product, moCode); IAction action = new ActionFactory(this.DataProvider).CreateAction(ActionType.DataCollectAction_GoMO); msg.AddMessages(action.Execute(args)); } if (msg.IsSuccess()) { this.DataProvider.CommitTransaction(); UpdateCollectQty(); msg.Add(new UserControl.Message(MessageType.Success, "$CS_GOMO_CollectSuccess $CS_GONEXT_BILL")); } else { ClearListRCard(); this.DataProvider.RollbackTransaction(); break; } } #endregion } catch (Exception E) { ClearListRCard(); this.DataProvider.RollbackTransaction(); msg.Add(new UserControl.Message(E)); } finally { //Laws Lu,2005/10/19,新增 缓解性能问题 ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.CloseConnection(); ucMessage.Add(msg); if (MoCodes != null && MoCodes.Length > 0) { UpdateList(MoCodes); } //CurrentSequence = 1; //dsMo.MultiMo.AcceptChanges(); } } else { //更新RunningCard UpdateListRCard(CurrentSequence - 1); CurrentSequence++; } #endregion } //提示用户继续输入产品序列号 ucMessage.Add(">>$CS_Please_Input_RunningCard " + CurrentSequence.ToString() + "/" + dsMo.MultiMo.Rows.Count.ToString()); txtRCard.Value = ""; txtRCard.TextFocus(false, true); } }