[mapguide-commits] r6762 - in trunk/Tools/MgInstantSetup: InstantSetup InstantSetup.Core

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu Jun 14 07:04:08 PDT 2012


Author: jng
Date: 2012-06-14 07:04:07 -0700 (Thu, 14 Jun 2012)
New Revision: 6762

Added:
   trunk/Tools/MgInstantSetup/InstantSetup.Core/FdoProviderRegistration.cs
Modified:
   trunk/Tools/MgInstantSetup/InstantSetup.Core/InstantSetup.Core.csproj
   trunk/Tools/MgInstantSetup/InstantSetup/Form1.Designer.cs
   trunk/Tools/MgInstantSetup/InstantSetup/Form1.cs
Log:
#2026: Add InstantSetup support for setting up providers.xml. This was needed because our InstantSetup bundle packaging process leaves us with a blank providers.xml most of the time.

Modified: trunk/Tools/MgInstantSetup/InstantSetup/Form1.Designer.cs
===================================================================
--- trunk/Tools/MgInstantSetup/InstantSetup/Form1.Designer.cs	2012-06-14 09:27:41 UTC (rev 6761)
+++ trunk/Tools/MgInstantSetup/InstantSetup/Form1.Designer.cs	2012-06-14 14:04:07 UTC (rev 6762)
@@ -44,13 +44,26 @@
             this.label3 = new System.Windows.Forms.Label();
             this.chkWriteMentorDictPath = new System.Windows.Forms.CheckBox();
             this.chk64Bit = new System.Windows.Forms.CheckBox();
+            this.groupBox1 = new System.Windows.Forms.GroupBox();
+            this.groupBox2 = new System.Windows.Forms.GroupBox();
+            this.label7 = new System.Windows.Forms.Label();
+            this.chkProviders = new System.Windows.Forms.CheckedListBox();
+            this.label6 = new System.Windows.Forms.Label();
+            this.button3 = new System.Windows.Forms.Button();
+            this.button2 = new System.Windows.Forms.Button();
+            this.txtFdoRegUtilPath = new System.Windows.Forms.TextBox();
+            this.label5 = new System.Windows.Forms.Label();
+            this.txtFdoDir = new System.Windows.Forms.TextBox();
+            this.label4 = new System.Windows.Forms.Label();
             this.tabControl1.SuspendLayout();
+            this.groupBox1.SuspendLayout();
+            this.groupBox2.SuspendLayout();
             this.SuspendLayout();
             // 
             // btnConfigure
             // 
             this.btnConfigure.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
-            this.btnConfigure.Location = new System.Drawing.Point(465, 509);
+            this.btnConfigure.Location = new System.Drawing.Point(672, 563);
             this.btnConfigure.Name = "btnConfigure";
             this.btnConfigure.Size = new System.Drawing.Size(75, 23);
             this.btnConfigure.TabIndex = 0;
@@ -60,15 +73,13 @@
             // 
             // tabControl1
             // 
-            this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
-                        | System.Windows.Forms.AnchorStyles.Left)
-                        | System.Windows.Forms.AnchorStyles.Right)));
             this.tabControl1.Controls.Add(this.TAB_APACHE);
             this.tabControl1.Controls.Add(this.TAB_IIS7);
-            this.tabControl1.Location = new System.Drawing.Point(13, 111);
+            this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.tabControl1.Location = new System.Drawing.Point(3, 16);
             this.tabControl1.Name = "tabControl1";
             this.tabControl1.SelectedIndex = 0;
-            this.tabControl1.Size = new System.Drawing.Size(527, 392);
+            this.tabControl1.Size = new System.Drawing.Size(474, 423);
             this.tabControl1.TabIndex = 1;
             // 
             // TAB_APACHE
@@ -76,7 +87,7 @@
             this.TAB_APACHE.Location = new System.Drawing.Point(4, 22);
             this.TAB_APACHE.Name = "TAB_APACHE";
             this.TAB_APACHE.Padding = new System.Windows.Forms.Padding(3);
-            this.TAB_APACHE.Size = new System.Drawing.Size(519, 366);
+            this.TAB_APACHE.Size = new System.Drawing.Size(466, 397);
             this.TAB_APACHE.TabIndex = 1;
             this.TAB_APACHE.Text = "Apache";
             this.TAB_APACHE.UseVisualStyleBackColor = true;
@@ -86,7 +97,7 @@
             this.TAB_IIS7.Location = new System.Drawing.Point(4, 22);
             this.TAB_IIS7.Name = "TAB_IIS7";
             this.TAB_IIS7.Padding = new System.Windows.Forms.Padding(3);
