예제 #1
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;
            }
        }
예제 #2
0
        public void Setup(string workerType, DateTime startTime, DateTime endTime)
        {
            Worker = factory.GetWorker(workerType);
            Worker.CreateNewEvent(startTime, endTime);
            var cost = Worker.CalculatePayment();

            this.view.UpdateView(startTime, endTime, workerType, cost);
        }