public async Task LogForSignature(string nodeId, string fileId, string nextGroup, string nextOwner)
        {
            try
            {
                var nodeEntry = await _alfrescoHttpClient.GetNodeInfo(nodeId);

                var personEntry = await _alfrescoHttpClient.GetPerson(nextOwner);

                var groupEntry = await _alfrescoHttpClient.GetGroup(nextGroup);

                var pid = nodeEntry?.GetPid();

                // Audit log for a document
                await _auditLogService.Record(nodeId, SpisumNames.NodeTypes.Document, pid, NodeTypeCodes.Dokument, EventCodes.PostoupeniAgende,
                                              string.Format(TransactinoHistoryMessages.DocumentForSignature, personEntry?.Entry?.DisplayName, groupEntry?.Entry?.DisplayName));

                // Audit log for a file
                if (fileId != null)
                {
                    await _auditLogService.Record(fileId, SpisumNames.NodeTypes.Document, pid, NodeTypeCodes.Dokument, EventCodes.PostoupeniAgende,
                                                  string.Format(TransactinoHistoryMessages.DocumentForSignature, personEntry?.Entry?.DisplayName, groupEntry?.Entry?.DisplayName));
                }
            }
            catch (Exception ex)
            {
                Log.Logger?.Error(ex, "Audit log failed");
            }
        }
示例#2
0
        public async Task <PersonGroup> GetCreateUserGroup()
        {
            if (string.IsNullOrWhiteSpace(_identityUser.RequestGroup))
            {
                throw new BadRequestException("", "User has not properties set");
            }

            GroupEntry groupInfo = null;

            var personGroupName = $"{SpisumNames.Prefixes.UserGroup}{_identityUser.Id}";

            try
            {
                groupInfo = await _alfrescoHttpClient.GetGroup(personGroupName);
            }
            catch
            {
                throw new BadRequestException("", "User group not found");
            }

            var groupMembers = await _alfrescoHttpClient.GetGroupMembers(personGroupName);

            if (groupMembers?.List?.Entries?.ToList().Find(x => x.Entry?.Id == _identityUser.Id) == null)
            {
                await _alfrescoHttpClient.CreateGroupMember(personGroupName, new GroupMembershipBodyCreate { Id = _identityUser.Id, MemberType = GroupMembershipBodyCreateMemberType.PERSON });
            }

            return(new PersonGroup {
                PersonId = _identityUser.Id, GroupId = groupInfo.Entry.Id, GroupPrefix = _identityUser.RequestGroup
            });
        }
示例#3
0
        private async Task CreateGroup(GroupBodyCreate body)
        {
            string groupId = null;

            try
            {
                var groupInfo = await _alfrescoHttpClient.GetGroup(body.Id);

                groupId = groupInfo?.Entry?.Id;
            }
            catch
            {
            }

            if (groupId == null)
            {
                try
                {
                    await _alfrescoHttpClient.CreateGroup(body);
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "CreateGroup Fail");
                }
            }
        }
        private async Task <bool> groupExist(IAlfrescoHttpClient alfrescoHttpClient, string groupId)
        {
            try
            {
                await alfrescoHttpClient.GetGroup(groupId);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
示例#5
0
 public GroupValidator(IAlfrescoHttpClient alfrescoHttpClient)
 {
     RuleFor(o => o)
     .Cascade(CascadeMode.StopOnFirstFailure)
     .Must(o => new Regex(@"^([a-zA-Z0-9_]+)$").IsMatch(o.Id))
     .MustAsync(async(context, cancellationToken) =>
     {
         try
         {
             await alfrescoHttpClient.GetGroup($"{SpisumNames.Prefixes.Group}{context.Id}");
             return(false);
         }
         catch
         {
             return(true);
         }
     });
 }