Esempio n. 1
0
 // executes a single listener heartbeat
 private void DoListenerHeartbeat(ActionRule actionRule, By by, int interval)
 {
     try
     {
         // find all the elements match the locator send action to them
         var elements = WebDriver?.FindElements(by);
         if (elements?.Count > 0)
         {
             foreach (var element in elements)
             {
                 ActionFactory.Execute(actionRule, element);
             }
         }
     }
     catch (Exception e) when(e is NoSuchElementException || e is StaleElementReferenceException)
     {
         Logger.LogDebug("No elements found, ElementsListener is still running.");
     }
     finally
     {
         Thread.Sleep(interval);
     }
 }
Esempio n. 2
0
        //执行Action
        private void doAction(object vc)
        {
            Messages messages = this._helper.GetIDInfo(Convert.ToString(this.inputBuffer[0]));

            if (messages.IsSuccess())
            {
                ProductInfo product = (ProductInfo)messages.GetData().Values[0];

                if (product == null ||
                    (product != null && product.LastSimulation == null))
                {
                    messages.Add(new UserControl.Message(MessageType.Error, "$NoSimulation"));
                }
                //初始化参数
                SoftwareActionEventArgs args = new SoftwareActionEventArgs(
                    ActionType.DataCollectAction_SoftINFO,
                    this.inputBuffer[0].ToString(),
                    ApplicationService.Current().UserCode,
                    ApplicationService.Current().ResourceCode,
                    (vc == null ? this.inputBuffer[2].ToString() : (vc as Domain.DataCollect.VersionCollect).VersionInfo) /*
                                                                                                                           * this.inputBuffer[2].ToString()*/,
                    this.inputBuffer[1].ToString());

                if (messages.IsSuccess())
                {
                    if (args.CurrentMO == null)
                    {
                        args.CurrentMO = (new MOModel.MOFacade(DataProvider)).GetMO(product.LastSimulation.MOCode) as Domain.MOModel.MO;
                    }
                    if (chkAutoGetVersion.Checked == true && vc != null)
                    {                           //是否需要比对工单版本
                        if (args.CurrentMO.IsCompareSoft == 1)
                        {
                            Messages msgs = CheckSoftVersion(vc, (vc as Domain.DataCollect.VersionCollect).VersionInfo.Trim().ToUpper(), args, product);
                            if (msgs.IsSuccess())
                            {
                                this.ucMessage.Add(new UserControl.Message(MessageType.Success, "$CS_SOFT_CHECK_SUCCESS"));
                            }
                            else
                            {
                                this.ucMessage.Add(msgs);
                            }
                        }
                    }
                    if (chkAutoGetVersion.Checked == false)
                    {                           //是否需要比对工单版本
                        if (args.CurrentMO.IsCompareSoft == 1)
                        {
                            if (this.inputBuffer[2].ToString().Trim().ToUpper() == args.CurrentMO.MOBIOSVersion)
                            {
                                this.ucMessage.Add(new UserControl.Message(MessageType.Success, "$CS_SOFT_CHECK_SUCCESS"));
                            }
                            else
                            {
                                this.ucMessage.Add(new UserControl.Message(MessageType.Error, "$CS_VERSION_COMPARE_NOT_PASS $CS_MO_VERSION="
                                                                           + args.CurrentMO.MOBIOSVersion + " $CS_CURRENT_VERSION=" + this.inputBuffer[2].ToString().Trim().ToUpper()));


                                DataCollectFacade dcf = new DataCollectFacade(DataProvider);
                                Domain.DataCollect.VersionError ve = dcf.CreateNewVersionError();
                                ve.PKID          = System.Guid.NewGuid().ToString();
                                ve.MoVersionInfo = args.CurrentMO.MOBIOSVersion;
                                ve.Mocode        = args.CurrentMO.MOCode;
                                ve.Rcard         = args.RunningCard;
                                ve.VersionInfo   = this.inputBuffer[2].ToString().Trim().ToUpper();

                                //Laws Lu,2006/11/13 uniform system collect date
                                DBDateTime dbDateTime;

                                dbDateTime = FormatHelper.GetNowDBDateTime(DataProvider);


                                ve.MDate = dbDateTime.DBDate;
                                ve.MTime = dbDateTime.DBTime;

                                ve.MUser = args.UserCode;

                                DataProvider.BeginTransaction();
                                try
                                {
                                    dcf.AddVersionError(ve);
                                    //dcf.DeleteVersionCollect(vc as Domain.DataCollect.VersionCollect);

                                    DataProvider.CommitTransaction();
                                }
                                catch (Exception E)
                                {
                                    this.ucMessage.Add(new UserControl.Message(E));
                                    DataProvider.RollbackTransaction();
                                }
                                finally
                                {
                                    ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.CloseConnection();
                                }
                            }
                        }
                    }

                    IAction action = new ActionFactory(this.DataProvider).CreateAction(ActionType.DataCollectAction_SoftINFO);

                    ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.OpenConnection();
                    this.DataProvider.BeginTransaction();
                    try
                    {
                        messages.AddMessages(action.Execute(args));

                        this.ucMessage.Add(CheckConfig(args, product));

                        if (messages.IsSuccess())
                        {
                            this.DataProvider.CommitTransaction();
//							if(chkConfig.Checked == true)
//							{
//								this.ucMessage.Add(new UserControl.Message(MessageType.Success,"$CS_CONFIG_CHECK_SUCCESS"));	//配置比对成功
//							}
                            this.ucMessage.Add(new UserControl.Message(MessageType.Success, "$CS_Soft_CollectSuccess"));                                //软件版本采集成功
                        }
                        else
                        {
                            this.DataProvider.RollbackTransaction();
                        }
                    }
                    catch (Exception ex)
                    {
                        this.DataProvider.RollbackTransaction();
                        messages.Add(new UserControl.Message(ex));
                    }
                    finally
                    {
                        ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.CloseConnection();
                    }
                }
            }

            this.ucMessage.Add(messages);
            ucMessage.Add(">>$CS_Please_Input_RunningCard ");
            ucLEInput.Value = String.Empty;
            this.inputBuffer.Clear();
            ucLEInput.TextFocus(false, true);
        }
