Exemple #1
0
        private void buttonUpdateSubRole_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.treeViewRoles.SelectedNode != null &&
                    this.treeViewRoles.SelectedNode.Tag is RoleDescription &&
                    this.treeViewRoles.SelectedNode.Parent != null)
                {
                    RoleDescription selectedRole = (RoleDescription)this.treeViewRoles.SelectedNode.Tag;

                    RoleDescription parentRole = (RoleDescription)this.treeViewRoles.SelectedNode.Parent.Tag;

                    CustomizeRoleDialog dialog = new CustomizeRoleDialog(selectedRole, "Update the role " + selectedRole.Name.GetString());
                    DialogResult        result = dialog.ShowDialog();

                    if (result == DialogResult.OK)
                    {
                        IPreService preProxy = GetPreProxy();
                        dialog.Role.Name = preProxy.Encrypt(this.keyPair.Public, dialog.Role.Name);


                        IGatewayService proxy = GetServiceProxy();
                        proxy.UpdateSubRole(this.myId, parentRole.Id, dialog.Role);

                        buttonRefreshRolesAndUsers_Click(this, EventArgs.Empty);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
                Logger.LogError("Error updating sub-role user", ex);
            }
        }
Exemple #2
0
        private void buttonCreateSubRole_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.treeViewRoles.SelectedNode != null &&
                    this.treeViewRoles.SelectedNode.Tag is RoleDescription)
                {
                    RoleDescription selectedRole = (RoleDescription)this.treeViewRoles.SelectedNode.Tag;

                    IGatewayService    proxy        = GetServiceProxy();
                    IList <DataEntity> dataEntities = proxy.GetDataEntitiesForRole(this.myId, selectedRole.Id);

                    DecryptDataEntities(dataEntities);

                    CustomizeRoleDialog dialog = new CustomizeRoleDialog("Create new subrole from " + selectedRole.Name.GetString());
                    dialog.SetDataEntities(dataEntities);

                    DialogResult result = dialog.ShowDialog();

                    if (result == DialogResult.OK)
                    {
                        Role newRole = dialog.Role;
                        newRole.Id = Guid.NewGuid();

                        IPreService preProxy = GetPreProxy();
                        newRole.Name = preProxy.Encrypt(this.keyPair.Public, newRole.Name);

                        if (newRole.IsRoot)
                        {
                            newRole.Users.Add(this.myId);
                        }

                        proxy = GetServiceProxy();
                        proxy.CreateSubRole(this.myId, selectedRole.Id, newRole);

                        buttonRefreshRolesAndUsers_Click(this, EventArgs.Empty);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
                Logger.LogError("Error creating sub-role user", ex);
            }
        }
Exemple #3
0
        private void buttonUpdateSubRole_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.treeViewRoles.SelectedNode != null &&
                    this.treeViewRoles.SelectedNode.Tag is RoleDescription &&
                    this.treeViewRoles.SelectedNode.Parent != null)
                {
                    RoleDescription selectedRole = (RoleDescription)this.treeViewRoles.SelectedNode.Tag;

                    RoleDescription parentRole = (RoleDescription) this.treeViewRoles.SelectedNode.Parent.Tag;

                    CustomizeRoleDialog dialog = new CustomizeRoleDialog(selectedRole, "Update the role " + selectedRole.Name.GetString());
                    DialogResult result = dialog.ShowDialog();

                    if (result == DialogResult.OK)
                    {
                        IPreService preProxy = GetPreProxy();
                        dialog.Role.Name = preProxy.Encrypt(this.keyPair.Public, dialog.Role.Name);

                        IGatewayService proxy = GetServiceProxy();
                        proxy.UpdateSubRole(this.myId, parentRole.Id, dialog.Role);

                        buttonRefreshRolesAndUsers_Click(this, EventArgs.Empty);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
                Logger.LogError("Error updating sub-role user", ex);
            }
        }
Exemple #4
0
        private void buttonCreateSubRole_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.treeViewRoles.SelectedNode != null &&
                    this.treeViewRoles.SelectedNode.Tag is RoleDescription)
                {
                    RoleDescription selectedRole = (RoleDescription)this.treeViewRoles.SelectedNode.Tag;

                    IGatewayService proxy = GetServiceProxy();
                    IList<DataEntity> dataEntities = proxy.GetDataEntitiesForRole(this.myId, selectedRole.Id);

                    DecryptDataEntities(dataEntities);

                    CustomizeRoleDialog dialog = new CustomizeRoleDialog("Create new subrole from " + selectedRole.Name.GetString());
                    dialog.SetDataEntities(dataEntities);

                    DialogResult result = dialog.ShowDialog();

                    if (result == DialogResult.OK)
                    {
                        Role newRole = dialog.Role;
                        newRole.Id = Guid.NewGuid();

                        IPreService preProxy = GetPreProxy();
                        newRole.Name = preProxy.Encrypt(this.keyPair.Public, newRole.Name);

                        if (newRole.IsRoot)
                        {
                            newRole.Users.Add(this.myId);
                        }

                        proxy = GetServiceProxy();
                        proxy.CreateSubRole(this.myId, selectedRole.Id, newRole);

                        buttonRefreshRolesAndUsers_Click(this, EventArgs.Empty);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
                Logger.LogError("Error creating sub-role user", ex);
            }
        }