コード例 #1
0
        public void CheckForNewClientVersion(IWebProxy proxy)
        {
            try
            {
                Logging.Info("About to check for new client version at server: {0}", _clientVersionUrl);
                string temp_file = null;
                try
                {
                    temp_file = DownloadFile(proxy, _clientVersionUrl);

                    //  deserialize into memory
                    ClientVersionInformation client_version_information = XmlSerializeFile.Deserialize <ClientVersionInformation>(temp_file);
                    if (client_version_information != null)
                    {
                        Logging.Info("Received latest client version information from server: {0}", client_version_information);

                        ProcessClientVersionInformation(client_version_information);
                    }
                    else
                    {
                        Logging.Info("Unable to deserialize client version information from server, nothing to do.");
                    }
                }
                finally
                {
                    //  clean up the client version xml file
                    if (!string.IsNullOrEmpty(temp_file))
                    {
                        //  this method doesn't throw an exception
                        FileTools.Delete(temp_file);
                    }
                }
            }
            catch (Exception ex)
            {
                Logging.Error(ex, "Problem checking for new client version");
            }
        }
コード例 #2
0
        private void ProcessClientVersionInformation(ClientVersionInformation client_version_information)
        {
            _latestClientVersionInformation = client_version_information;

            int current_executing_version = ClientVersion.CurrentVersion;

            string notification_bar_text;
            string notification_bar_tooltip;

            NotificationManager.NotificationType notification_type;

            //  are we on the latest version? whohooooo
            if (current_executing_version == client_version_information.LatestVersion)
            {
                Logging.Info("We are on the latest version: {0}", current_executing_version);
                //  nothing left to do
                return;
            }

            //  is this version ok - based on the compliant version flag, in which case nothing to do except log
            if (client_version_information.CompliantFromVersion.HasValue && current_executing_version >= client_version_information.CompliantFromVersion)
            {
                Logging.Info("User is running an old version (v{0}), but it is still >= the compliant version (v{1}), so not telling them to update.", current_executing_version, client_version_information.CompliantFromVersion);
                //return;
            }

            //  are we ahead of the latest version (in the event we have rolled back, let the user know)
            if (current_executing_version > client_version_information.LatestVersion)
            {
                Logging.Warn("Current executing version (v{0}) is ahead of server version (v{1})??? Have we rolled back a version?", current_executing_version, client_version_information.LatestVersion);
                notification_bar_text    = "We have reverted to an old version of " + _appName + ", please download the previous version.";
                notification_bar_tooltip = "It appears that we have reverted to an old version of " + _appName + ", most likely due to some issues with the latest version.  Please download LexLens again and reinstall (the installer will warn you that you are installing an old version which you can safely ignore).";
                notification_type        = NotificationManager.NotificationType.Warning;
            }
            //  is this version obsolete - let them know with a strongly worded message
            else if (client_version_information.ObsoleteToVersion.HasValue && current_executing_version <= client_version_information.ObsoleteToVersion)
            {
                notification_bar_text    = "Your " + _appName + " version is out-of-date, please download the latest version.";
                notification_bar_tooltip = "You are using an old version of " + _appName + " which is not currently supported, please download the latest version.";
                notification_type        = NotificationManager.NotificationType.Warning;
            }
            //  just a bog standard update message
            else
            {
                notification_bar_text    = "A new version of " + _appName + " is available for download.";
                notification_bar_tooltip = null;
                notification_type        = NotificationManager.NotificationType.Warning;
            }

            //  should we notify them about a new version available - only do if their version isn't compliant
            if (!client_version_information.CompliantFromVersion.HasValue || current_executing_version < client_version_information.CompliantFromVersion)
            {
                WPFDoEvents.ResetHourglassCursor();

                NotificationManager.Instance.AddPendingNotification(
                    new NotificationManager.Notification(
                        notification_bar_text,
                        notification_bar_tooltip,
                        notification_type,
                        _downloadLogo, //Icons.lexlens_logo,
                        "See Changes",
                        ViewChanges,
                        "Download",
                        DownloadNewClientVersion
                        ));
            }
        }