-            this.TAB_IIS7.Size = new System.Drawing.Size(519, 390);
+            this.TAB_IIS7.Size = new System.Drawing.Size(466, 343);
             this.TAB_IIS7.TabIndex = 2;
             this.TAB_IIS7.Text = "IIS7";
             this.TAB_IIS7.UseVisualStyleBackColor = true;
@@ -106,7 +117,7 @@
                         | System.Windows.Forms.AnchorStyles.Right)));
             this.txtServiceName.Location = new System.Drawing.Point(156, 61);
             this.txtServiceName.Name = "txtServiceName";
-            this.txtServiceName.Size = new System.Drawing.Size(380, 20);
+            this.txtServiceName.Size = new System.Drawing.Size(587, 20);
             this.txtServiceName.TabIndex = 3;
             this.txtServiceName.TextChanged += new System.EventHandler(this.txtServiceName_TextChanged);
             // 
@@ -125,14 +136,14 @@
                         | System.Windows.Forms.AnchorStyles.Right)));
             this.txtSourceDirectory.Location = new System.Drawing.Point(156, 9);
             this.txtSourceDirectory.Name = "txtSourceDirectory";
-            this.txtSourceDirectory.Size = new System.Drawing.Size(345, 20);
+            this.txtSourceDirectory.Size = new System.Drawing.Size(552, 20);
             this.txtSourceDirectory.TabIndex = 5;
             this.txtSourceDirectory.TextChanged += new System.EventHandler(this.txtSourceDirectory_TextChanged);
             // 
             // btnSourceDir
             // 
             this.btnSourceDir.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
-            this.btnSourceDir.Location = new System.Drawing.Point(507, 7);
+            this.btnSourceDir.Location = new System.Drawing.Point(714, 7);
             this.btnSourceDir.Name = "btnSourceDir";
             this.btnSourceDir.Size = new System.Drawing.Size(29, 23);
             this.btnSourceDir.TabIndex = 6;
@@ -144,7 +155,7 @@
             // 
             this.chkInstallServices.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
             this.chkInstallServices.AutoSize = true;
-            this.chkInstallServices.Location = new System.Drawing.Point(13, 513);
+            this.chkInstallServices.Location = new System.Drawing.Point(13, 567);
             this.chkInstallServices.Name = "chkInstallServices";
             this.chkInstallServices.Size = new System.Drawing.Size(97, 17);
             this.chkInstallServices.TabIndex = 7;
@@ -156,7 +167,7 @@
             // button1
             // 
             this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
-            this.button1.Location = new System.Drawing.Point(507, 33);
+            this.button1.Location = new System.Drawing.Point(714, 33);
             this.button1.Name = "button1";
             this.button1.Size = new System.Drawing.Size(29, 23);
             this.button1.TabIndex = 10;
@@ -170,7 +181,7 @@
                         | System.Windows.Forms.AnchorStyles.Right)));
             this.txtBatchOutput.Location = new System.Drawing.Point(156, 35);
             this.txtBatchOutput.Name = "txtBatchOutput";
-            this.txtBatchOutput.Size = new System.Drawing.Size(345, 20);
+            this.txtBatchOutput.Size = new System.Drawing.Size(552, 20);
             this.txtBatchOutput.TabIndex = 9;
             this.txtBatchOutput.TextChanged += new System.EventHandler(this.txtBatchOutput_TextChanged);
             // 
@@ -185,8 +196,9 @@
             // 
             // chkWriteMentorDictPath
             // 
+            this.chkWriteMentorDictPath.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
             this.chkWriteMentorDictPath.AutoSize = true;
-            this.chkWriteMentorDictPath.Location = new System.Drawing.Point(116, 513);
+            this.chkWriteMentorDictPath.Location = new System.Drawing.Point(116, 567);
             this.chkWriteMentorDictPath.Name = "chkWriteMentorDictPath";
             this.chkWriteMentorDictPath.Size = new System.Drawing.Size(271, 17);
             this.chkWriteMentorDictPath.TabIndex = 11;
@@ -205,11 +217,124 @@
             this.chk64Bit.UseVisualStyleBackColor = true;
             this.chk64Bit.CheckedChanged += new System.EventHandler(this.chk64Bit_CheckedChanged);
             // 
