Пример #1
0
        public async Task Run()
        {
            try
            {
                await StartUp();

                var newTasks = await _dataGatherer.PrepareData(Rules);

                _logger.LogTrace($"Trying to create {newTasks.Count()} new tasks @ {_processKey}");
                var createTasksResponse = await _anymateService.CreateTasksAsync(newTasks, _processKey);

                if (!createTasksResponse.Succeeded)
                {
                    _logger.LogError("Failed to create new tasks");
                }


                await ShutDown();
            }
            catch (Exception ex)
            {
                var failure = $"Got Exception with msg: {ex.Message} // from: {ex.Source} // stackTrace: {ex.StackTrace}";
                _logger.LogError("Encountered a failure. " + failure);
                var failureResponse = await _anymateService.FailureAsync(_processKey, failure);

                if (!failureResponse.Succeeded)
                {
                    _logger.LogError("Failed to register Failure with Anymate.");
                }
                return;
            }
        }
Пример #2
0
        public async Task Run()
        {
            try
            {
                await StartUp();

                var task = await _anymateService.TakeNextAsync <AnymateTask>(_processKey);

                while (task.TaskId > 0)
                {
                    var worker = _workerFactory.GetWorker(Rules);
                    var action = await worker.ProcessTask(task);

                    var response = await ReturnTaskToAnymate(action);

                    task = await _anymateService.TakeNextAsync <AnymateTask>(_processKey);
                }

                await ShutDown();
            }
            catch (Exception ex)
            {
                var failure = $"Got Exception with msg: {ex.Message} // from: {ex.Source} // stackTrace: {ex.StackTrace}";
                _logger.LogError("Encountered a failure. " + failure);
                var failureResponse = await _anymateService.FailureAsync(_processKey, failure);

                if (!failureResponse.Succeeded)
                {
                    _logger.LogError("Failed to register Failure with Anymate.");
                }
                return;
            }
        }