示例#1
0
            private void ProcessReleaseDayGroup(UnapprovedUpdate update, PerGroupInformation group)
            {
                // Calculate the date this update can be approved
                group.Approvable = update.ArrivalDate.Add(group.GroupRule.updateinterval);

                // Process child groups
                foreach (PerGroupInformation gi in update.Groups)
                {
                    if (gi.GroupRule.parentcomputergroup != null && gi.GroupRule.parentcomputergroup.Id == group.Group.Id)
                    {
                        // Found child - process this group
                        ProcessChildGroup(update, group, gi);
                    }
                }
            }
示例#2
0
 private void ProcessChildGroup(UnapprovedUpdate update, PerGroupInformation parent, PerGroupInformation group)
 {
     // Has parent been approved?
     if (parent.Approved.HasValue)
     {
         // Yes - Update to be approved at parent.Approved + group.updateinterval
         group.Approvable = parent.Approved.Value.Add(group.GroupRule.updateinterval);
     }
     else
     // No.  Is parent approvable at all?
     if (!parent.Approvable.HasValue)
     {
         // Parent not approvable, therefore child not approvable
         group.Approvable = null;
     }
     else
     // Yes - do any parent PCs require the update?
     if (parent.PCs.HasValue && parent.PCs > 0)
     {
         // Yes - this update may not be approved until it is approved for the parent group
         group.Approvable = null;
     }
     else
     {
         // No - update to be approved at parent.Approvable + group.childupdateinterval
         group.Approvable = parent.Approvable.Value.Add(group.GroupRule.childupdateinterval);
     }
     // Recursively process child groups
     foreach (PerGroupInformation gi in update.Groups)
     {
         if (gi.GroupRule.parentcomputergroup != null && gi.GroupRule.parentcomputergroup.Id == group.Group.Id)
         {
             // Found child - process this group
             ProcessChildGroup(update, group, gi);
         }
     }
 }
示例#3
0
            // Locate item by GUID
            public PerGroupInformation this[Guid groupid]
            {
                get
                {
                    // Loop through each item, looking for a group that matches
                    foreach (PerGroupInformation gi in this.List)
                    {
                        if (gi.Group.Id == groupid)
                        {
                            // Got one - return it
                            return(gi);
                        }
                    }

                    // Couldn't find one - return null
                    return(null);
                }

                set
                {
                    // Loop through each item, looking for a group that matches
                    for (int i = 0; i < this.List.Count; i++)
                    {
                        PerGroupInformation gi = (PerGroupInformation)this.List[i];

                        if (gi.Group.Id == groupid)
                        {
                            gi = value;
                            return;
                        }
                    }

                    // Couldn't find a group - throw an exception
                    throw new ArgumentException("Computer group ID " + groupid + " could not be found.");
                }
            }
示例#4
0
            void wrkUpdate_DoWork(object sender, DoWorkEventArgs e)
            {
                // Get list of unapproved updates
                DataTable uudt = cfg.wsus.GetUnapprovedUpdatesNew();

                // Empty collection and start populating based on results
                this.List.Clear();

                foreach (DataRow r in uudt.Rows)
                {
                    // Do we already know about this update?
                    UnapprovedUpdate uu = this[r["updateid"].ToString()];

                    if (uu == null)
                    {
                        // No we don't - add it.
                        uu = this.Add(r["updateid"].ToString(), r["defaulttitle"].ToString(), r["defaultdescription"].ToString(), r["knowledgebasearticle"].ToString(), (DateTime)r["arrivaldate"]);
                    }

                    // Find the group that this row refers to
                    PerGroupInformation gi = uu.Groups[r["pcgroup"].ToString()];

                    if (gi != null)
                    {
                        // Update the number of PCs requiring this update (null if none)
                        if (r["PCs"] == null || r["PCs"].ToString() == "")
                        {
                            gi.PCs = null;
                        }
                        else
                        {
                            gi.PCs = int.Parse(r["PCs"].ToString());
                        }

                        // Update the date this update was approved (null or empty if it hasn't)
                        if (r["approvaldate"] == null || r["approvaldate"].ToString() == "")
                        {
                            gi.Approved = null;
                        }
                        else
                        {
                            gi.Approved = DateTime.Parse(r["approvaldate"].ToString());
                        }
                    }
                }

                // Now that we have a full collection of results, find each child of "release day" and process it, followed by any children
                foreach (UnapprovedUpdate uu in this.List)
                {
                    // Loop through each group
                    foreach (PerGroupInformation gi in uu.Groups)
                    {
                        // Is this a child of "release day"?
                        if (gi.GroupRule.parentcomputergroup == null)
                        {
                            // Yes - process this rule and it's children
                            ProcessReleaseDayGroup(uu, gi);
                        }
                    }
                }
            }
示例#5
0
            private void ProcessReleaseDayGroup(UnapprovedUpdate update, PerGroupInformation group)
            {
                // Calculate the date this update can be approved
                group.Approvable = update.ArrivalDate.Add(group.GroupRule.updateinterval);

                // Process child groups
                foreach (PerGroupInformation gi in update.Groups)
                {
                    if (gi.GroupRule.parentcomputergroup != null && gi.GroupRule.parentcomputergroup.Id == group.Group.Id)
                        // Found child - process this group
                        ProcessChildGroup(update, group, gi);
                }
            }
示例#6
0
 private void ProcessChildGroup(UnapprovedUpdate update, PerGroupInformation parent, PerGroupInformation group)
 {
     // Has parent been approved?
     if (parent.Approved.HasValue)
         // Yes - Update to be approved at parent.Approved + group.updateinterval
         group.Approvable = parent.Approved.Value.Add(group.GroupRule.updateinterval);
     else
         // No.  Is parent approvable at all?
         if (!parent.Approvable.HasValue)
             // Parent not approvable, therefore child not approvable
             group.Approvable = null;
         else
             // Yes - do any parent PCs require the update?
             if (parent.PCs.HasValue && parent.PCs > 0)
                 // Yes - this update may not be approved until it is approved for the parent group
                 group.Approvable = null;
             else
                 // No - update to be approved at parent.Approvable + group.childupdateinterval
                 group.Approvable = parent.Approvable.Value.Add(group.GroupRule.childupdateinterval);
     // Recursively process child groups
     foreach (PerGroupInformation gi in update.Groups)
     {
         if (gi.GroupRule.parentcomputergroup != null && gi.GroupRule.parentcomputergroup.Id == group.Group.Id)
             // Found child - process this group
             ProcessChildGroup(update, group, gi);
     }
 }