Beispiel #1
0
        private void action1ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var ra = new RoleAction
            {
                ActionType = 1,
                Roles = roleSelector1.SelectedRoles,
                Principals = principalSelector1.SelectedItems
            };

            WorkAsync("Adding roles to principal(s)...",
                (bw, evt) =>
                {
                    var action = (RoleAction)evt.Argument;

                    var rManager = new RoleManager(Service);
                    rManager.AddRolesToPrincipals(action.Roles, action.Principals, allRoles, bw);
                },
                evt =>
                {
                    if (evt.Error != null)
                    {
                        MessageBox.Show(this, "An error occured: " + evt.Error.Message, "Error", MessageBoxButtons.OK,
                            MessageBoxIcon.Error);
                    }
                },
                evt => SetWorkingMessage(string.Format(evt.UserState.ToString(), evt.ProgressPercentage)),
                ra);
        }
Beispiel #2
0
        public void LoadRoles(Guid? specificBusinessUnitId = null)
        {
            listView1.Items.Clear();

            var rManager = new RoleManager(service);
            var rootBuId = rManager.GetRootBusinessUnitId();
            AllRoles = rManager.GetRoles();

            listView1.Items.AddRange(AllRoles
                .Where(role => role.GetAttributeValue<EntityReference>("parentrootroleid").Id == role.Id)
                .Select(role => new ListViewItem
            {
                Text = role.GetAttributeValue<string>("name"),
                SubItems =
                {
                    role.GetAttributeValue<EntityReference>("businessunitid").Name,
                    (rootBuId != role.GetAttributeValue<EntityReference>("businessunitid").Id).ToString()
                },
                ImageIndex = 0,
                StateImageIndex = 0,
                Tag = role
            }).ToArray());
        }
Beispiel #3
0
        private void action2ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var ra = new RoleAction
            {
                ActionType = 2,
                Roles = roleSelector1.SelectedRoles,
                Principals = principalSelector1.SelectedItems
            };

            if (ra.Principals.Any(p => p.Id == currentUserId))
            {
                MessageBox.Show(this,
                    "You can't remove roles from your own profile. Your profile will be removed from the principals list",
                    "Warning",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning);

                ra.Principals.Remove(ra.Principals.First(r => r.Id == currentUserId));
            }

            WorkAsync("Removing roles to principal(s)...",
                (bw, evt) =>
                {
                    var action = (RoleAction) evt.Argument;

                    var rManager = new RoleManager(Service);
                    rManager.RemoveRolesFromPrincipals(action.Roles, action.Principals, allRoles, bw);
                },
                evt =>
                {
                    if (evt.Error != null)
                    {
                        MessageBox.Show(this, "An error occured: " + evt.Error.Message, "Error", MessageBoxButtons.OK,
                            MessageBoxIcon.Error);
                    }
                },
                evt => SetWorkingMessage(string.Format(evt.UserState.ToString(), evt.ProgressPercentage)),
                ra);
        }