Esempio n. 1
0
        private void btnEditServer_Click(object sender, EventArgs e)
        {
            Logger.EnteringMethod();
            if (cmbBxServerList.SelectedItem != null)
            {
                WsusServer serverToEdit = (WsusServer)cmbBxServerList.SelectedItem;
                int        port         = 443;
                if (cmbBxConnectionPort.SelectedItem != null)
                {
                    if (int.TryParse(cmbBxConnectionPort.SelectedItem.ToString(), out port))
                    {
                        serverToEdit.Port = port;
                    }
                }
                else if (!string.IsNullOrEmpty(cmbBxConnectionPort.Text))
                {
                    if (int.TryParse(cmbBxConnectionPort.Text, out port))
                    {
                        serverToEdit.Port = port;
                    }
                }

                serverToEdit.IsLocal = chkBxConnectToLocalServer.Checked;
                serverToEdit.UseSSL  = chkBxUseSSL.Checked;
                serverToEdit.IgnoreCertificateErrors = chkBxIgnoreCertificateErrors.Checked;
                serverToEdit.DeadLineDaysSpan        = (int)nupDeadLineDaysSpan.Value;
                serverToEdit.DeadLineHour            = (int)nupDeadLineHour.Value;
                serverToEdit.DeadLineMinute          = (int)nupDeadLineMinute.Value;
                if (rdBtnVisibleAlways.Checked)
                {
                    serverToEdit.VisibleInWsusConsole = MakeVisibleInWsusPolicy.Always;
                }
                if (rdBtnVisibleChoose.Checked)
                {
                    serverToEdit.VisibleInWsusConsole = MakeVisibleInWsusPolicy.LetMeChoose;
                }
                if (rdBtnVisibleNever.Checked)
                {
                    serverToEdit.VisibleInWsusConsole = MakeVisibleInWsusPolicy.Never;
                }

                ServerList.Clear();
                foreach (object obj in cmbBxServerList.Items)
                {
                    WsusServer server = (WsusServer)obj;
                    ServerList.Add(server);
                }
                cmbBxServerList.Items.Clear();
                cmbBxServerList.Items.AddRange(ServerList.ToArray());
                cmbBxServerList.SelectedItem = serverToEdit;
            }
        }
Esempio n. 2
0
 private void btnRemoveServer_Click(object sender, EventArgs e)
 {
     Logger.EnteringMethod();
     if (cmbBxServerList.SelectedItem != null)
     {
         WsusServer serverToRemove = (WsusServer)cmbBxServerList.SelectedItem;
         if (ServerList.Contains(serverToRemove))
         {
             Logger.Write("Remove server : " + serverToRemove.Name);
             ServerList.Remove(serverToRemove);
             cmbBxServerList.Items.Remove(serverToRemove);
             if (cmbBxServerList.Items.Count != 0)
             {
                 cmbBxServerList.SelectedIndex = 0;
             }
             ValidateData();
         }
     }
 }
Esempio n. 3
0
        private void SaveMetaGroup(System.Xml.XmlDocument xmlDoc, WsusServer server, System.Xml.XmlElement serverElement)
        {
            Logger.EnteringMethod(serverElement.ToString());
            foreach (MetaGroup metaGroup in server.MetaGroups)
            {
                Logger.Write(metaGroup.Name);
                System.Xml.XmlElement metaGroupElement = xmlDoc.CreateElement("MetaGroup");
                metaGroupElement.AppendChild(xmlDoc.CreateElement("Name")).InnerText = metaGroup.Name;
                foreach (MetaGroup innerMetaGroup in metaGroup.InnerMetaGroups)
                {
                    metaGroupElement.AppendChild(xmlDoc.CreateElement("InnerMetaGroup")).InnerText = innerMetaGroup.Name;
                }
                foreach (ComputerGroup innerComputerGroup in metaGroup.InnerComputerGroups)
                {
                    metaGroupElement.AppendChild(xmlDoc.CreateElement("InnerComputerGroup")).InnerText = innerComputerGroup.Name;
                }

                serverElement.AppendChild(metaGroupElement);
            }
        }
