public async Task<bool> Handle(UpdateHumanTaskDefInfoCommand request, CancellationToken cancellationToken)
        {
            if (string.IsNullOrWhiteSpace(request.Name))
            {
                _logger.LogError("the parameter 'name' is missing");
                throw new BadRequestException(string.Format(Global.MissingParameter, "name"));
            }

            var result = await _humanTaskDefQueryRepository.Get(request.Id, cancellationToken);
            if (result == null)
            {
                _logger.LogError($"The human task definition '{request.Id}' doesn't exist");
                throw new UnknownHumanTaskDefException(string.Format(Global.UnknownHumanTaskDef, request.Id));
            }

            var r = await _humanTaskDefQueryRepository.Search(new SearchHumanTaskDefParameter
            {
                Name = request.Name
            }, cancellationToken);
            r.Content = r.Content.Where(_ => _.AggregateId != request.Id).ToList();
            if (r != null && r.Content.Count() > 0)
            {
                _logger.LogError($"the human task '{request.Name}' already exists");
                throw new BadRequestException(string.Format(Global.HumanTaskDefExists, request.Name));
            }

            result.UpdateInfo(request.Name, request.Priority);
            await _humanTaskDefCommandRepository.Update(result, cancellationToken);
            await _humanTaskDefCommandRepository.SaveChanges(cancellationToken);
            _logger.LogInformation($"Human task definition '{result.Name}', information has been updated");
            return true;
        }
예제 #2
0
        public async Task <bool> Handle(AddHumanTaskDefPresentationElementCommand request, CancellationToken cancellationToken)
        {
            var result = await _humanTaskDefQueryRepository.Get(request.Id, cancellationToken);

            if (result == null)
            {
                _logger.LogError($"The human task definition '{request.Id}' doesn't exist");
                throw new UnknownHumanTaskDefException(string.Format(Global.UnknownHumanTaskDef, request.Id));
            }

            if (request.PresentationElement == null)
            {
                _logger.LogError($"The 'presentationElement' parameter is missing");
                throw new BadRequestException(string.Format(Global.MissingParameter, "parameter"));
            }

            var record = request.PresentationElement.ToDomain();

            if (result.PresentationElements.Any(_ => _.Usage == record.Usage && _.Language == record.Language))
            {
                _logger.LogError($"The presentation element already exists");
                throw new BadRequestException(Global.PresentationElementExists);
            }

            result.AddPresentationElement(record);
            await _humanTaskDefCommandRepository.Update(result, cancellationToken);

            await _humanTaskDefCommandRepository.SaveChanges(cancellationToken);

            _logger.LogInformation($"Human task definition '{result.Name}', presentation element has been added");
            return(true);
        }
        public async Task <bool> Handle(UpdateHumanTaskDefDeadlineCommand request, CancellationToken cancellationToken)
        {
            if (request.DeadLineInfo == null)
            {
                _logger.LogError("the parameter 'deadLineInfo' is missing");
                throw new BadRequestException(string.Format(Global.MissingParameter, "deadLineInfo"));
            }

            var result = await _humanTaskDefQueryRepository.Get(request.Id, cancellationToken);

            if (result == null)
            {
                _logger.LogError($"The human task definition '{request.Id}' doesn't exist");
                throw new UnknownHumanTaskDefException(string.Format(Global.UnknownHumanTaskDef, request.Id));
            }

            result.UpdateDeadline(request.DeadLineId,
                                  request.DeadLineInfo.Name,
                                  request.DeadLineInfo.For,
                                  request.DeadLineInfo.Until);
            await _humanTaskDefCommandRepository.Update(result, cancellationToken);

            await _humanTaskDefCommandRepository.SaveChanges(cancellationToken);

            return(true);
        }
예제 #4
0
        public async Task <HumanTaskDefResult> Handle(GetHumanTaskDefQuery request, CancellationToken cancellationToken)
        {
            var result = await _humanTaskDefQueryRepository.Get(request.Id, cancellationToken);

            if (result == null)
            {
                _logger.LogError($"The human task definition '{request.Id}' doesn't exist");
                throw new UnknownHumanTaskDefException(string.Format(Global.UnknownHumanTaskDef, request.Id));
            }

            return(HumanTaskDefResult.ToDto(result));
        }
