[mapguide-commits] r8120 - in trunk/Tools/Maestro: MgCooker MgCooker.Cmd OSGeo.MapGuide.MaestroAPI

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed May 7 02:14:44 PDT 2014


Author: jng
Date: 2014-05-07 02:14:44 -0700 (Wed, 07 May 2014)
New Revision: 8120

Modified:
   trunk/Tools/Maestro/MgCooker.Cmd/Program.cs
   trunk/Tools/Maestro/MgCooker/Program.cs
   trunk/Tools/Maestro/MgCooker/Progress.cs
   trunk/Tools/Maestro/MgCooker/SetupRun.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/IServerConnection.cs
Log:
#2443: Where a username/password has been specified, inject the credentials into the connection string field so that it will be properly saved out to any batch or script file.

Also show progress percentage in the MgCooker progress dialog

Modified: trunk/Tools/Maestro/MgCooker/Program.cs
===================================================================
--- trunk/Tools/Maestro/MgCooker/Program.cs	2014-05-07 09:10:30 UTC (rev 8119)
+++ trunk/Tools/Maestro/MgCooker/Program.cs	2014-05-07 09:14:44 UTC (rev 8120)
@@ -48,7 +48,7 @@
         private static long mapCount;
         private static long groupCount;
 
-        private static bool m_logableProgress = false;
+        private static bool m_loggableProgress = false;
 
         private static bool hasConsole = true;
 
@@ -138,12 +138,12 @@
             try
             {
                 Console.Clear();
-                m_logableProgress = true;
+                m_loggableProgress = true;
             }
             catch
             {
                 hasConsole = false;
-                m_logableProgress = false;
+                m_loggableProgress = false;
             }
 
 
@@ -151,6 +151,8 @@
 
             string[] maps = mapdefinitions.Split(',');
 
