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); } }
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); }
public UserControl.Messages GoodCollect(object[] parserObjs) { UserControl.Messages returnMsg = new UserControl.Messages(); try { foreach (object obj in parserObjs) { AOIData aoiData = obj as AOIData; int errorCount = 0; try { errorCount = int.Parse(aoiData.ERRORCOUNT); } catch {} if (errorCount == 0) { ActionOnLineHelper onLine = new ActionOnLineHelper(this._domainDataProvider); // ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)_domainDataProvider).PersistBroker.AutoCloseConnection = false; // ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)_domainDataProvider).PersistBroker.OpenConnection(); Messages messages = onLine.GetIDInfo(aoiData.RCARD.Trim().ToUpper()); try { ProductInfo product = (ProductInfo)messages.GetData().Values[0]; // Added by Icyer 2006/08/03 // 只有当Simulation中没有数据时,才认为是第一次经过AOI站,才执行SMT上料 bool bExecuteSMTLoadItem = (product.LastSimulation == null); // Added end this._domainDataProvider.BeginTransaction(); string goodResult = string.Empty; //归属工单采集 //Laws Lu,2006/08/10 归属工单时需要检查是否符合首字符串和长度检查 string moCode = this.getMOCode(aoiData.RCARD.Trim().ToUpper()); if (System.Configuration.ConfigurationSettings.AppSettings["MOPREFIXSTRING"] != null) { string moPrefix = System.Configuration.ConfigurationSettings.AppSettings["MOPREFIXSTRING"].Trim(); //首字符串检查 if (moCode.Length < moPrefix.Length || moCode.Substring(0, moPrefix.Length) != moPrefix) { returnMsg.Add(new UserControl.Message(MessageType.Error , "$CS_Before_Card_FLetter_NotCompare $CS_Param_ID: " + aoiData.RCARD.Trim().ToUpper())); } } if (System.Configuration.ConfigurationSettings.AppSettings["SNLENGTH"] != null) { try { int snLength = int.Parse(System.Configuration.ConfigurationSettings.AppSettings["SNLENGTH"].Trim()); //长度检查 if (aoiData.RCARD.Trim().ToUpper().Length != snLength) { returnMsg.Add(new UserControl.Message(MessageType.Error, "$CS_Before_Card_Length_FLetter_NotCompare $CS_Param_ID: " + aoiData.RCARD.Trim().ToUpper())); } } catch (Exception ex) { returnMsg.Add(new UserControl.Message(ex)); } } if (returnMsg.IsSuccess()) { 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, moCode))); if (messages.IsSuccess()) { returnMsg.Add(new UserControl.Message(UserControl.MessageType.Success, string.Format("{0} $CS_GOMO_CollectSuccess", aoiData.RCARD.ToUpper()))); } else { returnMsg.Add(new UserControl.Message(UserControl.MessageType.Error, AgentHelp.GetErrorMessage(messages))); } } messages.ClearMessages(); //GOOD采集 messages = onLine.GetIDInfo(aoiData.RCARD.Trim().ToUpper()); product = (ProductInfo)messages.GetData().Values[0]; BenQGuru.eMES.DataCollect.DataCollectFacade dcFacade = new BenQGuru.eMES.DataCollect.DataCollectFacade(this._domainDataProvider); goodResult = dcFacade.ActionCollectGood(aoiData.RCARD.ToUpper(), aoiData.USER.ToUpper(), AgentHelp.getResCode(aoiData.RESOURCE.ToUpper())); // Added by Icyer 2006/08/03 // SMT上料 if (returnMsg.IsSuccess() == true && bExecuteSMTLoadItem == true) { returnMsg.AddMessages(this.SMTLoadItem(aoiData.RCARD.ToUpper(), AgentHelp.getResCode(aoiData.RESOURCE.ToUpper()), aoiData.USER.ToUpper())); } // Added end if (goodResult == "OK") { this._domainDataProvider.CommitTransaction(); returnMsg.Add(new UserControl.Message(UserControl.MessageType.Success, string.Format("{0} $CS_GOOD_CollectSuccess", aoiData.RCARD.ToUpper()))); returnMsg.Add(new UserControl.Message(" ")); BenQGuru.eMES.Common.Log.Info(string.Format("{0} $CS_GOOD_CollectSuccess: {1}", aoiData.RCARD.Trim().ToUpper(), "OK")); messages.Add(new UserControl.Message(MessageType.Success, string.Format("$CS_GOODSUCCESS,$CS_Param_ID:{0}", aoiData.RCARD.ToUpper()))); } else { this._domainDataProvider.RollbackTransaction(); string errorMsg = string.Format("{0} $CS_GOOD_CollectFail : {1}", aoiData.RCARD.Trim().ToUpper(), goodResult); 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(); // ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)_domainDataProvider).PersistBroker.AutoCloseConnection = true; } } } } catch {} return(returnMsg); }