Esempio n. 4
0
        private void cmbBxServerList_SelectedIndexChanged(object sender, EventArgs e)
        {
            Logger.EnteringMethod();
            Logger.Write(cmbBxServerList);
            btnRemoveServer.Enabled = !string.IsNullOrEmpty(cmbBxServerList.SelectedItem.ToString());

            if (cmbBxServerList.SelectedItem != null)
            {
                WsusServer serverWsus = (WsusServer)cmbBxServerList.SelectedItem;
                txtBxServerName.Text = serverWsus.Name;
                chkBxConnectToLocalServer.Checked = serverWsus.IsLocal;
                if (!cmbBxConnectionPort.Items.Contains(serverWsus.Port.ToString()))
                {
                    cmbBxConnectionPort.Items.Add(serverWsus.Port.ToString());
                }
                cmbBxConnectionPort.SelectedItem = serverWsus.Port.ToString();
                chkBxUseSSL.Checked = serverWsus.UseSSL;
                chkBxIgnoreCertificateErrors.Checked = serverWsus.IgnoreCertificateErrors;
                nupDeadLineDaysSpan.Value            = serverWsus.DeadLineDaysSpan;
                nupDeadLineHour.Value   = serverWsus.DeadLineHour;
                nupDeadLineMinute.Value = serverWsus.DeadLineMinute;
                switch (serverWsus.VisibleInWsusConsole)
                {
                case MakeVisibleInWsusPolicy.Never:
                    rdBtnVisibleNever.Checked = true;
                    break;

                case MakeVisibleInWsusPolicy.LetMeChoose:
                    rdBtnVisibleChoose.Checked = true;
                    break;

                case MakeVisibleInWsusPolicy.Always:
                    rdBtnVisibleAlways.Checked = true;
                    break;

                default:
                    break;
                }
            }
        }
Esempio n. 5
0
        private void btnAddServer_Click(object sender, EventArgs e)
        {
            Logger.EnteringMethod();
            int port = 443;

            if (!chkBxConnectToLocalServer.Checked)
            {
                if (cmbBxConnectionPort.SelectedItem != null)
                {
                    int.TryParse(cmbBxConnectionPort.SelectedItem.ToString(), out port);
                }
                else if (!string.IsNullOrEmpty(cmbBxConnectionPort.Text))
                {
                    int.TryParse(cmbBxConnectionPort.Text, out port);
                }
            }
            WsusServer serverToAdd = new WsusServer(txtBxServerName.Text, chkBxConnectToLocalServer.Checked, port, chkBxUseSSL.Checked, (int)nupDeadLineDaysSpan.Value, (int)nupDeadLineHour.Value, (int)nupDeadLineMinute.Value);

            cmbBxServerList.Items.Add(serverToAdd);
            cmbBxServerList.SelectedIndex = cmbBxServerList.Items.Count - 1;
            Logger.Write("Adding server : " + serverToAdd.Name);
            ServerList.Add(serverToAdd);
            ValidateData();
        }