+            string username = string.Empty;
+            string password = string.Empty;
             if (opts.ContainsKey(TileRunParameters.PROVIDER) && opts.ContainsKey(TileRunParameters.CONNECTIONPARAMS))
             {
                 var initP = ConnectionProviderRegistry.ParseConnectionString(opts[TileRunParameters.CONNECTIONPARAMS]);
@@ -167,6 +169,9 @@
                 if (frm.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                     return;
 
+                username = frm.Username;
+                password = frm.Password;
+
                 connection = frm.Connection;
             }
 
@@ -187,7 +192,13 @@
 
             if (!cmdLineMode)
             {
-                using (var sr = new SetupRun(connection, maps, opts))
+                SetupRun sr = null;
+                if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
+                    sr = new SetupRun(username, password, connection, maps, opts);
+                else
+                    sr = new SetupRun(connection, maps, opts);
+
+                using (sr)
                 {
                     sr.ShowDialog();
                     return;
@@ -320,7 +331,7 @@
         static void bx_FinishRenderingGroup(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel)
         {
             TimeSpan duration = DateTime.Now - beginGroup;
-            if (m_logableProgress)
+            if (m_loggableProgress)
                 Console.WriteLine(string.Format(Strings.ConsoleOperationFinishGroup, DateTime.Now, group, duration));
         }
 
@@ -329,7 +340,7 @@
             groupCount++;
             beginGroup = DateTime.Now;
 
-            if (m_logableProgress)
+            if (m_loggableProgress)
                 Console.WriteLine(string.Format(Strings.ConsoleOperationBeginGroup, beginGroup, group, 1, 1));
 
             tileRuns = new List<TimeSpan>();
@@ -360,9 +371,8 @@
 
                 tileRuns.Clear();
                 lastUpdate = DateTime.Now;
-
-
-                if (m_logableProgress)
+                
+                if (m_loggableProgress)
                     Console.WriteLine(string.Format(Strings.ConsoleOperationFinishTile, tileCount, totalTiles, group, duration));
                 else
                     DisplayProgress(map, group, scaleindex, row, column, ref cancel);
@@ -377,14 +387,14 @@
         static void bx_FinishRenderingScale(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel)
         {
             TimeSpan duration = DateTime.Now - beginScale;
-            if (m_logableProgress)
+            if (m_loggableProgress)
                 Console.WriteLine(string.Format(Strings.ConsoleOperationFinishScale, DateTime.Now, map.MapDefinition.BaseMap.GetScaleAt(scaleindex), duration));
         }
 
         static void bx_BeginRenderingScale(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel)
         {
             beginScale = DateTime.Now;
-            if (m_logableProgress)
+            if (m_loggableProgress)
                 Console.WriteLine(string.Format(Strings.ConsoleOperationBeginScale, beginMap, map.MapDefinition.BaseMap.GetScaleAt(scaleindex), scaleindex, map.Resolutions));
         }
 
@@ -392,7 +402,7 @@
         {
             groupCount = 0;
             TimeSpan duration = DateTime.Now - beginMap;
-            if (m_logableProgress)
+            if (m_loggableProgress)
                 Console.WriteLine(string.Format(Strings.ConsoleOperationFinishMap, DateTime.Now, map.ResourceId, duration));
         }
 
@@ -400,7 +410,7 @@
         {
             mapCount++;
             beginMap = DateTime.Now;
-            if (m_logableProgress)
+            if (m_loggableProgress)
                 Console.WriteLine(string.Format(Strings.ConsoleOperationBeginMap, beginMap, map.ResourceId));
         }
     }

Modified: trunk/Tools/Maestro/MgCooker/Progress.cs
===================================================================
--- trunk/Tools/Maestro/MgCooker/Progress.cs	2014-05-07 09:10:30 UTC (rev 8119)
+++ trunk/Tools/Maestro/MgCooker/Progress.cs	2014-05-07 09:14:44 UTC (rev 8120)
@@ -45,9 +45,12 @@
         private bool m_allowClose = true;
         private long m_failCount = 0;
 
+        private string m_origTitle;
+
         private Progress()
         {
             InitializeComponent();
+            m_origTitle = this.Text;
         }
 
         public Progress(TilingRunCollection bx)
@@ -146,6 +149,8 @@
                 tilePG.Value = (int)Math.Max(Math.Min((m_tileCount / (double)m_totalTiles) * (tilePG.Maximum - tilePG.Minimum), tilePG.Maximum), tilePG.Minimum);
                 totalPG.Value = (int)Math.Max(Math.Min((m_grandTotalTileCount / (double)m_grandTotalTiles) * (totalPG.Maximum - totalPG.Minimum), totalPG.Maximum), totalPG.Minimum);
 
+                this.Text = m_origTitle + " - (" + (int)(((double)m_grandTotalTileCount / (double)m_grandTotalTiles) * 100.0) +"%)";
+
                 if (m_failCount == 0)
                     tileCounter.Text = string.Format(Strings.CurrentTileCounter, m_grandTotalTileCount, m_grandTotalTiles, "");
                 else
@@ -156,7 +161,7 @@
                 TimeSpan remain = finish - DateTime.Now;
 
                 if (finish < DateTime.Now)
-                   finishEstimate.Text = Strings.InsufficientTimePassed;
+                    finishEstimate.Text = Strings.InsufficientTimePassed;
                 else
                     finishEstimate.Text = string.Format(Strings.RemainingTime, finish.ToShortTimeString(), string.Format("{0}:{1}:{2}", (int)Math.Floor(remain.TotalHours), remain.Minutes.ToString("00"), remain.Seconds.ToString("00")));
             }

Modified: trunk/Tools/Maestro/MgCooker/SetupRun.cs
===================================================================
--- trunk/Tools/Maestro/MgCooker/SetupRun.cs	2014-05-07 09:10:30 UTC (rev 8119)
+++ trunk/Tools/Maestro/MgCooker/SetupRun.cs	2014-05-07 09:14:44 UTC (rev 8120)
@@ -44,8 +44,8 @@
     public partial class SetupRun : Form
     {
         private IServerConnection m_connection;
-        private Dictionary<string, string> m_commandlineargs;
-        private Dictionary<string, IEnvelope> m_coordinateOverrides;
+        private IDictionary<string, string> m_commandlineargs;
+        private IDictionary<string, IEnvelope> m_coordinateOverrides;
         private bool m_isUpdating = false;
 
         private SetupRun()
@@ -55,7 +55,19 @@
                                      OSGeo.MapGuide.MaestroAPI.StringConstants.AllFilesFilter; //NOXLATE
         }
 
-        public SetupRun(IServerConnection connection, string[] maps, Dictionary<string, string> args)
+        internal SetupRun(string username, string password, IServerConnection connection, string[] maps, IDictionary<string, string> args)
+            : this(connection, maps, args)
+        {
+            var cloneP = connection.CloneParameters;
+            //HACK: Provider-specific information, but there isn't too many providers for this to be a problem
+            if (cloneP["SessionId"] != null)
+                cloneP.Remove("SessionId");
+            cloneP["Username"] = username;
+            cloneP["Password"] = password;
+            txtConnectionString.Text = Utility.ToConnectionString(cloneP);
+        }
+
+        public SetupRun(IServerConnection connection, string[] maps, IDictionary<string, string> args)
             : this()
         {
             m_connection = connection;

Modified: trunk/Tools/Maestro/MgCooker.Cmd/Program.cs
===================================================================
--- trunk/Tools/Maestro/MgCooker.Cmd/Program.cs	2014-05-07 09:10:30 UTC (rev 8119)
+++ trunk/Tools/Maestro/MgCooker.Cmd/Program.cs	2014-05-07 09:14:44 UTC (rev 8120)
@@ -31,7 +31,6 @@
             //Append the "/commandline" switch
             List<string> tmp = new List<string>(args);
             tmp.Add("/commandline");
-            System.Diagnostics.Debugger.Break();
             MgCooker.Program.Main(tmp.ToArray());
         }
     }

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/IServerConnection.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/IServerConnection.cs	2014-05-07 09:10:30 UTC (rev 8119)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/IServerConnection.cs	2014-05-07 09:14:44 UTC (rev 8120)
@@ -65,6 +65,7 @@
         /// Gets a collection of name-value parameters required to create another copy
         /// of this connection via the <see cref="T:OSGeo.MapGuide.MaestroAPI.ConnectionProviderRegistry"/>
         /// </summary>
+        /// <remarks>Each invocation returns a new instance</remarks>
         /// <returns></returns>
         NameValueCollection CloneParameters { get; }
 



More information about the mapguide-commits mailing list