/// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="service">An initialized Dfa Reporting service object
    /// </param>
    public override void Run(DfareportingService service) {
      long parentUserRoleId = long.Parse(_T("INSERT_PARENT_USER_ROLE_ID_HERE"));
      long permission1Id = long.Parse(_T("INSERT_FIRST_PERMISSION_ID_HERE"));
      long permission2Id = long.Parse(_T("INSERT_SECOND_PERMISSIONS_ID_HERE"));
      long profileId = long.Parse(_T("INSERT_PROFILE_ID_HERE"));
      long subaccountId = long.Parse(_T("INSERT_SUBACCOUNT_ID_HERE"));

      String userRoleName = _T("INSERT_USER_ROLE_NAME_HERE");

      // Create user role structure.
      UserRole userRole = new UserRole();
      userRole.Name = userRoleName;
      userRole.SubaccountId = subaccountId;
      userRole.ParentUserRoleId = parentUserRoleId;

      // Create a permission object to represent each permission this user role
      // has.
      UserRolePermission permission1 = new UserRolePermission();
      permission1.Id = permission1Id;
      UserRolePermission permission2 = new UserRolePermission();
      permission2.Id = permission2Id;
      List<UserRolePermission> permissions =
          new List<UserRolePermission> { permission1, permission2 };

      // Add the permissions to the user role.
      userRole.Permissions = permissions;

      // Create user role.
      UserRole result = service.UserRoles.Insert(userRole, profileId).Execute();

      // Display user role ID.
      Console.WriteLine("User role with ID {0} was created.", result.Id);
    }
Exemplo n.º 2
0
        public void updateUserRolePermission(int id, Edit userRolePermission)
        {
            DBHelper._UserRolePermission dbhelp = new DBHelper._UserRolePermission();
            UserRolePermission           existingUserRolePermission = dbhelp.GetByid(id);

            existingUserRolePermission.PermissionCatalogID = userRolePermission.PermissionCatalogId;
            existingUserRolePermission.UserRoleID          = userRolePermission.UserRoleId;

            dbhelp.Update(existingUserRolePermission);
        }
Exemplo n.º 3
0
        public void addUserRolePermission(Edit userRolePermission)
        {
            DBHelper._UserRolePermission dbhelp = new DBHelper._UserRolePermission();
            var newUserRolePermission           = new UserRolePermission()
            {
                UserRoleID          = userRolePermission.UserRoleId,
                PermissionCatalogID = userRolePermission.PermissionCatalogId
            };

            dbhelp.Add(newUserRolePermission);
        }
Exemplo n.º 4
0
        public void updateUserRole(int id, Edit userRole)
        {
            DBHelper._UserRole dbhelp_useRole   = new DBHelper._UserRole();
            UserRole           existingUserRole = dbhelp_useRole.GetByid(id);

            existingUserRole.Name      = userRole.Name;
            existingUserRole.CompanyId = userRole.CompanyId;

            dbhelp_useRole.Update(existingUserRole);

            DBHelper._UserRolePermission dbhelp_useRolePermission = new DBHelper._UserRolePermission();
            List <UserRolePermission>    existingPermissionList   = dbhelp_useRolePermission.GetAllByUserRoleIdIncludeDelete(id);
            List <UserRolePermission>    insertPermissionList     = new List <UserRolePermission>();
            List <int> existingPermissionIdList = new List <int>();

            if (existingPermissionList.Count > 0)
            {
                foreach (var eurp in existingPermissionList)
                {
                    if (userRole.PermissionCatalogId == null || (!userRole.PermissionCatalogId.Contains(eurp.PermissionCatalogID) && !eurp.DeletedFlag))
                    {
                        eurp.DeletedFlag = true;
                    }
                    else if (userRole.PermissionCatalogId.Contains(eurp.PermissionCatalogID) && eurp.DeletedFlag)
                    {
                        eurp.DeletedFlag = false;
                    }
                    existingPermissionIdList.Add(eurp.PermissionCatalogID);
                }
                dbhelp_useRolePermission.UpdateManyRows(existingPermissionList);
            }


            if (userRole.PermissionCatalogId != null)
            {
                foreach (var permissionCatalogId in userRole.PermissionCatalogId)
                {
                    if (existingPermissionList.Count == 0 || (permissionCatalogId > 0 && !existingPermissionIdList.Contains(permissionCatalogId)))
                    {
                        var newUserRolePermissio = new UserRolePermission()
                        {
                            UserRoleID          = id,
                            PermissionCatalogID = permissionCatalogId
                        };
                        insertPermissionList.Add(newUserRolePermissio);
                    }
                }
                dbhelp_useRolePermission.AddManyRows(insertPermissionList);
            }
        }
