List:Commits« Previous MessageNext Message »
From:Reggie Burnett Date:January 24 2011 5:24pm
Subject:bzr commit into wex-installer-1.0 branch (reggie.burnett:261)
View as plain text  
#At file:///C:/Users/Reggie/work/wex/installer-updated/ based on revid:reggie.burnett@stripped

  261 Reggie Burnett	2011-01-24
      the wex installer will now detect and launch the update tool if appropriate

    modified:
      WexInstaller/Core/ProductManager.cs
      WexInstaller/Core/ProductManifest.cs
      WexInstaller/Program.cs
      WexInstaller/Properties/Resources.Designer.cs
      WexInstaller/Properties/Resources.resx
=== modified file 'WexInstaller/Core/ProductManager.cs'
=== modified file 'WexInstaller/Core/ProductManager.cs'
--- a/WexInstaller/Core/ProductManager.cs	2011-01-24 16:44:49 +0000
+++ b/WexInstaller/Core/ProductManager.cs	2011-01-24 17:24:16 +0000
@@ -30,6 +30,7 @@
             get { return manifest.ProductCatalogs.AsReadOnly(); }
         }
 
+        public static ProductManifest Manifest { get; set; }
         public static bool ProductsInstalled { get; private set; }
         public static bool ProductsUpgrade { get; private set; }
         public static ProductCatalog ActiveCatalog { get; set; }
@@ -59,6 +60,7 @@
             //TODO: fix this to handle it better
             if (manifest == null || manifest.ProductCategories == null || manifest.ProductCatalogs == null)
                 throw new InvalidOperationException("Manifest failed to load properly");
+            Manifest = manifest;
 
             foreach (ProductCategory pc in manifest.ProductCategories)
             {

=== modified file 'WexInstaller/Core/ProductManifest.cs'
--- a/WexInstaller/Core/ProductManifest.cs	2011-01-24 15:28:26 +0000
+++ b/WexInstaller/Core/ProductManifest.cs	2011-01-24 17:24:16 +0000
@@ -15,6 +15,12 @@
         [XmlAttribute("format")]
         public int Format;
 
+        [XmlElement("UpdateVersion")]
+        public string UpdateVersion { get; set; }
+
+        [XmlElement("UpdateURL")]
+        public string UpdateUrl { get; set; }
+
         [XmlArray()]
         public List<ProductCatalog> ProductCatalogs;
 

=== modified file 'WexInstaller/Program.cs'
--- a/WexInstaller/Program.cs	2010-09-24 15:32:17 +0000
+++ b/WexInstaller/Program.cs	2011-01-24 17:24:16 +0000
@@ -5,6 +5,9 @@
 using System.Runtime.InteropServices;
 using WexInstaller.Properties;
 using WexInstaller.Core;
+using System.Reflection;
+using System.IO;
+using System.Diagnostics;
 
 namespace WexInstaller
 {
@@ -25,13 +28,46 @@
 
             Logger.LogInformation("Loading product manifest");
             ProductManager.Load();
-
+            if (CheckForUpdate())
+                return;
             Application.Run(new MainForm());
 
             InstallerConfiguration.Save();
             Logger.LogInformation("Installer exit");
         }
 
+        private static bool CheckForUpdate()
+        {
+            Assembly assembly = Assembly.GetExecutingAssembly();
+            Version version = assembly.GetName().Version;
+            try
+            {
+                Version updateVersion = new Version(ProductManager.Manifest.UpdateVersion);
+                if (version >= updateVersion) return false;
+                DialogResult confirm = MessageBox.Show(Resources.UpdateAvailable, Resources.UpdateCaption,
+                    MessageBoxButtons.YesNo, MessageBoxIcon.Question);
+                if (confirm == DialogResult.No) return false;
+                string path = Path.GetDirectoryName(assembly.Location);
+                string updateTool = String.Format("{0}{1}WexInstallerUpdater.exe",
+                    path, Path.DirectorySeparatorChar);
+                if (!File.Exists(updateTool))
+                {
+                    Logger.LogError("Unable to find update tool - " + updateTool);
+                    return false;
+                }
+                ProcessStartInfo psi = new ProcessStartInfo();
+                psi.FileName = updateTool;
+                psi.Arguments = ProductManager.Manifest.UpdateUrl;
+                Process.Start(psi);
+                return true;
+            }
+            catch (Exception ex)
+            {
+                Logger.LogException(ex);
+                return false;
+            }
+        }
+
 /*        static bool ProcessCommandLineArguments()
         {
             bool checkForUpdates = false;

=== modified file 'WexInstaller/Properties/Resources.Designer.cs'
--- a/WexInstaller/Properties/Resources.Designer.cs	2011-01-17 17:05:19 +0000
+++ b/WexInstaller/Properties/Resources.Designer.cs	2011-01-24 17:24:16 +0000
@@ -684,6 +684,24 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to There is an update available to the MySQL Universal Installer.  Do you want to download and install it now?.
+        /// </summary>
+        internal static string UpdateAvailable {
+            get {
+                return ResourceManager.GetString("UpdateAvailable", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Update?.
+        /// </summary>
+        internal static string UpdateCaption {
+            get {
+                return ResourceManager.GetString("UpdateCaption", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Updates are available for one or more of your installed MySQL products. Would you like to upgrade them now?.
         /// </summary>
         internal static string UpdatesAreAvailable {

=== modified file 'WexInstaller/Properties/Resources.resx'
--- a/WexInstaller/Properties/Resources.resx	2011-01-17 17:05:19 +0000
+++ b/WexInstaller/Properties/Resources.resx	2011-01-24 17:24:16 +0000
@@ -381,4 +381,10 @@
   <data name="PackagesAvailableForDownload" xml:space="preserve">
     <value>(available for download)</value>
   </data>
+  <data name="UpdateAvailable" xml:space="preserve">
+    <value>There is an update available to the MySQL Universal Installer.  Do you want to download and install it now?</value>
+  </data>
+  <data name="UpdateCaption" xml:space="preserve">
+    <value>Update?</value>
+  </data>
 </root>
\ No newline at end of file


Attachment: [text/bzr-bundle] bzr/reggie.burnett@oracle.com-20110124172416-9n9i3kg6xf600b3i.bundle
Thread
bzr commit into wex-installer-1.0 branch (reggie.burnett:261) Reggie Burnett24 Jan