public ActionResult <IEnumerable <TModelViewGet> > Get() { var request = new ManagementModelRetrieverRequest <TModel> { User = CurrentUser }; var result = _retrieverBusinessLogic.Execute(request); if (result.ComputeResult().IsOk()) { return(Ok(_mapper.Map <IEnumerable <TModelViewGet> >(request.Items))); } return(BadRequest(result)); }
private void Execute() { this.BackColor = Color.LightGray; try { step.Execute(); Do(() => { this.IconBox.Image = Icons.Ok; this.BackColor = Color.White; InvokeComplete(); }); } catch (Exception e) { lastException = e; Do(() => { this.IconBox.Image = Icons.Warning; this.BackColor = Color.MistyRose; detailsButton.Visible = true; ignoreButton.Visible = true; }); } }
public static StepRunner <T1, TResult> AddStep <T1, T2, TResult>(this StepRunner <T1, T2> pipeline, IStep <T2, TResult> step) { StepRunner <T2, TResult> next = (StepRunner <T2, TResult>) new StepRunner <T2, TResult> { Handle = (Func <T2, PipelineContext, TResult>) delegate(T2 arg, PipelineContext context) { if (!context.IsCancelled) { return(step.Execute(arg, context)); } return(default(TResult)); } }; return(new StepRunner <T1, TResult> { Handle = (Func <T1, PipelineContext, TResult>) delegate(T1 arg, PipelineContext context) { if (!context.IsCancelled) { T2 arg2 = pipeline.Execute(arg, context); if (!context.IsCancelled) { return ((StepRunner <T2, TResult>)next).Handle(arg2, context); } return default(TResult); } return default(TResult); } }); }
public void Execute(SequenceExecutionContext context) { for (int i = 0; i < _numberOfSends; i++) { _stepToRepeat.Execute(context); } }
/// <summary> /// Creates a task to be executed later on for the given stepExecution. /// </summary> /// <param name="step"></param> /// <param name="stepExecution"></param> /// <returns></returns> protected Task <StepExecution> CreateTask(IStep step, StepExecution stepExecution) { return(new Task <StepExecution>(() => { step.Execute(stepExecution); return stepExecution; })); }
public IEnumerable <TModelViewGet> Get() { var request = new ManagementModelRetrieverRequest <TModel> { }; var result = _retrieverBusinessLogic.Execute(request); if (result.ComputeResult().IsOk()) { return(_mapper.Map <IEnumerable <TModelViewGet> >(request.Items)); } throw new System.Web.Http.HttpResponseException(HttpStatusCode.NotFound) { Source = result.Message() }; }
public async Task <StepValue <T> > Execute <T>(IStep <T> stepIn) where T : class { var @in = await stepIn.Execute(); _dbContext.Set <T>().Add(@in.Value); _dbContext.SaveChanges(); return(@in); }
public ActionResult <TModelViewGet> Post([FromBody] TModelView value) { var request = new ManagementModelRequest <TModel> { User = CurrentUser, Item = _mapper.Map <TModel>(value), Type = EnumOperation.NEW }; var result = _businessLogic.Execute(request); if (result.ComputeResult().IsOk()) { return(Ok(_mapper.Map <TModelViewGet>(request.Item))); } return(BadRequest(result.Message())); }
public async Task <IEnumerable <TModelViewGet> > Get() { //return await Task.FromException<IEnumerable<TModelViewGet>>(new Exception("result.Message()")); return(await Task <IEnumerable <TModelViewGet> > .Run(() => { var request = new ManagementModelRetrieverRequest <TModel> { }; var result = _retrieverBusinessLogic.Execute(request); if (!result.ComputeResult().IsOk()) { return Task.FromException <IEnumerable <TModelViewGet> >(new Exception(result.Message())).Result; } return _mapper.Map <IEnumerable <TModelViewGet> >(request.Items); })); }
public TaskResponse ExecuteStep(int stepId, string stepType, TaskRequest request) { Dictionary <string, object> stepData = _dal.GetStep(stepId, stepType); IStep step = _stepAccessor(stepType); step.Initialize(stepData); TaskResponse response = step.Execute(request); return(response); }
private TReturn ExecuteStep(IStep <TState, TReturn> step) { var result = WorkFlowContext.Lock(() => WorkFlowContext.Path.AddLast(step)); if (!result) { return(default(TReturn)); } return(step.Execute(WorkFlowContext.State)); }
/// <summary> /// Executes the step for the specified resource. /// </summary> /// <param name="resource">The resource.</param> public void Execute(SNAP.Scripts.IStepArgs args) { if (_if.Process(args)) { _then.Execute(args); } else if (_else != null) { _else.Execute(args); } }
public virtual void Execute(ProcessorInfo info, int stepId) { try { Step.Execute(); info.StepStatus[stepId] = Status.Successful; } catch { info.StepStatus[stepId] = Status.Failed; } }
public void ExecuteNextStep(SequenceExecutionContext executionContext) { if (Done) { return; } if (UpdateExecutionContextWithNextStep(executionContext)) { IStep currentStep = executionContext.GetCurrentStep(this); currentStep.Execute(executionContext); } }
public ResponseWorkerViewModel GetWorkerInfo(string sCode) { WorkerInfo request = new WorkerInfo { Worker = new Worker { Code = sCode } }; var resProductSupplied = _supplyBusinessLogic.Execute(request); if (resProductSupplied.ComputeResult().IsError()) { return(Mappers.SetStatusProperty(new ResponseWorkerViewModel(), resProductSupplied)); } return(Mappers.Get(request)); }
public async Task <ActionResult> Post([FromBody] TModelView value) { return(await Task.Run <ActionResult>(() => { var request = new ManagementModelRequest <TModel> { Item = _mapper.Map <TModel>(value), Type = Operation.NEW }; var result = _businessLogic.Execute(request); if (result.ComputeResult().IsOk()) { return Ok(result.Message()); } return BadRequest(result.Message()); })); }
public IResult Execute(T obj) { try { IResult resultCurrent = null; try { resultCurrent = ExecuteTemplate(obj); } catch (Exception ex) { return(new Result(EnumResultBL.ERROR_UNEXPECTED_EXCEPTION, "STEP::" + this.GetType().ToString() + " => " + Description() + " :" + ex.Message)); } if (resultCurrent == null) { return(new Result(EnumResultBL.ERROR_BAD_IMPLEMENTATION, this.GetType().ToString())); } if (resultCurrent.ComputeResult().IsError() || Next == null) { return(resultCurrent); } if (resultCurrent.ComputeResult().IsOk() && IsOkAndFinish) { return(resultCurrent); } return(Next.Execute(obj)); } catch (Exception ex) { return(new Result(EnumResultBL.ERROR_UNEXPECTED_EXCEPTION, Next?.Description() + " :" + ex.Message)); } }
/// <summary> /// Handle normal step execution. /// </summary> /// <param name="step"></param> /// <param name="execution"></param> /// <param name="currentStepExecution"></param> private void HandleStepExecution(IStep step, JobExecution execution, StepExecution currentStepExecution) { JobRepository.Add(currentStepExecution); Logger.Info("Executing step: [ {0} ]", step.Name); try { step.Execute(currentStepExecution); currentStepExecution.ExecutionContext.Put("batch.executed", true); } catch (JobInterruptedException) { // Ensure that the job gets the message that it is stopping // and can pass it on to other steps that are executing // concurrently. execution.Status = BatchStatus.Stopping; throw; } JobRepository.UpdateExecutionContext(execution); }
public override async void Execute(BotUpdate update, IBotClient client) { var message = update.MessageText; var callbackData = update.CallbackData; IStep step = null; if (ContainsCommandName(message)) { StepPool.Where(s => s.ChatId == update.ChatId && s.CommandName == Name) .ToList().ForEach(s => StepPool.Remove(s)); //StepPool.Where(s => s.ChatId == update.ChatId).ToList().ForEach(s => StepPool.Remove(s)); step = GetInitialStep(update, client); } else if (!string.IsNullOrEmpty(callbackData) && ContainsCommandName(callbackData) && StepPool.Any(s => s.ChatId == update.ChatId && s.CommandName == Name)) { step = StepPool.SingleOrDefault(s => s.ChatId == update.ChatId && s.CommandName == Name); StepPool.Remove(step); } else if (!string.IsNullOrEmpty(message) && StepPool.Any(s => s.ChatId == update.ChatId && s.CommandName == Name)) { step = StepPool.SingleOrDefault(s => s.ChatId == update.ChatId && s.CommandName == Name); StepPool.Remove(step); } try { await step.Execute(update, client); if (step.NextStep != null) { StepPool.Add(step.NextStep); } } catch { await client.SendTextMessageAsync(update.ChatId, "Что-то пошло не так! Попробуйте ещё раз."); } }
public override bool Show() { bool ok = true; string endText; OnShow(); Draw(); StartProgressAnimation(progressLine); try { if (step.Execute()) { endText = step.OkText; } else { ok = false; endText = step.ErrorText; } } catch (Exception e) { ok = false; endText = "Exception executing " + step.StepText; Console.WriteLine("Exception " + e.Message); Console.WriteLine(e.StackTrace); } StopProgressAnimation(); if ((step.ShowOkText && ok) || !ok) { ClearContent(); WriteTextOnDialog(endText); DrawCenterButton("Ok", false); Lcd.Instance.Update(); btns.GetKeypress(); //Wait for any key } OnExit(); return(ok); }
private void CreateProcessThread() { progress = new Thread(delegate() { Ok = true; string endText; StartProgressAnimation(progressLine); OnShow(); base.Draw(); try { if (step.Execute()) { endText = step.OkText; } else { Ok = false; endText = step.ErrorText; } } catch { Ok = false; endText = "Exception executing " + step.StepText; } StopProgressAnimation(); if ((step.ShowOkText && Ok) || !Ok) { ClearContent(); WriteTextOnDialog(endText); DrawCenterButton("Ok", false); waitForOk.Reset(); Lcd.Update(); waitForOk.WaitOne(); } OnExit(); }); }
async Task ExecuteStep(IStep step, CancellationToken cancellationToken) { Log($"Executing migration step {step.GetId()}: {step.GetType().FullName}"); var stopwatch = Stopwatch.StartNew(); try { await step.Execute(_mongoDatabase, _log, cancellationToken); Log($"Recording execution of step {step.GetId()}"); var elapsed = stopwatch.Elapsed; await RecordExecution(step, elapsed); Log($"Successfully executed migration step {step.GetId()}: {step.GetType().FullName} in {elapsed.TotalSeconds:0.0} s", verbose: false); } catch (Exception exception) { throw new ApplicationException($"Could not execute step with ID {step.GetId()}", exception); } }
private static void ExecuteStep(Database database, string changeTable, IStep step) { step.Execute(database); database.Tables[changeTable].Rows.Add(new { Step = step.StepName, ExecutedAt = DateTime.Now }); }
public bool Execute() { return(Checked ? unCheckStep.Execute() : checkedStep.Execute()); }
public async Task <StepValue <T> > Execute <T>(IStep <T> stepIn) where T : class { return(await stepIn.Execute()); }
/// <summary> /// Creates a task to be executed later on for the given stepExecution. /// </summary> /// <param name="step"></param> /// <param name="stepExecution"></param> /// <returns></returns> protected Task<StepExecution> CreateTask(IStep step, StepExecution stepExecution) { return new Task<StepExecution>(() => { step.Execute(stepExecution); return stepExecution; }); }
public StepRunner <Tin, Tout> AddStep <Tin, Tout>(IStep <Tin, Tout> step) { return(new StepRunner <Tin, Tout> { Handle = (Func <Tin, PipelineContext, Tout>)((Tin arg, PipelineContext context) => step.Execute(arg, context)) }); }