protected override void Context()
 {
     _view = A.Fake <ISimulationEventsConfigurationView>();
     _editParameterPresenterTask = A.Fake <IEditParameterPresenterTask>();
     _eventMappingDTOMapper      = A.Fake <IEventMappingToEventMappingDTOMapper>();
     _simBuildingBlockUpdater    = A.Fake <ISimulationBuildingBlockUpdater>();
     _eventTask          = A.Fake <IEventTask>();
     _eventMappingMapper = A.Fake <IEventMappingDTOToEventMappingMapper>();
     sut = new SimulationEventsConfigurationPresenter(_view, _editParameterPresenterTask, _eventMappingDTOMapper, _simBuildingBlockUpdater, _eventTask, _eventMappingMapper);
 }
 public SimulationEventsConfigurationPresenter(ISimulationEventsConfigurationView view, IEditParameterPresenterTask editParameterPresenterTask,
                                               IEventMappingToEventMappingDTOMapper eventMappingDTOMapper,
                                               ISimulationBuildingBlockUpdater simulationBuildingBlockUpdater, IEventTask eventTask,
                                               IEventMappingDTOToEventMappingMapper eventMappingMapper)
     : base(view)
 {
     _editParameterPresenterTask     = editParameterPresenterTask;
     _eventMappingDTOMapper          = eventMappingDTOMapper;
     _simulationBuildingBlockUpdater = simulationBuildingBlockUpdater;
     _eventTask          = eventTask;
     _eventMappingMapper = eventMappingMapper;
 }
        //  尝试回退任务
        internal static Task<bool> TryRevertTask<TTData>(IEventTask<TTData> task, TTData data,  int triedTimes)
        {
            try
            {
                return task.Revert(data,triedTimes);
            }
            catch (Exception e)
            {
                LogUtil.Error($"Task revert error! detail:{e}", task.TaskMeta.task_id, EventTaskProvider.ModuleName);
            }

            return Task.FromResult(false);
        }
        //  尝试获取任务执行结果
        internal static Task <EventTaskResp <TTRes> > TryGetTaskItemResult <TTData, TTRes>(TTData data, IEventTask <TTData, TTRes> task)
            where TTData : class
        //where TTRes : class, new()
        {
            //try
            //{
            return(task.Process(data));
            //}
            //catch (Exception ex)
            //{
            //    LogUtil.Error($"An error occurred while the task was running. Detail:{ex}", task.TaskMeta.node_id, EventTaskProvider.ModuleName);
            //}

            //return new TaskResp<Resp>().WithError(TaskRunStatus.RunFailed, new RunCondition(),
            //    "Task of node run error!");
        }
        //  尝试获取任务执行结果
        internal static async Task<TaskResp<Resp>> TryGetTaskItemResult<TTData>(TTData data, IEventTask<TTData> task,
            int triedTimes)
            where TTData : class
        {
            //if (nodeInsType == InstanceType.Stand && task.InstanceTaskType == InstanceType.Domain)
            //{
            //    return new TaskResponse<Resp>().WithError(TaskRunStatus.RunFailed, new RunCondition(),
            //        "Stand Node can't use Domain Task!");
            //}
            try
            {
                return await task.Run(data, triedTimes);
            }
            catch (Exception ex)
            {
                LogUtil.Error($"An error occurred while the task was running. Detail:{ex}", task.TaskMeta.node_id, EventTaskProvider.ModuleName);
            }

            return new TaskResp<Resp>().WithError(TaskRunStatus.RunFailed, new RunCondition(),
                "Task of node run error!");
        }