Exemple #1
0
        public void Run()
        {
            try
            {
                _message = _dbContext.Messages.First(m => m.Id == _messageId);
                _message.AttemptCount++;
                _message.StatusCode = (int)MessageStatusCodes.Preparing;
                _dbContext.SaveChanges();

                var workflowActions = _dbContext
                                      .WorkflowActions
                                      .Where(wa => wa.Workflow.RequestCodeId == _requestCode)
                                      .ToList();

                List <GlobalSetting> globalSettings = _dbContext.GlobalSettings.ToList();
                _workflowExecutionContext = new WorkflowExecutionContext(_message, globalSettings);

                SetMessageStatus(MessageStatusCodes.InProgress);
                foreach (var workflowAction in workflowActions)
                {
                    PipelineExecutionContext pipelineExecutionContext = new PipelineExecutionContext(_workflowExecutionContext, _dbContext);
                    PipelineProcessor        pipeline = new PipelineProcessor(pipelineExecutionContext, workflowAction);
                    pipeline.Run();
                    //TODO: Temp solution
                    _message.ResponseBody = pipelineExecutionContext.ResponseBody;
                }
                SetMessageStatus(MessageStatusCodes.Processed);
            }
            catch (Exception ex)
            {
                log.Fatal("Во время выполнения работы WorkflowProcessor произошла ошибка", ex);
                _message.ErrorMessage = ex.Message;
                SetMessageStatus(MessageStatusCodes.Error);
            }
        }