Esempio n. 3
0
        private Messages DoAction(string runningCard, string moCode)
        {
            #region 脱离工单业务处理
            Messages msg = new Messages();

            DataCollectFacade dataCollectFacade = new DataCollectFacade(this.DataProvider);
            string            sourceRCard       = dataCollectFacade.GetSourceCard(runningCard.Trim().ToUpper(), string.Empty);

            ActionOnLineHelper _helper = new ActionOnLineHelper(DataProvider);
            msg = _helper.GetIDInfo(sourceRCard);

            if (msg.IsSuccess())
            {
                ProductInfo product = (ProductInfo)msg.GetData().Values[0];

                #region 必要的检查
                if (product == null || (product != null && product.LastSimulation == null))
                {
                    msg.Add(new UserControl.Message(MessageType.Error, "$NoSimulation"));
                }
                else if (product != null && product.LastSimulation.MOCode != moCode)
                {
                    msg.Add(new UserControl.Message(MessageType.Error, "$CS_MO_NOT_MATCH $MOCode=" + product.LastSimulation.MOCode));
                }
                #endregion

                if (msg.IsSuccess())
                {
                    OffMoEventArgs args = new OffMoEventArgs(
                        ActionType.DataCollectAction_OffMo,
                        sourceRCard.Trim(),
                        ApplicationService.Current().UserCode,
                        ApplicationService.Current().ResourceCode,
                        product,
                        moCode);

                    args.MOType = (GetMo(moCode) as Domain.MOModel.MO).MOType;

                    IAction action = new ActionFactory(this.DataProvider).CreateAction(ActionType.DataCollectAction_OffMo);

                    //Laws Lu,2005/10/19,新增	缓解性能问题
                    //					((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.OpenConnection();
                    //					if(!((SQLDomainDataProvider)DataProvider).PersistBroker.IsInTransaction)
                    //					{
                    DataProvider.BeginTransaction();
                    //					}
                    try
                    {
                        msg.AddMessages(action.Execute(args));

                        if (msg.IsSuccess())
                        {
                            //							if(!((SQLDomainDataProvider)DataProvider).PersistBroker.IsInTransaction)
                            //							{
                            DataProvider.CommitTransaction();
                            //							}
                            msg.Add(new UserControl.Message(MessageType.Success, string.Format("$CS_OffMO_Success $MOCode={0} $CS_Param_ID={1}", moCode, runningCard)));

                            DisplayMoInfo(moCode);
                            UpdateCollectQty();
                        }
                        else
                        {
                            //							if(!((SQLDomainDataProvider)DataProvider).PersistBroker.IsInTransaction)
                            //							{
                            this.DataProvider.RollbackTransaction();
                            //							}
                        }
                    }
                    catch (Exception ex)
                    {
                        //						if(!((SQLDomainDataProvider)DataProvider).PersistBroker.IsInTransaction)
                        //						{
                        DataProvider.RollbackTransaction();
                        //						}
                        msg.Add(new UserControl.Message(ex));
                    }
                    finally
                    {
                        //Laws Lu,2005/10/19,新增	缓解性能问题
                        //						if(!((SQLDomainDataProvider)DataProvider).PersistBroker.IsInTransaction)
                        //						{
                        ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.CloseConnection();
                        //						}
                    }
                }
            }
            #endregion

            return(msg);
        }
