Beispiel #1
0
        private void grdvUsers_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                UsersSource.UsersRow editedRow;


                if (e.RowIndex < 0 || e.ColumnIndex < 0)
                {
                    return;
                }

                editedRow     = (UsersSource.UsersRow)(( DataRowView )UsersBindingSource [e.RowIndex]).Row;
                _SelectedUser = UsersDataGridView.Rows[e.RowIndex].Cells[UserNameDataGridViewTextBoxColumn.Index].Value.ToString();

                if (e.ColumnIndex == NewPasswordDataGridViewButtonColumn.Index)
                {
                    PasswordRequestEventArgs ea = new PasswordRequestEventArgs();

                    PasswordRequest(this, ea);
                    if (!ea.Cancel)
                    {
                        UsersDataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = ea.Password;
                        if (ea.Expires.HasValue)
                        {
                            UsersDataGridView.Rows[e.RowIndex].Cells[ExpiresColumn.Index].Value = ea.Expires;
                        }
                        else
                        {
                            UsersDataGridView.Rows[e.RowIndex].Cells[ExpiresColumn.Index].Value = DBNull.Value;
                        }
                        UsersBindingSource.EndEdit();
                    }
                }
                else if (e.ColumnIndex == Permissions.Index)
                {
                    EditUserPermissionsEventArgs     ea          = new EditUserPermissionsEventArgs(_SelectedUser);
                    UsersSource.UserPermissionsRow[] permissions = (from p in Source.UserPermissions
                                                                    where p.RowState != DataRowState.Deleted && p.UserName == _SelectedUser
                                                                    select p).ToArray();

                    foreach (UsersSource.UserPermissionsRow permission in permissions)
                    {
                        ea.Permissions.Add(permission.Permission);
                    }
                    EditUserPermissions(this, ea);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(this, exception.Message, "User Access", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
        void UsersAccounts_EditUserPermissions(object sender, EditUserPermissionsEventArgs e)
        {
            PermissionsDialog permissionDialog         = new PermissionsDialog();
            IPermissionManagementDataAccessAgent agent = DataAccessFactory.GetInstance(new PermissionManagementDataAccessConfigurationView(DicomDemoSettingsManager.GetGlobalPacsConfiguration(), DicomDemoSettingsManager.ProductNameStorageServer, null)).CreateDataAccessAgent <IPermissionManagementDataAccessAgent>();

            Permission[] permissions = agent.GetPermissions();

            permissionDialog.Username = e.Username;
            permissionDialog.SetPermissions(permissions, e.Permissions);
            permissionDialog.SetRoles(RoleManager.GetAllRoles(), RoleManager.GetUserRoles(e.Username));
            if (permissionDialog.ShowDialog() == DialogResult.OK)
            {
                View.UsersAccounts.SetUserPermissions(permissionDialog.SelectedPermissions);
                RoleManager.SetUserRoles(e.Username, permissionDialog.Roles);
                View_SettingsChanged(sender, e);
            }
        }