public BaseDCTAction GetEndNodeAction(IDCTClient client) { BaseDCTAction action = null; SQLDomainDataProvider domainProvider = null; if (client.DBConnection != null) { domainProvider = client.DBConnection as BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider; } else { domainProvider = DomainDataProviderManager.DomainDataProvider() as SQLDomainDataProvider; client.DBConnection = domainProvider; } BaseModelFacade baseModelFacade = new BaseModelFacade(domainProvider); if (client.ResourceCode != null && client.ResourceCode.Trim().Length > 0) { Resource res = (Resource)baseModelFacade.GetResource(client.ResourceCode.Trim().ToUpper()); if (res != null && res.DctCode != null & res.DctCode.Trim().Length > 0) { action = (new ActionHelper()).GetActionByCommand(res.DctCode.Trim().ToUpper()); } } if (action == null) { action = new ActionIdle(); } return(action); }
public frmDCTMonitor(IDCTClient client) { // // Windows 窗体设计器支持所必需的 // InitializeComponent(); _client = client; // // TODO: 在 InitializeComponent 调用后添加任何构造函数代码 // }
public virtual void SendMessage(object sender, Messages msgs) { Message msg = new Message(); for (int i = 0; i < msgs.Count(); i++) { if (msgs.Objects(i).Type != MessageType.Data) { msg = msgs.Objects(i); } } IDCTClient client = sender as IDCTClient; if (msg.Body != String.Empty) { string send_msg = MutiLanguages.ParserMessage(msg.Body); if (send_msg.IndexOf("$") < 0) { client.SendMessage(send_msg); } } if (msg.Exception != null) { string send_msg = MutiLanguages.ParserMessage(msg.Exception.Message); if (send_msg.IndexOf("$") < 0) { client.SendMessage(send_msg); } } if (msg != null) { switch (msg.Type) { case MessageType.Succes: { break; } case MessageType.Error: { System.Threading.Thread.Sleep(500); break; } default: { break; } } } }
// public DCTFactory() // { // // // // TODO: 在此处添加构造函数逻辑 // // // } public static IDCTClient CreateDCTClient(string ip, int port) { IDCTClient client = null; if (frmDCTServer.IsRS485 == true) { client = new DSC19Client(ip, port); } else if (port == 55962) { client = new GW28Client(ip, port); } else if (port == 4660) { client = new DT4000Client(ip, port); } else if (port == 12345) { client = new PCClient(ip, port); } return(client); }
public Messages CheckProduct(string rcard, object act) { currentProductInfo = null; moWillGo = null; Messages msg = new Messages(); 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); msg = _helper.GetIDInfo(rcard); if (msg.IsSuccess()) { IDCTClient client = (IDCTClient)act; ProductInfo product = (ProductInfo)msg.GetData().Values[0]; bool bNeedCheckMO = false; if (product == null || product.LastSimulation == null) { /* 需要再检查是否归属工单 * msg.Add(new UserControl.Message(UserControl.MessageType.Error,"$NoSimulation")); * return msg; */ bNeedCheckMO = true; } else { // 如果完工,并且当前资源不属于Simulation的当前工序,则需要检查归属工单 if (product.LastSimulation.IsComplete == "1") { BenQGuru.eMES.BaseSetting.BaseModelFacade dataModel = new BenQGuru.eMES.BaseSetting.BaseModelFacade(domainProvider); if (dataModel.GetOperation2Resource(product.LastSimulation.OPCode, client.ResourceCode) == null) { bNeedCheckMO = true; } } } Messages msgChkErr = new Messages(); if (bNeedCheckMO == true) { ActionGoToMO actionGoMO = new ActionGoToMO(domainProvider); Messages msgMo = actionGoMO.GetItemCodeFromGoMoRCard(client.ResourceCode, rcard); if (msgMo.IsSuccess() == false) // 如果有错误,表示需要归属工单,但是解析工单或查询工单发生错误 { msgChkErr.AddMessages(msgMo); } else // 返回成功,有两种情况:需要归属工单并且返回正确的工单信息;不需要归属工单 { UserControl.Message msgMoData = msgMo.GetData(); if (msgMoData != null && msgMoData.Values.Length > 0) // 有DATA数据,表示需要归属工单 { this.moWillGo = (MO)msgMoData.Values[0]; } else // 如果没有DATA数据,表示不需要归属工单,则调用以前的代码:如果LastSimulation为空,则报没有序列号 { if (product.LastSimulation == null) { msgChkErr.Add(new UserControl.Message(UserControl.MessageType.Error, "$NoSimulation")); } } } } if (msgChkErr.IsSuccess() == false) { return(msgChkErr); } if (product.LastSimulation != null) // 只有在序列号存在的情况下才检查途程 { msg = _helper.CheckID(new TSActionEventArgs(ActionType.DataCollectAction_NG, rcard, client.LoginedUser, client.ResourceCode, product, new object[] {}, null, "")); } if (product.LastSimulation == null || msg.IsSuccess() == true) { currentProductInfo = product; } else if (product.LastSimulation.LastAction == ActionType.DataCollectAction_GOOD || product.LastSimulation.LastAction == ActionType.DataCollectAction_NG || product.LastSimulation.LastAction == ActionType.DataCollectAction_OutLineGood || product.LastSimulation.LastAction == ActionType.DataCollectAction_OutLineNG) // 允许测试站重复采集 { BenQGuru.eMES.BaseSetting.BaseModelFacade dataModel = new BenQGuru.eMES.BaseSetting.BaseModelFacade(domainProvider); if (dataModel.GetOperation2Resource(product.LastSimulation.OPCode, (act as IDCTClient).ResourceCode) != null) { msg.ClearMessages(); currentProductInfo = product; } } } return(msg); }
public virtual void SendMessage(object sender, Messages msgs, string command) { IDCTClient client = sender as IDCTClient; Message msg = new Message(); for (int i = 0; i < msgs.Count(); i++) { if (msgs.Objects(i).Type != MessageType.Data) { msg = msgs.Objects(i); //处理一般的输出信息 if (msg.Body != String.Empty) { string send_msg = MutiLanguages.ParserMessage(msg.Body); if (send_msg.IndexOf("$") < 0) { if (msg.Type == MessageType.DCTClear) { client.SendMessage(empty); } if (msg.Type == MessageType.DCTData) { SendMessageEx(client, send_msg); } else { SendMessageEx(client, send_msg); } } else // 将缺失的Message记录下来 { try { string strFile = @"C:\DCT_EmptyMessage.txt"; System.IO.StreamWriter writer = new System.IO.StreamWriter(strFile, true); writer.WriteLine(msg.Body); writer.Close(); } catch { } } if (msg.Type == MessageType.Normal && msg.Body.Trim().Length > 0) { this._LastPrompt = send_msg.Trim(); } } //处理异常 if (msg.Exception != null) { string send_msg = MutiLanguages.ParserMessage(msg.Exception.Message); if (send_msg.IndexOf("$") < 0) { if (msg.Type == MessageType.DCTClear) { client.SendMessage(empty); } if (msg.Type == MessageType.DCTData) { SendMessageEx(client, send_msg); } else { SendMessageEx(client, send_msg); } } } //发出声音 if (msg != null) { switch (msg.Type) { case MessageType.Success: { //if(CurrentDirect == FlowDirect.WaitingOutPut && BeepSuccess) if (BeepSuccess) { client.SendCommand(DCTCommand.SpeakerOn); } break; } case MessageType.Error: { if (BeepError) { for (int j = 0; j < BeepCount; j++) { client.SendCommand(BeepType); System.Threading.Thread.Sleep(BeepInterval); } } break; } default: { if (BeepSuccess) { client.SendCommand(DCTCommand.SpeakerOn); } break; } } } //记录WorkingError if (msg.Type == MessageType.Error || msg.Exception != null) { try { SQLDomainDataProvider domainProvider = null; if (client.DBConnection != null) { domainProvider = client.DBConnection as BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider; } else { domainProvider = DomainDataProviderManager.DomainDataProvider() as SQLDomainDataProvider; client.DBConnection = domainProvider; } DataCollectFacade dataCollectFacade = new DataCollectFacade(domainProvider); string userCode = client.LoginedUser; string resCode = client.ResourceCode; string segCode = client.SegmentCode; string ssCode = client.StepSequenceCode; string shiftTypeCode = client.ShiftTypeCode; string errorMessageCode = string.Empty; string errorMessage = string.Empty; if (msg.Type == MessageType.Error) { errorMessageCode = msg.Body; errorMessage = MutiLanguages.ParserMessage(msg.Body); } if (msg.Exception != null) { errorMessageCode = msg.Exception.Message; errorMessage = MutiLanguages.ParserMessage(msg.Exception.Message); } dataCollectFacade.LogWorkingError(userCode, resCode, segCode, ssCode, shiftTypeCode, WorkingErrorFunctionType.DCT, command, this._LastPrompt + ": " + client.ToString(), errorMessageCode, errorMessage); } catch (Exception ex) { //throw ex; } } } } }
//DCT每行的英文字符数 //private int DCTEnLineLen = 30; private void SendMessageEx(IDCTClient client, string send_msg) { client.SendMessage(send_msg); }
public override Messages Action(object act) { Messages msg = new Messages(); if (act == null) { return(msg); } DataCollect.Action.ActionEventArgs args; if (ObjectState == null) { args = new BenQGuru.eMES.DataCollect.Action.ActionEventArgs(); } else { args = ObjectState as DataCollect.Action.ActionEventArgs; } string data = act.ToString().ToUpper().Trim(); msg = CheckData(data); if (msg.IsSuccess()) { base.Action(act); //关键逻辑,将ActionEventArgs对象传递到下一个Action args.ResourceCode = data; //ActionPassword acPwd = new ActionPassword(); // acPwd.ObjectState = ObjectState; // next_action = acPwd; object[] objUserGroup = args.UserGroup; bool bIsAdmin = false; if (objUserGroup != null) { foreach (object o in objUserGroup) { if (((UserGroup)o).UserGroupType == "ADMIN") { bIsAdmin = true; break; } } } if (!bIsAdmin) { if (!(new Security.SecurityFacade(Common.DomainDataProvider.DomainDataProviderManager.DomainDataProvider())) .CheckResourceRight(args.UserCode, args.ResourceCode)) { msg.Add(new UserControl.Message(UserControl.MessageType.Error, "$Error_No_Resource_Right")); } } ObjectState = args; msg.Add(new Message(MessageType.Data, "", new object[] { args })); } if (msg.IsSuccess()) { msg.Add(new UserControl.Message(UserControl.MessageType.Success, "$DCT_WELCOME")); if (act is IDCTClient) { IDCTClient client = act as IDCTClient; client.Authorized = true; client.LoginedUser = args.UserCode; client.LoginedPassword = args.Passwod; client.ResourceCode = args.ResourceCode; } ActionRCard actRcard = new ActionRCard(); //actRcard.LastAction = this; NextAction = actRcard; } return(msg); }
public override Messages Action(object act) { Messages msg = new Messages(); BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider domainProvider = null; if (act == null) { return(msg); } 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; } if (m_FlowControl == 1) { string itemCode = ((Item)_item).ItemCode.ToString(); strCarton = act.ToString().Trim().ToUpper(); if (((Item)_item).NeedCheckCarton == FormatHelper.TRUE_STRING) { if (strRcard.StartsWith(itemCode, StringComparison.CurrentCultureIgnoreCase)) { if (string.Compare(strRcard, strCarton, true) == 0) { msg.Add(new UserControl.Message(MessageType.Error, "$Error_CartonNotMatchTheRule")); msg.Add(new UserControl.Message(MessageType.Success, "$CS_PLEASE_INPUT_CARTONNO")); this.Status = ActionStatus.PrepareData; return(msg); } else { if (string.Compare(strRcard.Replace(" ", ""), strCarton.Replace(" ", ""), true) != 0) { msg.Add(new UserControl.Message(MessageType.Error, "$Error_CartonCheckFailed")); msg.Add(new UserControl.Message(MessageType.Success, "$CS_PLEASE_INPUT_CARTONNO")); this.Status = ActionStatus.PrepareData; return(msg); } else { msg.Add(new UserControl.Message(MessageType.Success, "$CARTON_COMPARE_ISSUCCESS")); } } } else { if (string.Compare(strRcard, strCarton, true) == 0) { msg.Add(new UserControl.Message(MessageType.Success, "$CARTON_COMPARE_ISSUCCESS")); } else { msg.Add(new UserControl.Message(MessageType.Error, "$Error_CartonCheckFailed")); msg.Add(new UserControl.Message(MessageType.Success, "$CS_PLEASE_INPUT_CARTONNO")); this.Status = ActionStatus.PrepareData; return(msg); } } } object obj = (new Package.PackageFacade(domainProvider)).GetCARTONINFO(act.ToString().Trim().ToUpper()); if (obj != null && ((CARTONINFO)obj).CAPACITY.ToString() == ((CARTONINFO)obj).COLLECTED.ToString()) { msg.Add(new UserControl.Message(MessageType.Error, "$CARTON_ALREADY_FILL_OUT")); msg.Add(new UserControl.Message(MessageType.Success, "$CS_PLEASE_INPUT_CARTONNO")); this.Status = ActionStatus.PrepareData; return(msg); } else { m_FlowControl++; msg.Add(new UserControl.Message(MessageType.Normal, "$CS_PLEASE_INPUT_WRAPPER")); this.Status = ActionStatus.PrepareData; return(msg); } } else { //if (((Simulation)_objSimulation).ItemCode.ToUpper().Trim() == act.ToString().ToUpper()) if (((Simulation)_objSimulation).RunningCard.ToUpper().IndexOf(act.ToString().ToUpper()) == 0) { ActionOnLineHelper actionOnLineHelper = new ActionOnLineHelper(domainProvider); BenQGuru.eMES.DataCollect.Action.ActionFactory actionFactory = new BenQGuru.eMES.DataCollect.Action.ActionFactory(domainProvider); IAction actionCartonPack = actionFactory.CreateAction(ActionType.DataCollectAction_Carton); //((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.OpenConnection(); msg = actionOnLineHelper.GetIDInfo(strRcard); string cartonno = FormatHelper.CleanString(strCarton); IDCTClient client = act as IDCTClient; //add by hiro 08/09/28 DBDateTime dbDateTime; dbDateTime = FormatHelper.GetNowDBDateTime(domainProvider); PackageFacade _Packfacade = new PackageFacade(domainProvider); PACKINGCHK newPackingCheck = _Packfacade.CreateNewPACKINGCHK(); newPackingCheck.Rcard = ((Simulation)_objSimulation).RunningCard.ToString().ToUpper(); newPackingCheck.CheckAccessory = FormatHelper.TRUE_STRING; newPackingCheck.CheckProductCode = FormatHelper.FALSE_STRING; newPackingCheck.MUSER = (act as IDCTClient).LoginedUser; newPackingCheck.MDATE = dbDateTime.DBDate; newPackingCheck.MTIME = dbDateTime.DBTime; newPackingCheck.EATTRIBUTE1 = " "; object objGet = _Packfacade.GetPACKINGCHK(((Simulation)_objSimulation).RunningCard.ToString().ToUpper()); if (objGet != null) { _Packfacade.DeletePACKINGCHK((PACKINGCHK)objGet); _Packfacade.AddPACKINGCHK(newPackingCheck); } else { _Packfacade.AddPACKINGCHK(newPackingCheck); } //end by hiro Messages msgTwo = new Messages(); domainProvider.BeginTransaction(); try { if (msg.IsSuccess()) { ProductInfo product = (ProductInfo)msg.GetData().Values[0]; if (product.LastSimulation == null) { base.Action(act); msgTwo.Add(new UserControl.Message(new Exception("$Error_LastSimulation_IsNull!"))); this.ObjectState = null; return(msgTwo); } CartonPackEventArgs cartonPackEventArgs = new CartonPackEventArgs(ActionType.DataCollectAction_Carton, strRcard, client.LoginedUser, client.ResourceCode, "", cartonno, product); msgTwo.AddMessages(actionCartonPack.Execute(cartonPackEventArgs)); } if (msgTwo.IsSuccess()) { domainProvider.CommitTransaction(); } else { domainProvider.RollbackTransaction(); msgTwo.Add(new UserControl.Message(MessageType.Normal, "$CS_Please_Input_RunningCard")); this.Status = ActionStatus.PrepareData; this.FlowDirect = FlowDirect.WaitingInput; this.ObjectState = null; this.clearValue(); return(msgTwo); } } catch (Exception ex) { domainProvider.RollbackTransaction(); msg.Add(new UserControl.Message(ex)); msg.Add(new UserControl.Message(MessageType.Normal, "$CS_Please_Input_RunningCard")); this.Status = ActionStatus.PrepareData; this.FlowDirect = FlowDirect.WaitingInput; this.ObjectState = null; this.clearValue(); return(msg); } finally { ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.CloseConnection(); } base.Action(act); msg.Add(new UserControl.Message(MessageType.Success, "$CS_COMPAREAPPENDIX_SUCCESS")); msg.Add(new UserControl.Message(MessageType.Success, "$CS_RCARD_CARTON_SUCCESS [" + strCarton + "]")); this.ObjectState = null; this.clearValue(); return(msg); } else { msg.Add(new UserControl.Message(MessageType.Error, "$CS_COMPAREAPPENDIX_NOTSUCCESS")); msg.Add(new UserControl.Message(MessageType.Normal, "$CS_PLEASE_INPUT_WRAPPER")); this.Status = ActionStatus.PrepareData; return(msg); } } }
// 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(); //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; } DataCollectFacade dataCollect = new DataCollect.DataCollectFacade(domainProvider); TSFacade tsFacade = new TSFacade(domainProvider); if (msg.IsSuccess()) { MO moWillGo = (MO)keypartsHT["MOWillGo"]; ProductInfo product = (ProductInfo)keypartsHT["ProdcutInfo"]; if (opBomDetailCount > opBomDetailCollectNum) { try { object[] opBomDetailCompare = new object[opBomDetailList.Count]; opBomDetailList.CopyTo(opBomDetailCompare); string ItemCode = string.Empty; string parseTypeSetting = "," + ((OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]).OPBOMParseType + ","; string checkTypeSetting = "," + ((OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]).OPBOMCheckType + ","; bool checkStatus = ((OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]).CheckStatus == BenQGuru.eMES.Web.Helper.FormatHelper.TRUE_STRING; string CheckNeedVendor = string.Empty; if (!string.IsNullOrEmpty(((OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]).NeedVendor)) { CheckNeedVendor = ((OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]).NeedVendor; } string MItemCode = ((OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]).OPBOMItemCode; string OBSItemCode = ((OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]).OPBOMSourceItemCode; int inputLength = ((OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]).SerialNoLength; MaterialFacade facade = new MaterialFacade(domainProvider); MINNO newMINNO = facade.CreateNewMINNO(); newMINNO.MItemCode = MItemCode; Messages parseSuccess = new Messages(); Messages oldParseSuccess = new Messages(); parseSuccess.Add(new UserControl.Message(MessageType.Error, "$CS_Error_ParseFailed:")); int num = 0; //勾选了料号比对,必须选择解析方式 if (checkTypeSetting.IndexOf("," + OPBOMDetailCheckType.CHECK_COMPAREITEM.ToLower() + ",") >= 0) { if (parseTypeSetting.IndexOf("," + OPBOMDetailParseType.PARSE_BARCODE.ToLower() + ",") < 0 && parseTypeSetting.IndexOf("," + OPBOMDetailParseType.PARSE_PREPARE.ToLower() + ",") < 0 && parseTypeSetting.IndexOf("," + OPBOMDetailParseType.PARSE_PRODUCT.ToLower() + ",") < 0) { msg.Add(new UserControl.Message(MessageType.Error, " $CS_Error_ParseFailed:$CheckCompareItem_Must_CheckOneParse")); goto Label2; } } //Parse from barcode if (!parseSuccess.IsSuccess() && parseTypeSetting.IndexOf("," + OPBOMDetailParseType.PARSE_BARCODE.ToLower() + ",") >= 0) { OPBOMDetail opBOMDetailForItemCode = null; if (checkTypeSetting.IndexOf("," + OPBOMDetailCheckType.CHECK_COMPAREITEM.ToLower() + ",") >= 0) { opBOMDetailForItemCode = (OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]; } oldParseSuccess.AddMessages(parseSuccess); parseSuccess = dataCollect.ParseFromBarcode(ref newMINNO, data, opBOMDetailForItemCode, inputLength); num += 1; } //Parse from prepare if (!parseSuccess.IsSuccess() && parseTypeSetting.IndexOf("," + OPBOMDetailParseType.PARSE_PREPARE.ToLower() + ",") >= 0) { Simulation sim = (Simulation)dataCollect.GetSimulation(ID); newMINNO.MOCode = sim.MOCode; OPBOMDetail opBOMDetailForItemCode = null; if (checkTypeSetting.IndexOf("," + OPBOMDetailCheckType.CHECK_COMPAREITEM.ToLower() + ",") >= 0) { opBOMDetailForItemCode = (OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]; } oldParseSuccess.AddMessages(parseSuccess); parseSuccess = dataCollect.ParseFromPrepare(ref newMINNO, data, opBOMDetailForItemCode, inputLength); num += 1; } //Parse from product if (!parseSuccess.IsSuccess() && parseTypeSetting.IndexOf("," + OPBOMDetailParseType.PARSE_PRODUCT.ToLower() + ",") >= 0) { OPBOMDetail opBOMDetailForItemCode = null; if (checkTypeSetting.IndexOf("," + OPBOMDetailCheckType.CHECK_COMPAREITEM.ToLower() + ",") >= 0) { opBOMDetailForItemCode = (OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]; } oldParseSuccess.AddMessages(parseSuccess); parseSuccess = dataCollect.ParseFromProduct(ref newMINNO, checkStatus, data, opBOMDetailForItemCode, inputLength); num += 1; } if (!parseSuccess.IsSuccess()) { if (num > 0) { oldParseSuccess.AddMessages(parseSuccess); msg.AddMessages(oldParseSuccess); goto Label2; } if (num == 0) { if (inputLength > 0 && data.Trim().Length != inputLength) { msg.Add(new UserControl.Message(MessageType.Error, "$Error_SNLength_Wrong")); goto Label2; } } } //检查新上料是否在TS中而不可用 if (!tsFacade.RunningCardCanBeClollected(data, CardType.CardType_Part)) { msg.Add(new UserControl.Message(MessageType.Error, "$Error_Material_InTSOrScrapped $SERIAL_NO=" + data)); goto Label2; } #region Check if key part was used if (((OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]).OPBOMItemControlType == BOMItemControlType.ITEM_CONTROL_KEYPARTS && KeyPartUsed(domainProvider, data, newMINNO.MItemCode, true)) { msg.Add(new UserControl.Message(MessageType.Error, "$CS_Error_KeyPartUsed")); goto Label2; } #endregion #region check NeedVendor //如果VendorCode为空,到tblmaterial中获取 if (newMINNO.VendorCode == null || newMINNO.VendorCode.Trim().Length <= 0) { ItemFacade itemfacade = new ItemFacade(domainProvider); object objMaterial = itemfacade.GetMaterial(newMINNO.MItemCode.Trim(), GlobalVariables.CurrentOrganizations.First().OrganizationID); if (objMaterial != null) { newMINNO.VendorCode = ((BenQGuru.eMES.Domain.MOModel.Material)objMaterial).VendorCode; } } if (CheckNeedVendor == NeedVendor.NeedVendor_Y) { Messages checkNeedVendor = new Messages(); checkNeedVendor = dataCollect.CheckNeedVebdor(newMINNO); if (!checkNeedVendor.IsSuccess()) { msg.AddMessages(checkNeedVendor); goto Label2; } } #endregion if (checkTypeSetting.IndexOf("," + OPBOMDetailCheckType.CHECK_LINKBARCODE.ToLower() + ",") >= 0) { //Link barcode if (string.IsNullOrEmpty(newMINNO.MItemCode)) { newMINNO.MItemCode = MItemCode; } newMINNO.MItemPackedNo = data; if (((OPBOMDetail)opBomDetailList[opBomDetailCollectNum]).OPBOMItemControlType == BOMItemControlType.ITEM_CONTROL_KEYPARTS) { newMINNO.EAttribute1 = MCardType.MCardType_Keyparts; } else if (((OPBOMDetail)opBomDetailList[opBomDetailCollectNum]).OPBOMItemControlType == BOMItemControlType.ITEM_CONTROL_LOT) { newMINNO.EAttribute1 = MCardType.MCardType_INNO; newMINNO.Qty = ((OPBOMDetail)opBomDetailList[opBomDetailCollectNum]).OPBOMItemQty; } opBomdetailRealCollectList.Add((object)newMINNO); } ++opBomDetailCollectNum; Label2: if (opBomDetailCount > opBomDetailCollectNum) { if (((OPBOMDetail)opBomDetailList[opBomDetailCollectNum]).OPBOMItemControlType != null && ((OPBOMDetail)opBomDetailList[opBomDetailCollectNum]).OPBOMItemControlType == BOMItemControlType.ITEM_CONTROL_LOT) { msg.Add(new UserControl.Message(MessageType.Normal, ">>$DCT_PLEASE_INPUT_Lot:" + ((OPBOMDetail)opBomDetailList[opBomDetailCollectNum]).OPBOMSourceItemCode)); ProcessBeforeReturn(this.Status, msg); return(msg); } else { msg.Add(new UserControl.Message(MessageType.Normal, ">>$CS_PleaseInputKeypart:" + ((OPBOMDetail)opBomDetailList[opBomDetailCollectNum]).OPBOMSourceItemCode)); ProcessBeforeReturn(this.Status, msg); return(msg); } } } catch (Exception ex) { msg.Add(new UserControl.Message(MessageType.Error, ex.Message)); } } 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); 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; //检查新上料是否在TS中而不可用 if (opBomdetailRealCollectList != null) { foreach (MINNO minno in opBomdetailRealCollectList) { if (!tsFacade.RunningCardCanBeClollected(minno.MItemPackedNo, CardType.CardType_Part)) { msg.Add(new UserControl.Message(MessageType.Error, "$Error_Material_InTSOrScrapped $SERIAL_NO=" + minno.MItemPackedNo)); break; } } } #region Check if key part was used if (opBomdetailRealCollectList != null) { foreach (MINNO minno in opBomdetailRealCollectList) { if (minno.EAttribute1 == MCardType.MCardType_Keyparts) { if (KeyPartUsed(domainProvider, minno.MItemPackedNo, minno.MItemCode, false)) { msg.Add(new UserControl.Message(MessageType.Error, "$CS_Error_KeyPartUsed")); break; } } } } #endregion if (msg.IsSuccess()) { object[] objOpBomdetailRealCollect = new object[opBomdetailRealCollectList.Count]; opBomdetailRealCollectList.CopyTo(objOpBomdetailRealCollect); string strRCard = product.NowSimulation.RunningCard; msg.AddMessages(_helper.ActionWithTransaction( new CINNOActionEventArgs( ActionType.DataCollectAction_CollectINNO, strRCard, client.LoginedUser, client.ResourceCode, product, string.Empty, wfacade), actionCheckStatus, objOpBomdetailRealCollect)); } #region 物料过账 if (msg.IsSuccess()) { BaseModelFacade bMfacade = new BaseModelFacade(domainProvider); object objOP = bMfacade.GetOperationByResource(client.ResourceCode); string strRCard = product.NowSimulation.RunningCard; object[] objOpBomdetailRealCollect = new object[opBomdetailRealCollectList.Count]; opBomdetailRealCollectList.CopyTo(objOpBomdetailRealCollect); if (opBomdetailRealCollectList != null && opBomdetailRealCollectList.Count > 0) { Messages messagesNew = new Messages(); string ItemCode = string.Empty; DataCollectFacade dataCollectFacade = new DataCollectFacade(domainProvider); object objectSimulation = dataCollectFacade.GetSimulation(strRCard); if (objectSimulation != null) { ItemCode = ((Simulation)objectSimulation).ItemCode; } foreach (MINNO minno in opBomdetailRealCollectList) { messagesNew.AddMessages(_helper.ActionWithTransaction(new TryEventArgs( ActionType.DataCollectAction_TryNew, client.LoginedUser, ((Operation2Resource)objOP).OPCode, client.ResourceCode, ItemCode, strRCard, minno.MItemCode, minno.MItemPackedNo, string.Empty, true, true))); } msg.AddMessages(messagesNew); } } #endregion if (msg.IsSuccess()) { if (System.Configuration.ConfigurationSettings.AppSettings["NeedMaterialModule"].Trim() == "1") { if (wfacade != null) { wfacade.ExecCacheSQL(); } } #region 增加良品采集 { Resource Resource = (Resource)dataModel.GetResource(client.ResourceCode); Messages messages1 = new Messages(); if (actionCheckStatus.ProductInfo == null) { messages1 = _helper.GetIDInfo(ID); actionCheckStatus.ProductInfo = (ProductInfo)messages1.GetData().Values[0]; actionCheckStatus.ProductInfo.Resource = Resource; lastSimulation = actionCheckStatus.ProductInfo.LastSimulation; msg.AddMessages(messages1); } else //将上一个Action的NowSimulation设置为本Action的LastSimulation { if (actionCheckStatus.ActionList.Count > 0) { actionCheckStatus.ProductInfo = new ProductInfo(); actionCheckStatus.ProductInfo.NowSimulation = new Simulation(); actionCheckStatus.ProductInfo.Resource = Resource; //actionCheckStatus.ProductInfo.LastSimulation = // new ExtendSimulation(((ActionEventArgs)actionCheckStatus.ActionList[actionCheckStatus.ActionList.Count - 1]).ProductInfo.NowSimulation); actionCheckStatus.ProductInfo.LastSimulation = new ExtendSimulation((Simulation)(new DataCollectFacade(domainProvider)).GetLastSimulationOrderByDateAndTime(ID)); } } product = actionCheckStatus.ProductInfo; // Changed end if (msg.IsSuccess()) { messages1.AddMessages(_helper.ActionWithTransaction(new ActionEventArgs(ActionType.DataCollectAction_GOOD, ID, client.LoginedUser, client.ResourceCode, product), actionCheckStatus)); } } #endregion } if (msg.IsSuccess()) { domainProvider.CommitTransaction(); msg.Add(new UserControl.Message(MessageType.Success, string.Format("$CS_CollectSuccess"))); } else { domainProvider.RollbackTransaction(); } } catch (Exception ex) { domainProvider.RollbackTransaction(); msg.Add(new UserControl.Message(ex)); } finally { ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.CloseConnection(); } } if (msg.IsSuccess()) { base.Action(act); this.ObjectState = null; this.keypartsHT = null; this.opBomDetailList.Clear(); this.opBomDetailCount = 0; this.opBomDetailCollectNum = 0; this.opBomdetailRealCollectList.Clear(); ID = string.Empty; } ProcessBeforeReturn(this.Status, msg); return(msg); }
// 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 override Messages Action(object act) { Messages msg = new Messages(); BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider domainProvider = null; if (act == null) { return(msg); } if (currentProductInfo == null) { return(msg); } DataCollect.Action.ActionEventArgs args; if (ObjectState == null) { args = new BenQGuru.eMES.DataCollect.Action.ActionEventArgs(); } else { args = ObjectState as DataCollect.Action.ActionEventArgs; } string data = act.ToString().ToUpper().Trim(); //Errorcode //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; } if (string.Compare(data, BaseDCTDriver.FINERROR, true) != 0)//结束的标志 { msg = CheckData(data, domainProvider); if (msg.IsSuccess()) { if (errorCodesHT == null) { errorCodesHT = new Hashtable(); } bool bExist = false; if (!errorCodesHT.ContainsKey(data)) { errorCodesHT.Add(data, data); } else { bExist = true; } if (bExist == false) { //msg.Add(new UserControl.Message(MessageType.Succes,data)); // Removed by Icyer 2007/01/09 避免重复输出 } else { msg.Add(new UserControl.Message(MessageType.Success, "$ErrorCodeCollected")); } this.Status = ActionStatus.PrepareData; return(msg); } else { this.Status = ActionStatus.PrepareData; return(msg); } } if (msg.IsSuccess()) { //检查序列号 ActionOnLineHelper _helper = new ActionOnLineHelper(domainProvider); msg = _helper.GetIDInfo(args.RunningCard); if (msg.IsSuccess()) { ProductInfo product = (ProductInfo)msg.GetData().Values[0]; TSModelFacade tsmodelFacade = new TSModelFacade(domainProvider); if (errorCodesHT == null) { msg.Add(new UserControl.Message(UserControl.MessageType.Error, "$ErrorCode_Not_Exist")); } if (msg.IsSuccess()) { string[] errorcs = new string[errorCodesHT.Count]; int i = 0; foreach (DictionaryEntry dic in errorCodesHT) { errorcs[i] = dic.Key.ToString(); i++; } /* Removed by Icyer 2007/03/15 允许自动归属工单 * //Laws Lu,2006/06/22 modify fix the bug that system alert object not set an instance when the product.LastSimulation is null * if(product.LastSimulation == null) * { * msg.Add(new UserControl.Message(UserControl.MessageType.Error,"$NoSimulation")); * } */ object[] errorcodes = null; if (msg.IsSuccess()) { //errorcodes = tsmodelFacade.QueryECG2ECByECAndModelCode(errorcs, product.LastSimulation.ModelCode); string strModelCode = this.GetModelCodeFromProduct(product, this.moWillGo, domainProvider); if (strModelCode != "") { errorcodes = tsmodelFacade.QueryECG2ECByECAndModelCode(errorcs, strModelCode); } if (errorcodes == null || errorcodes.Length == 0) { msg.Add(new UserControl.Message(UserControl.MessageType.Error, "$ErrorCode_Not_BelongTo_ModelCode")); this.Status = ActionStatus.PrepareData; return(msg); } } if (msg.IsSuccess()) { IAction dataCollectModule = new BenQGuru.eMES.DataCollect.Action.ActionFactory(domainProvider).CreateAction(ActionType.DataCollectAction_NG); //((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.OpenConnection(); domainProvider.BeginTransaction(); try { IDCTClient client = act as IDCTClient; msg.AddMessages(((IActionWithStatus)dataCollectModule).Execute( new TSActionEventArgs(ActionType.DataCollectAction_NG, args.RunningCard, client.LoginedUser, client.ResourceCode, product, errorcodes, null, ""))); if (msg.IsSuccess()) { domainProvider.CommitTransaction(); msg.Add(new UserControl.Message(MessageType.Success, string.Format("$CS_NGSUCCESS"))); //msg.Add( new UserControl.Message(MessageType.Succes ,string.Format("$CS_NGSUCCESS,$CS_Param_ID: {0}", args.RunningCard))); } else { domainProvider.RollbackTransaction(); } } catch (Exception ex) { domainProvider.RollbackTransaction(); msg.Add(new UserControl.Message(ex)); } finally { ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.CloseConnection(); } } } } } //if((act as IDCTClient).CachedAction is ActionCollectNG) //{ // if(this.Status == BenQGuru.eMES.Common.DCT.Core.ActionStatus.Working) // { // this.ObjectState = null; // if(this.errorCodesHT != null) // { // this.errorCodesHT.Clear(); // } // } // this.Status = BenQGuru.eMES.Common.DCT.Core.ActionStatus.PrepareData; // (act as IDCTClient).CachedAction = this; //} if (this.errorCodesHT == null) { msg.ClearMessages(); } if (msg.IsSuccess() || this.errorCodesHT == null) { base.Action(act); } else { msg.Add(new UserControl.Message(MessageType.Normal, "$DCT_NG_Please_Input_NG_SN")); this.Status = ActionStatus.PrepareData; this.FlowDirect = FlowDirect.WaitingInput; } currentProductInfo = null; moWillGo = null; this.ObjectState = null; if (this.errorCodesHT != null) { this.errorCodesHT.Clear(); } return(msg); }
public override Messages Action(object act) { Messages msgs = new Messages(); if (act == null) { return(msgs); } 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 = DomainDataProviderManager.DomainDataProvider() as SQLDomainDataProvider; (act as IDCTClient).DBConnection = domainProvider; } string data = act.ToString().Trim().ToUpper(); if (_ResCode.Trim().Length <= 0) { //输入资源 if (msgs.IsSuccess()) { if (data.Length <= 0) { msgs.Add(new UserControl.Message(UserControl.MessageType.Error, "$Error_Resource_Empty")); } } if (msgs.IsSuccess()) { object resource = new BaseModelFacade(domainProvider).GetResource(data); if (resource == null) { msgs.Add(new UserControl.Message(UserControl.MessageType.Error, "$Error_Resource_Not_Exist")); } } if (msgs.IsSuccess()) { _ResCode = data; } } if (msgs.IsSuccess()) { bool bIsAdmin = false; if (_UserGroup != null) { foreach (object o in _UserGroup) { if (((UserGroup)o).UserGroupType == "ADMIN") { bIsAdmin = true; break; } } } if (!bIsAdmin) { if (!(new Security.SecurityFacade(domainProvider)).CheckResourceRight(_UserCode, _ResCode)) { msgs.Add(new UserControl.Message(UserControl.MessageType.Error, "$Error_No_Resource_Right")); } } } if (msgs.IsSuccess()) { object res = new BaseModelFacade(domainProvider).GetResource(_ResCode); object org = (new BaseModelFacade(domainProvider)).GetOrg(((Resource)res).OrganizationID); if (org != null) { GlobalVariables.CurrentOrganizations.Clear(); GlobalVariables.CurrentOrganizations.Add((Organization)org); } else { msgs.Add(new UserControl.Message(UserControl.MessageType.Error, "$Error_NoOrganizationOfTheResource")); } } if (msgs.IsSuccess()) { msgs.Add(new UserControl.Message(UserControl.MessageType.Success, "$DCT_WELCOME")); if (act is IDCTClient) { IDCTClient client = act as IDCTClient; client.Authorized = true; client.LoginedUser = _UserCode; client.LoginedPassword = _Password; client.ResourceCode = _ResCode; Resource resource = (Resource)(new BaseModelFacade(domainProvider)).GetResource(data); if (resource != null) { client.SegmentCode = resource.SegmentCode; client.StepSequenceCode = resource.StepSequenceCode; client.ShiftTypeCode = resource.ShiftTypeCode; } } } if (msgs.IsSuccess()) { this.Status = ActionStatus.Pass; } ProcessBeforeReturn(this.Status, msgs); return(msgs); }
public override Messages Action(object act) { Messages msg = new Messages(); 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(); } else { args = ObjectState as DataCollect.Action.ActionEventArgs; } string data = act.ToString().ToUpper().Trim(); //Errorcode //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; } if (string.Compare(data, BaseDCTDriver.FINERROR, true) != 0) //结束的标志 { msg = CheckData(data, domainProvider); if (msg.IsSuccess()) { if (errorCodesHT == null) { errorCodesHT = new Hashtable(); } if (!errorCodesHT.ContainsKey(data)) { errorCodesHT.Add(data, data); } base.Action(act); ActionCollectOutlineNG actionCollectOutlineNG = this; actionCollectOutlineNG.IsTopAction = false; this.NextAction = actionCollectOutlineNG; this.Status = ActionStatus.PrepareData; //Laws Lu,2006/07/11 write back error code msg.Add(new UserControl.Message(MessageType.Success, data)); return(msg); } } if (msg.IsSuccess()) { //检查序列号 ActionOnLineHelper _helper = new ActionOnLineHelper(domainProvider); msg = _helper.GetIDInfo(args.RunningCard); if (msg.IsSuccess()) { ProductInfo product = (ProductInfo)msg.GetData().Values[0]; TSModelFacade tsmodelFacade = new TSModelFacade(domainProvider); if (errorCodesHT == null) { msg.Add(new UserControl.Message(UserControl.MessageType.Error, "$ErrorCode_Not_Exist")); } if (msg.IsSuccess()) { string[] errorcs = new string[errorCodesHT.Count]; int i = 0; foreach (DictionaryEntry dic in errorCodesHT) { errorcs[i] = dic.Key.ToString(); i++; } //Laws Lu,2006/06/22 modify fix the bug that system alert object not set an instance when the product.LastSimulation is null if (product.LastSimulation == null) { msg.Add(new UserControl.Message(UserControl.MessageType.Error, "$NoSimulation")); } object[] errorcodes = null; if (msg.IsSuccess()) { errorcodes = tsmodelFacade.QueryECG2ECByECAndModelCode(errorcs, product.LastSimulation.ModelCode); if (errorcodes == null || errorcodes.Length == 0) { msg.Add(new UserControl.Message(UserControl.MessageType.Error, "$ErrorCode_Not_BelongTo_ModelCode")); } } object[] oplist = null; if (msg.IsSuccess()) { oplist = GetOutLineOP(domainProvider, (act as IDCTClient).ResourceCode); if (oplist == null || oplist.Length == 0) { msg.Add(new UserControl.Message(MessageType.Error, "$CSError_Res_Cannot_Collect_OUtlineGood")); } } string opcode = string.Empty; if (msg.IsSuccess()) { opcode = (oplist[0] as Operation).OPCode; if (CheckOutlineOPInRoute(domainProvider, product.LastSimulation.RouteCode, opcode)) { msg.Add(new UserControl.Message(MessageType.Error, "$CS_OutLineOP_In_ThisRoute")); } } if (msg.IsSuccess()) { if (IsLastOP(domainProvider, product.LastSimulation.MOCode, product.LastSimulation.RouteCode, product.LastSimulation.OPCode)) { msg.Add(new UserControl.Message(MessageType.Error, "$CS_Op_IsLast_OutLineOP_Cannot_Collect")); } } if (msg.IsSuccess()) { IAction dataCollectModule = new BenQGuru.eMES.DataCollect.Action.ActionFactory(domainProvider).CreateAction(ActionType.DataCollectAction_OutLineNG); domainProvider.BeginTransaction(); try { IDCTClient client = act as IDCTClient; msg.AddMessages((dataCollectModule).Execute(new OutLineActionEventArgs( ActionType.DataCollectAction_OutLineNG, args.RunningCard, client.LoginedUser, client.ResourceCode, product, opcode, errorcodes, ""))); if (msg.IsSuccess()) { domainProvider.CommitTransaction(); msg.Add(new UserControl.Message(MessageType.Success, string.Format("$CS_NGSUCCESS"))); //msg.Add( new UserControl.Message(MessageType.Succes ,string.Format("$CS_NGSUCCESS,$CS_Param_ID: {0}", args.RunningCard))); } else { domainProvider.RollbackTransaction(); } } catch (Exception ex) { domainProvider.RollbackTransaction(); msg.Add(new UserControl.Message(ex)); } finally { ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.CloseConnection(); } } } } } if ((act as IDCTClient).CachedAction is ActionCollectOutlineNG) { if (this.Status == BenQGuru.eMES.Common.DCT.Core.ActionStatus.Working) { this.ObjectState = null; if (this.errorCodesHT != null) { this.errorCodesHT.Clear(); } } this.Status = BenQGuru.eMES.Common.DCT.Core.ActionStatus.PrepareData; (act as IDCTClient).CachedAction = this; } base.Action(act); ActionRCard actRcard = new ActionRCard(); this.NextAction = actRcard; return(msg); }
public override Messages Action(object act) { Messages msg = new Messages(); BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider domainProvider = null; if (act == null) { return(msg); } if (currentProductInfo == null) { return(msg); } DataCollect.Action.ActionEventArgs args; if (ObjectState == null) { args = new BenQGuru.eMES.DataCollect.Action.ActionEventArgs(); } else { args = ObjectState as DataCollect.Action.ActionEventArgs; } string data = act.ToString().ToUpper().Trim();//Errorcode //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 (msg.IsSuccess()) { //检查序列号 ActionOnLineHelper _helper = new ActionOnLineHelper(domainProvider); msg = _helper.GetIDInfo(args.RunningCard); if (msg.IsSuccess()) { ProductInfo product = (ProductInfo)msg.GetData().Values[0]; TSModelFacade tsmodelFacade = new TSModelFacade(domainProvider); if (msg.IsSuccess()) { SystemSettingFacade systemSettingFacade = new SystemSettingFacade(domainProvider); object parameter = systemSettingFacade.GetParameter("DEFAULTERRORCODE", "NGCOLLECTDEFAULTERRORCODE"); if (parameter == null) { msg.Add(new UserControl.Message(MessageType.Error, "$Error_NoDefaultErrorCode")); msg.Add(new UserControl.Message(MessageType.Normal, "$DCT_NG_Please_Input_NG_SN")); this.Status = ActionStatus.PrepareData; this.FlowDirect = FlowDirect.WaitingInput; //base.Action(act); return(msg); } Parameter errorCodeParameter = parameter as Parameter; object errorCode = tsmodelFacade.GetErrorCode(errorCodeParameter.ParameterAlias); if (errorCode == null) { msg.Add(new UserControl.Message(MessageType.Error, "$ErrorCode_Not_Exist")); msg.Add(new UserControl.Message(MessageType.Normal, "$DCT_NG_Please_Input_NG_SN")); this.Status = ActionStatus.PrepareData; this.FlowDirect = FlowDirect.WaitingInput; return(msg); } object[] ecgObjects = tsmodelFacade.GetErrorCodeGroupByErrorCodeCode(((ErrorCodeA)errorCode).ErrorCode); if (ecgObjects == null || ecgObjects.Length == 0) { msg.Add(new UserControl.Message(MessageType.Error, "$Error_ErrorCodeNoErrorGroup")); msg.Add(new UserControl.Message(MessageType.Normal, "$DCT_NG_Please_Input_NG_SN")); this.Status = ActionStatus.PrepareData; this.FlowDirect = FlowDirect.WaitingInput; return(msg); } ErrorCodeGroup2ErrorCode ecg2ec = (ErrorCodeGroup2ErrorCode)tsmodelFacade.GetErrorCodeGroup2ErrorCodeByecCode(((ErrorCodeA)errorCode).ErrorCode); object[] errorcodes = new object[] { ecg2ec }; //if (msg.IsSuccess()) //{ // string strModelCode = this.GetModelCodeFromProduct(product, this.moWillGo, domainProvider); // if (strModelCode != "") // { // errorcodes = tsmodelFacade.QueryECG2ECByECAndModelCode(new string[] { ((ErrorCodeA)errorCode).ErrorCode }, strModelCode); // } // if (errorcodes == null || errorcodes.Length == 0) // { // msg.Add(new UserControl.Message(UserControl.MessageType.Error, "$ErrorCode_Not_BelongTo_ModelCode")); // base.Action(act); // ActionRCard actRcard = new ActionRCard(); // this.NextAction = actRcard; // return msg; // } //} if (msg.IsSuccess()) { IAction dataCollectModule = new BenQGuru.eMES.DataCollect.Action.ActionFactory(domainProvider).CreateAction(ActionType.DataCollectAction_NG); domainProvider.BeginTransaction(); try { IDCTClient client = act as IDCTClient; msg.AddMessages(((IActionWithStatus)dataCollectModule).Execute( new TSActionEventArgs(ActionType.DataCollectAction_NG, args.RunningCard, client.LoginedUser, client.ResourceCode, product, errorcodes, null, ""))); if (msg.IsSuccess()) { domainProvider.CommitTransaction(); base.Action(act); msg.Add(new UserControl.Message(MessageType.Success, string.Format("$CS_NGSUCCESS"))); return(msg); } else { domainProvider.RollbackTransaction(); } } catch (Exception ex) { domainProvider.RollbackTransaction(); msg.Add(new UserControl.Message(ex)); } finally { ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.CloseConnection(); } } } } } if (msg.IsSuccess()) { base.Action(act); } else { msg.Add(new UserControl.Message(MessageType.Normal, "$DCT_NG_Please_Input_NG_SN")); this.FlowDirect = FlowDirect.WaitingInput; } return(msg); }
public override Messages Action(object act) { Messages msg = new Messages(); BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider domainProvider = null; if (act == null) { return(msg); } IDCTClient client = act as IDCTClient; if (currentProductInfo == null) { return(msg); } DataCollect.Action.ActionEventArgs args; if (ObjectState == null) { args = new BenQGuru.eMES.DataCollect.Action.ActionEventArgs(); } else { args = ObjectState as DataCollect.Action.ActionEventArgs; } string data = act.ToString().ToUpper().Trim(); //Errorcode //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; } if (string.Compare(data, BaseDCTDriver.FINERROR, true) != 0) //结束的标志 { msg = CheckData(data, domainProvider); if (msg.IsSuccess()) { if (_currInputStep.StepType == InputStepType.ErrorCode) //一次完整的ErrorCode 与 Error Location的输入完成 { if (errorCodesHT == null) { errorCodesHT = new Hashtable(); } string key = _currInputStep.ErrorCode + "&" + _currInputStep.ErrorLoc; bool bExist = false; if (!errorCodesHT.ContainsKey(key)) { errorCodesHT.Add(key, key); } else { bExist = true; } if (bExist == false) { //msg.Add(new UserControl.Message(MessageType.Succes,data)); // Removed by Icyer 2007/01/09 避免重复输出 } else { msg.Add(new UserControl.Message(MessageType.Success, "$ErrorCodeCollected")); } this.Status = ActionStatus.PrepareData; return(msg); } else { this.Status = ActionStatus.PrepareData; return(msg); } } else { this.Status = ActionStatus.PrepareData; return(msg); } } if (msg.IsSuccess()) { //检查序列号 ActionOnLineHelper _helper = new ActionOnLineHelper(domainProvider); msg = _helper.GetIDInfo(args.RunningCard); if (msg.IsSuccess()) { ProductInfo product = (ProductInfo)msg.GetData().Values[0]; TSModelFacade tsmodelFacade = new TSModelFacade(domainProvider); if (errorCodesHT == null) { msg.Add(new UserControl.Message(UserControl.MessageType.Error, "$ErrorCode_Not_Exist")); } if (msg.IsSuccess()) { #region 得到用户输入的 Error Code和Error Location BenQGuru.eMES.Domain.TS.TSErrorCode2Location[] errorInfo = new BenQGuru.eMES.Domain.TS.TSErrorCode2Location[errorCodesHT.Count]; TSModel.TSModelFacade tsFacade = new TSModelFacade(domainProvider); int i = 0; foreach (DictionaryEntry dic in errorCodesHT) { string[] keys = dic.Key.ToString().Split('&'); if (keys.Length > 1) { //没有Location if (keys[1].Contains(NoLoc)) { object[] objs = tsFacade.GetErrorCodeGroupByErrorCodeCode(keys[0]); errorInfo[i] = new BenQGuru.eMES.Domain.TS.TSErrorCode2Location(); if (objs != null && objs.Length > 0) { ErrorCodeGroupA errorgroup = (ErrorCodeGroupA)objs[0]; errorInfo[i].ErrorCode = keys[0]; errorInfo[i].ErrorCodeGroup = errorgroup.ErrorCodeGroup; errorInfo[i].ErrorLocation = string.Empty; errorInfo[i].AB = ItemLocationSide.ItemLocationSide_AB; } } else //有location { object[] objs = tsFacade.GetErrorCodeGroupByErrorCodeCode(keys[0]); errorInfo[i] = new BenQGuru.eMES.Domain.TS.TSErrorCode2Location(); if (objs != null && objs.Length > 0) { ErrorCodeGroupA errorgroup = (ErrorCodeGroupA)objs[0]; errorInfo[i].ErrorCode = keys[0]; errorInfo[i].ErrorCodeGroup = errorgroup.ErrorCodeGroup; errorInfo[i].ErrorLocation = keys[1]; errorInfo[i].AB = ItemLocationSide.ItemLocationSide_AB; } } } else //没有Location { object[] objs = tsFacade.GetErrorCodeGroupByErrorCodeCode(keys[0]); errorInfo[i] = new BenQGuru.eMES.Domain.TS.TSErrorCode2Location(); if (objs != null && objs.Length > 0) { ErrorCodeGroupA errorgroup = (ErrorCodeGroupA)objs[0]; errorInfo[i].ErrorCode = keys[0]; errorInfo[i].ErrorCodeGroup = errorgroup.ErrorCodeGroup; errorInfo[i].ErrorLocation = string.Empty; errorInfo[i].AB = ItemLocationSide.ItemLocationSide_AB; } } i++; } #endregion /* * string[] errorcs = new string[errorCodesHT.Count]; * int i=0; * foreach( DictionaryEntry dic in errorCodesHT ) * { * errorcs[i] = dic.Key.ToString(); * i++; * } * */ /* Removed by Icyer 2007/03/15 允许自动归属工单 * //Laws Lu,2006/06/22 modify fix the bug that system alert object not set an instance when the product.LastSimulation is null * if(product.LastSimulation == null) * { * msg.Add(new UserControl.Message(UserControl.MessageType.Error,"$NoSimulation")); * } */ /* * object[] errorcodes = null; * if(msg.IsSuccess()) * { * //errorcodes = tsmodelFacade.QueryECG2ECByECAndModelCode(errorcs, product.LastSimulation.ModelCode); * string strModelCode = this.GetModelCodeFromProduct(product, this.moWillGo, domainProvider); * if (strModelCode != "") * { * errorcodes = tsmodelFacade.QueryECG2ECByECAndModelCode(errorcs, strModelCode); * } * * if( errorcodes==null || errorcodes.Length==0 ) * { * msg.Add(new UserControl.Message(UserControl.MessageType.Error,"$ErrorCode_Not_BelongTo_ModelCode")); * base.Action (act); * ActionCollectSMTNG actionCollectNG = this; * actionCollectNG.IsTopAction = false; * this.NextAction = actionCollectNG; * this.Status = ActionStatus.PrepareData; * return msg; * } * } */ if (msg.IsSuccess()) { IAction dataCollectModule = new BenQGuru.eMES.DataCollect.Action.ActionFactory(domainProvider).CreateAction(ActionType.DataCollectAction_NG); //((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.OpenConnection(); domainProvider.BeginTransaction(); try { //IDCTClient client = act as IDCTClient; ActionCheckStatus actionCheckStatus = new ActionCheckStatus(); msg.AddMessages(((IActionWithStatus)dataCollectModule).Execute( new TSActionEventArgs(ActionType.DataCollectAction_SMTNG, args.RunningCard, client.LoginedUser, client.ResourceCode, product, errorInfo, ""), actionCheckStatus)); if (msg.IsSuccess()) { domainProvider.CommitTransaction(); msg.Add(new UserControl.Message(MessageType.Success, string.Format("$CS_NGSUCCESS"))); } else { domainProvider.RollbackTransaction(); } } catch (Exception ex) { domainProvider.RollbackTransaction(); msg.Add(new UserControl.Message(ex)); } finally { ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.CloseConnection(); } } } } } //if((act as IDCTClient).CachedAction is ActionCollectSMTNG) //{ // if(this.Status == BenQGuru.eMES.Common.DCT.Core.ActionStatus.Working) // { // this.ObjectState = null; // if(this.errorCodesHT != null) // { // this.errorCodesHT.Clear(); // } // } // this.Status = BenQGuru.eMES.Common.DCT.Core.ActionStatus.PrepareData; // (act as IDCTClient).CachedAction = this; //} if (this.errorCodesHT == null) { msg.ClearMessages(); } if (msg.IsSuccess() || this.errorCodesHT == null) { base.Action(act); } else { msg.Add(new UserControl.Message(MessageType.Normal, "$DCT_NG_Please_Input_NG_SN")); this.Status = ActionStatus.PrepareData; this.FlowDirect = FlowDirect.WaitingInput; } currentProductInfo = null; moWillGo = null; this.ObjectState = null; if (this.errorCodesHT != null) { this.errorCodesHT.Clear(); } return(msg); }
// private Messages DoDataCollectAction(Common.DomainDataProvider.SQLDomainDataProvider domainProvider, IDCTClient client, string runningCard) { Messages messages = new Messages(); ActionOnLineHelper _helper = new ActionOnLineHelper(domainProvider); messages = _helper.GetIDInfo(runningCard); ProductInfo product = (ProductInfo)messages.GetData().Values[0]; /* * if (product == null || product.LastSimulation == null) * { * messages.Add(new UserControl.Message(MessageType.Error, "$NoSimulation")); * return messages; * } */ CINNOActionEventArgs args = new CINNOActionEventArgs( ActionType.DataCollectAction_CollectINNO, runningCard, client.LoginedUser, client.ResourceCode, product, INNOCode, null ); IAction action = new BenQGuru.eMES.DataCollect.Action.ActionFactory(domainProvider).CreateAction(ActionType.DataCollectAction_CollectINNO); domainProvider.BeginTransaction(); try { messages.AddMessages(action.Execute(args)); if (messages.IsSuccess()) { domainProvider.CommitTransaction(); messages.Add(new UserControl.Message(MessageType.Success, "$CS_INNO_CollectSuccess")); } else { domainProvider.RollbackTransaction(); } return(messages); } catch (Exception ex) { domainProvider.RollbackTransaction(); messages.Add(new UserControl.Message(ex)); return(messages); } finally { ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.CloseConnection(); } }
public override Messages Action(object act) { Messages msgs = new Messages(); if (act == null) { return(msgs); } SQLDomainDataProvider domainProvider = null; if ((act as IDCTClient).DBConnection != null) { domainProvider = (act as IDCTClient).DBConnection as SQLDomainDataProvider; } else { domainProvider = DomainDataProviderManager.DomainDataProvider() as SQLDomainDataProvider; (act as IDCTClient).DBConnection = domainProvider; } 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; } if (msgs.IsSuccess()) { ActionOnLineHelper _helper = new ActionOnLineHelper(domainProvider); msgs = _helper.GetIDInfo(args.RunningCard); if (msgs.IsSuccess()) { ProductInfo product = (ProductInfo)msgs.GetData().Values[0]; IAction dataCollectModule = new BenQGuru.eMES.DataCollect.Action.ActionFactory(domainProvider).CreateAction(ActionType.DataCollectAction_GOOD); domainProvider.BeginTransaction(); try { IDCTClient client = act as IDCTClient; //良品采集 if (msgs.IsSuccess()) { msgs.AddMessages(((IActionWithStatus)dataCollectModule).Execute( new ActionEventArgs( ActionType.DataCollectAction_GOOD, args.RunningCard, client.LoginedUser, client.ResourceCode, product))); } if (msgs.IsSuccess()) { domainProvider.CommitTransaction(); msgs.Add(new UserControl.Message(MessageType.Success, string.Format("$CS_GOODSUCCESS"))); } else { domainProvider.RollbackTransaction(); } } catch (Exception ex) { domainProvider.RollbackTransaction(); msgs.Add(new UserControl.Message(ex)); } finally { ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.CloseConnection(); } } } if (msgs.IsSuccess()) { base.Action(act); } ProcessBeforeReturn(this.Status, msgs); return(msgs); }
public override Messages Action(object act) { Messages msg = new Messages(); 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; } //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; } if (msg.IsSuccess()) { //检查序列号 ActionOnLineHelper _helper = new ActionOnLineHelper(domainProvider); msg = _helper.GetIDInfo(args.RunningCard); if (msg.IsSuccess()) { ProductInfo product = (ProductInfo)msg.GetData().Values[0]; if (product.LastSimulation == null) { msg.Add(new UserControl.Message(UserControl.MessageType.Error, "$NoSimulation")); } object[] oplist = null; if (msg.IsSuccess()) { oplist = GetOutLineOP(domainProvider, (act as IDCTClient).ResourceCode); if (oplist == null || oplist.Length == 0) { msg.Add(new UserControl.Message(MessageType.Error, "$CSError_Res_Cannot_Collect_OUtlineGood")); } } string opcode = string.Empty; if (msg.IsSuccess()) { opcode = (oplist[0] as Operation).OPCode; if (CheckOutlineOPInRoute(domainProvider, product.LastSimulation.RouteCode, opcode)) { msg.Add(new UserControl.Message(MessageType.Error, "$CS_OutLineOP_In_ThisRoute")); } } if (msg.IsSuccess()) { if (IsLastOP(domainProvider, product.LastSimulation.MOCode, product.LastSimulation.RouteCode, product.LastSimulation.OPCode)) { msg.Add(new UserControl.Message(MessageType.Error, "$CS_Op_IsLast_OutLineOP_Cannot_Collect")); } } if (msg.IsSuccess()) { //((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)Common.DomainDataProvider.DomainDataProviderManager.DomainDataProvider()).PersistBroker.OpenConnection(); domainProvider.BeginTransaction(); try { IDCTClient client = act as IDCTClient; IAction dataCollectModule = new BenQGuru.eMES.DataCollect.Action.ActionFactory(domainProvider).CreateAction(ActionType.DataCollectAction_OutLineGood); msg.AddMessages((dataCollectModule).Execute(new OutLineActionEventArgs( ActionType.DataCollectAction_OutLineGood, args.RunningCard, client.LoginedUser, client.ResourceCode, product, opcode))); if (msg.IsSuccess()) { domainProvider.CommitTransaction(); msg.Add(new UserControl.Message(MessageType.Success, string.Format("$CS_GOODSUCCESS"))); } 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); // // Web.Helper.ActionType acttype = new Web.Helper.ActionType(); // if(acttype.Items.Contains(args.RunningCard)) // { // (act as IDCTClient).CachedAction = null; // } // ActionRCard actRcard = new ActionRCard(); this.NextAction = actRcard; return(msg); }
// private Messages DoDataCollectAction(Common.DomainDataProvider.SQLDomainDataProvider domainProvider, IDCTClient client, bool IsSameMO, int ExistIMEISeq, bool UpdateSimulation) { Messages messages = new Messages(); ProductInfo product = (ProductInfo)(((UserControl.Messages)mergeList["ProdcutInfo"]).GetData().Values[0]); ArrayList listId = (ArrayList)mergeList["MergeIdList"]; SplitIDActionEventArgs args = new SplitIDActionEventArgs( ActionType.DataCollectAction_Split, product.LastSimulation.RunningCard, client.LoginedUser, client.ResourceCode, product, (object[])listId.ToArray(), this.mergeIdType, IsSameMO, ExistIMEISeq, UpdateSimulation); IAction action = new BenQGuru.eMES.DataCollect.Action.ActionFactory(domainProvider).CreateAction(ActionType.DataCollectAction_Split); domainProvider.BeginTransaction(); try { messages.AddMessages(action.Execute(args)); if (messages.IsSuccess()) { domainProvider.CommitTransaction(); messages.Add(new UserControl.Message(MessageType.Success, "$CS_SplitID_CollectSuccess")); } else { domainProvider.RollbackTransaction(); } return(messages); } catch (Exception ex) { domainProvider.RollbackTransaction(); messages.Add(new UserControl.Message(ex)); return(messages); } finally { ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.CloseConnection(); } }
// 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 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); }
// 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; } }
public override Messages Action(object act) { Messages msg = new Messages(); 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(); } else { args = ObjectState as DataCollect.Action.ActionEventArgs; } string data = act.ToString().ToUpper().Trim(); //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 (msg.IsSuccess()) { //关键逻辑,将ActionEventArgs对象传递到下一个Action args.ResourceCode = data; //ActionPassword acPwd = new ActionPassword(); // acPwd.ObjectState = ObjectState; // this.NextAction = acPwd; object[] objUserGroup = args.UserGroup; bool bIsAdmin = false; if (objUserGroup != null) { foreach (object o in objUserGroup) { if (((UserGroup)o).UserGroupType == "ADMIN") { bIsAdmin = true; break; } } } if (!bIsAdmin) { if (!(new Security.SecurityFacade(domainProvider)) .CheckResourceRight(args.UserCode, args.ResourceCode)) { msg.Add(new UserControl.Message(UserControl.MessageType.Error, "$Error_No_Resource_Right")); } } ObjectState = args; msg.Add(new Message(MessageType.Data, "", new object[] { args })); // Added By Scott Gu for Hisense Version : Add Org ID object obj = new BaseModelFacade(domainProvider).GetResource(args.ResourceCode); object org = (new BaseModelFacade(domainProvider)).GetOrg(((Resource)obj).OrganizationID); if (org != null) { GlobalVariables.CurrentOrganizations.Clear(); GlobalVariables.CurrentOrganizations.Add((Organization)org); } else { msg.Add(new UserControl.Message(UserControl.MessageType.Error, "$Error_NoOrganizationOfTheResource")); } } if (msg.IsSuccess()) { base.Action(act); msg.Add(new UserControl.Message(UserControl.MessageType.Success, "$DCT_WELCOME")); if (act is IDCTClient) { IDCTClient client = act as IDCTClient; client.Authorized = true; client.LoginedUser = args.UserCode; client.LoginedPassword = args.Passwod; client.ResourceCode = args.ResourceCode; } ActionRCard actRcard = new ActionRCard(); actRcard.OutMesssage = new Message(MessageType.Normal, "$DCT_PLEASE_ACTION"); actRcard.NeedInputActionCommand = true; //actRcard.LastAction = this; this.NextAction = actRcard; } return(msg); }
public override Messages Action(object act) { Messages msgs = new Messages(); if (act == null) { return(msgs); } SQLDomainDataProvider domainProvider = null; if ((act as IDCTClient).DBConnection != null) { domainProvider = (act as IDCTClient).DBConnection as SQLDomainDataProvider; } else { domainProvider = DomainDataProviderManager.DomainDataProvider() as SQLDomainDataProvider; (act as IDCTClient).DBConnection = domainProvider; } 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; } if (msgs.IsSuccess()) { ActionOnLineHelper _helper = new ActionOnLineHelper(domainProvider); msgs = _helper.GetIDInfo(args.RunningCard); if (msgs.IsSuccess()) { ProductInfo product = (ProductInfo)msgs.GetData().Values[0]; IAction dataCollectModule = new BenQGuru.eMES.DataCollect.Action.ActionFactory(domainProvider).CreateAction(ActionType.DataCollectAction_GOOD); domainProvider.BeginTransaction(); try { IDCTClient client = act as IDCTClient; // 同时做归属工单 if (this.NeedGoMO == true && this.NeedGoMOCode != string.Empty) { ActionGotoMO actionGoMO = new ActionGotoMO(); msgs.AddMessages(actionGoMO.CheckSNFormat(args)); if (msgs.IsSuccess()) { IAction dataCollectModuleGoMO = new BenQGuru.eMES.DataCollect.Action.ActionFactory(domainProvider).CreateAction(ActionType.DataCollectAction_GoMO); msgs.AddMessages(((IActionWithStatus)dataCollectModuleGoMO).Execute( new GoToMOActionEventArgs( ActionType.DataCollectAction_GoMO, args.RunningCard, client.LoginedUser, client.ResourceCode, product, this.NeedGoMOCode))); } // 做归属工单后,重新获取ProductInfo if (msgs.IsSuccess()) { msgs = _helper.GetIDInfo(args.RunningCard); product = (ProductInfo)msgs.GetData().Values[0]; } } //良品采集 if (msgs.IsSuccess()) { msgs.AddMessages(((IActionWithStatus)dataCollectModule).Execute( new ActionEventArgs( ActionType.DataCollectAction_GOOD, args.RunningCard, client.LoginedUser, client.ResourceCode, product))); } // 做SMT物料关联 if (msgs.IsSuccess()) { if (System.Configuration.ConfigurationSettings.AppSettings["PartConn"] != null && System.Configuration.ConfigurationSettings.AppSettings["PartConn"].ToUpper().Trim() == "TRUE") { msgs.AddMessages(this.SMTLoadItem(args.RunningCard.ToUpper().Trim(), client.ResourceCode.ToUpper(), client.LoginedUser.ToUpper(), domainProvider)); } } if (msgs.IsSuccess()) { domainProvider.CommitTransaction(); msgs.Add(new UserControl.Message(MessageType.Success, string.Format("$CS_GOODSUCCESS"))); } else { domainProvider.RollbackTransaction(); } } catch (Exception ex) { domainProvider.RollbackTransaction(); msgs.Add(new UserControl.Message(ex)); } finally { ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.CloseConnection(); } } } if (msgs.IsSuccess()) { base.Action(act); } ProcessBeforeReturn(this.Status, msgs); return(msgs); }
// Added end public override Messages Action(object act) { Messages msgs = new Messages(); BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider domainProvider = null; if (act == null) { return(msgs); } DataCollect.Action.ActionEventArgs args; if (ObjectState == null) { args = new BenQGuru.eMES.DataCollect.Action.ActionEventArgs(); } else { args = ObjectState as DataCollect.Action.ActionEventArgs; } string data = act.ToString().ToUpper().Trim();//产品序列号 args.RunningCard = data; //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); // Removed by Icyer 2006/12/15 msgs = CheckSN(this._moCode, args.RunningCard, domainProvider); //add by hiro 08/11/05 if (msgs.IsSuccess()) { msgs = this.CheckSNContent(this._moCode, args.RunningCard, domainProvider); } //end by hiro if (msgs.IsSuccess()) { //检查序列号 ActionOnLineHelper _helper = new ActionOnLineHelper(domainProvider); //msg.AddMessages( _helper.GetIDInfo( args.RunningCard ) ); msgs = _helper.GetIDInfoByMoCodeAndId(_moCode, args.RunningCard); if (msgs.IsSuccess()) { IDCTClient client = act as IDCTClient; ProductInfo product = (ProductInfo)msgs.GetData().Values[0]; GoToMOActionEventArgs gotoMOArgs = new GoToMOActionEventArgs( ActionType.DataCollectAction_GoMO, args.RunningCard, client.LoginedUser, client.ResourceCode, product, _moCode); IAction action = new BenQGuru.eMES.DataCollect.Action.ActionFactory(domainProvider).CreateAction(ActionType.DataCollectAction_GoMO); //((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.OpenConnection(); domainProvider.BeginTransaction(); try { msgs = ((IActionWithStatus)action).Execute(gotoMOArgs); if (msgs.IsSuccess()) { domainProvider.CommitTransaction(); msgs.Add(new UserControl.Message(MessageType.Success, string.Format("$CS_GOMO_CollectSuccess"))); } else { if (msgs.OutPut().IndexOf("$CS_ID_Has_Already_Belong_To_This_MO") == 0) { msgs.ClearMessages(); msgs.Add(new UserControl.Message(UserControl.MessageType.Error, "$CS_ID_Has_Already_Belong_To_This_MO")); } domainProvider.RollbackTransaction(); } } catch (Exception ex) { domainProvider.RollbackTransaction(); msgs.Add(new UserControl.Message(ex)); } finally { ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.CloseConnection(); } } } if (msgs.IsSuccess()) { base.Action(act); } this.ObjectState = null; ProcessBeforeReturn(this.Status, msgs); return(msgs); }