Пример #1
0
        public BotStepResult Step(BotStepInput input)
        {
            var beginTimeMilli = GetTimeMilli();

            StepLastInput = input;

            Exception exception = null;

            var listMotion = new List <MotionRecommendation>();

            IBotTask[][] outputListTaskPath = null;

            try
            {
                MemorizeStepInput(input);

                outputListTaskPath = StepOutputListTaskPath()?.ToArray();

                foreach (var moduleToggle in outputListTaskPath.ConcatNullable().OfType <ModuleToggleTask>().Select(moduleToggleTask => moduleToggleTask?.module).WhereNotDefault())
                {
                    ToggleLastStepIndexFromModule[moduleToggle] = stepIndex;
                }

                foreach (var taskPath in outputListTaskPath.EmptyIfNull())
                {
                    var taskMotionParam = taskPath?.LastOrDefault()?.Motion;

                    if (null == taskMotionParam)
                    {
                        continue;
                    }

                    listMotion.Add(new MotionRecommendation
                    {
                        Id          = motionId++,
                        MotionParam = taskMotionParam,
                    });
                }
            }
            catch (Exception e)
            {
                exception = e;
            }

            var stepResult = new BotStepResult
            {
                Exception          = exception,
                ListMotion         = listMotion?.ToArrayIfNotEmpty(),
                OutputListTaskPath = outputListTaskPath,
            };

            MemorizeStepResult(stepResult);

            StepLastResult = new PropertyGenTimespanInt64 <BotStepResult>(stepResult, beginTimeMilli, GetTimeMilli());

            ++stepIndex;

            return(stepResult);
        }
Пример #2
0
        public BotStepResult Step(BotStepInput input)
        {
            var beginTimeMilli = GetTimeMilli();

            StepLastInput = input;

            Exception exception = null;

            var listMotion = new List <MotionRecommendation>();

            IBotTask[][] outputListTaskPath = null;

            try
            {
                MemorizeStepInput(input);

                outputListTaskPath = ((IBotTask) new BotTask(null)
                {
                    Component = strategy.GetTasks(this)
                })
                                     ?.EnumeratePathToNodeFromTreeDFirst(node => node?.Component)
                                     ?.Where(taskPath => (taskPath?.LastOrDefault()).ShouldBeIncludedInStepOutput())
                                     ?.TakeSubsequenceWhileUnwantedInferenceRuledOut()
                                     ?.ToArray();

                foreach (var moduleToggle in outputListTaskPath.ConcatNullable().OfType <ModuleToggleTask>()
                         .Select(moduleToggleTask => moduleToggleTask?.module).WhereNotDefault())
                {
                    ToggleLastStepIndexFromModule[moduleToggle] = stepIndex;
                }

                foreach (var effect in outputListTaskPath.EmptyIfNull().SelectMany(taskPath =>
                                                                                   (taskPath?.LastOrDefault()?.ApplicableEffects()).EmptyIfNull()))
                {
                    listMotion.Add(effect);
                }
            }
            catch (Exception e)
            {
                exception = e;
            }

            var stepResult = new BotStepResult
            {
                Exception          = exception,
                ListMotion         = listMotion?.ToArrayIfNotEmpty(),
                OutputListTaskPath = outputListTaskPath,
            };

            MemorizeStepResult(stepResult);

            StepLastResult = new PropertyGenTimespanInt64 <BotStepResult>(stepResult, beginTimeMilli, GetTimeMilli());

            ++stepIndex;

            return(stepResult);
        }
Пример #3
0
        void MemorizeStepResult(BotStepResult stepResult)
        {
            var setMotionMouseWaypointUIElement =
                stepResult?.ListMotion
                ?.Select(motion => motion?.MotionParam)
                ?.Where(motionParam => 0 < motionParam?.MouseButton?.Count())
                ?.Select(motionParam => motionParam?.MouseListWaypoint)
                ?.ConcatNullable()?.Select(mouseWaypoint => mouseWaypoint?.UIElement)?.WhereNotDefault();

            foreach (var mouseWaypointUIElement in setMotionMouseWaypointUIElement.EmptyIfNull())
            {
                MouseClickLastStepIndexFromUIElementId[mouseWaypointUIElement.Id] = stepIndex;
            }
        }