Esempio n. 6
0
        internal List <WsusServer> LoadServerSettings()
        {
            Logger.EnteringMethod();
            ServerList.Clear();
            cmbBxServerList.Items.Clear();

            if (System.IO.File.Exists("Options.xml"))
            {
                System.Xml.XmlDocument document = new System.Xml.XmlDocument();
                document.Load("Options.xml");
                System.Xml.XmlNodeList nodeList = document.GetElementsByTagName("Server");
                foreach (System.Xml.XmlNode node in nodeList)
                {
                    if (node.HasChildNodes)
                    {
                        WsusServer serverWsus = new WsusServer();
                        foreach (System.Xml.XmlNode childNode in node.ChildNodes)
                        {
                            switch (childNode.Name)
                            {
                            case "Name":
                                serverWsus.Name = childNode.InnerText;
                                Logger.Write("Name : " + serverWsus.Name);
                                break;

                            case "IsLocal":
                                bool isLocal;
                                if (bool.TryParse(childNode.InnerText, out isLocal))
                                {
                                    serverWsus.IsLocal = isLocal;
                                    Logger.Write("IsLocal : " + serverWsus.IsLocal.ToString());
                                }
                                break;

                            case "Port":
                                int port;
                                if (int.TryParse(childNode.InnerText, out port))
                                {
                                    serverWsus.Port = port;
                                    Logger.Write("Port : " + serverWsus.Port.ToString());
                                }
                                break;

                            case "UseSSL":
                                bool useSSL;
                                if (bool.TryParse(childNode.InnerText, out useSSL))
                                {
                                    serverWsus.UseSSL = useSSL;
                                    Logger.Write("UseSSL : " + serverWsus.UseSSL.ToString());
                                }
                                break;

                            case "IgnoreCertErrors":
                                bool ignoreCertErrors;
                                if (bool.TryParse(childNode.InnerText, out ignoreCertErrors))
                                {
                                    serverWsus.IgnoreCertificateErrors = ignoreCertErrors;
                                    Logger.Write("ignoreCertErrors : " + serverWsus.IgnoreCertificateErrors.ToString());
                                }
                                break;

                            case "DeadLineDaysSpan":
                                int day;
                                if (int.TryParse(childNode.InnerText, out day))
                                {
                                    serverWsus.DeadLineDaysSpan = day;
                                }
                                break;

                            case "DeadLineHour":
                                int hour;
                                if (int.TryParse(childNode.InnerText, out hour))
                                {
                                    serverWsus.DeadLineHour = hour;
                                }
                                break;

                            case "DeadLineMinute":
                                int minute;
                                if (int.TryParse(childNode.InnerText, out minute))
                                {
                                    serverWsus.DeadLineMinute = minute;
                                }
                                break;

                            case "MetaGroup":
                                serverWsus.MetaGroups.Add(GetMetaGroupFromXml(childNode));
                                break;

                            case "VisibleInWsusConsole":
                                string option = "Never";
                                option = childNode.InnerText;
                                if (option == "Never")
                                {
                                    serverWsus.VisibleInWsusConsole = MakeVisibleInWsusPolicy.Never;
                                }
                                if (option == "Always")
                                {
                                    serverWsus.VisibleInWsusConsole = MakeVisibleInWsusPolicy.Always;
                                }
                                if (option == "LetMeChoose")
                                {
                                    serverWsus.VisibleInWsusConsole = MakeVisibleInWsusPolicy.LetMeChoose;
                                }
                                break;

                            default:
                                break;
                            }
                        }
                        if (serverWsus.IsValid())
                        {
                            Logger.Write("Adding server : " + serverWsus.Name);
                            ServerList.Add(serverWsus);
                            cmbBxServerList.Items.Add(serverWsus);
                        }
                    }
                }
            }
            if (ServerList.Count == 0)
            {
                Logger.Write("Server count = 0");

                if (IsWsusInstalledOnLocalMachine())
                {
                    Logger.Write("Local Machine is Wsus.");
                    WsusServer serverWsus = new WsusServer();
                    serverWsus.Name                 = GetLocalMachineName();
                    serverWsus.IsLocal              = true;
                    serverWsus.Port                 = 80;
                    serverWsus.UseSSL               = false;
                    serverWsus.DeadLineDaysSpan     = 0;
                    serverWsus.DeadLineHour         = 0;
                    serverWsus.DeadLineMinute       = 0;
                    serverWsus.VisibleInWsusConsole = MakeVisibleInWsusPolicy.Never;

                    ServerList.Add(serverWsus);
                    cmbBxServerList.Items.Add(serverWsus);
                    SaveSettings(ServerList);
                    MessageBox.Show(resMan.GetString("AddAutomaticallyThisServer"));
                }
                else
                {
                    Logger.Write("No server are configured. Showing UI.");
                    if (this.Visible == false)
                    {
                        this.ShowDialog();
                    }
                }
            }

            Logger.Write("Returning " + ServerList.Count + " Servers.");
            return(ServerList);
        }
