コード例 #1
0
ファイル: frmMain.cs プロジェクト: rjch-au/WSUSAdminAssistant
        private void EndpointUpdateUngroupedComputers()
        {
            if (CheckDBConnection())
            {
                // Update the data grid
                DataTable d = wsus.GetUnassignedComputers();

                foreach (DataRow dr in d.Rows)
                {
                    epRowData r = new epRowData("Not Assigned to a Group");

                    r.EndpointName = dr["name"];
                    r.ipAddress = dr["ipaddress"];
                    r.SetUpstreamServerByGuid(dr["parentserverid"], cfg.wsus.server);

                    AddUpdateEndpointGrid(r);
                }
            }
        }
コード例 #2
0
ファイル: frmMain.cs プロジェクト: rjch-au/WSUSAdminAssistant
        private void AddUpdateEndpointGrid(epRowData row)
        {
            // Locate an existing matching row
            int rn = -1;

            foreach (DataGridViewRow dgr in grdEndpoints.Rows)
            {
                if (dgr.Cells[epName.Index].Value.ToString() == row.EndpointName.ToString() && dgr.Cells[epFault.Index].Value.ToString() == row.Fault)
                {
                    rn = dgr.Index;
                    break;
                }

            }

            // If no row is located, create a new one
            if (rn == -1) rn = grdEndpoints.Rows.Add();

            DataGridViewRow r = grdEndpoints.Rows[rn];

            // Fill in data grid
            r.Cells[epName.Index].Value = row.EndpointName;
            r.Cells[epIP.Index].Value = row.ipAddress;
            r.Cells[epLastStatus.Index].Value = row.LastStatus;
            r.Cells[epComputerGroup.Index].Value = row.ComputerGroup;
            r.Cells[epFault.Index].Value = row.Fault;
            r.Cells[epDownstreamServer.Index].Value = row.UpstreamServer;
            r.Cells[epExtraInfo.Index].Value = row.ExtraInfo;

            // Cleanly handle items with potentially no value
            if (row.LastContact > DateTime.MinValue) r.Cells[epLastContact.Index].Value = row.LastContact;
            if (row.ApprovedUpdates.HasValue) r.Cells[epApprovedUpdates.Index].Value = row.ApprovedUpdates;
            if (row.ErrorUpdates.HasValue) r.Cells[epUpdateErrors.Index].Value = row.ErrorUpdates;

            // Create sort index
            r.Cells[epSortOrder.Index].Value = row.ipAddress.ToString() + row.EndpointName.ToString();

            // Tag the row as updated
            r.Cells[epUpdate.Index].Value = "Y";
        }
コード例 #3
0
ファイル: frmMain.cs プロジェクト: rjch-au/WSUSAdminAssistant
        private void EndpointUpdateNotCommunicating()
        {
            // Get list of computers that hasn't updated in the last week
            ComputerTargetScope cs = new ComputerTargetScope();
            cs.ToLastSyncTime = DateTime.Now.AddDays(-7);
            cs.IncludeDownstreamComputerTargets = true;

            // Update grid
            foreach (IComputerTarget c in wsus.server.GetComputerTargets(cs))
            {
                epRowData r = new epRowData("Not Communicating", c);

                AddUpdateEndpointGrid(r);
            }
        }
コード例 #4
0
ファイル: frmMain.cs プロジェクト: rjch-au/WSUSAdminAssistant
        private void EndpointUpdateErrors()
        {
            if (CheckDBConnection())
            {
                // Update the data grid;
                DataTable t = wsus.GetUpdateErrors();

                foreach (DataRow d in t.Rows)
                {
                    // Fill in data grid
                    epRowData r = new epRowData("Updates With Errors");

                    r.EndpointName = d["fulldomainname"];
                    r.ipAddress = d["ipaddress"];
                    r.ErrorUpdates = int.Parse(d["updateerrors"].ToString());
                    r.LastContact = DateTime.Parse(d["lastsynctime"].ToString());
                    r.SetUpstreamServerByGuid(d["parentserverid"], cfg.wsus.server);

                    AddUpdateEndpointGrid(r);
                }
            }
        }