예제 #5
0
        public async Task <bool> Handle(DeleteHumanTaskDefDeadlineCommand request, CancellationToken cancellationToken)
        {
            var result = await _humanTaskDefQueryRepository.Get(request.Id, cancellationToken);

            if (result == null)
            {
                _logger.LogError($"The human task definition '{request.Id}' doesn't exist");
                throw new UnknownHumanTaskDefException(string.Format(Global.UnknownHumanTaskDef, request.Id));
            }

            result.DeleteDeadLine(request.DeadLineId);
            await _humanTaskDefCommandRepository.Update(result, cancellationToken);

            await _humanTaskDefCommandRepository.SaveChanges(cancellationToken);

            return(true);
        }
예제 #6
0
        public async Task <bool> Handle(DeleteHumanTaskDefParameterCommand request, CancellationToken cancellationToken)
        {
            var result = await _humanTaskDefQueryRepository.Get(request.Id, cancellationToken);

            if (result == null)
            {
                _logger.LogError($"The human task definition '{request.Id}' doesn't exist");
                throw new UnknownHumanTaskDefException(string.Format(Global.UnknownHumanTaskDef, request.Id));
            }

            result.RemoveParameter(request.ParameterId);
            await _humanTaskDefCommandRepository.Update(result, cancellationToken);

            await _humanTaskDefCommandRepository.SaveChanges(cancellationToken);

            _logger.LogInformation($"Human task definition '{result.Name}', operation parameter '{request.ParameterId}' has been removed");
            return(true);
        }
        public async Task <bool> Handle(DeleteHumanTaskDefPresentationElementCommand request, CancellationToken cancellationToken)
        {
            var result = await _humanTaskDefQueryRepository.Get(request.Id, cancellationToken);

            if (result == null)
            {
                _logger.LogError($"The human task definition '{request.Id}' doesn't exist");
                throw new UnknownHumanTaskDefException(string.Format(Global.UnknownHumanTaskDef, request.Id));
            }

            result.DeletePresentationElement(request.Usage, request.Language);
            await _humanTaskDefCommandRepository.Update(result, cancellationToken);

            await _humanTaskDefCommandRepository.SaveChanges(cancellationToken);

            _logger.LogInformation($"Human task definition '{result.Name}', presentation element has been remvoed");
            return(true);
        }
        public async Task <bool> Handle(AddHumanTaskDefPresentationParameterCommand request, CancellationToken cancellationToken)
        {
            var result = await _humanTaskDefQueryRepository.Get(request.Id, cancellationToken);

            if (result == null)
            {
                _logger.LogError($"The human task definition '{request.Id}' doesn't exist");
                throw new UnknownHumanTaskDefException(string.Format(Global.UnknownHumanTaskDef, request.Id));
            }

            if (request.PresentationParameter == null)
            {
                _logger.LogError($"The 'presentationParameter' parameter is missing");
                throw new BadRequestException(string.Format(Global.MissingParameter, "parameter"));
            }

            result.AddPresentationParameter(request.PresentationParameter.ToDomain());
            await _humanTaskDefCommandRepository.Update(result, cancellationToken);

            await _humanTaskDefCommandRepository.SaveChanges(cancellationToken);

            _logger.LogInformation($"Human task definition '{result.Name}', presentation parameter '{request.PresentationParameter.Name}' has been added");
            return(true);
        }
예제 #9
0
        public async Task <bool> Handle(UpdateHumanTaskDefEscalationDeadlineCommand request, CancellationToken cancellationToken)
        {
            if (string.IsNullOrWhiteSpace(request.Condition))
            {
                _logger.LogError("the parameter 'condition' is missing");
                throw new BadRequestException(string.Format(Global.MissingParameter, "condition"));
            }

            var result = await _humanTaskDefQueryRepository.Get(request.Id, cancellationToken);

            if (result == null)
            {
                _logger.LogError($"The human task definition '{request.Id}' doesn't exist");
                throw new UnknownHumanTaskDefException(string.Format(Global.UnknownHumanTaskDef, request.Id));
            }

            result.UpdateEscalationDeadline(request.DeadlineId, request.EscalationId, request.Condition, request.NotificationId);
            await _humanTaskDefCommandRepository.Update(result, cancellationToken);

            await _humanTaskDefCommandRepository.SaveChanges(cancellationToken);

            _logger.LogInformation("Escalation has been updated");
            return(true);
        }
