Exemplo n.º 1
0
        public async Task <TaskReference> BizActionAsync(MazeTask inputData)
        {
            if (ValidateModelFailed(inputData))
            {
                return(null);
            }

            var taskReference = await _dbAccess.FindAsync(inputData.Id);

            if (taskReference != null)
            {
                return(ReturnError <TaskReference>(TaskErrors.TaskAlreadyExists));
            }

            await _taskDirectory.WriteTask(inputData);

            taskReference = new TaskReference {
                TaskId = inputData.Id, IsCompleted = false, IsEnabled = true, AddedOn = DateTimeOffset.UtcNow
            };
            await _dbAccess.CreateAsync(taskReference);

            var hash = _taskDirectory.ComputeTaskHash(inputData);
            await _management.InitializeTask(inputData, hash, transmit : true, executeLocally : true);

            return(taskReference);
        }
Exemplo n.º 2
0
        public async Task BizActionAsync(MazeTask inputData)
        {
            if (ValidateModelFailed(inputData))
            {
                return;
            }

            var taskReference = await _dbAccess.FindAsync(inputData.Id);

            if (taskReference == null)
            {
                AddValidationResult(TaskErrors.TaskNotFound);
                return;
            }

            await _taskDirectory.WriteTask(inputData);

            if (taskReference.IsEnabled)
            {
                var hash = _taskDirectory.ComputeTaskHash(inputData);

                await _management.CancelTask(inputData.Id);

                await _management.InitializeTask(inputData, hash, transmit : true, executeLocally : true);
            }
        }
Exemplo n.º 3
0
        public async Task BizActionAsync(Guid inputData)
        {
            var tasks = await _taskDirectory.LoadTasks();

            var task = tasks.FirstOrDefault(x => x.Id == inputData);

            if (task == null)
            {
                AddValidationResult(TaskErrors.TaskNotFound);
                return;
            }

            await _dbAccess.SetTaskIsEnabled(inputData, true);

            var taskReference = await _dbAccess.FindAsync(inputData);

            var hash = _taskDirectory.ComputeTaskHash(task);

            await _management.InitializeTask(task, hash, true, !taskReference.IsCompleted);
        }