Exemplo n.º 5
0
        public IHttpActionResult GetPartnerPermissions()
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            UserRolePermission result = _SitemapService.GetPartnerPermissions();

            if (result == null)
            {
                return(NotFound());
            }
            return(Ok(result));
        }
Exemplo n.º 6
0
        public Detail getUserRolePermissionById(int id)
        {
            DBHelper._UserRolePermission dbhelp             = new DBHelper._UserRolePermission();
            UserRolePermission           userRolePermission = dbhelp.GetByid(id);

            return(new Detail()
            {
                Id = userRolePermission.Id,
                UserRoleId = userRolePermission.UserRole.Id,
                UserRoleName = userRolePermission.UserRole.Name,
                PermissionCatalogId = userRolePermission.PermissionCatalog.Id,
                PermissionCatalogName = userRolePermission.PermissionCatalog.Name,
                PermissionDescription = userRolePermission.PermissionCatalog.Description
            });
        }
Exemplo n.º 7
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long parentUserRoleId = long.Parse(_T("INSERT_PARENT_USER_ROLE_ID_HERE"));
            long permission1Id    = long.Parse(_T("INSERT_FIRST_PERMISSION_ID_HERE"));
            long permission2Id    = long.Parse(_T("INSERT_SECOND_PERMISSIONS_ID_HERE"));
            long profileId        = long.Parse(_T("INSERT_PROFILE_ID_HERE"));
            long subaccountId     = long.Parse(_T("INSERT_SUBACCOUNT_ID_HERE"));

            String userRoleName = _T("INSERT_USER_ROLE_NAME_HERE");

            // Create user role structure.
            UserRole userRole = new UserRole();

            userRole.Name             = userRoleName;
            userRole.SubaccountId     = subaccountId;
            userRole.ParentUserRoleId = parentUserRoleId;

            // Create a permission object to represent each permission this user role
            // has.
            UserRolePermission permission1 = new UserRolePermission();

            permission1.Id = permission1Id;
            UserRolePermission permission2 = new UserRolePermission();

            permission2.Id = permission2Id;
            List <UserRolePermission> permissions =
                new List <UserRolePermission> {
                permission1, permission2
            };

            // Add the permissions to the user role.
            userRole.Permissions = permissions;

            // Create user role.
            UserRole result = service.UserRoles.Insert(userRole, profileId).Execute();

            // Display user role ID.
            Console.WriteLine("User role with ID {0} was created.", result.Id);
        }
Exemplo n.º 8
0
        //private void checkBox2_CheckedChanged(object sender, EventArgs e)
        //{

        //}

        private void SaveBtn_Click(object sender, EventArgs e)
        {
            //IList<Role> roles = Roles.DefaultRoles.GetAllRoles();
            foreach (Control control in panel2.Controls)
            {
                CheckBox cb = control as CheckBox;
                if (cb != null)
                {
                    Role role = cb.Tag as Role;
                    if (cb.Checked == false)
                    {
                        for (int i = 0; i < user.UserRolePermissionCount; i++)
                        {
                            UserRolePermission rolePermission = new UserRolePermission();
                            rolePermission.Role       = Roles.DefaultRoles.AllPermission;
                            rolePermission.Permission = user[i].Permission;
                            user[i] = rolePermission;
                            //rolePermission.Role = Roles.DefaultRoles.AllPermission;
                            user.DeleteRole(role);
                        }
                    }
                    else
                    {
                        if (cb.Checked == true)
                        {
                            if (!user.HaveRole(role))
                            {
                                user.AddRole(role);
                            }
                        }
                    }
                }
            }
            Users.DefaultUsers.SaveUser(user, true, true);
            DialogResult = DialogResult.OK;
            Hide();
        }
Exemplo n.º 9
0
 public static UserRolePermission CreateUserRolePermission(global::System.Collections.ObjectModel.ObservableCollection<string> permission)
 {
     UserRolePermission userRolePermission = new UserRolePermission();
     if ((permission == null))
     {
         throw new global::System.ArgumentNullException("permission");
     }
     userRolePermission.Permission = permission;
     return userRolePermission;
 }
Exemplo n.º 10
0
 public UserMinimumRequirement(UserRolePermission permission)
 {
     Permission = permission;
 }