Esempio n. 4
0
        private Messages DoAction(string rcard, int iRow)
        {
            Messages msg = new Messages();

            if ((chkNeedMemo.Checked == true && CurrentSequence <= dsMo.MultiMo.Rows.Count) ||
                chkNeedMemo.Checked == false)
            {
                msg.AddMessages(MatchMo(rcard, iRow));
            }

            if (!msg.IsSuccess())
            {
                ucMessage.Add(msg);
            }
            else
            {
                if (chkNeedMemo.Checked == true && CurrentSequence > dsMo.MultiMo.Rows.Count)
                {
                    Memo = rcard;
                }
                else
                {
                    //更新RunningCard
                    UpdateListRCard(iRow);
                }

                #region 业务处理
                //如果为最后一次,则提交更新
                if ((CurrentSequence == dsMo.MultiMo.Rows.Count && chkNeedMemo.Checked == false) ||
                    ((CurrentSequence > dsMo.MultiMo.Rows.Count && chkNeedMemo.Checked == true && Memo != String.Empty)))
                {
                    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);


                                args.Memo = Memo;
                                IAction action = new ActionFactory(this.DataProvider).CreateAction(ActionType.DataCollectAction_GoMO);

                                msg.AddMessages(action.Execute(args));
                            }
                        }

                        if (msg.IsSuccess())
                        {
                            this.DataProvider.CommitTransaction();

                            UpdateCollectQty();

                            Memo = String.Empty;

                            msg.Add(new UserControl.Message(MessageType.Success, "$CS_GOMO_CollectSuccess $CS_GONEXT_BILL"));
                        }
                        else
                        {
                            ClearListRCard();
                            this.DataProvider.RollbackTransaction();
                        }
                        #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
                {
                    CurrentSequence++;
                }
                #endregion
            }

            return(msg);
        }
Esempio n. 5
0
        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);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Reject指令采集
        /// </summary>
        /// <returns></returns>
        private Messages RunReject()
        {
            Messages messages = new Messages();

            try
            {
                object[] ErrorCodes = GetSelectedErrorCodes();                //取不良代码组+不良代码
                if (cbxOutLine.Checked == true)
                {
                    if (CheckOutlineOPInRoute())
                    {
                        messages.Add(new UserControl.Message(MessageType.Error, "$CS_OutLineOP_In_ThisRoute"));
                        return(messages);
                    }

                    //added by jessie lee, 2005/12/12, 判断是否是最后一道工序
                    if (IsLastOP(product.LastSimulation.MOCode, product.LastSimulation.RouteCode, product.LastSimulation.OPCode))
                    {
                        messages.Add(new UserControl.Message(MessageType.Error, "$CS_Op_IsLast_OutLineOP_Cannot_Collect"));
                        return(messages);
                    }


                    IAction dataCollectModule = new ActionFactory(this.DataProvider).CreateAction(ActionType.DataCollectAction_OutLineReject);

                    TSActionEventArgs actionArgs = new TSActionEventArgs(ActionType.DataCollectAction_OutLineReject,
                                                                         txtRunningCard.Value.Trim(),
                                                                         ApplicationService.Current().UserCode,
                                                                         ApplicationService.Current().ResourceCode,
                                                                         product,
                                                                         ErrorCodes,
                                                                         null,
                                                                         txtMEMO.Value);
                    actionArgs.OPCode = cbxOutLine.SelectedItemText;
                    messages.AddMessages(dataCollectModule.Execute(actionArgs));
                }
                else
                {
                    IAction dataCollectModule = new ActionFactory(this.DataProvider).CreateAction(ActionType.DataCollectAction_Reject);
                    messages.AddMessages(dataCollectModule.Execute(
                                             new TSActionEventArgs(ActionType.DataCollectAction_Reject,
                                                                   txtRunningCard.Value.Trim(),
                                                                   ApplicationService.Current().UserCode,
                                                                   ApplicationService.Current().ResourceCode,
                                                                   product,
                                                                   ErrorCodes,
                                                                   null,
                                                                   txtMEMO.Value)));
                }
                if (messages.IsSuccess())
                {
                    messages.Add(new UserControl.Message(MessageType.Success, "$CS_RejectSUCCESS"));
                }
                return(messages);
            }
            catch (Exception e)
            {
                messages.Add(new UserControl.Message(e));
                return(messages);
            }
        }