private void btnRemove_Click(object sender, EventArgs e)
        {
            // Get current group rule
            clsConfig.GroupUpdateRule ur = (clsConfig.GroupUpdateRule)trvGroupRules.SelectedNode.Tag;

            grouprules.Remove(ur.computergroup.Name);
        }
        private void btnEdit_Click(object sender, EventArgs e)
        {
            // Get current group rule
            clsConfig.GroupUpdateRule ur = (clsConfig.GroupUpdateRule)trvGroupRules.SelectedNode.Tag;

            // Copy the information to the form
            numDisplayOrder.Value = ur.displayorder;
            numSortWeight.Value   = (decimal)ur.sortweight;

            cboComputerGroup.Text = ur.computergroup.Name;
            txtShortName.Text     = ur.shortname;

            // If we're dealing with a null parent, we only need set the parent computer group.  If not, we've got more information to load...
            if (ur.parentcomputergroup == null)
            {
                cboParentGroup.Text = root.Text;
            }
            else
            {
                cboParentGroup.Text = ur.parentcomputergroup.Name;
                TimeSpanToForm(ur.childupdateinterval, numNoApprovalInterval, cboNoApprovalInterval);
            }

            TimeSpanToForm(ur.updateinterval, numParentInterval, cboParentInterval);

            cboComputerGroup.Enabled = false;
            btnEdit.Enabled          = false;
            btnRemove.Enabled        = false;
        }
        private void trvGroupRules_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (trvGroupRules.SelectedNode == null || trvGroupRules.SelectedNode == root)
            {
                // Either the root item or no item is selected, therefore can't remove or edit anything
                btnEdit.Enabled   = false;
                btnRemove.Enabled = false;
            }
            else
            {
                // Editing is available
                btnEdit.Enabled = true;

                // Are there any children of this node?
                clsConfig.GroupUpdateRule o = (clsConfig.GroupUpdateRule)trvGroupRules.SelectedNode.Tag;

                if (grouprules.ChildGroups(o).Count > 0)
                {
                    // Yes, you can't delete this rule
                    btnRemove.Enabled = false;
                }
                else
                {
                    // No, you can delete the rule
                    btnRemove.Enabled = true;
                }
            }
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            // Try to convert to a group update rule object
            clsConfig.GroupUpdateRule ur = new clsConfig.GroupUpdateRule(wsus);

            ur.displayorder = (int)numDisplayOrder.Value;
            ur.sortweight   = (int)numSortWeight.Value;

            ur.computergroup = FindComputerGroup(cboComputerGroup.Text);
            ur.shortname     = txtShortName.Text;

            // Parent group and intervals should be handled differently depending on whether the parent is the root or not
            if (cboParentGroup.Text == root.Text)
            {
                // This is the root node.  Null parent group, only the first interval is relevant
                ur.parentcomputergroup = null;
                ur.updateinterval      = ToTimeSpan((int)numParentInterval.Value, cboParentInterval.Text);
            }
            else
            {
                // Parent is another computer group.  Set it and both intervals are relevant
                ur.parentcomputergroup = FindComputerGroup(cboParentGroup.Text);
                ur.updateinterval      = ToTimeSpan((int)numParentInterval.Value, cboParentInterval.Text);
                ur.childupdateinterval = ToTimeSpan((int)numNoApprovalInterval.Value, cboNoApprovalInterval.Text);
            }

            // Add or update the group rule
            grouprules.AddEdit(ur);

            // Update the treeview and reset the form
            UpdateGroupUpdateRules();

            numDisplayOrder.Value = grouprules.MaxDisplayOrder + 1;
            numSortWeight.Value   = 0;

            cboComputerGroup.Enabled = true;
            cboComputerGroup.Text    = "";
            txtShortName.Text        = "";
            cboParentGroup.Text      = "";

            numParentInterval.Value = 1;
            cboParentInterval.Text  = "";

            numNoApprovalInterval.Value = 1;
            cboNoApprovalInterval.Text  = "";

            btnAdd.Enabled = false;
        }
        private void cboComputerGroup_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Clear parent group textbox and repopulate
            cboParentGroup.Items.Clear();

            foreach (string g in groupnames)
            {
                // Loop through rule collection and see if the current group is already there
                foreach (clsConfig.GroupUpdateRule ur in grouprules)
                {
                    if (ur.computergroup.Name == g)
                    {
                        // Found current computer in existing rules, but are we editing or adding a group?
                        if (cboComputerGroup.Enabled)
                        {
                            // We're adding - add it to the list
                            cboParentGroup.Items.Add(g);
                            break;
                        }
                        else
                        {
                            // We're editing - only add it to the list if the group isn't a child
                            clsConfig.GroupUpdateRule pr = grouprules[cboComputerGroup.Text];
                            if (!grouprules.ChildGroups(pr, true).Contains(g))
                            {
                                // Not in list, ok to add
                                cboParentGroup.Items.Add(g);
                            }
                        }
                    }
                }
            }

            // Add the Release Day "group"
            cboParentGroup.Items.Insert(0, "Release Day");

            // Validate input
            ValidateInput();
        }
Beispiel #6
0
 public PerGroupInformation(clsConfig.GroupUpdateRule updaterule)
 {
     _grouprule = updaterule;
 }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            // Try to convert to a group update rule object
            clsConfig.GroupUpdateRule ur = new clsConfig.GroupUpdateRule(wsus);

            ur.displayorder = (int)numDisplayOrder.Value;
            ur.sortweight = (int)numSortWeight.Value;

            ur.computergroup = FindComputerGroup(cboComputerGroup.Text);
            ur.shortname = txtShortName.Text;

            // Parent group and intervals should be handled differently depending on whether the parent is the root or not
            if (cboParentGroup.Text == root.Text)
            {
                // This is the root node.  Null parent group, only the first interval is relevant
                ur.parentcomputergroup = null;
                ur.updateinterval = ToTimeSpan((int)numParentInterval.Value, cboParentInterval.Text);
            }
            else
            {
                // Parent is another computer group.  Set it and both intervals are relevant
                ur.parentcomputergroup = FindComputerGroup(cboParentGroup.Text);
                ur.updateinterval = ToTimeSpan((int)numParentInterval.Value, cboParentInterval.Text);
                ur.childupdateinterval = ToTimeSpan((int)numNoApprovalInterval.Value, cboNoApprovalInterval.Text);
            }

            // Add or update the group rule
            grouprules.AddEdit(ur);

            // Update the treeview and reset the form
            UpdateGroupUpdateRules();

            numDisplayOrder.Value = grouprules.MaxDisplayOrder + 1;
            numSortWeight.Value = 0;

            cboComputerGroup.Enabled = true;
            cboComputerGroup.Text = "";
            txtShortName.Text = "";
            cboParentGroup.Text = "";

            numParentInterval.Value = 1;
            cboParentInterval.Text = "";

            numNoApprovalInterval.Value = 1;
            cboNoApprovalInterval.Text = "";

            btnAdd.Enabled = false;
        }
Beispiel #8
0
 public PerGroupInformation(clsConfig.GroupUpdateRule updaterule)
 {
     _grouprule = updaterule;
 }