+            // groupBox1
+            // 
+            this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+                        | System.Windows.Forms.AnchorStyles.Left)
+                        | System.Windows.Forms.AnchorStyles.Right)));
+            this.groupBox1.Controls.Add(this.tabControl1);
+            this.groupBox1.Location = new System.Drawing.Point(267, 111);
+            this.groupBox1.Name = "groupBox1";
+            this.groupBox1.Size = new System.Drawing.Size(480, 442);
+            this.groupBox1.TabIndex = 13;
+            this.groupBox1.TabStop = false;
+            this.groupBox1.Text = "Web";
+            // 
+            // groupBox2
+            // 
+            this.groupBox2.Controls.Add(this.label7);
+            this.groupBox2.Controls.Add(this.chkProviders);
+            this.groupBox2.Controls.Add(this.label6);
+            this.groupBox2.Controls.Add(this.button3);
+            this.groupBox2.Controls.Add(this.button2);
+            this.groupBox2.Controls.Add(this.txtFdoRegUtilPath);
+            this.groupBox2.Controls.Add(this.label5);
+            this.groupBox2.Controls.Add(this.txtFdoDir);
+            this.groupBox2.Controls.Add(this.label4);
+            this.groupBox2.Location = new System.Drawing.Point(12, 111);
+            this.groupBox2.Name = "groupBox2";
+            this.groupBox2.Size = new System.Drawing.Size(249, 439);
+            this.groupBox2.TabIndex = 14;
+            this.groupBox2.TabStop = false;
+            this.groupBox2.Text = "Server";
+            // 
+            // label7
+            // 
+            this.label7.Location = new System.Drawing.Point(19, 370);
+            this.label7.Name = "label7";
+            this.label7.Size = new System.Drawing.Size(206, 53);
+            this.label7.TabIndex = 8;
+            this.label7.Text = "NOTE: Some providers (eg. MySQL) require 3rd party external dependencies in order" +
+                " to sucessfully register";
+            // 
+            // chkProviders
+            // 
+            this.chkProviders.CheckOnClick = true;
+            this.chkProviders.FormattingEnabled = true;
+            this.chkProviders.HorizontalScrollbar = true;
+            this.chkProviders.Location = new System.Drawing.Point(20, 137);
+            this.chkProviders.Name = "chkProviders";
+            this.chkProviders.ScrollAlwaysVisible = true;
+            this.chkProviders.Size = new System.Drawing.Size(205, 229);
+            this.chkProviders.TabIndex = 7;
+            // 
+            // label6
+            // 
+            this.label6.AutoSize = true;
+            this.label6.Location = new System.Drawing.Point(16, 121);
+            this.label6.Name = "label6";
+            this.label6.Size = new System.Drawing.Size(113, 13);
+            this.label6.TabIndex = 6;
+            this.label6.Text = "Provider dlls to register";
+            // 
+            // button3
+            // 
+            this.button3.Location = new System.Drawing.Point(216, 86);
+            this.button3.Name = "button3";
+            this.button3.Size = new System.Drawing.Size(27, 23);
+            this.button3.TabIndex = 5;
+            this.button3.Text = "...";
+            this.button3.UseVisualStyleBackColor = true;
+            // 
+            // button2
+            // 
+            this.button2.Location = new System.Drawing.Point(216, 41);
+            this.button2.Name = "button2";
+            this.button2.Size = new System.Drawing.Size(27, 23);
+            this.button2.TabIndex = 4;
+            this.button2.Text = "...";
+            this.button2.UseVisualStyleBackColor = true;
+            // 
+            // txtFdoRegUtilPath
+            // 
+            this.txtFdoRegUtilPath.Location = new System.Drawing.Point(20, 88);
+            this.txtFdoRegUtilPath.Name = "txtFdoRegUtilPath";
+            this.txtFdoRegUtilPath.Size = new System.Drawing.Size(190, 20);
+            this.txtFdoRegUtilPath.TabIndex = 3;
+            // 
+            // label5
+            // 
+            this.label5.AutoSize = true;
+            this.label5.Location = new System.Drawing.Point(16, 72);
+            this.label5.Name = "label5";
+            this.label5.Size = new System.Drawing.Size(85, 13);
+            this.label5.TabIndex = 2;
+            this.label5.Text = "FdoRegUtil Path";
+            // 
+            // txtFdoDir
+            // 
+            this.txtFdoDir.Location = new System.Drawing.Point(20, 43);
+            this.txtFdoDir.Name = "txtFdoDir";
+            this.txtFdoDir.Size = new System.Drawing.Size(190, 20);
+            this.txtFdoDir.TabIndex = 1;
+            this.txtFdoDir.TextChanged += new System.EventHandler(this.txtFdoDir_TextChanged);
+            // 
+            // label4
+            // 
+            this.label4.AutoSize = true;
+            this.label4.Location = new System.Drawing.Point(16, 27);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(54, 13);
+            this.label4.TabIndex = 0;
+            this.label4.Text = "FDO Path";
+            // 
             // Form1
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(552, 544);
+            this.ClientSize = new System.Drawing.Size(759, 598);
+            this.Controls.Add(this.groupBox2);
+            this.Controls.Add(this.groupBox1);
             this.Controls.Add(this.chk64Bit);
             this.Controls.Add(this.chkWriteMentorDictPath);
             this.Controls.Add(this.button1);
