/// <summary> /// Updates the document global annotation permissions /// </summary> /// <param name="fileId">The document path to update the permissions for</param> /// <param name="rights">The annotation permissions</param> public void SetDocumentAccessRights(string fileId, AnnotationReviewerRights rights) { var document = _documentSvc.GetDocument(fileId); long documentId = document != null ? document.Id : _annotator.CreateDocument(fileId); _annotator.SetDocumentAccessRights(documentId, rights); }
/// <summary> /// Updates collaborator annotation permissions /// </summary> /// <param name="fileId">The document path to update the collaborator permission for</param> /// <param name="userName">The collaborator name</param> /// <param name="rights">The collaborator's annotation permissions</param> /// <returns>An instance of an object containing the collaborator's details</returns> public ReviewerInfo SetCollaboratorRights(string fileId, string userName, AnnotationReviewerRights rights) { var document = _documentSvc.GetDocument(fileId); var collaborator = _annotator.GetDocumentCollaborator(document.Id, userName); collaborator.AccessRights = rights; var result = _annotator.UpdateCollaborator(document.Id, collaborator); _annotationBroadcaster.SetReviewersColors(result.Collaborators.Select(c => c.Guid).ToList(), null, _mapper.Map <ReviewerInfo[]>(result.Collaborators)); return(_mapper.Map <ReviewerInfo>(result.Collaborators.FirstOrDefault(c => c.PrimaryEmail == userName))); }
/// <summary> /// Adds document collaborator /// </summary> /// <param name="fileId">The document path to add the collaborator to</param> /// <param name="reviewerEmail">The email address of the collaborator</param> /// <param name="reviewerFirstName">The first name of the collaborator</param> /// <param name="reviewerLastName">The last name of the collaborator</param> /// <param name="reviewerInvitationMessage">The invitation text message to be sent to the collaborator</param> /// <param name="rights">The annotation permissions for the collaborator</param> /// <param name="avatar">The file stream of the collaborator's avatar</param> /// <returns>An instance of an object containing the operation result and collaborators details</returns> public SetCollaboratorsResult AddCollaborator(string fileId, string reviewerEmail, string reviewerFirstName, string reviewerLastName, string reviewerInvitationMessage, AnnotationReviewerRights rights, Stream avatar = null) { MemoryStream memoryStream = (MemoryStream)avatar; var reviewer = new GroupDocs.Annotation.Domain.ReviewerInfo { PrimaryEmail = reviewerEmail, FirstName = reviewerFirstName, LastName = reviewerLastName, AccessRights = rights, Avatar = memoryStream != null?memoryStream.ToArray() : new byte[0] }; User user = _userSvc.GetUserByEmail(reviewerEmail); if (user == null) { _userSvc.Add(new User { Email = reviewer.PrimaryEmail, Guid = Guid.NewGuid().ToString(), Photo = reviewer.Avatar, FirstName = reviewer.FirstName, LastName = reviewer.LastName }); user = _userSvc.GetUserByEmail(reviewerEmail); } var document = GetDocument(fileId, user.Id); var result = _mapper.Map <SetCollaboratorsResult>(_annotator.AddCollaborator(document.Id, reviewer)); return(result); }
/// <summary> /// Updates the document global annotation permissions /// </summary> /// <param name="fileId">The document path to update the permissions for</param> /// <param name="rights">The annotation permissions</param> public void SetDocumentAccessRights(string fileId, AnnotationReviewerRights rights) { var document = _documentSvc.GetDocument(fileId); long documentId = document?.Id ?? _annotator.CreateDocument(fileId); _annotator.SetDocumentAccessRights(documentId, rights); }
/// <summary> /// Updates collaborator annotation permissions /// </summary> /// <param name="fileId">The document path to update the collaborator permission for</param> /// <param name="userName">The collaborator name</param> /// <param name="rights">The collaborator's annotation permissions</param> /// <returns>An instance of an object containing the collaborator's details</returns> public ReviewerInfo SetCollaboratorRights(string fileId, string userName, AnnotationReviewerRights rights) { var document = _documentSvc.GetDocument(fileId); var collaborator = _annotator.GetDocumentCollaborator(document.Id, userName); collaborator.AccessRights = rights; var result = _annotator.UpdateCollaborator(document.Id, collaborator); _annotationBroadcaster.SetReviewersColors(result.Collaborators.Select(c => c.Guid).ToList(), null, _mapper.Map<ReviewerInfo[]>(result.Collaborators)); return _mapper.Map<ReviewerInfo>(result.Collaborators.FirstOrDefault(c => c.PrimaryEmail == userName)); }
/// <summary> /// Adds document collaborator /// </summary> /// <param name="fileId">The document path to add the collaborator to</param> /// <param name="reviewerEmail">The email address of the collaborator</param> /// <param name="reviewerFirstName">The first name of the collaborator</param> /// <param name="reviewerLastName">The last name of the collaborator</param> /// <param name="reviewerInvitationMessage">The invitation text message to be sent to the collaborator</param> /// <param name="rights">The annotation permissions for the collaborator</param> /// <param name="avatar">The file stream of the collaborator's avatar</param> /// <returns>An instance of an object containing the operation result and collaborators details</returns> public SetCollaboratorsResult AddCollaborator(string fileId, string reviewerEmail, string reviewerFirstName, string reviewerLastName, string reviewerInvitationMessage, AnnotationReviewerRights rights, Stream avatar = null) { MemoryStream memoryStream = (MemoryStream) avatar; var reviewer = new GroupDocs.Annotation.Domain.ReviewerInfo { PrimaryEmail = reviewerEmail, FirstName = reviewerFirstName, LastName = reviewerLastName, AccessRights = rights, Avatar = memoryStream?.ToArray() ?? new byte[0] }; User user = _userSvc.GetUserByEmail(reviewerEmail); if(user == null) { _userSvc.Add(new User { Email = reviewer.PrimaryEmail, Guid = Guid.NewGuid().ToString(), Photo = reviewer.Avatar, FirstName = reviewer.FirstName, LastName = reviewer.LastName }); user = _userSvc.GetUserByEmail(reviewerEmail); } var document = GetDocument(fileId, user.Id); var result = _mapper.Map<SetCollaboratorsResult>(_annotator.AddCollaborator(document.Id, reviewer)); return result; }