예제 #10
0
        public async Task <string> Handle(AddHumanTaskDefPeopleAssignmentCommand request, CancellationToken cancellationToken)
        {
            var result = await _humanTaskDefQueryRepository.Get(request.Id, cancellationToken);

            if (result == null)
            {
                _logger.LogError($"The human task definition '{request.Id}' doesn't exist");
                throw new UnknownHumanTaskDefException(string.Format(Global.UnknownHumanTaskDef, request.Id));
            }

            if (request.PeopleAssignment == null)
            {
                _logger.LogError($"The 'peopleAssignment' parameter is missing");
                throw new BadRequestException(string.Format(Global.MissingParameter, "peopleAssignment"));
            }

            var id = result.Assign(request.PeopleAssignment.ToDomain());
            await _humanTaskDefCommandRepository.Update(result, cancellationToken);

            await _humanTaskDefCommandRepository.SaveChanges(cancellationToken);

            _logger.LogInformation($"Human task definition '{result.Name}', people is assigned");
            return(id);
        }
        public async Task <string> Handle(AddHumanTaskDefDeadLineCommand request, CancellationToken cancellationToken)
        {
            if (request.DeadLine == null)
            {
                _logger.LogError("the parameter 'deadLine' is missing");
                throw new BadRequestException(string.Format(Global.MissingParameter, "deadLine"));
            }

            var result = await _humanTaskDefQueryRepository.Get(request.Id, cancellationToken);

            if (result == null)
            {
                _logger.LogError($"The human task definition '{request.Id}' doesn't exist");
                throw new UnknownHumanTaskDefException(string.Format(Global.UnknownHumanTaskDef, request.Id));
            }

            var id = result.AddDeadLine(request.DeadLine.ToDomain());
            await _humanTaskDefCommandRepository.Update(result, cancellationToken);

            await _humanTaskDefCommandRepository.SaveChanges(cancellationToken);

            _logger.LogInformation($"Human task definition '{result.Name}', deadline '{request.DeadLine.Name}' has been added");
            return(id);
        }
예제 #12
0
        public async Task <bool> Handle(DeleteHumanTaskDefPresentationParameterCommand request, CancellationToken cancellationToken)
        {
            var result = await _humanTaskDefQueryRepository.Get(request.Id, cancellationToken);

            if (result == null)
            {
                _logger.LogError($"The human task definition '{request.Id}' doesn't exist");
                throw new UnknownHumanTaskDefException(string.Format(Global.UnknownHumanTaskDef, request.Id));
            }

            if (string.IsNullOrWhiteSpace(request.Name))
            {
                _logger.LogError($"The 'name' parameter is missing");
                throw new BadRequestException(string.Format(Global.MissingParameter, "name"));
            }

            result.DeletePresentationParameter(request.Name);
            await _humanTaskDefCommandRepository.Update(result, cancellationToken);

            await _humanTaskDefCommandRepository.SaveChanges(cancellationToken);

            _logger.LogInformation($"Human task definition '{result.AggregateId}', presentation parameter '{request.Name}' has been removed");
            return(true);
        }
        public async Task <bool> Handle(UpdateHumanTaskDefRenderingCommand request, CancellationToken cancellationToken)
        {
            if (request.Rendering == null)
            {
                _logger.LogError("the parameter 'rendering' is missing");
                throw new BadRequestException(string.Format(Global.MissingParameter, "rendering"));
            }

            var result = await _humanTaskDefQueryRepository.Get(request.Id, cancellationToken);

            if (result == null)
            {
                _logger.LogError($"The human task definition '{request.Id}' doesn't exist");
                throw new UnknownHumanTaskDefException(string.Format(Global.UnknownHumanTaskDef, request.Id));
            }

            result.UpdateRendering(request.Rendering.ToString());
            await _humanTaskDefCommandRepository.Update(result, cancellationToken);

            await _humanTaskDefCommandRepository.SaveChanges(cancellationToken);

            _logger.LogInformation("The rendering has been updated");
            return(true);
        }