List:Commits« Previous MessageNext Message »
From:Reggie Burnett Date:September 17 2010 10:17pm
Subject:bzr commit into wex-installer-1.0 branch (reggie.burnett:200)
View as plain text  
#At file:///C:/work/wex/installer/ based on revid:reggie.burnett@stripped

  200 Reggie Burnett	2010-09-17
      adding in a Debug.Assert to make sure our background worker is null when we expect it to be null
      Also, switched to using a method where we call a single method to install a single package from the install completed handler of the last install.  Makes for simpler code I think
      Plus a few other minor cleanups

    modified:
      WexInstaller/Core/Product.cs
      WexInstaller/Core/ProductFeature.cs
      WexInstaller/InstallWizard/InstallProgressPanel.cs
=== modified file 'WexInstaller/Core/Product.cs'
=== modified file 'WexInstaller/Core/Product.cs'
--- a/WexInstaller/Core/Product.cs	2010-09-16 17:38:54 +0000
+++ b/WexInstaller/Core/Product.cs	2010-09-17 22:17:42 +0000
@@ -149,16 +149,14 @@
 
         private void ExecuteMSI(PackageParameters parameters)
         {
-            if (bgw == null)
-            {
-                bgw = new BackgroundWorker();
-                bgw.WorkerReportsProgress = true;
-                bgw.WorkerSupportsCancellation = false;
-                bgw.DoWork += new DoWorkEventHandler(bgw_DoExecuteMSI);
-                bgw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgw_RunExecuteMSICompleted);
-                bgw.ProgressChanged += new ProgressChangedEventHandler(bgw_ExecuteMSIProgressChanged);
-                bgw.RunWorkerAsync(parameters);
-            }
+            Debug.Assert(bgw == null);
+            bgw = new BackgroundWorker();
+            bgw.WorkerReportsProgress = true;
+            bgw.WorkerSupportsCancellation = false;
+            bgw.DoWork += new DoWorkEventHandler(bgw_DoExecuteMSI);
+            bgw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgw_RunExecuteMSICompleted);
+            bgw.ProgressChanged += new ProgressChangedEventHandler(bgw_ExecuteMSIProgressChanged);
+            bgw.RunWorkerAsync(parameters);
         }
 
         private void bgw_DoExecuteMSI(object sender, DoWorkEventArgs e)
@@ -173,7 +171,7 @@
             {
                 ChainedInstallerEventArgs cStart = new ChainedInstallerEventArgs();
                 cStart.Action = ChainedInstallerAction.StartInstallation;
-                ChainedInstallerUpdated(this, cStart);
+                ChainedInstallerUpdated(i, cStart);
 
                 returnCodes = i.Install();
             }
@@ -184,9 +182,7 @@
 
             ChainedInstallerEventArgs cEnd = new ChainedInstallerEventArgs();
             cEnd.Action = ChainedInstallerAction.EndInstallation;
-            ChainedInstallerUpdated(this, cEnd);
-
-            return;
+            ChainedInstallerUpdated(i, cEnd);
         }
 
         private void bgw_RunExecuteMSICompleted(object sender, RunWorkerCompletedEventArgs e)
@@ -208,8 +204,6 @@
             c.Action = ChainedInstallerAction.FinalAction;
             c.ExitCode = (uint) Convert.ToInt32(e.Result);
             DoInstallationProgressChange(c);
-
-            return;
         }
 
         private void bgw_ExecuteMSIProgressChanged(object sender, ProgressChangedEventArgs e)
@@ -306,8 +300,6 @@
                 CurrentState = ProductState.InstallStarted;
                 ExecuteMSI(parameters);
             }
-
-            return;
         }
 
         public void Remove()
@@ -320,8 +312,6 @@
                 CurrentState = ProductState.RemoveStarted;
                 ExecuteMSI(parameters);
             }
-
-            return;
         }
 
         public void Update()
@@ -334,8 +324,6 @@
                 CurrentState = ProductState.UpdateStarted;
                 ExecuteMSI(parameters);
             }
-
-            return;
         }
 
         public void MakeChanges()
@@ -515,8 +503,6 @@
             {
                 DownloadProductCompleted(this, e);
             }
-
-            return;
         }
 
         private void DownloadProductProgress(object sender, DownloadProgressChangedEventArgs e)
@@ -531,8 +517,6 @@
                     DownloadProductProgressChanged(this, e);
                 }
             }
-
-            return;
         }
 
         public void Download()

=== modified file 'WexInstaller/Core/ProductFeature.cs'
--- a/WexInstaller/Core/ProductFeature.cs	2010-09-17 18:37:46 +0000
+++ b/WexInstaller/Core/ProductFeature.cs	2010-09-17 22:17:42 +0000
@@ -137,17 +137,6 @@
             return sizeEst;
         }
 
