BExISMigration.UserMigration.CreateOnBPP C# (CSharp) Method

CreateOnBPP() public method

public CreateOnBPP ( List transferUsers, string filePath, long groupId ) : void
transferUsers List
filePath string
groupId long
return void
        public void CreateOnBPP(List<UserProperties> transferUsers, string filePath, long groupId)
        {
            SubjectManager subjectManager = new SubjectManager();
            StreamWriter file = new StreamWriter(filePath + @"\passwords.txt");

            foreach (UserProperties transferUser in transferUsers)
            {
                // transfer user if not exist
                if (!subjectManager.ExistsUserName(transferUser.username))
                {
                    // create user
                    User user = subjectManager.CreateUser(
                        transferUser.username,
                        transferUser.password,
                        transferUser.firstname + " " + transferUser.lastname,
                        transferUser.email,
                        transferUser.securityQuestionId,
                        transferUser.securityAnswer,
                        transferUser.authenticatorId
                        );

                    // add user to group; the group "bexisUser" must be created manually
                    subjectManager.AddUserToGroup(user.Id, groupId);
                    // write username and generated password to file "passwords.txt"
                    file.WriteLine(transferUser.username + ",\t" + transferUser.password);
                }
            }

            file.Close();
        }

Usage Example

Example #1
0
        public void UserMigration()
        {
            // data base of bexis1 user query
            string filePath = AppConfiguration.GetModuleWorkspacePath("BMM");
            // names of the features witch set to the group "bexisUser"
            string[] featureNames = { "Search", "Data Collection", "Research Plan", "Data Dissemination" };

            UserMigration userMigration = new UserMigration();

            // create or get a group named "bexisUser"
            long groupId = userMigration.bexisUserGroup();

            // set feature permission of the group "bexisUser"
            userMigration.SetFeaturePermissions(groupId, featureNames);

            // query bexis1 user from provider.users and generate a random password
            List<UserProperties> BExISUsers = userMigration.GetFromBExIS(DataBase);

            // transfer users to bpp; not all user data are provided in bpp
            // save usernames and passwords in file "passwords.txt"
            userMigration.CreateOnBPP(BExISUsers, filePath, groupId);
        }