/// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="group">Owner group.</param>
        internal GroupMemberCollection(Group group)
        {
            m_pGroup   = group;
            m_pMembers = new List<string>();

            Bind();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Edit constructor.
        /// </summary>
        /// <param name="virtualServer">Virtual server.</param>
        /// <param name="group">Group to update.</param>
        public wfrm_UsersAndGroups_Group(VirtualServer virtualServer,Group group)
        {
            m_pVirtualServer = virtualServer;
            m_pGroup         = group;      

            InitUI();

            m_pTab_General_Name.Text = group.GroupName;
            m_pTab_General_Description.Text = group.Description;
            m_pTab_General_Enabled.Checked = group.Enabled;

            LoadMembers();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Deletes and removes specified group from group collection.
        /// </summary>
        /// <param name="group">Group to delete.</param>
        public void Remove(Group group)
        {
            /* DeleteGroup <virtualServerID> "<groupID>"
                  Responses:
                    +OK                     
                    -ERR <errorText>
            */

            string id = Guid.NewGuid().ToString();

            // Call TCP DeleteGroup
            m_pVirtualServer.Server.TcpClient.TcpStream.WriteLine("DeleteGroup " + m_pVirtualServer.VirtualServerID + " " + TextUtils.QuoteString(group.GroupID));
                        
            string response = m_pVirtualServer.Server.ReadLine();
            if(!response.ToUpper().StartsWith("+OK")){
                throw new Exception(response);
            }

            m_pGroups.Remove(group);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates and adds new group to group collection.
        /// </summary>
        /// <param name="name">Group name.</param>
        /// <param name="description">Group description.</param>
        /// <param name="enabled">Specifies if group is enabled.</param>
        /// <returns></returns>
        public Group Add(string name,string description,bool enabled)
        {
            /* AddGroup <virtualServerID> "<groupID>" "<groupName>" "<description>" <enabled>
                  Responses:
                    +OK                     
                    -ERR <errorText>
            */

            string id = Guid.NewGuid().ToString();

            // Call TCP AddGroup
            m_pVirtualServer.Server.TcpClient.TcpStream.WriteLine("AddGroup " + m_pVirtualServer.VirtualServerID + " " + TextUtils.QuoteString(id) + " " + TextUtils.QuoteString(name) + " " + TextUtils.QuoteString(description) + " " + enabled);
                        
            string response = m_pVirtualServer.Server.ReadLine();
            if(!response.ToUpper().StartsWith("+OK")){
                throw new Exception(response);
            }

            Group group = new Group(m_pVirtualServer,this,id,name,description,enabled);
            m_pGroups.Add(group);
            return group;
        }
Ejemplo n.º 5
0
        private void m_pOk_Click(object sender, EventArgs e)
        {
            //--- Validate values ---------------------------//
            if(m_pTab_General_Name.Text == ""){
                MessageBox.Show(this,"Please fill Group name !","Error:",MessageBoxButtons.OK,MessageBoxIcon.Error);
                return;
            }
            //----------------------------------------------//

            // Add new group
            if(m_pGroup == null){
                m_pGroup = m_pVirtualServer.Groups.Add(m_pTab_General_Name.Text,m_pTab_General_Description.Text,m_pTab_General_Enabled.Checked);
            }
            // Update group
            else{
                m_pGroup.GroupName   = m_pTab_General_Name.Text;
                m_pGroup.Description = m_pTab_General_Description.Text;
                m_pGroup.Enabled     = m_pTab_General_Enabled.Checked; 
                m_pGroup.Commit();
            }

            this.DialogResult = DialogResult.OK;
        }
Ejemplo n.º 6
0
        private void m_pTab_General_Toolbar_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if(e.ClickedItem.Tag == null){
                return;
            }

            if(e.ClickedItem.Tag.ToString() == "add"){
                //--- Validate values ---------------------------//
                if(m_pTab_General_Name.Text == ""){
                    MessageBox.Show(this,"Please fill Group name !","Error:",MessageBoxButtons.OK,MessageBoxIcon.Error);
                    return;
                }
                //----------------------------------------------//

                // This is new not yet added group, add it
                if(m_pGroup == null){
                    m_pGroup = m_pVirtualServer.Groups.Add(m_pTab_General_Name.Text,m_pTab_General_Description.Text,m_pTab_General_Enabled.Checked);
                }

                //--- Exclude existing members + group itself ---//
                List<string> excludeList = new List<string>();
                excludeList.Add(m_pTab_General_Name.Text.ToLower());
                foreach(ListViewItem it in m_pTab_General_GroupMembers.Items){
                    excludeList.Add(it.Text.ToLower());
                }
                //-----------------------------------------------//

                wfrm_se_UserOrGroup frm = new wfrm_se_UserOrGroup(m_pVirtualServer,true,false,excludeList);
                if(frm.ShowDialog(this) == DialogResult.OK){
                    m_pGroup.Members.Add(frm.SelectedUserOrGroup);

                    m_pTab_General_GroupMembers.SelectedItems.Clear();
                    ListViewItem it = new ListViewItem(frm.SelectedUserOrGroup);
                    it.Selected = true;
                    // Member is group
                    if(m_pVirtualServer.Groups.Contains(frm.SelectedUserOrGroup)){
                        it.ImageIndex = 0;
                    }
                    // Member is user
                    else{
                        it.ImageIndex = 1;
                    }
                    m_pTab_General_GroupMembers.Items.Add(it);
                }
            }
            else if(e.ClickedItem.Tag.ToString() == "delete"){
                m_pGroup.Members.Remove(m_pTab_General_GroupMembers.SelectedItems[0].Text);
                m_pTab_General_GroupMembers.SelectedItems[0].Remove();
            }
        }