Beispiel #1
0
        private void LoadRolesAndPrivs()
        {
            lvPrivileges.Items.Clear();
            lvSelectedPrivileges.Items.Clear();
            lvRoles.Items.Clear();

            WorkAsync(new WorkAsyncInfo
            {
                Message       = "Retrieving roles...",
                AsyncArgument = null,
                Work          = (bw, e) =>
                {
                    var rManager = new RolesManager(Service);
                    roles        = rManager.GetRoles();

                    bw.ReportProgress(0, "Retrieving privileges...");

                    privileges = rManager.GetPrivileges();

                    bw.ReportProgress(0, "Retrieving entities privileges...");

                    var mdManager = new MetadataManager(Service);
                    entities      = mdManager.GetEntitiesWithPrivileges();
                },
                PostWorkCallBack = e =>
                {
                    if (e.Error != null)
                    {
                        MessageBox.Show(this, "An error occured: " + e.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        fillPrivThread = new Thread(DoWork);
                        fillPrivThread.Start();
                    }

                    txtSearch.Enabled = true;
                },
                ProgressChanged = e => { SetWorkingMessage(e.UserState.ToString()); }
            });
        }