Ejemplo n.º 1
0
        private void butCheckForUpdates_Click(object sender, EventArgs e)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                MsgBox.Show(this, "Updates are only allowed from the web server");
                return;
            }
            if (PrefC.GetString(PrefName.WebServiceServerName) != "" &&       //using web service
                !ODEnvironment.IdIsThisComputer(PrefC.GetString(PrefName.WebServiceServerName).ToLower()))                  //and not on web server
            {
                MessageBox.Show(Lan.g(this, "Updates are only allowed from the web server") + ": " + PrefC.GetString(PrefName.WebServiceServerName));
                return;
            }
            if (ReplicationServers.ServerIsBlocked())
            {
                MsgBox.Show(this, "Updates are not allowed on this replication server");
                return;
            }
            Cursor                     = Cursors.WaitCursor;
            groupBuild.Visible         = false;
            groupStable.Visible        = false;
            groupBeta.Visible          = false;
            groupAlpha.Visible         = false;
            textConnectionMessage.Text = Lan.g(this, "Attempting to connect to web service......");
            Application.DoEvents();
            string result = "";

            try {
                result = CustomerUpdatesProxy.SendAndReceiveUpdateRequestXml();
            }
            catch (Exception ex) {
                Cursor = Cursors.Default;
                string friendlyMessage = Lan.g(this, "Error checking for updates.");
                FriendlyException.Show(friendlyMessage, ex);
                textConnectionMessage.Text = friendlyMessage;
                return;
            }
            textConnectionMessage.Text = Lan.g(this, "Connection successful.");
            Cursor = Cursors.Default;
            try {
                ParseXml(result);
            }
            catch (Exception ex) {
                string friendlyMessage = Lan.g(this, "Error checking for updates.");
                FriendlyException.Show(friendlyMessage, ex);
                textConnectionMessage.Text = friendlyMessage;
                return;
            }
            if (!string.IsNullOrEmpty(_buildAvailableDisplay))
            {
                groupBuild.Visible = true;
                textBuild.Text     = _buildAvailableDisplay;
            }
            if (!string.IsNullOrEmpty(_stableAvailableDisplay))
            {
                groupStable.Visible = true;
                textStable.Text     = _stableAvailableDisplay;
            }
            if (!string.IsNullOrEmpty(_betaAvailableDisplay))
            {
                groupBeta.Visible = true;
                textBeta.Text     = _betaAvailableDisplay;
            }
            if (!string.IsNullOrEmpty(_alphaAvailableDisplay))
            {
                groupAlpha.Visible = true;
                textAlpha.Text     = _alphaAvailableDisplay;
            }
            if (string.IsNullOrEmpty(_betaAvailable) &&
                string.IsNullOrEmpty(_stableAvailable) &&
                string.IsNullOrEmpty(_buildAvailable) &&
                string.IsNullOrEmpty(_alphaAvailable))
            {
                textConnectionMessage.Text += Lan.g(this, "  There are no downloads available.");
            }
            else
            {
                textConnectionMessage.Text += Lan.g(this, "  The following downloads are available.\r\n"
                                                    + "Be sure to stop the program on all other computers in the office before installing.");
            }
        }
Ejemplo n.º 2
0
        private void FormSupportStatus_Load(object sender, EventArgs e)
        {
            Cursor          = Cursors.WaitCursor;
            _regKey         = PrefC.GetString(PrefName.RegistrationKey);
            textRegKey.Text = _regKey;
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent      = true;
            settings.IndentChars = ("    ");
            StringBuilder strbuild = new StringBuilder();

            using (XmlWriter writer = XmlWriter.Create(strbuild, settings)) {
                writer.WriteStartElement("RegistrationKey");
                writer.WriteString(_regKey);
                writer.WriteEndElement();
            }
            OpenDentBusiness.localhost.Service1 updateService = CustomerUpdatesProxy.GetWebServiceInstance();
            string result = "";

            try {
                result = updateService.RequestRegKeyStatus(strbuild.ToString());
            }
            catch (Exception ex) {
                Cursor = Cursors.Default;
                MessageBox.Show("Error: " + ex.Message);
                this.Close();
                return;
            }
            Cursor = Cursors.Default;
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(result);
            XmlNode node = doc.SelectSingleNode("//Error");

            if (node != null)
            {
                MessageBox.Show(node.InnerText, "Error");
                return;
            }
            node = doc.SelectSingleNode("//KeyDisabled");
            if (node != null)
            {
                if (Prefs.UpdateBool(PrefName.RegistrationKeyIsDisabled, true))
                {
                    DataValid.SetInvalid(InvalidType.Prefs);
                }
                labelStatusValue.Text      = "DISABLED " + node.InnerText;
                labelStatusValue.ForeColor = Color.Red;
            }
            //Checking all three statuses in case RequestRegKeyStatus changes in the future
            node = doc.SelectSingleNode("//KeyEnabled");
            if (node != null)
            {
                if (Prefs.UpdateBool(PrefName.RegistrationKeyIsDisabled, false))
                {
                    DataValid.SetInvalid(InvalidType.Prefs);
                }
                labelStatusValue.Text      = "ENABLED";
                labelStatusValue.ForeColor = Color.Green;
            }
            node = doc.SelectSingleNode("//KeyEnded");
            if (node != null)
            {
                if (Prefs.UpdateBool(PrefName.RegistrationKeyIsDisabled, true))
                {
                    DataValid.SetInvalid(InvalidType.Prefs);
                }
                labelStatusValue.Text      = "EXPIRED " + node.InnerText;
                labelStatusValue.ForeColor = Color.Red;
            }
        }