示例#1
0
        public static StepTaskEntityBase GetStepEntity(SlaveContext context, CallStack stack)
        {
            if (stack.Session != context.SessionId)
            {
                return(null);
            }
            SequenceTaskEntity sequenceTaskEntity = context.SessionTaskEntity.GetSequenceTaskEntity(stack.Sequence);

            return(sequenceTaskEntity.GetStepEntity(stack));
        }
示例#2
0
        protected override void FlowTaskAction()
        {
            SendStartMessage();

            // 打印状态日志
            Context.LogSession.Print(LogLevel.Info, Context.SessionId, $"Start run sequence {_sequenceIndex}.");

            Context.State = RuntimeState.Running;

            SessionTaskEntity sessionTaskEntity = Context.SessionTaskEntity;

            try
            {
                sessionTaskEntity.InvokeSetUp();
                RuntimeState setUpState = sessionTaskEntity.GetSequenceTaskState(CommonConst.SetupIndex);
                // 如果SetUp执行失败,则执行TearDown,且配置所有序列为失败状态,并发送所有序列都失败的信息
                if (CoreUtils.IsFailed(setUpState))
                {
                    // 打印状态日志
                    Context.LogSession.Print(LogLevel.Error, Context.SessionId, "Run setup failed.");
                    for (int i = 0; i < sessionTaskEntity.SequenceCount; i++)
                    {
                        SequenceTaskEntity sequenceTaskEntity = sessionTaskEntity.GetSequenceTaskEntity(i);
                        sequenceTaskEntity.State = RuntimeState.Failed;

                        FailedInfo         failedInfo    = new FailedInfo(Context.I18N.GetStr("SetUpFailed"), FailedType.SetUpFailed);
                        CallStack          sequenceStack = ModuleUtils.GetSequenceStack(i, sequenceTaskEntity.RootCoroutineId);
                        SequenceStatusInfo statusInfo    = new SequenceStatusInfo(i, sequenceStack,
                                                                                  StatusReportType.Failed, setUpState, StepResult.NotAvailable, failedInfo)
                        {
                            ExecutionTime  = DateTime.Now,
                            ExecutionTicks = -1,
                            CoroutineId    = sequenceTaskEntity.RootCoroutineId
                        };
                        Context.StatusQueue.Enqueue(statusInfo);
                    }
                }
                else
                {
                    sessionTaskEntity.InvokeSequence(_sequenceIndex);
                }
            }
            finally
            {
                sessionTaskEntity.InvokeTearDown();

                Context.State = RuntimeState.Over;
                this.Next     = null;

                SendOverMessage();

                // 打印状态日志
                Context.LogSession.Print(LogLevel.Info, Context.SessionId, "Run single sequence over.");
            }
        }
        private void SendSetupFailedEvents(SessionTaskEntity sessionTaskEntity, RuntimeState sequenceState)
        {
            for (int i = 0; i < sessionTaskEntity.SequenceCount; i++)
            {
                SequenceTaskEntity sequenceTaskEntity = sessionTaskEntity.GetSequenceTaskEntity(i);
                sequenceTaskEntity.State = RuntimeState.Failed;

                FailedInfo failedInfo = new FailedInfo(Context.I18N.GetStr("SetUpFailed"),
                                                       FailedType.SetUpFailed);
                CallStack          sequenceStack = ModuleUtils.GetSequenceStack(i, sequenceTaskEntity.RootCoroutineId);
                SequenceStatusInfo statusInfo    = new SequenceStatusInfo(i, sequenceStack,
                                                                          StatusReportType.Failed, sequenceState, StepResult.NotAvailable,
                                                                          failedInfo)
                {
                    ExecutionTime  = DateTime.Now,
                    ExecutionTicks = -1,
                    CoroutineId    = sequenceTaskEntity.RootCoroutineId
                };
                Context.StatusQueue.Enqueue(statusInfo);
            }
        }