Esempio n. 1
0
        /// <summary>
        /// This method checks if an update is required. During this process the appcast
        /// will be downloaded and checked against the reference assembly. Ensure that
        /// the calling process has access to the internet and read access to the
        /// reference assembly. This method is also called from the background loops.
        /// </summary>
        /// <param name="config">the configuration</param>
        /// <param name="latestVersion">returns the latest version</param>
        /// <returns><c>true</c> if an update is required</returns>
        public UpdateStatus GetUpdateStatus(NetSparkleConfiguration config, out NetSparkleAppCastItem latestVersion)
        {
            // report
            ReportDiagnosticMessage("Downloading and checking appcast");

            // init the appcast
            NetSparkleAppCast cast = new NetSparkleAppCast(_appCastUrl, config);

            // check if any updates are available
            try
            {
                latestVersion = cast.GetLatestVersion();
            }
            catch (Exception e)
            {
                // show the exception message
                ReportDiagnosticMessage("Error during app cast download: " + e.Message);

                // just null the version info
                latestVersion = null;
            }

            if (latestVersion == null)
            {
                ReportDiagnosticMessage("No version information in app cast found");
                return(UpdateStatus.CouldNotDetermine);
            }
            ReportDiagnosticMessage("Latest version on the server is " + latestVersion.Version);

            // set the last check time
            ReportDiagnosticMessage("Touch the last check timestamp");
            config.TouchCheckTime();

            // check if the available update has to be skipped
            if (latestVersion.Version.Equals(config.SkipThisVersion))
            {
                ReportDiagnosticMessage("Latest update has to be skipped (user decided to skip version " + config.SkipThisVersion + ")");
                return(UpdateStatus.UserSkipped);
            }

            // check if the version will be the same then the installed version
            Version v1 = new Version(config.InstalledVersion);
            Version v2 = new Version(latestVersion.Version);

            if (v2 <= v1)
            {
                ReportDiagnosticMessage("Installed version is valid, no update needed (" + config.InstalledVersion + ")");
                return(UpdateStatus.UpdateNotAvailable);
            }

            // ok we need an update
            return(UpdateStatus.UpdateAvailable);
        }
Esempio n. 2
0
        /// <summary>
        /// This method checks if an update is required. During this process the appcast
        /// will be downloaded and checked against the reference assembly. Ensure that
        /// the calling process has access to the internet and read access to the 
        /// reference assembly. This method is also called from the background loops.
        /// </summary>
        /// <param name="config">the configuration</param>
        /// <param name="updates">list of available updates sorted decreasing</param>
        /// <returns><c>true</c> if an update is required</returns>
        public UpdateStatus GetUpdateStatus(NetSparkleConfiguration config, out NetSparkleAppCastItem[] updates)
        {
            // report
            ReportDiagnosticMessage("Downloading and checking appcast");

            // init the appcast
            NetSparkleAppCast cast = new NetSparkleAppCast(_appCastUrl, config);
            cast.Read();

            // check if any updates are available
            try
            {
                updates = cast.GetUpdates();
            }
            catch (Exception e)
            {
                // show the exception message 
                ReportDiagnosticMessage("Error during app cast download: " + e.Message);

                // just null the version info
                updates = null;
            }

            if (updates == null)
            {
                ReportDiagnosticMessage("No version information in app cast found");
                return UpdateStatus.CouldNotDetermine;
            }

            // set the last check time
            ReportDiagnosticMessage("Touch the last check timestamp");
            config.TouchCheckTime();

            // check if the version will be the same then the installed version
            if (updates.Length == 0)
            {
                ReportDiagnosticMessage("Installed version is valid, no update needed (" + config.InstalledVersion + ")");
                return UpdateStatus.UpdateNotAvailable;
            }
            ReportDiagnosticMessage("Latest version on the server is " + updates[0].Version);

            // check if the available update has to be skipped
            if (updates[0].Version.Equals(config.SkipThisVersion))
            {
                ReportDiagnosticMessage("Latest update has to be skipped (user decided to skip version " + config.SkipThisVersion + ")");
                return UpdateStatus.UserSkipped;
            }

            // ok we need an update
            return UpdateStatus.UpdateAvailable;
        }
Esempio n. 3
0
        /// <summary>
        /// This method checks if an update is required. During this process the appcast
        /// will be downloaded and checked against the reference assembly. Ensure that
        /// the calling process has read access to the reference assembly.
        /// This method is also called from the background loops.
        /// </summary>
        /// <param name="config">the configuration</param>
        /// <returns>SparkleUpdate with information on whether there is an update available or not.</returns>
        public async Task<SparkleUpdateInfo> GetUpdateStatus(NetSparkleConfiguration config)
        {
            NetSparkleAppCastItem[] updates = null;
            // report
            ReportDiagnosticMessage("Downloading and checking appcast");

            // init the appcast
            NetSparkleAppCast cast = new NetSparkleAppCast(_appCastUrl, this, config);
            // check if any updates are available
            try
            {
                var task = Task.Factory.StartNew(() =>
                {
                    if (cast.Read())
                        updates = cast.GetUpdates();
                });
                await task;
            }
            catch (Exception e)
            {
                ReportDiagnosticMessage("Couldn't read/parse the app cast: " + e.Message);
                updates = null;
            }


            if (updates == null)
            {
                ReportDiagnosticMessage("No version information in app cast found");
                return new SparkleUpdateInfo(UpdateStatus.CouldNotDetermine);
            }

            // set the last check time
            ReportDiagnosticMessage("Touch the last check timestamp");
            config.TouchCheckTime();

            // check if the version will be the same then the installed version
            if (updates.Length == 0)
            {
                ReportDiagnosticMessage("Installed version is valid, no update needed (" + config.InstalledVersion + ")");
                return new SparkleUpdateInfo(UpdateStatus.UpdateNotAvailable);
            }
            ReportDiagnosticMessage("Latest version on the server is " + updates[0].Version);

            // check if the available update has to be skipped
            if (updates[0].Version.Equals(config.SkipThisVersion))
            {
                ReportDiagnosticMessage("Latest update has to be skipped (user decided to skip version " + config.SkipThisVersion + ")");
                return new SparkleUpdateInfo(UpdateStatus.UserSkipped);
            }

            // ok we need an update
            return new SparkleUpdateInfo(UpdateStatus.UpdateAvailable, updates);
        }