#At file:///C:/Users/Reggie/work/wex/installer-updated/ based on revid:reggie.burnett@strippedwn7kva5oo4hcyd
322 Reggie Burnett 2011-02-09
more changes related to developing new Examples plugin
removed:
StandardPlugins/Examples/ExamplesConfigPanel1.Designer.cs
StandardPlugins/Examples/ExamplesConfigPanel1.cs
StandardPlugins/Examples/ExamplesConfigPanel1.resx
WexInstaller/Core/
WexInstaller/Core/IniTemplate.cs
WexInstaller/Core/MysqlSCM.cs
renamed:
WexInstaller/Core/ListViewWex.cs => WexInstaller/Controls/ListViewWex.cs
WexInstaller/Core/Options.cs => WexInstaller.Core/Options.cs
WexInstaller/Core/ProductManager.cs => WexInstaller.Core/ProductManager.cs
WexInstaller/Core/ProductManifest.cs => WexInstaller.Core/ProductManifest.cs
WexInstaller/Core/ProductVersion.cs => WexInstaller.Core/ProductVersion.cs
modified:
Examples/Product.wxs
StandardPlugins/Examples/ConfigurationController.cs
StandardPlugins/Properties/Resources.Designer.cs
StandardPlugins/Properties/Resources.resx
StandardPlugins/StandardPlugins.csproj
WexInstaller.Core/Product.cs
WexInstaller.Core/ProductConfigurationController.cs
WexInstaller.Core/WexInstaller.Core.csproj
WexInstaller/Controls/InstallWizardControl.cs
WexInstaller/WexInstaller.csproj
WexInstaller.Core/ProductManager.cs
WexInstaller.Core/ProductManifest.cs
=== modified file 'Examples/Product.wxs'
=== modified file 'Examples/Product.wxs'
--- a/Examples/Product.wxs 2011-02-09 13:49:30 +0000
+++ b/Examples/Product.wxs 2011-02-09 17:35:42 +0000
@@ -9,7 +9,17 @@
<Directory Id="ProgramFilesFolder">
<Directory Id="MySQLFolder" Name="MySQL">
<Directory Id="INSTALLLOCATION" Name="Samples and Examples">
+ <Component Id="C_RegistryKey" Guid="">
+ <RegistryKey Id="MainRegistryKey" Action="createAndRemoveOnUninstall" Root="HKLM" Key="Software\MySQL AB\MySQL Examples 5.1">
+ <RegistryValue Name="Location" Value="[INSTALLLOCATION]" Type="string"/>
+ </RegistryKey>
+ </Component>
<Directory Id="SampleDBFolder" Name="Sample Databases">
+ <Component Id="C_SampleDBRegistryKey" Guid="">
+ <RegistryKey Id="SampleDBRegistryKey" Action="createAndRemoveOnUninstall" Root="HKLM" Key="Software\MySQL AB\MySQL Examples 5.1">
+ <RegistryValue Name="Sample Databases" Value="[SampleDBFolder]" Type="string"/>
+ </RegistryKey>
+ </Component>
<Component Id="WorldDBComponent" Guid="8BD6E222-AC47-4FD0-96A6-7EEA75D62A10">
<File Name="world.sql" Source="Sample DB\world.sql"/>
<File Name="world_innodb.sql" Source="Sample DB\world_innodb.sql"/>
@@ -39,6 +49,8 @@
</Directory>
<Feature Id="SampleDB" Title="Sample Databases" Level="1">
+ <ComponentRef Id="C_RegistryKey"/>
+ <ComponentRef Id="C_SampleDBRegistryKey"/>
<ComponentRef Id="WorldDBComponent" />
<ComponentRef Id="SakilaDBComponent" />
<ComponentRef Id="MenagerieDBComponent" />
=== modified file 'StandardPlugins/Examples/ConfigurationController.cs'
--- a/StandardPlugins/Examples/ConfigurationController.cs 2011-02-09 13:49:30 +0000
+++ b/StandardPlugins/Examples/ConfigurationController.cs 2011-02-09 17:35:42 +0000
@@ -10,50 +10,152 @@
using System.ComponentModel;
using System.Threading;
using System.Diagnostics;
+using WexInstaller.Plugins.Properties;
namespace WexInstaller.Plugins
{
[ProductConfiguration("examples", 1)]
public class ExamplesConfigurationController : ProductConfigurationController
{
- UserControl[] pages = new UserControl[1];
-
List<string> sampleDbNames = new List<string>();
-
+ ProductCatalog ourCatalog;
+ Product serverProductInCatalog;
+ bool alreadySearchedForServer;
+ string connectionString;
+ List<string> featuresToConfigure = null;
+
public List<ServerProductConfigurationController> Servers = new List<ServerProductConfigurationController>();
public override int NumPages
{
- get { return pages.Length; }
+ get { return 0; }
}
public override UserControl[] Pages
{
- get { return pages; }
+ get { return null; }
}
public override void Initialize()
{
- pages[0] = new ExamplesConfigStep1(this);
sampleDbNames.Add("World");
sampleDbNames.Add("World (InnoDB)");
sampleDbNames.Add("Sakila");
sampleDbNames.Add("Menagerie");
}
- public override void PostAction(ConfigurationAction action)
- {
- if (action == ConfigurationAction.Install)
- {
- // now we need a list of all running servers
- Servers = PluginManager.Instance.GetServerControllers(true);
- }
- base.PostAction(action);
- }
-
protected override void BackgroundConfigure(object sender, DoWorkEventArgs e)
{
- base.BackgroundConfigure(sender, e);
+ // determine if we have any features to configure
+ if (featuresToConfigure == null)
+ CheckForFeaturesToConfigure();
+ if (featuresToConfigure.Count == 0)
+ {
+ ReportStatus(ConfigurationEventType.Success, null, Resources.ConfigSuccessNoFeaturesToConfig, 100);
+ return;
+ }
+
+ // determine what our catalog is
+ if (ourCatalog == null)
+ ourCatalog = GetOurCatalog();
+ if (ourCatalog == null) return;
+
+ // now find server in the catalog
+ if (serverProductInCatalog == null && !alreadySearchedForServer)
+ serverProductInCatalog = GetServerProductInCatalog();
+ if (serverProductInCatalog == null)
+ {
+ ReportStatus(ConfigurationEventType.Error, "", "Unable to configure as there is no server product available", 100);
+ return;
+ }
+
+ // now make sure the server product is installed
+ if (!serverProductInCatalog.Installed)
+ {
+ ReportStatus(ConfigurationEventType.Error, "", Resources.ConfigErrorServerNotInstalled, 100);
+ return;
+ }
+
+ // now make sure the server product is running
+ ServerProductConfigurationController controller = serverProductInCatalog.Controller as ServerProductConfigurationController;
+ if (!controller.IsRunning)
+ {
+ ReportStatus(ConfigurationEventType.Error, "", Resources.ConfigErrorServerNotRunning, 100);
+ return;
+ }
+
+ // now ask the controller for a connection string, prompting for credentials if we need to
+ connectionString = controller.GetConnectionString(true);
+ if (String.IsNullOrEmpty(connectionString))
+ {
+ ReportStatus(ConfigurationEventType.Error, "", Resources.ConfigErrorServerBadConnectionString, 100);
+ return;
+ }
+
+ RunDatabaseScripts();
+ }
+
+ /// <summary>
+ /// Looks at the features for this product and returns all features that installed and need configuring
+ /// </summary>
+ private void CheckForFeaturesToConfigure()
+ {
+ featuresToConfigure = new List<string>();
+
+ ReportStatus(ConfigurationEventType.Info, null, Resources.ConfigInfoCheckingFeaturesToConfigure, 10);
+ foreach (ProductFeature feature in Owner.GetProductFeatures())
+ {
+ string lowerFeatureName = feature.Name.ToLowerInvariant();
+ if (lowerFeatureName.StartsWith("sampledb_") && feature.Installed)
+ featuresToConfigure.Add(feature.Name);
+ }
+ }
+
+ private void RunDatabaseScripts()
+ {
+ }
+
+ private Product GetServerProductInCatalog()
+ {
+ if (alreadySearchedForServer) return serverProductInCatalog;
+
+ alreadySearchedForServer = true;
+ // if we are not in a catalog, then return no product
+ if (ourCatalog == null)
+ {
+ ReportStatus(ConfigurationEventType.Info, "SERVER_PRODUCT",
+ "Unable to determine server product as we are not in a catalog", 100);
+ return null;
+ }
+
+ // find out what catalog our owner belongs to
+ ReportStatus(ConfigurationEventType.Info, "SERVER_PRODUCT", "Determining server product in catalog", 15);
+
+ foreach (CatalogProduct catalogProduct in ourCatalog.Products)
+ if (catalogProduct.ReferencedProduct.IsServerProduct)
+ {
+ ReportStatus(ConfigurationEventType.Success, "SERVER_PRODUCT",
+ "Successfully determined server product in our catalog", 20);
+ return catalogProduct.ReferencedProduct;
+ }
+ ReportError("SERVER_PRODUCT", "Failed to determine server product in our catalog");
+ return null;
+ }
+
+ private ProductCatalog GetOurCatalog()
+ {
+ // find out what catalog our owner belongs to
+ ReportStatus(ConfigurationEventType.Info, "CATALOG", "Determining product catalog", 0);
+
+ foreach (ProductCatalog catalog in ProductManager.Catalogs)
+ foreach (CatalogProduct catalogProduct in catalog.Products)
+ if (catalogProduct.ReferencedProduct == Owner)
+ {
+ ReportStatus(ConfigurationEventType.Success, "CATALOG", "Successfully determined product catalog", 10);
+ return catalog;
+ }
+ ReportError("CATALOG", "Failed to determine product catalog");
+ return null;
}
}
}
=== removed file 'StandardPlugins/Examples/ExamplesConfigPanel1.Designer.cs'
--- a/StandardPlugins/Examples/ExamplesConfigPanel1.Designer.cs 2011-02-09 13:49:30 +0000
+++ b/StandardPlugins/Examples/ExamplesConfigPanel1.Designer.cs 1970-01-01 00:00:00 +0000
@@ -1,170 +0,0 @@
-using WexInstaller.Plugins.Properties;
-namespace WexInstaller.Plugins
-{
- partial class ExamplesConfigStep1
- {
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.IContainer components = null;
-
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Component Designer generated code
-
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- this.actionLabel = new System.Windows.Forms.Label();
- this.label1 = new System.Windows.Forms.Label();
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.label2 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- this.label4 = new System.Windows.Forms.Label();
- this.serverList1 = new System.Windows.Forms.ComboBox();
- this.serverList2 = new System.Windows.Forms.ComboBox();
- this.serverList3 = new System.Windows.Forms.ComboBox();
- this.serverList4 = new System.Windows.Forms.ComboBox();
- this.groupBox1.SuspendLayout();
- this.SuspendLayout();
- //
- // actionLabel
- //
- this.actionLabel.Font = new System.Drawing.Font("Tahoma", 10F);
- this.actionLabel.Location = new System.Drawing.Point(12, 80);
- this.actionLabel.Name = "actionLabel";
- this.actionLabel.Size = new System.Drawing.Size(443, 23);
- this.actionLabel.TabIndex = 2;
- this.actionLabel.Text = "Please select the install actions for each of the sample databases";
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(39, 38);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(35, 13);
- this.label1.TabIndex = 3;
- this.label1.Text = "World";
- //
- // groupBox1
- //
- this.groupBox1.Controls.Add(this.serverList4);
- this.groupBox1.Controls.Add(this.serverList3);
- this.groupBox1.Controls.Add(this.serverList2);
- this.groupBox1.Controls.Add(this.serverList1);
- this.groupBox1.Controls.Add(this.label4);
- this.groupBox1.Controls.Add(this.label3);
- this.groupBox1.Controls.Add(this.label2);
- this.groupBox1.Controls.Add(this.label1);
- this.groupBox1.Location = new System.Drawing.Point(37, 125);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(418, 288);
- this.groupBox1.TabIndex = 4;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "Sample Databases";
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(39, 88);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(81, 13);
- this.label2.TabIndex = 4;
- this.label2.Text = "World (InnoDB)";
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(39, 140);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(34, 13);
- this.label3.TabIndex = 5;
- this.label3.Text = "Sakila";
- //
- // label4
- //
- this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(39, 188);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(57, 13);
- this.label4.TabIndex = 6;
- this.label4.Text = "Menagerie";
- //
- // serverList1
- //
- this.serverList1.FormattingEnabled = true;
- this.serverList1.Location = new System.Drawing.Point(185, 35);
- this.serverList1.Name = "serverList1";
- this.serverList1.Size = new System.Drawing.Size(182, 21);
- this.serverList1.TabIndex = 7;
- //
- // serverList2
- //
- this.serverList2.FormattingEnabled = true;
- this.serverList2.Location = new System.Drawing.Point(185, 88);
- this.serverList2.Name = "serverList2";
- this.serverList2.Size = new System.Drawing.Size(182, 21);
- this.serverList2.TabIndex = 8;
- //
- // serverList3
- //
- this.serverList3.FormattingEnabled = true;
- this.serverList3.Location = new System.Drawing.Point(185, 137);
- this.serverList3.Name = "serverList3";
- this.serverList3.Size = new System.Drawing.Size(182, 21);
- this.serverList3.TabIndex = 9;
- //
- // serverList4
- //
- this.serverList4.FormattingEnabled = true;
- this.serverList4.Location = new System.Drawing.Point(185, 185);
- this.serverList4.Name = "serverList4";
- this.serverList4.Size = new System.Drawing.Size(182, 21);
- this.serverList4.TabIndex = 10;
- //
- // ExamplesConfigStep1
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.Controls.Add(this.groupBox1);
- this.Controls.Add(this.actionLabel);
- this.DoubleBuffered = true;
- this.Name = "ExamplesConfigStep1";
- this.Size = new System.Drawing.Size(560, 499);
- this.Controls.SetChildIndex(this.actionLabel, 0);
- this.Controls.SetChildIndex(this.groupBox1, 0);
- this.groupBox1.ResumeLayout(false);
- this.groupBox1.PerformLayout();
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private System.Windows.Forms.Label actionLabel;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.ComboBox serverList4;
- private System.Windows.Forms.ComboBox serverList3;
- private System.Windows.Forms.ComboBox serverList2;
- private System.Windows.Forms.ComboBox serverList1;
- private System.Windows.Forms.Label label4;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.Label label2;
- }
-}
=== removed file 'StandardPlugins/Examples/ExamplesConfigPanel1.cs'
--- a/StandardPlugins/Examples/ExamplesConfigPanel1.cs 2011-02-09 13:49:30 +0000
+++ b/StandardPlugins/Examples/ExamplesConfigPanel1.cs 1970-01-01 00:00:00 +0000
@@ -1,39 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Drawing;
-using System.Data;
-using System.Text;
-using System.Windows.Forms;
-using WexInstaller.Core;
-
-namespace WexInstaller.Plugins
-{
- public partial class ExamplesConfigStep1 : InstallerPanel
- {
- public ExamplesConfigStep1(ExamplesConfigurationController controller)
- {
- InitializeComponent();
- Caption = "Examples Configuration";
- Controller = controller;
- }
-
- private ExamplesConfigurationController Controller { get; set; }
-
- public override void Activate()
- {
- PopulateServerList(serverList1);
- PopulateServerList(serverList2);
- PopulateServerList(serverList3);
- PopulateServerList(serverList4);
- base.Activate();
- }
-
- private void PopulateServerList(ComboBox serverList)
- {
- serverList.Items.Add("Do not install");
- foreach (ServerProductConfigurationController server in Controller.Servers)
- serverList.Items.Add(server.Owner.TitleWithVersion);
- }
- }
-}
=== removed file 'StandardPlugins/Examples/ExamplesConfigPanel1.resx'
--- a/StandardPlugins/Examples/ExamplesConfigPanel1.resx 2011-02-09 13:49:30 +0000
+++ b/StandardPlugins/Examples/ExamplesConfigPanel1.resx 1970-01-01 00:00:00 +0000
@@ -1,120 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<root>
- <!--
- Microsoft ResX Schema
-
- Version 2.0
-
- The primary goals of this format is to allow a simple XML format
- that is mostly human readable. The generation and parsing of the
- various data types are done through the TypeConverter classes
- associated with the data types.
-
- Example:
-
- ... ado.net/XML headers & schema ...
- <resheader name="resmimetype">text/microsoft-resx</resheader>
- <resheader name="version">2.0</resheader>
- <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
- <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
- <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
- <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
- <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
- <value>[base64 mime encoded serialized .NET Framework object]</value>
- </data>
- <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
- <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
- <comment>This is a comment</comment>
- </data>
-
- There are any number of "resheader" rows that contain simple
- name/value pairs.
-
- Each data row contains a name, and value. The row also contains a
- type or mimetype. Type corresponds to a .NET class that support
- text/value conversion through the TypeConverter architecture.
- Classes that don't support this are serialized and stored with the
- mimetype set.
-
- The mimetype is used for serialized objects, and tells the
- ResXResourceReader how to depersist the object. This is currently not
- extensible. For a given mimetype the value must be set accordingly:
-
- Note - application/x-microsoft.net.object.binary.base64 is the format
- that the ResXResourceWriter will generate, however the reader can
- read any of the formats listed below.
-
- mimetype: application/x-microsoft.net.object.binary.base64
- value : The object must be serialized with
- : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
- : and then encoded with base64 encoding.
-
- mimetype: application/x-microsoft.net.object.soap.base64
- value : The object must be serialized with
- : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
- : and then encoded with base64 encoding.
-
- mimetype: application/x-microsoft.net.object.bytearray.base64
- value : The object must be serialized into a byte array
- : using a System.ComponentModel.TypeConverter
- : and then encoded with base64 encoding.
- -->
- <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
- <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
- <xsd:element name="root" msdata:IsDataSet="true">
- <xsd:complexType>
- <xsd:choice maxOccurs="unbounded">
- <xsd:element name="metadata">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" />
- </xsd:sequence>
- <xsd:attribute name="name" use="required" type="xsd:string" />
- <xsd:attribute name="type" type="xsd:string" />
- <xsd:attribute name="mimetype" type="xsd:string" />
- <xsd:attribute ref="xml:space" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="assembly">
- <xsd:complexType>
- <xsd:attribute name="alias" type="xsd:string" />
- <xsd:attribute name="name" type="xsd:string" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="data">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
- <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
- <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
- <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
- <xsd:attribute ref="xml:space" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="resheader">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required" />
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- </xsd:complexType>
- </xsd:element>
- </xsd:schema>
- <resheader name="resmimetype">
- <value>text/microsoft-resx</value>
- </resheader>
- <resheader name="version">
- <value>2.0</value>
- </resheader>
- <resheader name="reader">
- <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
- <resheader name="writer">
- <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
-</root>
\ No newline at end of file
=== modified file 'StandardPlugins/Properties/Resources.Designer.cs'
--- a/StandardPlugins/Properties/Resources.Designer.cs 2011-02-07 21:39:05 +0000
+++ b/StandardPlugins/Properties/Resources.Designer.cs 2011-02-09 17:35:42 +0000
@@ -95,6 +95,51 @@
}
}
+ /// <summary>
+ /// Looks up a localized string similar to Unable to configure as the connection string returns is null or empty.
+ /// </summary>
+ internal static string ConfigErrorServerBadConnectionString {
+ get {
+ return ResourceManager.GetString("ConfigErrorServerBadConnectionString", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Unable to configure as the server product in our catalog is not installed.
+ /// </summary>
+ internal static string ConfigErrorServerNotInstalled {
+ get {
+ return ResourceManager.GetString("ConfigErrorServerNotInstalled", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Unable to configure as the server product in our catalog is not running.
+ /// </summary>
+ internal static string ConfigErrorServerNotRunning {
+ get {
+ return ResourceManager.GetString("ConfigErrorServerNotRunning", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Checking if there are any features installed that need configuration..
+ /// </summary>
+ internal static string ConfigInfoCheckingFeaturesToConfigure {
+ get {
+ return ResourceManager.GetString("ConfigInfoCheckingFeaturesToConfigure", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to There are no features installed that need configuration..
+ /// </summary>
+ internal static string ConfigSuccessNoFeaturesToConfig {
+ get {
+ return ResourceManager.GetString("ConfigSuccessNoFeaturesToConfig", resourceCulture);
+ }
+ }
+
internal static System.Drawing.Bitmap dedicated_machine {
get {
object obj = ResourceManager.GetObject("dedicated_machine", resourceCulture);
=== modified file 'StandardPlugins/Properties/Resources.resx'
--- a/StandardPlugins/Properties/Resources.resx 2011-02-07 21:39:05 +0000
+++ b/StandardPlugins/Properties/Resources.resx 2011-02-09 17:35:42 +0000
@@ -117,7 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
- <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+ <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="ActionCurrent" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ActionCurrent.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
@@ -127,7 +127,6 @@
<data name="ActionError" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ActionError.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
- <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="ActionOpen" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ActionOpen.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
@@ -167,4 +166,19 @@
<data name="warning_sign" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\warning_sign.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
+ <data name="ConfigErrorServerBadConnectionString" xml:space="preserve">
+ <value>Unable to configure as the connection string returns is null or empty</value>
+ </data>
+ <data name="ConfigErrorServerNotInstalled" xml:space="preserve">
+ <value>Unable to configure as the server product in our catalog is not installed</value>
+ </data>
+ <data name="ConfigErrorServerNotRunning" xml:space="preserve">
+ <value>Unable to configure as the server product in our catalog is not running</value>
+ </data>
+ <data name="ConfigInfoCheckingFeaturesToConfigure" xml:space="preserve">
+ <value>Checking if there are any features installed that need configuration.</value>
+ </data>
+ <data name="ConfigSuccessNoFeaturesToConfig" xml:space="preserve">
+ <value>There are no features installed that need configuration.</value>
+ </data>
</root>
\ No newline at end of file
=== modified file 'StandardPlugins/StandardPlugins.csproj'
--- a/StandardPlugins/StandardPlugins.csproj 2011-02-09 14:52:59 +0000
+++ b/StandardPlugins/StandardPlugins.csproj 2011-02-09 17:35:42 +0000
@@ -56,7 +56,9 @@
<Compile Include="Server\MysqlSCM.cs">
<SubType>Component</SubType>
</Compile>
- <Compile Include="Server\ServerConfigPanel1.cs" />
+ <Compile Include="Server\ServerConfigPanel1.cs">
+ <SubType>UserControl</SubType>
+ </Compile>
<Compile Include="Server\ServerConfigPanel1.Designer.cs">
<DependentUpon>ServerConfigPanel1.cs</DependentUpon>
</Compile>
=== renamed file 'WexInstaller/Core/Options.cs' => 'WexInstaller.Core/Options.cs'
=== modified file 'WexInstaller.Core/Product.cs'
--- a/WexInstaller.Core/Product.cs 2011-02-08 21:28:42 +0000
+++ b/WexInstaller.Core/Product.cs 2011-02-09 17:35:42 +0000
@@ -156,6 +156,12 @@
}
}
+ [XmlIgnore]
+ public bool IsServerProduct
+ {
+ get { return Name.StartsWith("mysql-server"); }
+ }
+
public string GetUpgradeDisplayString()
{
string upgradeDisplayString = String.Empty;
=== modified file 'WexInstaller.Core/ProductConfigurationController.cs'
--- a/WexInstaller.Core/ProductConfigurationController.cs 2011-02-09 14:52:59 +0000
+++ b/WexInstaller.Core/ProductConfigurationController.cs 2011-02-09 17:35:42 +0000
@@ -68,6 +68,20 @@
public virtual void PostAction() { }
protected virtual void ReportConfigStatus(ConfigurationEventArgs args) { }
+ protected void ReportStatus(ConfigurationEventType type, string action, string details, int progress)
+ {
+ ConfigurationEventArgs args = new ConfigurationEventArgs(type, action);
+ args.Details = details;
+ args.PercentComplete = progress;
+ OnConfigured(args);
+ }
+
+ protected void ReportError(string action, string details)
+ {
+ CurrentState = ConfigState.ConfigurationError;
+ ReportStatus(ConfigurationEventType.Error, action, details, 100);
+ }
+
public event ConfigurationEventHandler Configured;
private void OnConfigured(ConfigurationEventArgs args)
{
=== renamed file 'WexInstaller/Core/ProductManager.cs' => 'WexInstaller.Core/ProductManager.cs'
--- a/WexInstaller/Core/ProductManager.cs 2011-02-08 18:41:30 +0000
+++ b/WexInstaller.Core/ProductManager.cs 2011-02-09 17:35:42 +0000
@@ -7,7 +7,6 @@
using System.ComponentModel;
using System.Collections.ObjectModel;
using WexInstaller.Core;
-using WexInstaller.Properties;
using System.Reflection;
using System.Threading;
=== renamed file 'WexInstaller/Core/ProductManifest.cs' => 'WexInstaller.Core/ProductManifest.cs'
--- a/WexInstaller/Core/ProductManifest.cs 2011-01-24 17:24:16 +0000
+++ b/WexInstaller.Core/ProductManifest.cs 2011-02-09 17:35:42 +0000
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.IO;
=== renamed file 'WexInstaller/Core/ProductVersion.cs' => 'WexInstaller.Core/ProductVersion.cs'
=== modified file 'WexInstaller.Core/WexInstaller.Core.csproj'
--- a/WexInstaller.Core/WexInstaller.Core.csproj 2011-02-09 13:49:30 +0000
+++ b/WexInstaller.Core/WexInstaller.Core.csproj 2011-02-09 17:35:42 +0000
@@ -50,6 +50,7 @@
<Compile Include="LoggerListener.cs" />
<Compile Include="MirrorsXML.cs" />
<Compile Include="MsiInterop.cs" />
+ <Compile Include="Options.cs" />
<Compile Include="Package.cs" />
<Compile Include="PluginManager.cs" />
<Compile Include="Product.cs" />
@@ -58,6 +59,8 @@
<Compile Include="ProductFeature.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="ProductManager.cs" />
+ <Compile Include="ProductManifest.cs" />
<Compile Include="RootPasswordPromptDlg.cs">
<SubType>Form</SubType>
</Compile>
=== modified file 'WexInstaller/Controls/InstallWizardControl.cs'
--- a/WexInstaller/Controls/InstallWizardControl.cs 2011-02-08 21:54:02 +0000
+++ b/WexInstaller/Controls/InstallWizardControl.cs 2011-02-09 17:35:42 +0000
@@ -74,13 +74,17 @@
wizardPages.TabPages.Remove(finalPage);
ProductConfigurationController c = p.Controller;
- foreach (UserControl page in c.Pages)
+
+ if (c.NumPages > 0 && c.Pages != null)
{
- TabPage tab = new TabPage("Config");
- tab.Controls.Add(page);
- page.Dock = DockStyle.Fill;
- tab.Hide();
- wizardPages.TabPages.Add(tab);
+ foreach (UserControl page in c.Pages)
+ {
+ TabPage tab = new TabPage("Config");
+ tab.Controls.Add(page);
+ page.Dock = DockStyle.Fill;
+ tab.Hide();
+ wizardPages.TabPages.Add(tab);
+ }
}
wizardPages.TabPages.Add(finalPage);
=== renamed file 'WexInstaller/Core/ListViewWex.cs' => 'WexInstaller/Controls/ListViewWex.cs'
=== removed directory 'WexInstaller/Core'
=== removed file 'WexInstaller/Core/IniTemplate.cs'
--- a/WexInstaller/Core/IniTemplate.cs 2010-07-26 16:54:03 +0000
+++ b/WexInstaller/Core/IniTemplate.cs 1970-01-01 00:00:00 +0000
@@ -1,1172 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.Text;
-using System.Text.RegularExpressions;
-
-namespace WexInstaller.Core
-{
- public class IniTemplateStatic
- {
- protected string line_as_read;
-
- public IniTemplateStatic(string input)
- {
- line_as_read = input;
- }
-
- public string LineAsRead
- {
- get { return line_as_read; }
- }
- }
-
- public class IniTemplateVariable : IniTemplateStatic
- {
- private string variable_name;
- private string formula;
- private string options;
- private string output_parameter;
- private string default_value;
- private bool reduce_result;
- private bool disabled;
-
- public IniTemplateVariable(string input, string name, string form, string opt)
- : base(input)
- {
- variable_name = name;
- formula = form;
- options = opt;
- reduce_result = opt.Contains("USE_BYTES");
- disabled = false;
- }
-
- public string VariableName
- {
- get { return variable_name; }
- }
- public string Formula
- {
- get { return formula; }
- }
- public string Options
- {
- get { return options; }
- }
- public bool ReduceResult
- {
- get { return reduce_result; }
- set { reduce_result = value; }
- }
- public bool Disabled
- {
- get { return disabled; }
- set { disabled = value; }
- }
- public string OutputParameter
- {
- get { return output_parameter; }
- set { output_parameter = value; }
- }
- public string DefaultValue
- {
- get { return default_value; }
- set { default_value = value; }
- }
- }
-
- public enum IniServerType
- {
- Developer,
- Server,
- Dedicated,
- InternalUnitTest // This will produce an unusable template file that is suitable testing on disparate hardware.
- }
-
- public class IniTemplate
- {
- #region Private
- private string template;
- private FormulaEngine fe;
- private Queue output;
- private IniServerType ist;
-
- private void SetDefaults()
- {
- fe = new FormulaEngine();
- output = new Queue();
- EnableStrictMode = true;
- EnableNetworking = true;
- DefaultCharacterSet = "utf8";
- InnoDBHomeDir = "";
- DefaultStorageEngine = "INNODB";
- Port = "3306";
- SkipInnodb = false;
- Reconfiguring = false;
- IsValid = false;
- OutputExists = false;
- ServerType = IniServerType.Developer;
- FoundExistingDataDir = false;
- }
-
- private bool OpenTemplate(string templateName)
- {
- bool great_success = false;
-
- try
- {
- StreamReader reader = new StreamReader(templateName);
- string current_line = null;
-
- while (!reader.EndOfStream)
- {
- current_line = reader.ReadLine();
-
- if (current_line.StartsWith("##")) // Template comment, do not output
- continue;
-
- if (current_line.StartsWith("# [")) // # [VARIABLE_NAME]="Forumla", "Options"
- {
- Regex TemplateFormulaExp = new Regex(@"\[(?<var_name>[^@]+)\]=""(?<formula>[^""]+)""((?:,\s*"")(?<options>[^@]+)?(?:""))?");
- Match m = TemplateFormulaExp.Match(current_line);
-
- if (m.Success)
- {
- string variable_name = m.Groups["var_name"].Value;
- IniTemplateVariable itv = new IniTemplateVariable(current_line, variable_name, m.Groups["formula"].Value, m.Groups["options"].Value);
-
- if (variable_name != "STATE_CHANGE")
- {
- current_line = reader.ReadLine();
- Regex TemplateOutputFormat = new Regex(@"(?<disabled>[#\s]+)?(?<output>.+)=(?<default>.+)?");
- Match m2 = TemplateOutputFormat.Match(current_line);
- if (m2.Success)
- {
- itv.DefaultValue = m2.Groups["default"].Value;
- itv.Disabled = m2.Groups["disabled"].Value.Contains("#");
- itv.OutputParameter = m2.Groups["output"].Value;
- }
-
- // Attempt to set values from template, just the basics.
- switch (itv.VariableName)
- {
- case "BASE_DIR":
- if (itv.DefaultValue != null)
- {
- string defaultValue = itv.DefaultValue.Replace('\"', ' ').Trim();
- if (defaultValue.Length > 0)
- BaseDir = defaultValue;
- }
- break;
- case "DATA_DIR":
- if (itv.DefaultValue != null)
- {
- string defaultValue = itv.DefaultValue.Replace('\"', ' ').Trim();
- if (defaultValue.Length > 0)
- {
- defaultValue = defaultValue.Replace("\\data\\", "\\");
- defaultValue = defaultValue.Replace("\\Data\\", "\\");
- DataDir = defaultValue.Trim();
- }
- }
- break;
- case "CLIENT_PORT":
- case "SERVER_PORT":
- this.EnableNetworking = itv.Disabled;
- if (EnableNetworking && itv.DefaultValue != "")
- Port = itv.DefaultValue;
- break;
- case "CLIENT_PIPE":
- case "CLIENT_SOCKET":
- case "SERVER_PIPE":
- case "SERVER_SOCKET":
- case "SERVER_SKIP":
- this.EnableNetworking = !itv.Disabled;
- break;
- case "INNODB_HOME":
- if (itv.Disabled == false)
- {
- InnoDBHomeDir = itv.DefaultValue;
- }
- else
- {
- InnoDBHomeDir = "";
- }
- break;
- case "SERVER_TYPE":
- itv.Disabled = true;
- switch (itv.DefaultValue)
- {
- case "1":
- ServerType = IniServerType.Dedicated;
- break;
- case "2":
- ServerType = IniServerType.Server;
- break;
- case "3":
- default:
- ServerType = IniServerType.Developer;
- break;
- }
- break;
- case "STATE_CHANGE":
- case "SQL_MODE":
- case "INNODB_LOG_FILE_SIZE":
- case "SKIP_INNODB":
- break;
- }
- }
-
- output.Enqueue(itv);
- }
- }
- else
- {
- output.Enqueue(new IniTemplateStatic(current_line));
- }
- }
-
- reader.Close();
- reader.Dispose();
-
- great_success = true;
- }
- catch
- {
- // Do cleanup.
- }
-
- return great_success;
- }
-
- private string ReduceBytesToString(double value)
- {
- string output = "";
- int unit_type = 0;
- char[] unit_names = new char[4] { ' ', 'K', 'M', 'G' };
-
- while (value / 1024 >= 1.0)
- {
- double round_up = 0.0;
- if (value % 1024 > 0)
- ++round_up;
- value /= 1024;
- value = Math.Round(value + round_up);
- ++unit_type;
- }
-
- output += value.ToString();
- if (unit_type >= 1)
- output += unit_names[unit_type].ToString();
-
- return output;
- }
- #endregion
-
- #region Public
- public IniTemplate(string base_dir, string data_dir, string template_name, string output_dir)
- {
- SetDefaults();
- BaseDir = base_dir;
- DataDir = data_dir;
-
- ConfigurationFile = String.Format("{0}my.ini", output_dir);
- if (File.Exists(ConfigurationFile))
- {
- // Create a backup of the existing file(s).
- string datetime = DateTime.Now.GetDateTimeFormats('s')[0].Replace(':', '-');
- string newConfig = String.Format("{0}my_{1}.ini", output_dir, datetime);
-
- int i = 0;
- while (File.Exists(newConfig))
- {
- i += 1;
- newConfig = String.Format("{0}my_{1}_{2}.ini", output_dir, datetime, i.ToString());
- }
-
- File.Copy(ConfigurationFile, newConfig);
- OutputExists = true;
- }
-
- IsValid = OpenTemplate(ConfigurationFile);
- if (IsValid)
- {
- template = ConfigurationFile;
- Reconfiguring = true;
- }
- else
- {
- template = template_name;
- output.Clear();
- IsValid = OpenTemplate(template);
- }
- }
-
- public void ProcessTemplate()
- {
- fe.AssignFormulaVariable("basedir", String.Format("\"{0}\"", BaseDir));
- fe.AssignFormulaVariable("datadir", String.Format("\"{0}data\\\"", DataDir));
- fe.AssignFormulaVariable("port", Port);
- fe.AssignFormulaVariable("default_storage_engine", DefaultStorageEngine);
- fe.AssignFormulaVariable("default_character_set", DefaultCharacterSet);
- fe.AssignFormulaVariable("myisam_percentage", MyisamUsage.ToString());
- fe.AssignFormulaVariable("innodb_buffer_pool_size_percentage", InnoDBBPSUsage.ToString());
- fe.AssignFormulaVariable("active_connections", NumberConnections.ToString());
- fe.AssignFormulaVariable("query_cache_pct", UseQueryCache.ToString());
-
- StreamWriter writer = new StreamWriter(ConfigurationFile);
-
- foreach (object obj in output)
- {
- if (obj.GetType() == typeof(IniTemplateVariable))
- {
- IniTemplateVariable itv = (IniTemplateVariable)obj;
- string result;
- fe.Parse(itv.Formula);
- result = fe.Evaluate();
-
- writer.WriteLine(itv.LineAsRead);
- switch (itv.VariableName)
- {
- case "STATE_CHANGE":
- // continue;
- break;
- case "CLIENT_PORT":
- case "SERVER_PORT":
- itv.Disabled = this.EnableNetworking;
- break;
- case "CLIENT_PIPE":
- case "CLIENT_SOCKET":
- case "SERVER_PIPE":
- case "SERVER_SOCKET":
- case "SERVER_SKIP":
- itv.Disabled = !this.EnableNetworking;
- break;
- case "SQL_MODE":
- itv.Disabled = true;
- break;
- case "INNODB_HOME":
- if (InnoDBHomeDir != "")
- {
- itv.Disabled = false;
- fe.AssignFormulaVariable("innodb_home", InnoDBHomeDir);
- }
- else
- {
- itv.Disabled = true;
- }
- break;
- case "INNODB_LOG_FILE_SIZE":
- if (itv.DefaultValue != "")
- {
- result = itv.DefaultValue;
- itv.ReduceResult = false;
- }
- break;
- case "SKIP_INNODB":
- itv.Disabled = SkipInnodb;
- break;
- }
- if (itv.VariableName != "STATE_CHANGE")
- writer.WriteLine((itv.Disabled ? "# " : "") + itv.OutputParameter + "=" + (itv.ReduceResult ? ReduceBytesToString(double.Parse(result)) : result));
-
- }
- else
- {
- IniTemplateStatic its = (IniTemplateStatic)obj;
- writer.WriteLine(its.LineAsRead);
- }
- }
-
- writer.Close();
- writer.Dispose();
- }
-
- public IniServerType ServerType
- {
- get
- {
- return ist;
- }
- set
- {
- ist = value;
-
- PerformanceCounter pc = new PerformanceCounter("Memory", "Available Bytes", "");
- double system_available_memory = (double)pc.NextValue();
- double mysql_memory_percentage = 0.08333; // By default, all servers should use 1/12 available system memory.
-
- fe.AssignFormulaVariable("cpus", Environment.ProcessorCount.ToString());
-
- switch (ist)
- {
- case IniServerType.Dedicated:
- mysql_memory_percentage = 0.90;
- fe.AssignFormulaVariable("server_type", "1");
- break;
- case IniServerType.Server:
- mysql_memory_percentage = 0.50;
- fe.AssignFormulaVariable("server_type", "2");
- break;
- case IniServerType.InternalUnitTest:
- mysql_memory_percentage = 0;
- system_available_memory = 0.0;
- fe.AssignFormulaVariable("cpus", "0.0");
- fe.AssignFormulaVariable("server_type", "4");
- break;
- case IniServerType.Developer:
- default:
- fe.AssignFormulaVariable("server_type", "3");
- if (system_available_memory < (48 * 1024 * 1024))
- {
- system_available_memory = 48 * 1024 * 1024;
- mysql_memory_percentage = 1.0;
- }
- break;
- }
-
- fe.AssignFormulaVariable("memory", (system_available_memory * mysql_memory_percentage).ToString());
- }
- }
-
- public double MyisamUsage { get; set; }
-
- public double InnoDBBPSUsage { get; set; }
-
- public double NumberConnections { get; set; }
-
- public double UseQueryCache { get; set; }
-
- public bool FoundExistingDataDir { get; set; }
-
- public bool IsValid { get; private set; }
-
- public bool Reconfiguring { get; private set; }
-
- public bool OutputExists { get; private set; }
-
- public bool EnableStrictMode { get; set; }
-
- public bool EnableNetworking { get; set; }
-
- public bool SkipInnodb { get; set; }
-
- public string DefaultStorageEngine { get; set; }
-
- public string DefaultCharacterSet { get; set; }
-
- public string BaseDir { get; set; }
-
- public string DataDir { get; set; }
-
- public string InnoDBHomeDir { get; set; }
-
- public string Port { get; set; }
-
- public string ConfigurationFile { get; set; }
-
- #endregion
- }
-
- public enum FormulaTokenType
- {
- None,
- Number,
- Constant,
- Variable,
- Assignment,
- Plus,
- Minus,
- Multiply,
- Divide,
- Exponent,
- UnaryMinus,
- Sine,
- Cosine,
- Tangent,
- Round,
- Min,
- Max,
- LeftParenthesis,
- RightParenthesis
- }
-
- public struct FormulaToken
- {
- public string TokenValue;
- public FormulaTokenType TokenValueType;
- }
-
- public class FormulaEngine
- {
- private Dictionary<string, string> formula_variables;
- private Queue output;
- private Stack ops;
- private string original_expression;
- private string transition_expression;
- private string postfix_expression;
-
- public string OriginalExpression
- {
- get { return original_expression; }
- }
-
- public string TransitionExpression
- {
- get { return transition_expression; }
- }
-
- public string PostfixExpression
- {
- get { return postfix_expression; }
- }
-
- public FormulaEngine()
- {
- original_expression = string.Empty;
- transition_expression = string.Empty;
- postfix_expression = string.Empty;
- formula_variables = new Dictionary<string, string>();
- }
-
- public void Parse(string Expression)
- {
- output = new Queue();
- ops = new Stack();
-
- original_expression = Expression;
-
- string rpn_buffer = Expression;
-
- // filter out the K, M, G unit specifiers.
- rpn_buffer = Regex.Replace(rpn_buffer, @"(?<number>\d+(\.\d+)?)K", " ${number} * 1024 ");
- rpn_buffer = Regex.Replace(rpn_buffer, @"(?<number>\d+(\.\d+)?)M", " ${number} * 1024 * 1024");
- rpn_buffer = Regex.Replace(rpn_buffer, @"(?<number>\d+(\.\d+)?)G", " ${number} * 1024 * 1024 * 1024");
- rpn_buffer = rpn_buffer.ToLower();
-
- // captures numbers. Anything like 11 or 22.34 is captured
- rpn_buffer = Regex.Replace(rpn_buffer, @"(?<number>\d+(\.\d+)?)", " ${number} ");
- // captures these symbols: + - * / ^ ( )
- rpn_buffer = Regex.Replace(rpn_buffer, @"(?<ops>[+\-*/^:()])", " ${ops} ");
- // captures constants, variables, and math fucntions.
- rpn_buffer = Regex.Replace(rpn_buffer, @"(?<var>([a-z_]+))", " ${var} ");
- // trims up consecutive spaces and replace it with just one space
- rpn_buffer = Regex.Replace(rpn_buffer, @"\s+", " ").Trim();
-
- // The following chunk captures unary minus operations.
- // 1) We replace every minus sign with the string "MINUS".
- // 2) Then if we find a "MINUS" with a number or constant in front,
- // then it's a normal minus operation.
- // 3) Otherwise, it's a unary minus operation.
-
- // Step 1.
- rpn_buffer = Regex.Replace(rpn_buffer, "-", "MINUS");
- // Step 2. Looking for pi or e or generic number \d+(\.\d+)?
- //rpn_buffer = Regex.Replace(rpn_buffer, @"(?<number>(pi|e|(\d+(\.\d+)?)))\s+MINUS", "${number} -");
- rpn_buffer = Regex.Replace(rpn_buffer, @"(?<number>([a-z_]+|[)]|(\d+(\.\d+)?)))\s+MINUS", "${number} -");
- // Step 3. Use the tilde ~ as the unary minus operator
- rpn_buffer = Regex.Replace(rpn_buffer, "MINUS", "~");
-
- transition_expression = rpn_buffer;
-
- // tokenize it!
- string[] parsed_tokens = rpn_buffer.Split(" ".ToCharArray());
- int i = 0;
- double token_value;
- FormulaToken token, opstoken;
- for (i = 0; i < parsed_tokens.Length; ++i)
- {
- token = new FormulaToken();
- token.TokenValue = parsed_tokens[i];
- token.TokenValueType = FormulaTokenType.None;
-
- try
- {
- token_value = double.Parse(parsed_tokens[i]);
- token.TokenValueType = FormulaTokenType.Number;
- // If the token is a number, then add it to the output queue.
- output.Enqueue(token);
- }
- catch
- {
- switch (parsed_tokens[i])
- {
- case "+":
- token.TokenValueType = FormulaTokenType.Plus;
- if (ops.Count > 0)
- {
- opstoken = (FormulaToken)ops.Peek();
- // while there is an operator, o2, at the top of the stack
- while (IsOperatorToken(opstoken.TokenValueType))
- {
- // pop o2 off the stack, onto the output queue;
- output.Enqueue(ops.Pop());
- if (ops.Count > 0)
- {
- opstoken = (FormulaToken)ops.Peek();
- }
- else
- {
- break;
- }
- }
- }
- // push o1 onto the operator stack.
- ops.Push(token);
- break;
- case "-":
- token.TokenValueType = FormulaTokenType.Minus;
- if (ops.Count > 0)
- {
- opstoken = (FormulaToken)ops.Peek();
- // while there is an operator, o2, at the top of the stack
- while (IsOperatorToken(opstoken.TokenValueType))
- {
- // pop o2 off the stack, onto the output queue;
- output.Enqueue(ops.Pop());
- if (ops.Count > 0)
- {
- opstoken = (FormulaToken)ops.Peek();
- }
- else
- {
- break;
- }
- }
- }
- // push o1 onto the operator stack.
- ops.Push(token);
- break;
- case "*":
- token.TokenValueType = FormulaTokenType.Multiply;
- if (ops.Count > 0)
- {
- opstoken = (FormulaToken)ops.Peek();
- // while there is an operator, o2, at the top of the stack
- while (IsOperatorToken(opstoken.TokenValueType))
- {
- if (opstoken.TokenValueType == FormulaTokenType.Plus || opstoken.TokenValueType == FormulaTokenType.Minus || opstoken.TokenValueType == FormulaTokenType.Assignment)
- {
- break;
- }
- else
- {
- // Once we're in here, the following algorithm condition is satisfied.
- // o1 is associative or left-associative and its precedence is less than (lower precedence) or equal to that of o2, or
- // o1 is right-associative and its precedence is less than (lower precedence) that of o2,
-
- // pop o2 off the stack, onto the output queue;
- output.Enqueue(ops.Pop());
- if (ops.Count > 0)
- {
- opstoken = (FormulaToken)ops.Peek();
- }
- else
- {
- break;
- }
- }
- }
- }
- // push o1 onto the operator stack.
- ops.Push(token);
- break;
- case "/":
- token.TokenValueType = FormulaTokenType.Divide;
- if (ops.Count > 0)
- {
- opstoken = (FormulaToken)ops.Peek();
- // while there is an operator, o2, at the top of the stack
- while (IsOperatorToken(opstoken.TokenValueType))
- {
- if (opstoken.TokenValueType == FormulaTokenType.Plus || opstoken.TokenValueType == FormulaTokenType.Minus || opstoken.TokenValueType == FormulaTokenType.Assignment)
- {
- break;
- }
- else
- {
- // Once we're in here, the following algorithm condition is satisfied.
- // o1 is associative or left-associative and its precedence is less than (lower precedence) or equal to that of o2, or
- // o1 is right-associative and its precedence is less than (lower precedence) that of o2,
-
- // pop o2 off the stack, onto the output queue;
- output.Enqueue(ops.Pop());
- if (ops.Count > 0)
- {
- opstoken = (FormulaToken)ops.Peek();
- }
- else
- {
- break;
- }
- }
- }
- }
- // push o1 onto the operator stack.
- ops.Push(token);
- break;
- case "^":
- token.TokenValueType = FormulaTokenType.Exponent;
- // push o1 onto the operator stack.
- ops.Push(token);
- break;
- case "~":
- token.TokenValueType = FormulaTokenType.UnaryMinus;
- // push o1 onto the operator stack.
- ops.Push(token);
- break;
- case "(":
- token.TokenValueType = FormulaTokenType.LeftParenthesis;
- // If the token is a left parenthesis, then push it onto the stack.
- ops.Push(token);
- break;
- case ")":
- token.TokenValueType = FormulaTokenType.RightParenthesis;
- if (ops.Count > 0)
- {
- opstoken = (FormulaToken)ops.Peek();
- // Until the token at the top of the stack is a left parenthesis
- while (opstoken.TokenValueType != FormulaTokenType.LeftParenthesis)
- {
- // pop operators off the stack onto the output queue
- output.Enqueue(ops.Pop());
- if (ops.Count > 0)
- {
- opstoken = (FormulaToken)ops.Peek();
- }
- else
- {
- // If the stack runs out without finding a left parenthesis,
- // then there are mismatched parentheses.
- throw new Exception("Unbalanced parenthesis!");
- }
-
- }
- // Pop the left parenthesis from the stack, but not onto the output queue.
- ops.Pop();
- }
-
- if (ops.Count > 0)
- {
- opstoken = (FormulaToken)ops.Peek();
- // If the token at the top of the stack is a function token
- if (IsFunctionToken(opstoken.TokenValueType))
- {
- // pop it and onto the output queue.
- output.Enqueue(ops.Pop());
- }
- }
- break;
- case "pi":
- token.TokenValueType = FormulaTokenType.Constant;
- // If the token is a number, then add it to the output queue.
- output.Enqueue(token);
- break;
- case "e":
- token.TokenValueType = FormulaTokenType.Constant;
- // If the token is a number, then add it to the output queue.
- output.Enqueue(token);
- break;
- case "sin":
- token.TokenValueType = FormulaTokenType.Sine;
- // If the token is a function token, then push it onto the stack.
- ops.Push(token);
- break;
- case "cos":
- token.TokenValueType = FormulaTokenType.Cosine;
- // If the token is a function token, then push it onto the stack.
- ops.Push(token);
- break;
- case "tan":
- token.TokenValueType = FormulaTokenType.Tangent;
- // If the token is a function token, then push it onto the stack.
- ops.Push(token);
- break;
- case "rnd":
- token.TokenValueType = FormulaTokenType.Round;
- // If the token is a funciton token, then push it onto the stack.
- ops.Push(token);
- break;
- case "max":
- token.TokenValueType = FormulaTokenType.Max;
- // If the token is a funciton token, then push it onto the stack.
- ops.Push(token);
- break;
- case "min":
- token.TokenValueType = FormulaTokenType.Min;
- // If the token is a funciton token, then push it onto the stack.
- ops.Push(token);
- break;
- case ":":
- // If the token is an assignment token, then push it onto the stack.
- token.TokenValueType = FormulaTokenType.Assignment;
- // push o0 onto the operator stack.
- ops.Push(token);
- break;
- case ",":
- if (ops.Count > 0)
- {
- opstoken = (FormulaToken)ops.Peek();
- // Until the token at the top of the stack is a left parenthesis
- while (opstoken.TokenValueType != FormulaTokenType.LeftParenthesis)
- {
- // pop operators off the stack onto the output queue
- output.Enqueue(ops.Pop());
- if (ops.Count > 0)
- {
- opstoken = (FormulaToken)ops.Peek();
- }
- else
- {
- // If the stack runs out without finding a left parenthesis,
- // then there are mismatched parentheses.
- throw new Exception("Couldn't find function start!");
- }
- }
- }
- break;
- default:
- if (Regex.IsMatch(parsed_tokens[i], @"[a-z_]+"))
- {
- token.TokenValueType = FormulaTokenType.Variable;
- output.Enqueue(token); // This is a variable.
- }
- break;
- }
- }
- }
-
- // While there are still operator tokens in the stack:
- while (ops.Count != 0)
- {
- opstoken = (FormulaToken)ops.Pop();
- // If the operator token on the top of the stack is a parenthesis
- if (opstoken.TokenValueType == FormulaTokenType.LeftParenthesis)
- {
- // then there are mismatched parenthesis.
- throw new Exception("Unbalanced parenthesis!");
- }
- else
- {
- // Pop the operator onto the output queue.
- output.Enqueue(opstoken);
- }
- }
-
- postfix_expression = string.Empty;
- foreach (object obj in output)
- {
- opstoken = (FormulaToken)obj;
- postfix_expression += string.Format("{0} ", opstoken.TokenValue);
- }
- }
-
- public string Evaluate()
- {
- Stack result = new Stack();
-
- FormulaToken token = new FormulaToken();
- FormulaToken operand1 = new FormulaToken();
- FormulaToken operand2 = new FormulaToken();
- FormulaToken result_token = new FormulaToken();
-
- // While there are input tokens left
- foreach (object obj in output)
- {
- // Read the next token from input.
- token = (FormulaToken)obj;
- switch (token.TokenValueType)
- {
- case FormulaTokenType.Number:
- case FormulaTokenType.Constant:
- case FormulaTokenType.Variable:
- result.Push(token);
- break;
- case FormulaTokenType.Assignment:
- if (result.Count >= 2)
- {
- operand2 = (FormulaToken)result.Pop();
- operand1 = (FormulaToken)result.Pop();
- if ( operand1.TokenValueType == FormulaTokenType.Variable &&
- (operand2.TokenValueType == FormulaTokenType.Number ||
- operand2.TokenValueType == FormulaTokenType.Constant ||
- operand2.TokenValueType == FormulaTokenType.Variable)
- )
- formula_variables[operand1.TokenValue] = GetTokenValue(operand2).ToString();
- else
- throw new Exception("Assignment error!");
-
- result.Push(operand1);
- }
- else
- throw new Exception("Evaluation error!");
- break;
- case FormulaTokenType.Plus:
- if (result.Count >= 2)
- {
- operand2 = (FormulaToken)result.Pop();
- operand1 = (FormulaToken)result.Pop();
-
- result_token.TokenValueType = FormulaTokenType.Number;
- result_token.TokenValue = (GetTokenValue(operand2) + GetTokenValue(operand1)).ToString();
-
- result.Push(result_token);
- }
- else
- throw new Exception("Evaluation error!");
- break;
- case FormulaTokenType.Minus:
- if (result.Count >= 2)
- {
- operand2 = (FormulaToken)result.Pop();
- operand1 = (FormulaToken)result.Pop();
-
- result_token.TokenValueType = FormulaTokenType.Number;
- result_token.TokenValue = (GetTokenValue(operand1) - GetTokenValue(operand2)).ToString();
-
- result.Push(result_token);
- }
- else
- throw new Exception("Evaluation error!");
- break;
- case FormulaTokenType.Multiply:
- if (result.Count >= 2)
- {
- operand2 = (FormulaToken)result.Pop();
- operand1 = (FormulaToken)result.Pop();
-
- result_token.TokenValueType = FormulaTokenType.Number;
- result_token.TokenValue = (GetTokenValue(operand2) * GetTokenValue(operand1)).ToString();
-
- result.Push(result_token);
- }
- else
- throw new Exception("Evaluation error!");
- break;
- case FormulaTokenType.Divide:
- if (result.Count >= 2)
- {
- operand2 = (FormulaToken)result.Pop();
- operand1 = (FormulaToken)result.Pop();
-
- result_token.TokenValueType = FormulaTokenType.Number;
- result_token.TokenValue = (GetTokenValue(operand1) / GetTokenValue(operand2)).ToString();
-
- result.Push(result_token);
- }
- else
- throw new Exception("Evaluation error!");
- break;
- case FormulaTokenType.Exponent:
- if (result.Count >= 2)
- {
- operand2 = (FormulaToken)result.Pop();
- operand1 = (FormulaToken)result.Pop();
-
- result_token.TokenValueType = FormulaTokenType.Number;
- result_token.TokenValue = Math.Pow(GetTokenValue(operand1), GetTokenValue(operand2)).ToString();
-
- result.Push(result_token);
- }
- else
- throw new Exception("Evaluation error!");
- break;
- case FormulaTokenType.UnaryMinus:
- if (result.Count >= 1)
- {
- operand1 = (FormulaToken)result.Pop();
-
- result_token.TokenValueType = FormulaTokenType.Number;
- result_token.TokenValue = (-GetTokenValue(operand1)).ToString();
-
- result.Push(result_token);
- }
- else
- throw new Exception("Evaluation error!");
- break;
- case FormulaTokenType.Sine:
- if (result.Count >= 1)
- {
- operand1 = (FormulaToken)result.Pop();
-
- result_token.TokenValueType = FormulaTokenType.Number;
- result_token.TokenValue = Math.Sin(GetTokenValue(operand1)).ToString();
-
- result.Push(result_token);
- }
- else
- throw new Exception("Evaluation error!");
- break;
- case FormulaTokenType.Cosine:
- if (result.Count >= 1)
- {
- operand1 = (FormulaToken)result.Pop();
-
- result_token.TokenValueType = FormulaTokenType.Number;
- result_token.TokenValue = Math.Cos(GetTokenValue(operand1)).ToString();
-
- result.Push(result_token);
- }
- else
- throw new Exception("Evaluation error!");
- break;
- case FormulaTokenType.Tangent:
- if (result.Count >= 1)
- {
- operand1 = (FormulaToken)result.Pop();
-
- result_token.TokenValueType = FormulaTokenType.Number;
- result_token.TokenValue = Math.Tan(GetTokenValue(operand1)).ToString();
-
- result.Push(result_token);
- }
- else
- throw new Exception("Evaluation error!");
- break;
- case FormulaTokenType.Round:
- if (result.Count >= 2)
- {
- operand2 = (FormulaToken)result.Pop();
- operand1 = (FormulaToken)result.Pop();
-
- result_token.TokenValueType = FormulaTokenType.Number;
- result_token.TokenValue = Math.Round((GetTokenValue(operand1) / GetTokenValue(operand2)) * GetTokenValue(operand2)).ToString();
-
- result.Push(result_token);
- }
- else
- throw new Exception("Evaluation error!");
- break;
- case FormulaTokenType.Max:
- if (result.Count >= 2)
- {
- operand2 = (FormulaToken)result.Pop();
- operand1 = (FormulaToken)result.Pop();
-
- if (GetTokenValue(operand1) >= GetTokenValue(operand2))
- result.Push(operand1);
- else
- result.Push(operand2);
-
- }
- else
- throw new Exception("Evaluation error!");
- break;
- case FormulaTokenType.Min:
- if (result.Count >= 2)
- {
- operand2 = (FormulaToken)result.Pop();
- operand1 = (FormulaToken)result.Pop();
-
- if (GetTokenValue(operand1) <= GetTokenValue(operand2))
- result.Push(operand1);
- else
- result.Push(operand2);
- }
- else
- throw new Exception("Evaluation error!");
- break;
- }
- }
-
- // If there is only one value in the stack
- if (result.Count == 1)
- {
- // That value is the result of the calculation.
- return GetTokenText((FormulaToken)result.Pop());
- }
- else
- {
- // If there are more values in the stack
- // (Error) The user input too many values.
- throw new Exception("Evaluation error!");
- }
- }
-
- public void AssignFormulaVariable(string key_name, string value)
- {
- string variable_value;
- formula_variables.TryGetValue(key_name, out variable_value);
- if(variable_value != value)
- formula_variables[key_name] = value;
- return;
- }
-
- private string GetTokenText(FormulaToken token)
- {
- string token_value = String.Empty;
-
- switch (token.TokenValueType)
- {
- case FormulaTokenType.Number:
- token_value = token.TokenValue;
- break;
- case FormulaTokenType.Variable:
- if (!formula_variables.TryGetValue(token.TokenValue, out token_value))
- token_value = "0.0";
- break;
- case FormulaTokenType.Constant:
- switch (token.TokenValue)
- {
- case "pi":
- token_value = Math.PI.ToString();
- break;
- case "e":
- token_value = Math.E.ToString();
- break;
- }
- break;
- }
-
- return token_value;
- }
-
- private double GetTokenValue(FormulaToken token)
- {
- return double.Parse(GetTokenText(token));
- }
-
- private bool IsOperatorToken(FormulaTokenType t)
- {
- bool result = false;
- switch (t)
- {
- case FormulaTokenType.Plus:
- case FormulaTokenType.Minus:
- case FormulaTokenType.Multiply:
- case FormulaTokenType.Divide:
- case FormulaTokenType.Exponent:
- case FormulaTokenType.UnaryMinus:
- result = true;
- break;
- default:
- result = false;
- break;
- }
- return result;
- }
-
- private bool IsFunctionToken(FormulaTokenType t)
- {
- bool result = false;
- switch (t)
- {
- case FormulaTokenType.Sine:
- case FormulaTokenType.Cosine:
- case FormulaTokenType.Tangent:
- case FormulaTokenType.Round:
- case FormulaTokenType.Max:
- case FormulaTokenType.Min:
- result = true;
- break;
- default:
- result = false;
- break;
- }
- return result;
- }
-
- }
-}
=== removed file 'WexInstaller/Core/MysqlSCM.cs'
--- a/WexInstaller/Core/MysqlSCM.cs 2010-11-29 17:02:30 +0000
+++ b/WexInstaller/Core/MysqlSCM.cs 1970-01-01 00:00:00 +0000
@@ -1,455 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Globalization;
-using System.IO;
-using System.Resources;
-using System.Runtime.InteropServices;
-using System.Runtime.ConstrainedExecution;
-using System.Security;
-using System.Security.Permissions;
-using System.ServiceProcess;
-using System.Text;
-using System.Text.RegularExpressions;
-using System.Threading;
-using Microsoft.Win32;
-
-namespace WexInstaller.Core
-{
- public class MySQLServiceControlManager
- {
- #region Private
- private TimeSpan ts;
- #endregion
-
- #region Public
- public MySQLServiceControlManager()
- {
- ts = new TimeSpan(0, 0, 20); // 20 Second timeout.
- }
-
- public string FindServiceName(string baseDirectory)
- {
- string foundService = String.Empty;
-
- // Search through all the registry keys for each reference to each instance's bin location.
- try
- {
- ServiceController[] scmServices;
- scmServices = ServiceController.GetServices();
-
- foreach (ServiceController scmService in scmServices)
- {
- ExpandedServiceController superSerivceController = new ExpandedServiceController(scmService);
-
- string regexSeed = Path.GetFullPath(baseDirectory) + ".";
- regexSeed = regexSeed.Replace(@"\", @"\\");
- regexSeed = regexSeed.Replace(@"(", @"\(");
- regexSeed = regexSeed.Replace(@")", @"\)");
-
- Regex localTemplate = new Regex(regexSeed.ToString());
- Match localMatch = localTemplate.Match(superSerivceController.BinaryPath);
-
- if (localMatch.Success)
- {
- foundService = superSerivceController.ServiceName;
- }
-
- superSerivceController.Close();
- scmService.Close();
- }
- }
- catch (Exception e)
- {
- Logger.LogException(e);
- }
-
- return foundService;
- }
-
- public void Add(string serviceName, string displayName, string fileName)
- {
- try
- {
- ExpandedServiceController ssc = new ExpandedServiceController(serviceName, displayName, fileName);
- ssc.Close();
- }
- catch (Exception e)
- {
- Logger.LogException(e);
- }
- }
-
- public void Delete(string serviceName)
- {
- try
- {
- ExpandedServiceController ssc = new ExpandedServiceController(serviceName);
- ssc.Remove(); // Automatically calls .Close();
- }
- catch (Exception e)
- {
- Logger.LogException(e);
- }
- }
-
- public void Start(string serviceName)
- {
- try
- {
- ExpandedServiceController ssc = new ExpandedServiceController(serviceName);
- ssc.Start();
- ssc.WaitForStatus(ServiceControllerStatus.Running, ts);
- ssc.Close();
- }
- catch (Exception e)
- {
- Logger.LogException(e);
- }
- }
-
- public void Stop(string serviceName)
- {
- try
- {
- ExpandedServiceController ssc = new ExpandedServiceController(serviceName);
- ssc.Stop();
- ssc.WaitForStatus(ServiceControllerStatus.Stopped, ts);
- ssc.Close();
- }
- catch (Exception e)
- {
- Logger.LogException(e);
- }
- }
-
- public void Restart(string serviceName)
- {
- try
- {
- ExpandedServiceController ssc = new ExpandedServiceController(serviceName);
- if (ssc.Status == ServiceControllerStatus.Running)
- ssc.Stop();
- ssc.WaitForStatus(ServiceControllerStatus.Stopped, ts);
- ssc.Start();
- ssc.WaitForStatus(ServiceControllerStatus.Running, ts);
- ssc.Close();
- }
- catch (Exception e)
- {
- Logger.LogException(e);
- }
- }
-
- public void Update(string serviceName, string fileName)
- {
- try
- {
- ExpandedServiceController ssc = new ExpandedServiceController(serviceName);
- if (ssc.Status == ServiceControllerStatus.Running)
- ssc.Stop();
- ssc.WaitForStatus(ServiceControllerStatus.Stopped, ts);
- ssc.BinaryPath = fileName;
- ssc.Close();
- }
- catch (Exception e)
- {
- Logger.LogException(e);
- }
- }
-
- public string BinaryPath(string serviceName)
- {
- String binaryPath = String.Empty;
-
- try
- {
- ExpandedServiceController ssc = new ExpandedServiceController(serviceName);
- binaryPath = ssc.BinaryPath;
- ssc.Close();
- }
- catch (Exception e)
- {
- Logger.LogException(e);
- }
-
- return binaryPath;
- }
-
- public ServiceControllerStatus GetServiceStatus(string serviceName)
- {
- ServiceControllerStatus currentStatus = ServiceControllerStatus.Stopped;
- try
- {
- ExpandedServiceController ssc = new ExpandedServiceController(serviceName);
- currentStatus = ssc.Status;
- ssc.Close();
- }
- catch (Exception e)
- {
- Logger.LogException(e);
- }
- return currentStatus;
- }
-
- #endregion
- }
-
- internal static class SystemServiceProcessNativeMethods
- {
- #region Fields
- public const int ACCESS_TYPE_ALL = 0xf01ff;
- public const int ACCESS_TYPE_CHANGE_CONFIG = 2;
- public const int ACCESS_TYPE_ENUMERATE_DEPENDENTS = 8;
- public const int ACCESS_TYPE_INTERROGATE = 0x80;
- public const int ACCESS_TYPE_PAUSE_CONTINUE = 0x40;
- public const int ACCESS_TYPE_QUERY_CONFIG = 1;
- public const int ACCESS_TYPE_QUERY_STATUS = 4;
- public const int ACCESS_TYPE_START = 0x10;
- public const int ACCESS_TYPE_STOP = 0x20;
- public const int ACCESS_TYPE_DELETE = 0x00010000;
- public const int ACCESS_TYPE_USER_DEFINED_CONTROL = 0x100;
- public const int ERROR_CONTROL_CRITICAL = 3;
- public const int ERROR_CONTROL_IGNORE = 0;
- public const int ERROR_CONTROL_NORMAL = 1;
- public const int ERROR_CONTROL_SEVERE = 2;
- public const int SC_MANAGER_ALL = 0xf003f;
- public const int SC_MANAGER_CONNECT = 1;
- public const int SC_MANAGER_CREATE_SERVICE = 2;
- public const int SC_MANAGER_ENUMERATE_SERVICE = 4;
- public const int SC_MANAGER_LOCK = 8;
- public const int SC_MANAGER_MODIFY_BOOT_CONFIG = 0x20;
- public const int SC_MANAGER_QUERY_LOCK_STATUS = 0x10;
- public const int START_TYPE_AUTO = 2;
- public const int START_TYPE_BOOT = 0;
- public const int START_TYPE_DEMAND = 3;
- public const int START_TYPE_DISABLED = 4;
- public const int START_TYPE_SYSTEM = 1;
- public const int SERVICE_TYPE_ADAPTER = 4;
- public const int SERVICE_TYPE_ALL = 0x13f;
- public const int SERVICE_TYPE_DRIVER = 11;
- public const int SERVICE_TYPE_FILE_SYSTEM_DRIVER = 2;
- public const int SERVICE_TYPE_INTERACTIVE_PROCESS = 0x100;
- public const int SERVICE_TYPE_KERNEL_DRIVER = 1;
- public const int SERVICE_TYPE_RECOGNIZER_DRIVER = 8;
- public const int SERVICE_TYPE_WIN32 = 0x30;
- public const int SERVICE_TYPE_WIN32_OWN_PROCESS = 0x10;
- public const int SERVICE_TYPE_WIN32_SHARE_PROCESS = 0x20;
- #endregion
-
- #region Methods
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success), DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
- public static extern bool CloseServiceHandle(IntPtr handle);
- [DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
- public static extern IntPtr OpenSCManager(string machineName, string databaseName, int access);
- [DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
- public static extern IntPtr CreateService(IntPtr databaseHandle, string serviceName, string displayName, int access, int serviceType, int startType, int errorControl, string binaryPath, string loadOrderGroup, IntPtr pTagId, string dependencies, string servicesStartName, string password);
- [DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
- public static extern bool DeleteService(IntPtr serviceHandle);
- [DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
- public static extern IntPtr OpenService(IntPtr databaseHandle, string serviceName, int access);
- #endregion
-
- #region Nested Types
- /*
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
- public struct SC_ACTION
- {
- public int type;
- public uint delay;
- }
-
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
- public struct SERVICE_DESCRIPTION
- {
- public IntPtr description;
- }
-
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
- public struct SERVICE_FAILURE_ACTIONS
- {
- public uint dwResetPeriod;
- public IntPtr rebootMsg;
- public IntPtr command;
- public uint numActions;
- public unsafe SystemServiceProcessNativeMethods.SC_ACTION* actions;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct SERVICE_STATUS
- {
- public int serviceType;
- public int currentState;
- public int controlsAccepted;
- public int win32ExitCode;
- public int serviceSpecificExitCode;
- public int checkPoint;
- public int waitHint;
- }
- */
- #endregion
- }
-
- // Wrapper for the ServiceController object that adds ability to Add and remove services and use service BinaryPath
- public class ExpandedServiceController : ServiceController
- {
- #region Private
- // Parameters
- private string binaryPath;
-
- // Methods
- private static Win32Exception CreateSafeWin32Exception()
- {
- Win32Exception exception = null;
- new SecurityPermission(PermissionState.Unrestricted).Assert();
- try
- {
- exception = new Win32Exception();
- }
- finally
- {
- CodeAccessPermission.RevertAssert();
- }
- return exception;
- }
-
- private static IntPtr GetDataBaseHandleWithAllAccess(string machineName)
- {
- IntPtr zero = IntPtr.Zero;
- if (machineName.Equals(".") || (machineName.Length == 0))
- {
- zero = SystemServiceProcessNativeMethods.OpenSCManager(null, null, (SystemServiceProcessNativeMethods.SC_MANAGER_ALL | SystemServiceProcessNativeMethods.ACCESS_TYPE_DELETE));
- }
- else
- {
- zero = SystemServiceProcessNativeMethods.OpenSCManager(machineName, null, (SystemServiceProcessNativeMethods.SC_MANAGER_ALL | SystemServiceProcessNativeMethods.ACCESS_TYPE_DELETE));
- }
- if (zero == IntPtr.Zero)
- {
- Exception innerException = CreateSafeWin32Exception();
- throw new InvalidOperationException("Failed to open connection to service database.", innerException);
- }
- return zero;
- }
-
- private void GetBinaryPath()
- {
- RegistryKey serviceEntry = Registry.LocalMachine;
- try
- {
- serviceEntry = serviceEntry.OpenSubKey("SYSTEM\\CurrentControlSet\\Services\\" + this.ServiceName, false);
- binaryPath = serviceEntry.GetValue("ImagePath", "").ToString();
- }
- catch (Exception e)
- {
- Logger.LogException(e);
- binaryPath = String.Empty;
- }
- finally
- {
- serviceEntry.Close();
- }
- }
- #endregion
-
- #region Public
- // Wrapper for existing constructors
- public ExpandedServiceController(string name)
- : base(name)
- {
- GetBinaryPath();
- }
-
- // New constructors used to create new services and cope an existing one.
- public ExpandedServiceController(string name, string displayName, string fileName)
- : base()
- {
- // Create the new Service.
- IntPtr scm = GetDataBaseHandleWithAllAccess(base.MachineName);
-
- try
- {
- IntPtr service = SystemServiceProcessNativeMethods.OpenService(scm, name, SystemServiceProcessNativeMethods.ACCESS_TYPE_ALL);
-
- if (service == IntPtr.Zero)
- service = SystemServiceProcessNativeMethods.CreateService(scm, name, displayName, SystemServiceProcessNativeMethods.ACCESS_TYPE_ALL, SystemServiceProcessNativeMethods.SERVICE_TYPE_WIN32_OWN_PROCESS, SystemServiceProcessNativeMethods.START_TYPE_AUTO, SystemServiceProcessNativeMethods.ERROR_CONTROL_NORMAL, fileName, null, IntPtr.Zero, null, null, null);
-
- if (service == IntPtr.Zero)
- throw CreateSafeWin32Exception();
- }
- finally
- {
- SystemServiceProcessNativeMethods.CloseServiceHandle(scm);
- }
-
- this.ServiceName = name;
- this.DisplayName = displayName;
-
- GetBinaryPath();
- }
- public ExpandedServiceController(ServiceController defaultBase)
- : base(defaultBase.ServiceName, defaultBase.MachineName)
- {
- GetBinaryPath();
- }
-
- public void Remove()
- {
- string serviceName = this.ServiceName;
- string machineName = this.MachineName;
-
- if (this.Status == ServiceControllerStatus.Running)
- this.Stop();
- this.WaitForStatus(ServiceControllerStatus.Stopped);
- base.Close();
-
- IntPtr scm = GetDataBaseHandleWithAllAccess(machineName);
-
- try
- {
- IntPtr service = SystemServiceProcessNativeMethods.OpenService(scm, serviceName, SystemServiceProcessNativeMethods.ACCESS_TYPE_ALL | SystemServiceProcessNativeMethods.ACCESS_TYPE_DELETE);
- if (service == IntPtr.Zero)
- throw CreateSafeWin32Exception();
-
- try
- {
- if (!SystemServiceProcessNativeMethods.DeleteService(service))
- throw CreateSafeWin32Exception();
- }
- finally
- {
- SystemServiceProcessNativeMethods.CloseServiceHandle(service);
- }
- }
- finally
- {
- SystemServiceProcessNativeMethods.CloseServiceHandle(scm);
- }
-
- }
-
- public string BinaryPath
- {
- get { return binaryPath; }
- set
- {
- binaryPath = value;
- RegistryKey serviceEntry = Registry.LocalMachine;
- try
- {
- serviceEntry = serviceEntry.OpenSubKey("SYSTEM\\CurrentControlSet\\Services\\" + this.ServiceName, true);
- serviceEntry.SetValue("ImagePath", binaryPath);
- }
- catch (Exception e)
- {
- Logger.LogException(e);
- }
- finally
- {
- serviceEntry.Close();
- }
- }
- }
- #endregion
- }
-}
=== modified file 'WexInstaller/WexInstaller.csproj'
--- a/WexInstaller/WexInstaller.csproj 2011-02-08 21:28:42 +0000
+++ b/WexInstaller/WexInstaller.csproj 2011-02-09 17:35:42 +0000
@@ -90,6 +90,9 @@
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\ListViewHelper.cs" />
+ <Compile Include="Controls\ListViewWex.cs">
+ <SubType>Component</SubType>
+ </Compile>
<Compile Include="Controls\RemoveControl.cs">
<SubType>UserControl</SubType>
</Compile>
@@ -108,17 +111,12 @@
<Compile Include="Controls\ResourcesPage.Designer.cs">
<DependentUpon>ResourcesPage.cs</DependentUpon>
</Compile>
- <Compile Include="Core\ListViewWex.cs">
- <SubType>Component</SubType>
- </Compile>
- <Compile Include="Core\ProductManifest.cs" />
<Compile Include="HiddenTabsControl.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="HiddenTabsControl.Designer.cs">
<DependentUpon>HiddenTabsControl.cs</DependentUpon>
</Compile>
- <Compile Include="Core\Options.cs" />
<Compile Include="Controls\InstallWizardControl.cs">
<SubType>UserControl</SubType>
</Compile>
@@ -185,7 +183,6 @@
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
- <Compile Include="Core\ProductManager.cs" />
<Compile Include="InstallWizard\AllConfigOverview.cs">
<SubType>UserControl</SubType>
</Compile>
Attachment: [text/bzr-bundle] bzr/reggie.burnett@oracle.com-20110209173542-q3s16qqdt3urejnu.bundle
| Thread |
|---|
| • bzr commit into wex-installer-1.0 branch (reggie.burnett:322) | Reggie Burnett | 9 Feb |