@@ -221,11 +346,13 @@
             this.Controls.Add(this.label2);
             this.Controls.Add(this.txtServiceName);
             this.Controls.Add(this.label1);
-            this.Controls.Add(this.tabControl1);
             this.Controls.Add(this.btnConfigure);
             this.Name = "Form1";
             this.Text = "MapGuide Instant Setup";
             this.tabControl1.ResumeLayout(false);
+            this.groupBox1.ResumeLayout(false);
+            this.groupBox2.ResumeLayout(false);
+            this.groupBox2.PerformLayout();
             this.ResumeLayout(false);
             this.PerformLayout();
 
@@ -249,6 +376,17 @@
         private System.Windows.Forms.CheckBox chkWriteMentorDictPath;
         private System.Windows.Forms.TabPage TAB_IIS7;
         private System.Windows.Forms.CheckBox chk64Bit;
+        private System.Windows.Forms.GroupBox groupBox1;
+        private System.Windows.Forms.GroupBox groupBox2;
+        private System.Windows.Forms.TextBox txtFdoDir;
+        private System.Windows.Forms.Label label4;
+        private System.Windows.Forms.Label label7;
+        private System.Windows.Forms.CheckedListBox chkProviders;
+        private System.Windows.Forms.Label label6;
+        private System.Windows.Forms.Button button3;
+        private System.Windows.Forms.Button button2;
+        private System.Windows.Forms.TextBox txtFdoRegUtilPath;
+        private System.Windows.Forms.Label label5;
     }
 }
 

Modified: trunk/Tools/MgInstantSetup/InstantSetup/Form1.cs
===================================================================
--- trunk/Tools/MgInstantSetup/InstantSetup/Form1.cs	2012-06-14 09:27:41 UTC (rev 6761)
+++ trunk/Tools/MgInstantSetup/InstantSetup/Form1.cs	2012-06-14 14:04:07 UTC (rev 6762)
@@ -23,6 +23,8 @@
 using System.Drawing;
 using System.Text;
 using System.Windows.Forms;
+using System.IO;
+using InstantSetup.Core;
 
 namespace InstantSetup
 {
@@ -67,6 +69,7 @@
         private void txtSourceDirectory_TextChanged(object sender, EventArgs e)
         {
             _iis7Conf.Config.BuildOutputPath = _apacheConf.Config.BuildOutputPath = txtSourceDirectory.Text;
+            TryAutoConfigureFdo();
         }
 
         private void txtBatchOutput_TextChanged(object sender, EventArgs e)
@@ -93,6 +96,26 @@
         {
             try
             {
+                if (!Directory.Exists(txtFdoDir.Text))
+                {
+                    MessageBox.Show("The specified FDO directory does not exist");
+                    return;
+                }
+
+                if (!File.Exists(txtFdoRegUtilPath.Text))
+                {
+                    MessageBox.Show("The specified FdoRegUtil path does not exist");
+                    return;
+                }
+
+                if (chkProviders.CheckedItems.Count == 0)
+                {
+                    MessageBox.Show("No FDO providers selected for registration");
+                    return;
+                }
+
+                var reg = new FdoProviderRegistration(txtFdoRegUtilPath.Text, GetCheckedProviders());
+                reg.Execute();
                 GetActiveView().Config.Execute();
                 if (!chkInstallServices.Checked)
                     MessageBox.Show("Batch scripts saved to " + GetActiveView().Config.BatchFileOutputDirectory);
@@ -104,6 +127,14 @@
             }
         }
 
+        private IEnumerable<string> GetCheckedProviders()
+        {
+            foreach (var item in chkProviders.CheckedItems)
+            {
+                yield return item.ToString();
+            }
+        }
+
         private void button1_Click(object sender, EventArgs e)
         {
             if (folderBrowser.ShowDialog() == DialogResult.OK)
@@ -116,5 +147,45 @@
         {
             _iis7Conf.Config.Is64BitMapGuide = _apacheConf.Config.Is64BitMapGuide = chk64Bit.Checked;
         }
+
+        private void TryAutoConfigureFdo()
+        {
+            if (string.IsNullOrEmpty(txtFdoDir.Text))
+            {
+                var path = Path.Combine(txtSourceDirectory.Text, "Server" + Path.DirectorySeparatorChar + "FDO");
+                if (Directory.Exists(path))
+                    txtFdoDir.Text = path;
+            }
+        }
+
+        private void txtFdoDir_TextChanged(object sender, EventArgs e)
+        {
+            if (!Directory.Exists(txtFdoDir.Text))
+                return;
+
+            if (string.IsNullOrEmpty(txtFdoRegUtilPath.Text))
+            {
+                var path = Path.Combine(txtFdoDir.Text, "FdoRegUtil.exe");
+                if (File.Exists(path))
+                    txtFdoRegUtilPath.Text = path;
+            }
+            var dlls = Directory.GetFiles(txtFdoDir.Text, "*.dll");
+            var list = new List<string>();
+            //Fortunately, FDO providers follow a standard convention of ending with
+            //provider.dll
+            foreach (var dllpath in dlls)
+            {
+                if (dllpath.ToLower().EndsWith("provider.dll"))
+                {
+                    list.Add(dllpath);
+                }
+            }
+
+            chkProviders.Items.Clear();
+            foreach (var item in list)
+            {
+                chkProviders.Items.Add(item, false);
+            }
+        }
     }
 }

