internal void buildApplicationsTreeView()
 {
     if (this.applications != null && this.applications.Length > 0)
     {
         IAzManStorage storage = this.applications[0].Store.Storage;
         storage.OpenConnection();
         this.itemsHierarchyTreeView.Nodes.Clear();
         TreeNode root = new TreeNode("NetSqlAzMan", 0, 0);
         root.ToolTipText = ".NET Sql Authorization Manager";
         this.itemsHierarchyTreeView.Nodes.Add(root);
         TreeNode storeNode = new TreeNode(this.applications[0].Store.Name, 1, 1);
         root.Nodes.Add(storeNode);
         root.Expand();
         storeNode.Expand();
         /*Application.DoEvents();*/
         storeNode.ToolTipText  = this.applications[0].Store.Description;
         this.pb.Value          = 0;
         this.pb.Minimum        = 0;
         this.pb.Maximum        = this.applications.Length - 1;
         this.pb.Visible        = true;
         this.lblStatus.Visible = true;
         for (int i = 0; i < this.applications.Length; i++)
         {
             if (this.closeRequest)
             {
                 return;
             }
             this.pb.Value = i;
             /*Application.DoEvents();*/
             this.add(storeNode, this.applications[i]);
             storeNode.Expand();
             /*Application.DoEvents();*/
         }
         storage.CloseConnection();
         root.ExpandAll();
         this.pb.Visible        = false;
         this.lblStatus.Visible = false;
     }
 }
Пример #2
0
        private void SaveRecord()
        {
            try
            {
                _Storage.OpenConnection();
                _Storage.BeginTransaction(AzManIsolationLevel.ReadUncommitted);

                #region  Managers
                KeyValuePair <string, bool>[] managers = _Store.GetManagers();
                foreach (CheckBox sqlLogin in flpManagers.Controls)
                {
                    if (sqlLogin.Checked)
                    {
                        if (!FindLogin(managers, sqlLogin.Text))
                        {
                            _Store.GrantAccessAsManager(sqlLogin.Text);
                        }
                    }
                    else
                    {
                        if (FindLogin(managers, sqlLogin.Text))
                        {
                            _Store.RevokeAccessAsManager(sqlLogin.Text);
                        }
                    }
                }
                #endregion

                #region Users
                KeyValuePair <string, bool>[] users = _Store.GetUsers();
                foreach (CheckBox sqlLogin in flpUsers.Controls)
                {
                    if (sqlLogin.Checked)
                    {
                        if (!FindLogin(users, sqlLogin.Text))
                        {
                            _Store.GrantAccessAsUser(sqlLogin.Text);
                        }
                    }
                    else
                    {
                        if (FindLogin(users, sqlLogin.Text))
                        {
                            _Store.RevokeAccessAsUser(sqlLogin.Text);
                        }
                    }
                }
                #endregion

                #region Readers
                KeyValuePair <string, bool>[] readers = _Store.GetReaders();
                foreach (CheckBox sqlLogin in flpReaders.Controls)
                {
                    if (sqlLogin.Checked)
                    {
                        if (!FindLogin(readers, sqlLogin.Text))
                        {
                            _Store.GrantAccessAsReader(sqlLogin.Text);
                        }
                    }
                    else
                    {
                        if (FindLogin(readers, sqlLogin.Text))
                        {
                            _Store.RevokeAccessAsReader(sqlLogin.Text);
                        }
                    }
                }
                #endregion

                _Storage.CommitTransaction();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                _Storage.CloseConnection();
            }
            _Dirty = true;
        }