-        public bool HasChanges
-        {
-            get
-            {
-                bool hasChanges = Installed != ProposedInstalled;
-                foreach (ProductFeature f in Features)
-                    hasChanges |= f.HasChanges;
-                return hasChanges;
-            }
-        }
-
         public override void SetParent(ProductElement parent)
         {
             base.SetParent(parent);

=== modified file 'WexInstaller/InstallWizard/InstallProgressPanel.cs'
--- a/WexInstaller/InstallWizard/InstallProgressPanel.cs	2010-09-15 21:17:03 +0000
+++ b/WexInstaller/InstallWizard/InstallProgressPanel.cs	2010-09-17 22:17:42 +0000
@@ -17,11 +17,10 @@
     public partial class InstallProgressPanel : InstallerPanel
     {
         private Dictionary<string, int> progressLevels;
-        private bool clearedToProceed;
-        private int overallMax;
         private bool nextOk;
         private bool backOk;
         private bool executed;
+        private int leftToInstall;
 
         ListViewItem installingItem;
         int start, stop, installStep, installPos;
@@ -34,7 +33,6 @@
             nextOk = true;
             executed = false;
             progressLevels = new Dictionary<string, int>();
-            clearedToProceed = true;
             ListViewHelper.EnableDoubleBuffer(productList);
         }
 
@@ -57,7 +55,7 @@
             {
                 foreach (Product p in pc.Products)
                 {
-                    if (!p.HasChanges) continue;
+                    if (!p.ProposedInstalled) continue;
                     ListViewItem item = new ListViewItem(p.Title);
                     item.Name = p.Title;
                     item.Tag = p;
@@ -66,6 +64,7 @@
                     productList.Items.Add(item);
                 }
             }
+            leftToInstall = productList.Items.Count;
 
             if (productList.Items.Count > 0)
                 installingItem = productList.Items[0];
@@ -91,16 +90,8 @@
                 enableDetails.Visible = true;
                 SignalChange();
 
-                overallMax = productList.Items.Count * 100;
-
-                foreach (ListViewItem item in productList.Items)
-                {
-                    Product p = (Product)item.Tag;
-                    if (!p.FoundLocal) overallMax += 100;
-                }
-
                 DownloadPackages();
-                InstallPackages();
+                InstallNextPackage();
 
                 nextOk = true;
                 NextButton.Enabled = true;
@@ -204,7 +195,7 @@
         private void AddToDetailsText(int index, string message)
         {
             detailsText.AppendText(String.Format("{0}: {1}{2}", 
-                                                 index.ToString(), 
+                                                 index, 
                                                  message, 
                                                  Environment.NewLine
                                                  )
@@ -226,8 +217,6 @@
                 p.DownloadProductCompleted += new DownloadProductCompleteHandler(product_DownloadProductCompleted);
                 progressLevels.Add(p.Title, 0);
                 p.Download();
-                Thread.Sleep(0);
-                Application.DoEvents();
             }
         }
 
@@ -251,9 +240,6 @@
             ListViewItem item = productList.Items.Find(p.Title, false)[0];
             Debug.Assert(item != null);
             progressLevels[p.Title] = e.ProgressPercentage;
-            int progress = 0;
-            foreach (int val in progressLevels.Values)
-                progress += val;
 
             if (item.StateImageIndex != (int)InstallProgressState.Download && e.BytesReceived > 0)
                 item.StateImageIndex = (int)InstallProgressState.Download;
@@ -261,52 +247,24 @@
             item.SubItems[2].Text = String.Format(Resources.StatusPercentage, e.ProgressPercentage);
         }
 
-        private void InstallPackages()
+        private void InstallNextPackage()
         {
-            int totalRemaining = productList.Items.Count;
-            clearedToProceed = true;
-            while (totalRemaining > 0)
+            while (leftToInstall > 0)
             {
-                if (clearedToProceed == true)
+                foreach (ListViewItem item in productList.Items)
                 {
-                    totalRemaining = productList.Items.Count;
-                    foreach (ListViewItem item in productList.Items)
-                    {
-                        Product p = (item.Tag as Product);
-                        ProductState state = p.CurrentState;
-                        if (p.CurrentState == ProductState.DownloadStarted ||
-                            p.CurrentState == ProductState.DownloadInProgress ||
-                            p.CurrentState == ProductState.InstallInProgress)
-                        {
-                            continue;
-                        }
-
-                        if (p.CurrentState == ProductState.DownloadSuccess ||
-                            p.CurrentState == ProductState.FoundLocal ||
-                            p.CurrentState == ProductState.WillPerformUpgrade)
-                        {
-                            lock (installingItem)
-                            {
-                                clearedToProceed = false;
-                                installingItem = item;
-                            }
-                            p.ProductInstallationProgressChanged += new ProductInstationActionEventHandler(ProductInstallationProgressChanged);
-                            p.MakeChanges();
-                            totalRemaining--;
-                            break;
-                        }
-                        else
-                        {
-                            totalRemaining--;
-                        }
-                    }
+                    Product p = (Product)item.Tag;
+                    if (p.CurrentState != ProductState.DownloadSuccess &&
+                        p.CurrentState != ProductState.FoundLocal &&
+                        p.CurrentState != ProductState.WillPerformUpgrade) continue;
+                    installingItem = item;
+                    p.ProductInstallationProgressChanged += new ProductInstationActionEventHandler(ProductInstallationProgressChanged);
+                    p.MakeChanges();
+                    leftToInstall--;
+                    return;
                 }
                 Application.DoEvents();
-            }
-
-            while (clearedToProceed == false)
-            {
-                Application.DoEvents();
+                Thread.Sleep(0);
             }
         }
 
@@ -368,9 +326,9 @@
                         installingItem.StateImageIndex = (int)InstallProgressState.Ok;
                         installingItem.SubItems[1].Text = GetProductStateString(p.CurrentState);
                         installingItem.SubItems[2].Text = String.Empty;
-                        clearedToProceed = true;
                     }
                     AddToDetailsText(item.Index, installingItem.SubItems[1].Text);
+                    InstallNextPackage();
                     break;
                 case ChainedInstallerAction.LogEvent:
                     AddToDetailsText(item.Index, e.Message);


Attachment: [text/bzr-bundle] bzr/reggie.burnett@oracle.com-20100917221742-jgosh1fhjfq8v5pc.bundle
Thread
bzr commit into wex-installer-1.0 branch (reggie.burnett:200) Reggie Burnett18 Sep