Added: trunk/Tools/MgInstantSetup/InstantSetup.Core/FdoProviderRegistration.cs
===================================================================
--- trunk/Tools/MgInstantSetup/InstantSetup.Core/FdoProviderRegistration.cs	                        (rev 0)
+++ trunk/Tools/MgInstantSetup/InstantSetup.Core/FdoProviderRegistration.cs	2012-06-14 14:04:07 UTC (rev 6762)
@@ -0,0 +1,71 @@
+#region Disclaimer / License
+// Copyright (C) 2012, Jackie Ng, jumpinjackie at gmail.com
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+// 
+#endregion
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.IO;
+using System.Xml;
+
+namespace InstantSetup.Core
+{
+    public class FdoProviderRegistration
+    {
+        private string _fdoRegUtilPath;
+
+        private IEnumerable<string> _providerDllPaths;
+
+        public FdoProviderRegistration(string fdoRegUtilPath, IEnumerable<string> providerDllPaths)
+        {
+            _fdoRegUtilPath = fdoRegUtilPath;
+            _providerDllPaths = providerDllPaths;
+        }
+
+        public FdoRegistrationResult[] Execute()
+        {
+            var providersXmlPath = Path.Combine(Path.GetDirectoryName(_fdoRegUtilPath), "providers.xml");
+            var doc = new XmlDocument();
+            doc.InnerXml = "<FeatureProviderRegistry></FeatureProviderRegistry>";
+            doc.Save(providersXmlPath);
+
+            List<FdoRegistrationResult> results = new List<FdoRegistrationResult>();
+            foreach (var dllPath in _providerDllPaths)
+            {
+                var dll = System.IO.Path.GetFileName(dllPath);
+                var proc = new System.Diagnostics.Process();
+                var psi = proc.StartInfo;
+                psi.FileName = _fdoRegUtilPath;
+                psi.WorkingDirectory = System.IO.Path.GetDirectoryName(_fdoRegUtilPath);
+                psi.Arguments = "-r " + dll;
+
+                proc.Start();
+                proc.WaitForExit();
+
+                results.Add(new FdoRegistrationResult() { DllPath = dllPath, ReturnCode = proc.ExitCode });
+            }
+            return results.ToArray();
+        }
+    }
+
+    public class FdoRegistrationResult
+    {
+        public string DllPath { get; set; }
+
+        public int ReturnCode { get; set; }
+    }
+}

Modified: trunk/Tools/MgInstantSetup/InstantSetup.Core/InstantSetup.Core.csproj
===================================================================
--- trunk/Tools/MgInstantSetup/InstantSetup.Core/InstantSetup.Core.csproj	2012-06-14 09:27:41 UTC (rev 6761)
+++ trunk/Tools/MgInstantSetup/InstantSetup.Core/InstantSetup.Core.csproj	2012-06-14 14:04:07 UTC (rev 6762)
@@ -41,6 +41,7 @@
     <Compile Include="AbstractSetupConfigurationProcess.cs" />
     <Compile Include="ApacheSetupConfigurationProcess.cs" />
     <Compile Include="AppCmd.cs" />
+    <Compile Include="FdoProviderRegistration.cs" />
     <Compile Include="IISSetupConfigurationProcess.cs" />
     <Compile Include="IniFile.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />



More information about the mapguide-commits mailing list