Esempio n. 7
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            Logger.EnteringMethod();
            btnEditServer.PerformClick();
            _serverlist.Clear();
            foreach (object obj in cmbBxServerList.Items)
            {
                WsusServer server = (WsusServer)obj;
                _serverlist.Add(server);
            }
            SaveSettings();
            if (rdBtnSameAsApplication.Checked)
            {
                Properties.Settings.Default.Credential = "SameAsApplication";
            }
            if (rdBtnSpecified.Checked)
            {
                Properties.Settings.Default.Credential       = "Specified";
                Properties.Settings.Default.RemoteAdminLogin = txtBxLogin.Text;
                Credentials.SetRemoteAdminPassword(txtBxPassword.Text);
            }
            if (rdBtnAsk.Checked)
            {
                Properties.Settings.Default.Credential = "Ask";
            }

            Credentials cred = Credentials.GetInstance();

            cred.UpdateAuthentifactionMethod();

            Properties.Settings.Default.DownloadedColor                = lblDownloaded.BackColor;
            Properties.Settings.Default.FailedColor                    = lblFailed.BackColor;
            Properties.Settings.Default.InstalledColor                 = lblInstalled.BackColor;
            Properties.Settings.Default.InstalledPendingRebootColor    = lblInstalledPendingReboot.BackColor;
            Properties.Settings.Default.NotInstalledColor              = lblNotInstalled.BackColor;
            Properties.Settings.Default.UnknownColor                   = lblUnknown.BackColor;
            Properties.Settings.Default.NotApplicableColor             = lblNotApplicable.BackColor;
            Properties.Settings.Default.ShowNonLocallyPublishedUpdates = chkBxShowNonLocallyPublishedUpdates.Checked;
            Properties.Settings.Default.PreventAutoApproval            = chkBxPreventAutoApproval.Checked;
            Properties.Settings.Default.OpenWindowsUpdateLogWith       = lnkLblOpenWith.Text;
            Properties.Settings.Default.ConnectToLastUsedServer        = chkBxConnectToLastUsedServer.Checked;

            if (txtBxDefaultRebootMessage.Text != Properties.Settings.Default.PersonalizedRebootMessage)
            {
                Properties.Settings.Default.PersonalizedRebootMessage = txtBxDefaultRebootMessage.Text;
            }

            if (chkBxConnectToLastUsedServer.Checked)
            {
                WsusWrapper wsus = WsusWrapper.GetInstance();
                if (wsus.IsConnected)
                {
                    Properties.Settings.Default.LastUsedServerName = wsus.CurrentServer.Name;
                }
            }

            if (rdBtnLastUsed.Checked)
            {
                Properties.Settings.Default.UpdateFilePathSetting = 0;
            }
            else
            {
                Properties.Settings.Default.UpdateFilePathSetting = 1;
                Properties.Settings.Default.LastUpdateFolder      = txtBxUseThisPath.Text;
                Properties.Settings.Default.AdditionalUpdateFilePathAsMainFile = chkBxSamePathForAdditionnal.Checked;
            }

            string pingStd = "IPv4";

            if (rdBtnIPv4.Checked)
            {
                pingStd = "IPv4";
            }
            if (rdBtnIPv6.Checked)
            {
                pingStd = "IPv6";
            }
            if (rdBtnIPv6IPv4.Checked)
            {
                pingStd = "IPv6IPv4";
            }
            Properties.Settings.Default.PingStandard = pingStd;
            string selectedDefaultAction = cmbBxUpdateDefaultAction.SelectedItem.ToString();

            Properties.Settings.Default.UpdateDefaultAction = "Revise";
            if (selectedDefaultAction == resMan.GetString("Revise"))
            {
                Properties.Settings.Default.UpdateDefaultAction = "Revise";
            }
            if (selectedDefaultAction == resMan.GetString("Approve"))
            {
                Properties.Settings.Default.UpdateDefaultAction = "Approve";
            }
            if (selectedDefaultAction == resMan.GetString("Decline"))
            {
                Properties.Settings.Default.UpdateDefaultAction = "Decline";
            }
            if (selectedDefaultAction == resMan.GetString("Expire"))
            {
                Properties.Settings.Default.UpdateDefaultAction = "Expire";
            }
            if (selectedDefaultAction == resMan.GetString("Delete"))
            {
                Properties.Settings.Default.UpdateDefaultAction = "Delete";
            }
            if (selectedDefaultAction == resMan.GetString("Resign"))
            {
                Properties.Settings.Default.UpdateDefaultAction = "Resign";
            }
            if (selectedDefaultAction == resMan.GetString("CreateSupersedingUpdate"))
            {
                Properties.Settings.Default.UpdateDefaultAction = "CreateSupersedingUpdate";
            }
            if (selectedDefaultAction == resMan.GetString("ExportThisUpdate"))
            {
                Properties.Settings.Default.UpdateDefaultAction = "ExportThisUpdate";
            }
            if (selectedDefaultAction == resMan.GetString("ShowInWsusConsole"))
            {
                Properties.Settings.Default.UpdateDefaultAction = "ShowInWsusConsole";
            }
            if (selectedDefaultAction == resMan.GetString("HideInWsusConsole"))
            {
                Properties.Settings.Default.UpdateDefaultAction = "HideInWsusConsole";
            }

            Properties.Settings.Default.IgnoreVersionMismatch = this.chkBxIgnoreVersionMismatch.Checked;

            SaveProxySettings();

            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }