Beispiel #1
0
 public async Task <UserAdminObject> ConvertUserResultToUserAdminObjectAsync(kCura.Relativity.Client.DTOs.User userResult)
 {
     return(new UserAdminObject()
     {
         ArtifactId = userResult.ArtifactID,
         FirstName = { Data = userResult.FirstName },
         LastName = { Data = userResult.LastName },
         EmailAddress = { Data = userResult.EmailAddress },
         Type = { Data = await ArtifactQueries.GetChoiceNameByArtifactID(RsapiRepositoryGroup.ChoiceRepository, RsapiApiOptions, userResult.Type.ArtifactID) },
         Client = { Data = await ArtifactQueries.GetClientNameByArtifactID(RsapiRepositoryGroup.ClientRepository, RsapiApiOptions, userResult.Client.ArtifactID) },
         RelativityAccess = { Data = userResult.RelativityAccess.ToString() },
         DocumentSkip = { Data = await ArtifactQueries.GetChoiceNameByArtifactID(RsapiRepositoryGroup.ChoiceRepository, RsapiApiOptions, userResult.DocumentSkip.ArtifactID) },
         BetaUser = { Data = userResult.BetaUser.ToString() },
         ChangeSettings = { Data = userResult.ChangeSettings.ToString() },
         KeyboardShortcuts = { Data = userResult.KeyboardShortcuts.ToString() },
         ItemListPageLength = { Data = userResult.ItemListPageLength.ToString() },
         DefaultSelectedFileType = { Data = await ArtifactQueries.GetChoiceNameByArtifactID(RsapiRepositoryGroup.ChoiceRepository, RsapiApiOptions, userResult.DefaultSelectedFileType.ArtifactID) },
         SkipDefaultPreference = { Data = await ArtifactQueries.GetChoiceNameByArtifactID(RsapiRepositoryGroup.ChoiceRepository, RsapiApiOptions, userResult.SkipDefaultPreference.ArtifactID) },
         EnforceViewerCompatibility = { Data = userResult.EnforceViewerCompatibility.ToString() },
         AdvancedSearchPublicByDefault = { Data = userResult.AdvancedSearchPublicByDefault.ToString() },
         NativeViewerCacheAhead = { Data = userResult.NativeViewerCacheAhead.ToString() },
         ChangeDocumentViewer = { Data = userResult.CanChangeDocumentViewer.ToString() },
         DocumentViewer = { Data = await ArtifactQueries.GetChoiceNameByArtifactID(RsapiRepositoryGroup.ChoiceRepository, RsapiApiOptions, userResult.DocumentViewer.ArtifactID) },
         Keywords = { Data = null },
         Notes = { Data = null },
         Groups = { Data = null },
         WindowsAccount = { Data = null },
         UserMustChangePasswordOnNextLogin = { Data = userResult.ChangePasswordNextLogin.GetValueOrDefault().ToString() },
         CanChangePassword = { Data = userResult.ChangePassword.GetValueOrDefault().ToString() },
         MaximumPasswordAgeInDays = { Data = userResult.MaximumPasswordAge.GetValueOrDefault().ToString() },
         TwoFactorMode = { Data = null },
         TwoFactorInfo = { Data = null }
     });
 }
        private async Task <IEnumerable <String> > ImportUserAsync(APIOptions apiOptions, IGenericRepository <kCura.Relativity.Client.DTOs.User> userRepository)
        {
            List <String> violations = new List <string>();

            kCura.Relativity.Client.DTOs.User user = null;
            try
            {
                apiOptions.WorkspaceID = -1;
                user = new kCura.Relativity.Client.DTOs.User()
                {
                    FirstName                     = (String)await FirstName.GetDataValueAsync(),
                    LastName                      = (String)await LastName.GetDataValueAsync(),
                    EmailAddress                  = (String)await EmailAddress.GetDataValueAsync(),
                    Groups                        = _groupList,
                    Type                          = _userType,
                    Client                        = _client,
                    RelativityAccess              = ((Boolean?)await RelativityAccess.GetDataValueAsync()).GetValueOrDefault(),
                    DocumentSkip                  = _documentSkip,
                    BetaUser                      = ((Boolean?)await BetaUser.GetDataValueAsync()).GetValueOrDefault(),
                    ChangeSettings                = ((Boolean?)await ChangeSettings.GetDataValueAsync()).GetValueOrDefault(),
                    KeyboardShortcuts             = ((Boolean?)await KeyboardShortcuts.GetDataValueAsync()).GetValueOrDefault(),
                    ItemListPageLength            = ((Int32?)await ItemListPageLength.GetDataValueAsync()).GetValueOrDefault(),
                    DefaultSelectedFileType       = _defaultSelectedFileType,
                    SkipDefaultPreference         = _skipDefaultPreference,
                    EnforceViewerCompatibility    = ((Boolean?)await EnforceViewerCompatibility.GetDataValueAsync()).GetValueOrDefault(),
                    AdvancedSearchPublicByDefault = ((Boolean?)await AdvancedSearchPublicByDefault.GetDataValueAsync()).GetValueOrDefault(),
                    NativeViewerCacheAhead        = ((Boolean?)await NativeViewerCacheAhead.GetDataValueAsync()).GetValueOrDefault(),
                    CanChangeDocumentViewer       = ((Boolean?)await ChangeDocumentViewer.GetDataValueAsync()).GetValueOrDefault(),
                    DocumentViewer                = _documentViewer,
                    TrustedIPs                    = String.Empty,
                    ChangePassword                = ((Boolean?)await CanChangePassword.GetDataValueAsync()).GetValueOrDefault(),
                    MaximumPasswordAge            = ((Int32?)await MaximumPasswordAgeInDays.GetDataValueAsync()).GetValueOrDefault(),
                    DataFocus                     = 1, // This field is no longer utilized in Relativity, however it's hardcoded because it is required
                    ChangePasswordNextLogin       = ((Boolean?)await UserMustChangePasswordOnNextLogin.GetDataValueAsync()).GetValueOrDefault()
                };

                ArtifactId = userRepository.CreateSingle(user);
            }
            catch (Exception ex)
            {
                String msg = null;
                if (ex.ToString().Contains("The entered E-Mail Address is already associated with a user") && user != null && !String.IsNullOrWhiteSpace(user.EmailAddress))
                {
                    msg = String.Format(Constant.ErrorMessages.UserAlreadyExists, user.EmailAddress);
                }
                else
                {
                    msg = ex.ToString();
                }
                violations.Add(msg);
            }
            return(violations);
        }
Beispiel #3
0
        public async Task <IEnumerable <String> > QueryGroupsNamesUserIsPartOfAsync(kCura.Relativity.Client.DTOs.User user)
        {
            try
            {
                var userGroupArtifactIDs           = user.Groups.Select(x => x.ArtifactID).ToList();
                IEnumerable <String> groupNameList = await ArtifactQueries.QueryGroupsNamesForArtifactIdsAsync(
                    rsapiApiOptions : RsapiApiOptions,
                    eddsWorkspaceArtifactId : -1,
                    groupRepository : RsapiRepositoryGroup.GroupRepository,
                    groupArtifactIdList : userGroupArtifactIDs);

                return(groupNameList);
            }
            catch (Exception ex)
            {
                throw new AdminMigrationUtilityException(Constant.ErrorMessages.QueryGroupNamesUserIsPartOfError, ex);
            }
        }
Beispiel #4
0
        public async Task ProcessSingleUserAsync(Int32 workspaceArtifactID, Int32 jobArtifactID, ExportWorkerQueueRecord exportWorkerQueueRecord)
        {
            try
            {
                RaiseAndLogDebugMessage($"Processing a single user in export worker batch. [{nameof(exportWorkerQueueRecord.ArtifactId)}] = {exportWorkerQueueRecord.ArtifactId}");

                kCura.Relativity.Client.DTOs.User userRDO = await ArtifactQueries.RetrieveUserAsync(RsapiApiOptions, RsapiRepositoryGroup.UserRepository, exportWorkerQueueRecord.ArtifactId);

                //query user Auth data
                LoginProfile userLoginProfile = await AuthenticationHelper.RetrieveExistingUserLoginProfileAsync(userRDO.ArtifactID);

                //query keywords and notes for user
                KeywordsNotesModel userKeywordsNotesModel = await SqlQueryHelper.RetrieveKeywordsAndNotesForUserAsync(
                    eddsDbContext : AgentHelper.GetDBContext(-1),
                    userArtifactId : userRDO.ArtifactID);

                //query groups user is part of
                IEnumerable <String> userGroupNameList = await QueryGroupsNamesUserIsPartOfAsync(userRDO);

                UserAdminObject userAdminObject = await ConvertUserResultToUserAdminObjectAsync(userRDO);

                //add keywords and notes, auth and groups data to UserAdminObject
                await AddKeywordsNotesAuthInfoAndGroupsToUserAdminObjectAsync(userAdminObject, userKeywordsNotesModel, userGroupNameList, userLoginProfile);

                //insert user data info into the export worker results table
                await InsertUserDataIntoExportWorkerResultsTableAsync(exportWorkerQueueRecord, userAdminObject);

                RaiseAndLogDebugMessage($"Processed a single user in export worker batch. [{nameof(exportWorkerQueueRecord.ArtifactId)}] = {exportWorkerQueueRecord.ArtifactId}");
            }
            catch (Exception ex)
            {
                //create export job error record
                String details = ExceptionMessageFormatter.GetExceptionMessageIncludingAllInnerExceptions(ex);
                await CreateExportJobErrorRecordAsync(workspaceArtifactID, jobArtifactID, exportWorkerQueueRecord.ObjectType, Constant.Status.JobErrors.ERROR, details);
            }
        }
Beispiel #5
0
        public override Response Execute()
        {
            Artifact   activeArtifact    = this.ActiveArtifact;
            int        activeWorkspaceId = this.Helper.GetActiveCaseID();
            string     currentUser       = this.Helper.GetAuthenticationManager().UserInfo.FullName;
            IDBContext dbcontext         = this.Helper.GetDBContext(activeWorkspaceId);
            bool       result            = true;
            ConsoleEventHandlerComment consoleEventHandler = new ConsoleEventHandlerComment();
            Response retVal = new Response()
            {
                Success = true,
                Message = String.Empty
            };

            //verify if the comment has a parent
            if (!(ActiveArtifact.Fields[RELATED_COMMENT_FIELD.ToString()] == null))
            {
                int parentCommentId = (int)ActiveArtifact.Fields[RELATED_COMMENT_FIELD.ToString()].Value.Value;
                kCura.Relativity.Client.DTOs.RDO parentComment = new kCura.Relativity.Client.DTOs.RDO(parentCommentId);
                using (kCura.Relativity.Client.IRSAPIClient client =
                           this.Helper.GetServicesManager().CreateProxy <kCura.Relativity.Client.IRSAPIClient>(ExecutionIdentity.System))
                {
                    int workspaceId = this.Helper.GetActiveCaseID();
                    client.APIOptions.WorkspaceID = workspaceId;
                    parentComment = client.Repositories.RDO.ReadSingle(parentCommentId);

                    client.APIOptions.WorkspaceID = -1;
                    kCura.Relativity.Client.DTOs.User userComment = new kCura.Relativity.Client.DTOs.User(parentComment.SystemCreatedBy.ArtifactID);
                    userComment = client.Repositories.User.ReadSingle(parentComment.SystemCreatedBy.ArtifactID);


                    if (ActiveArtifact.IsNew)
                    {
                        MailMessage email     = new MailMessage();
                        string      userEmail = userComment.EmailAddress;
                        string      author    = this.Helper.GetAuthenticationManager().UserInfo.FullName;
                        email.To.Add(new MailAddress(userEmail));
                        // sentEmailNew(email, author);
                    }
                }
            }
            else
            {
                using (kCura.Relativity.Client.IRSAPIClient client =
                           this.Helper.GetServicesManager().CreateProxy <kCura.Relativity.Client.IRSAPIClient>(ExecutionIdentity.System))
                {
                    string type        = string.Empty;
                    int    workspaceId = this.Helper.GetActiveCaseID();
                    client.APIOptions.WorkspaceID = workspaceId;
                    CORE.BLL.Service.RSAPIService.CommentRSAPIService commentRSAPIService = new CORE.BLL.Service.RSAPIService.CommentRSAPIService(client);
                    CORE.DAL.Entities.Comment comment     = commentRSAPIService.Get(ActiveArtifact.ArtifactID);
                    ChoiceCollection          typeChoices = (ChoiceCollection)this.ActiveArtifact.Fields[COMMENT_TYPE_FIELD_GUID.ToString()].Value.Value;
                    foreach (Choice typeC in typeChoices)
                    {
                        type = typeC.Name;
                    }
                    comment.TypeChoosed = type;
                    auditComment(comment, ActiveArtifact.IsNew, this.Helper.GetDBContext(workspaceId));
                }
            }


            try
            {
                ChoiceCollection typeChoices = (ChoiceCollection)this.ActiveArtifact.Fields[COMMENT_TYPE_FIELD_GUID.ToString()].Value.Value;

                foreach (Choice typeChoice in typeChoices)
                {
                    if (typeChoice.Name.Equals("Error"))
                    {
                        result = consoleEventHandler.insertJob(dbcontext, currentUser, activeArtifact);
                    }
                    else
                    {
                        result = consoleEventHandler.deleteJob(dbcontext, activeArtifact.ArtifactID);
                    }
                }
            }
            catch (Exception e)
            {
                retVal.Success = false;
                retVal.Message = e.Message;
            }
            return(retVal);
        }