public void Invoke(EventModel ev, object data)
        {
            bool isSuccess = ev.Condition.IsPass(data);

            if (isSuccess)
            {
                Task.Factory.StartNew(() =>
                {
                    taskID++;

                    //储存事件临时对象数据,事件变量
                    EventTemporaryObject.Add(taskID, ev, data);

                    //执行actions
                    ActionTask.Invoke(taskID, ev.Actions);
                });
                //响应触发事件
                OnEventTrigger?.Invoke(ev, true);
                //记录event触发
                EventLoger.Add(new EventLogModel()
                {
                    EventType = ev.EventType,
                    IsSuccess = isSuccess,
                });
            }
        }
Beispiel #2
0
        public System.Action GenerateAction(int taskID, ActionModel action)
        {
            return(() =>
            {
                OnEventStateChanged?.Invoke(taskID, action.ID, ActionInvokeStateType.Runing);
                var p = ObjectConvert.Get <LoopsActionParamsModel>(action.Parameter);
                int i = 0;
                if (p.Count <= 0)
                {
                    p.Count = 1;
                }
                var result = new ActionResultModel();
                result.ID = action.ID;
                result.Result = new Dictionary <int, object>();
                result.Result.Add((int)LoopsResultType.Index, "1");
                ActionTaskResulter.Add(taskID, result);
                while (true)
                {
                    result.Result[(int)LoopsResultType.Index] = i.ToString();
                    ActionTask.Invoke(taskID, p.Actions, taskID == ActionTask.TestTaskID, true);
                    i++;

                    if (i == p.Count)
                    {
                        break;
                    }
                }

                OnEventStateChanged?.Invoke(taskID, action.ID, ActionInvokeStateType.Done);
            });
        }
Beispiel #3
0
        public System.Action GenerateAction(int taskID, ActionModel action)
        {
            return(() =>
            {
                bool isPass = false;
                var p = ObjectConvert.Get <IFActionParameterModel>(action.Parameter);
                string left, right;
                //获取左输入
                left = ActionParameterConverter.ConvertToString(taskID, p.LeftInput);
                //获取右输入
                right = ActionParameterConverter.ConvertToString(taskID, p.RightInput);


                switch (p.Condition)
                {
                case Types.IFActionConditionType.Equal:
                    isPass = left == right;
                    break;

                case Types.IFActionConditionType.UnEqual:
                    isPass = left != right;
                    break;

                case Types.IFActionConditionType.Has:
                    isPass = left.IndexOf(right) != -1;
                    break;

                case Types.IFActionConditionType.Miss:
                    isPass = left.IndexOf(right) == -1;
                    break;
                }

                if (isPass)
                {
                    ActionTask.Invoke(taskID, p.PassActions, taskID == ActionTask.TestTaskID, true);
                }
                else
                {
                    ActionTask.Invoke(taskID, p.NoPassActions, taskID == ActionTask.TestTaskID, true);
                }

                var result = new ActionResultModel();
                result.ID = action.ID;
                result.Result = new Dictionary <int, string>();
                result.Result.Add((int)CommonResultKeyType.IsSuccess, isPass.ToString());
                //result.Result = new Dictionary<int, ActionResultValueModel>();
                //result.Result.Add((int)CommonResultKeyType.Status, new ActionResultValueModel()
                //{
                //    Type = ActoinResultValueType.BOOL,
                //    Value = isPass
                //});
                //返回数据
                ActionTaskResulter.Add(taskID, result);
            });
        }