Exemplo n.º 1
0
 public void CheckForUpdate()
 {
     try
     {
         WebClient client = new WebClient();
         List <ApplicationVersion> versions = new List <ApplicationVersion>();
         string index   = client.DownloadString(Configuration.UpdateURL);
         Regex  pattern = new Regex(Configuration.ReleasePattern);
         foreach (Match match in pattern.Matches(index))
         {
             string             filename       = match.Value;
             string             revisionString = match.Groups[1].Value;
             int                revision       = Convert.ToInt32(revisionString);
             ApplicationVersion version        = new ApplicationVersion(filename, revision);
             versions.Add(version);
         }
         if (versions.Count == 0)
         {
             WriteLine("No versions of this application are being offered by the update server - this should never happen.");
             return;
         }
         //Sort the archives by revision to easily determine the newest one
         versions.Sort();
         NewestVersion = versions[0];
         int newestRevision = NewestVersion.Revision;
         if (CurrentRevision < newestRevision || Configuration.ForceUpdate)
         {
             WriteLine("The current version of this software (r{0}) is outdated. The newest version available is r{1}.", CurrentRevision, newestRevision);
             if (UpdateHandler != null)
             {
                 UpdateHandler.UpdateDetected(CurrentRevision, NewestVersion);
             }
             else
             {
                 DownloadUpdate(false);
             }
         }
         else if (CurrentRevision == newestRevision)
         {
             WriteLine("This software is up to date.");
         }
         else
         {
             WriteLine("The current version (r{0}) is newer than the most recent version of this software available (r{1}).", CurrentRevision, newestRevision);
         }
     }
     catch (ArgumentException exception)
     {
         WriteLine("Invalid update release pattern specified: {0}", exception.Message);
     }
     catch (WebException exception)
     {
         WriteLine("Unable to determine the latest version of this software: {0}", exception.Message);
     }
 }
Exemplo n.º 2
0
        public UpdateService(Configuration configuration, IGlobalHandler globalHandler, IUpdateHandler updateHandler = null)
        {
            Configuration = configuration.Updates;

            GlobalHandler = globalHandler;
            UpdateHandler = updateHandler;

            IsCommandLineVersion = UpdateHandler == null;
            IsMono = Type.GetType("Mono.Runtime") != null;

            CurrentRevision = Assembly.GetEntryAssembly().GetName().Version.Revision;
            NewestVersion = null;
        }
Exemplo n.º 3
0
        public UpdateService(Configuration configuration, IGlobalHandler globalHandler, IUpdateHandler updateHandler = null)
        {
            Configuration = configuration.Updates;

            GlobalHandler = globalHandler;
            UpdateHandler = updateHandler;

            IsCommandLineVersion = UpdateHandler == null;
            IsMono = Type.GetType("Mono.Runtime") != null;

            CurrentRevision = Assembly.GetEntryAssembly().GetName().Version.Revision;
            NewestVersion   = null;
        }
Exemplo n.º 4
0
 public void CheckForUpdate()
 {
     try
     {
         WebClient client = new WebClient();
         List<ApplicationVersion> versions = new List<ApplicationVersion>();
         string index = client.DownloadString(Configuration.UpdateURL);
         Regex pattern = new Regex(Configuration.ReleasePattern);
         foreach (Match match in pattern.Matches(index))
         {
             string filename = match.Value;
             string revisionString = match.Groups[1].Value;
             int revision = Convert.ToInt32(revisionString);
             ApplicationVersion version = new ApplicationVersion(filename, revision);
             versions.Add(version);
         }
         if (versions.Count == 0)
         {
             WriteLine("No versions of this application are being offered by the update server - this should never happen.");
             return;
         }
         //Sort the archives by revision to easily determine the newest one
         versions.Sort();
         NewestVersion = versions[0];
         int newestRevision = NewestVersion.Revision;
         if (CurrentRevision < newestRevision || Configuration.ForceUpdate)
         {
             WriteLine("The current version of this software (r{0}) is outdated. The newest version available is r{1}.", CurrentRevision, newestRevision);
             if (UpdateHandler != null)
                 UpdateHandler.UpdateDetected(CurrentRevision, NewestVersion);
             else
                 DownloadUpdate(false);
         }
         else if (CurrentRevision == newestRevision)
             WriteLine("This software is up to date.");
         else
             WriteLine("The current version (r{0}) is newer than the most recent version of this software available (r{1}).", CurrentRevision, newestRevision);
     }
     catch (ArgumentException exception)
     {
         WriteLine("Invalid update release pattern specified: {0}", exception.Message);
     }
     catch (WebException exception)
     {
         WriteLine("Unable to determine the latest version of this software: {0}", exception.Message);
     }
 }
Exemplo n.º 5
0
        public void StartUpdate(ApplicationVersion newVersion)
        {
            var action = (Action)delegate
            {
                UpdateTabItem.IsEnabled = true;
                DownloadLabel.Content = string.Format("Downloading {0}...", newVersion.Filename);
                UpdateTabItem.Focus();
            };

            UpdateTabItem.Dispatcher.Invoke(action);
        }
Exemplo n.º 6
0
        public int CompareTo(object other)
        {
            ApplicationVersion otherVersion = (ApplicationVersion)other;

            return(-Revision.CompareTo(otherVersion.Revision));
        }
Exemplo n.º 7
0
 public void UpdateDetected(int currentRevision, ApplicationVersion newVersion)
 {
     MainWindow.StartUpdate(newVersion);
     UpdateService.DownloadUpdate();
 }