コード例 #5
0
ファイル: frmMain.cs プロジェクト: rjch-au/WSUSAdminAssistant
        private void EndpointUpdateDuplicateIPs()
        {
            //  Get a complete list of computers
            ComputerTargetScope cs = new ComputerTargetScope();
            cs.IncludeDownstreamComputerTargets = true;

            ComputerTargetCollection cc = wsus.server.GetComputerTargets(cs);

            // Assemble a dictionary for comparison
            Dictionary<String, String> ca = new Dictionary<String, String>();

            foreach (IComputerTarget c in cc)
            {
                ca.Add(c.Id.ToString(), c.IPAddress.ToString());
            }

            // Loop through all computers
            foreach (IComputerTarget c in cc)
            {
                string cn = c.Id.ToString();
                string ip = c.IPAddress.ToString();

                // See if we can find one with a duplicate IP address
                foreach (KeyValuePair<string,string> e in ca)
                {
                    // Do we have a different computer to the current one and does it have a duplicate IP address
                    if (cn != e.Key && ip == e.Value)
                    {
                        // Yep, it's a duplicate.
                        epRowData r = new epRowData("Duplicate IP address", c);

                        // Add it and break
                        AddUpdateEndpointGrid(r);
                        break;
                    }
                }
            }
        }
コード例 #6
0
ファイル: frmMain.cs プロジェクト: rjch-au/WSUSAdminAssistant
        private void EndpointUpdateApproved()
        {
            if (CheckDBConnection())
            {
                // Retreive the list of approved updates that have not yet been applied.
                DataTable t = wsus.GetApprovedUpdates();

                foreach (DataRow d in t.Rows)
                {
                    epRowData r = new epRowData("Uninstalled Approved Updates");

                    // Fill in data grid
                    r.EndpointName = d["fulldomainname"];
                    r.ipAddress = d["ipaddress"];
                    r.ApprovedUpdates = int.Parse(d["approvedupdates"].ToString());
                    r.LastContact = DateTime.Parse(d["lastsynctime"].ToString());
                    r.SetUpstreamServerByGuid(d["parentserverid"], cfg.wsus.server);

                    AddUpdateEndpointGrid(r);
                }
            }
        }
コード例 #7
0
ファイル: frmMain.cs プロジェクト: rjch-au/WSUSAdminAssistant
        private void EndpointIncorrectGroupUpdate()
        {
            // Get the group rules and sort by priority
            clsConfig.ComputerGroupRegexCollection rules = cfg.ComputerRegExList;
            rules.SortByPriority();

            if (CheckDBConnection())
            {
                // Update the data grid;
                DataTable t = wsus.GetComputerGroups();

                foreach (DataRow d in t.Rows)
                {
                    // Attempt to match the computer to a rule
                    clsConfig.ComputerGroupRegEx rx = rules.MatchPC(d["name"].ToString(), d["ipaddress"].ToString());

                    // Do we have a match?
                    if (rx != null)
                    {
                        // Yes - does it match the computer group we have?
                        if (d["groupname"].ToString() != rx.ComputerGroup)
                        {
                            // No - is it in a group we're supposed to be ignoring?
                            if (!cfg.IgnoreComputerGroupCollection.Values.ToArray().Contains(d["groupname"].ToString()))
                            {
                                // No - add it.
                                epRowData r = new epRowData("Incorrect Computer Group");

                                r.EndpointName = d["name"];
                                r.ipAddress = d["ipaddress"];
                                r.ComputerGroup = rx.ComputerGroup;
                                r.ExtraInfo = "Currently in " + d["groupname"].ToString();
                                r.SetUpstreamServerByGuid(d["parentserverid"], cfg.wsus.server);

                                AddUpdateEndpointGrid(r);
                            }
                        }
                    }
                }
            }
        }