BExISMigration.UserMigration.SetFeaturePermissions C# (CSharp) Method

SetFeaturePermissions() public method

public SetFeaturePermissions ( long groupId, string featureNames ) : void
groupId long
featureNames string
return void
        public void SetFeaturePermissions(long groupId, string[] featureNames)
        {
            FeatureManager featureManager = new FeatureManager();
            PermissionManager permissionManager = new PermissionManager();

            // never set administration features (this parent Id)
            long parentId = featureManager.FeaturesRepo.Get().Where(f => f.Name.Equals("Administration")).FirstOrDefault().Id;

            for (int i = 0; i < featureNames.Length; i++)
            {
                long featureId = featureManager.FeaturesRepo.Get(f => featureNames[i].Equals(f.Name) && !f.Parent.Id.Equals(parentId)).FirstOrDefault().Id;
                permissionManager.CreateFeaturePermission(groupId, featureId);
            }
        }

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);
        }