Browse files

Initial Load of 2.0

  • Loading branch information...
0 parents commit 51c4e4d94d506cf017474262f09bb5f6e2caa640 @robconery robconery committed Jul 2, 2009
Showing with 77,291 additions and 0 deletions.
  1. BIN Dependencies/ComponentFactory.Krypton.Toolkit.dll
  2. BIN Dependencies/MbUnit.Framework.dll
  3. +10,995 −0 Dependencies/MbUnit.Framework.xml
  4. BIN Dependencies/Microsoft.Practices.EnterpriseLibrary.Common.dll
  5. BIN Dependencies/Microsoft.Practices.EnterpriseLibrary.Data.dll
  6. BIN Dependencies/Microsoft.SqlServer.ConnectionInfo.dll
  7. BIN Dependencies/Microsoft.SqlServer.Management.Sdk.Sfc.dll
  8. BIN Dependencies/Microsoft.SqlServer.Smo.dll
  9. BIN Dependencies/Microsoft.SqlServer.SmoExtended.dll
  10. BIN Dependencies/MySql.Data.dll
  11. BIN Dependencies/PropertyGridEx.dll
  12. BIN Dependencies/QuickGraph.Algorithms.dll
  13. BIN Dependencies/QuickGraph.dll
  14. BIN Dependencies/Refly.dll
  15. BIN Dependencies/System.Data.SQLite.DLL
  16. BIN Dependencies/System.Data.SqlServerCe.dll
  17. BIN Dependencies/TestFu.dll
  18. +5,483 −0 Dependencies/TestFu.xml
  19. BIN Dependencies/Wilco.WebServer.dll
  20. BIN GhostDocSettings.gdc
  21. +28 −0 SolutionInfo.cs
  22. +53 −0 SubCommander/Arguments.cs
  23. +87 −0 SubCommander/CodeRunner.cs
  24. +84 −0 SubCommander/DBScripter.cs
  25. +1,148 −0 SubCommander/Program.cs
  26. +22 −0 SubCommander/Properties/App.config
  27. +21 −0 SubCommander/Properties/AssemblyInfo.cs
  28. +126 −0 SubCommander/SubSonic.SubCommander.csproj
  29. +5 −0 SubCommander/SubSonic.SubCommander.csproj.user
  30. BIN SubCommander/bin/Debug/Microsoft.Practices.EnterpriseLibrary.Common.dll
  31. BIN SubCommander/bin/Debug/Microsoft.Practices.EnterpriseLibrary.Data.dll
  32. BIN SubCommander/bin/Debug/Microsoft.SqlServer.ConnectionInfo.dll
  33. BIN SubCommander/bin/Debug/Microsoft.SqlServer.Smo.dll
  34. BIN SubCommander/bin/Debug/MySql.Data.dll
  35. BIN SubCommander/bin/Debug/SubSonic.Migrations.dll
  36. BIN SubCommander/bin/Debug/SubSonic.Migrations.pdb
  37. BIN SubCommander/bin/Debug/SubSonic.dll
  38. BIN SubCommander/bin/Debug/SubSonic.pdb
  39. BIN SubCommander/bin/Debug/System.Data.SQLite.dll
  40. BIN SubCommander/bin/Debug/sonic.exe
  41. +22 −0 SubCommander/bin/Debug/sonic.exe.config
  42. BIN SubCommander/bin/Debug/sonic.pdb
  43. BIN SubCommander/bin/Debug/sonic.vshost.exe
  44. +22 −0 SubCommander/bin/Debug/sonic.vshost.exe.config
  45. +11 −0 SubCommander/bin/Debug/sonic.vshost.exe.manifest
  46. +231 −0 SubCommander/bin/Debug/vs5BB7.tmp
  47. BIN SubCommander/bin/Release/Microsoft.Practices.EnterpriseLibrary.Common.dll
  48. BIN SubCommander/bin/Release/Microsoft.Practices.EnterpriseLibrary.Data.dll
  49. BIN SubCommander/bin/Release/Microsoft.SqlServer.ConnectionInfo.dll
  50. BIN SubCommander/bin/Release/Microsoft.SqlServer.Smo.dll
  51. BIN SubCommander/bin/Release/MySql.Data.dll
  52. BIN SubCommander/bin/Release/SubSonic.Migrations.dll
  53. BIN SubCommander/bin/Release/SubSonic.Migrations.pdb
  54. +103 −0 SubCommander/bin/Release/SubSonic.Migrations.xml
  55. BIN SubCommander/bin/Release/SubSonic.dll
  56. BIN SubCommander/bin/Release/SubSonic.pdb
  57. +14,084 −0 SubCommander/bin/Release/SubSonic.xml
  58. BIN SubCommander/bin/Release/System.Data.SQLite.dll
  59. BIN SubCommander/bin/Release/sonic.exe
  60. +22 −0 SubCommander/bin/Release/sonic.exe.config
  61. BIN SubCommander/bin/Release/sonic.pdb
  62. BIN SubCommander/obj/Debug/ResolveAssemblyReference.cache
  63. +16 −0 SubCommander/obj/Debug/SubSonic.SubCommander.csproj.FileListAbsolute.txt
  64. 0 SubCommander/obj/Debug/build.force
  65. BIN SubCommander/obj/Debug/sonic.exe
  66. BIN SubCommander/obj/Debug/sonic.pdb
  67. BIN SubCommander/obj/Release/ResolveAssemblyReference.cache
  68. +18 −0 SubCommander/obj/Release/SubSonic.SubCommander.csproj.FileListAbsolute.txt
  69. BIN SubCommander/obj/Release/sonic.exe
  70. BIN SubCommander/obj/Release/sonic.pdb
  71. +21 −0 SubCommander/obj/SubSonic.SubCommander.csproj.FileListAbsolute.txt
  72. +9 −0 SubSonic.4.0.resharper.user
  73. +61 −0 SubSonic.4.5.resharper.user
  74. +139 −0 SubSonic.Migrations/CodeRunner.cs
  75. +279 −0 SubSonic.Migrations/Migrator.cs
  76. +33 −0 SubSonic.Migrations/Properties/AssemblyInfo.cs
  77. +71 −0 SubSonic.Migrations/SubSonic.Migrations.csproj
  78. BIN SubSonic.Migrations/SubSonic.snk
  79. BIN SubSonic.Migrations/bin/Debug/Microsoft.Practices.EnterpriseLibrary.Common.dll
  80. BIN SubSonic.Migrations/bin/Debug/Microsoft.Practices.EnterpriseLibrary.Data.dll
  81. BIN SubSonic.Migrations/bin/Debug/MySql.Data.dll
  82. BIN SubSonic.Migrations/bin/Debug/SubSonic.Migrations.dll
  83. BIN SubSonic.Migrations/bin/Debug/SubSonic.Migrations.pdb
  84. BIN SubSonic.Migrations/bin/Debug/SubSonic.dll
  85. BIN SubSonic.Migrations/bin/Debug/SubSonic.pdb
  86. BIN SubSonic.Migrations/bin/Debug/System.Data.SQLite.dll
  87. BIN SubSonic.Migrations/bin/Release/Microsoft.Practices.EnterpriseLibrary.Common.dll
  88. BIN SubSonic.Migrations/bin/Release/Microsoft.Practices.EnterpriseLibrary.Data.dll
  89. BIN SubSonic.Migrations/bin/Release/MySql.Data.dll
  90. BIN SubSonic.Migrations/bin/Release/SubSonic.Migrations.dll
  91. BIN SubSonic.Migrations/bin/Release/SubSonic.Migrations.pdb
  92. +103 −0 SubSonic.Migrations/bin/Release/SubSonic.Migrations.xml
  93. BIN SubSonic.Migrations/bin/Release/SubSonic.dll
  94. BIN SubSonic.Migrations/bin/Release/SubSonic.pdb
  95. +14,084 −0 SubSonic.Migrations/bin/Release/SubSonic.xml
  96. BIN SubSonic.Migrations/bin/Release/System.Data.SQLite.dll
  97. BIN SubSonic.Migrations/obj/Debug/Refactor/SubSonic.Migrations.dll
  98. BIN SubSonic.Migrations/obj/Debug/ResolveAssemblyReference.cache
  99. +11 −0 SubSonic.Migrations/obj/Debug/SubSonic.Migrations.csproj.FileListAbsolute.txt
  100. BIN SubSonic.Migrations/obj/Debug/SubSonic.Migrations.dll
  101. BIN SubSonic.Migrations/obj/Debug/SubSonic.Migrations.pdb
  102. 0 SubSonic.Migrations/obj/Debug/build.force
  103. BIN SubSonic.Migrations/obj/Release/ResolveAssemblyReference.cache
  104. +13 −0 SubSonic.Migrations/obj/Release/SubSonic.Migrations.csproj.FileListAbsolute.txt
  105. BIN SubSonic.Migrations/obj/Release/SubSonic.Migrations.dll
  106. BIN SubSonic.Migrations/obj/Release/SubSonic.Migrations.pdb
  107. +14 −0 SubSonic.Migrations/obj/SubSonic.Migrations.csproj.FileListAbsolute.txt
  108. +246 −0 SubSonic.Tests/ActiveListTests.cs
  109. +271 −0 SubSonic.Tests/ActiveRecordTest.cs
  110. +1,023 −0 SubSonic.Tests/AllStructs.cs
  111. +22 −0 SubSonic.Tests/App.config
  112. +40 −0 SubSonic.Tests/AssemblyCleaner.cs
  113. +136 −0 SubSonic.Tests/CodeGeneratorTests.cs
  114. BIN SubSonic.Tests/DBScripts/Northwind.db3
  115. +6,779 −0 SubSonic.Tests/DBScripts/Northwind_Data_2007_5_7.sql
  116. +754 −0 SubSonic.Tests/DBScripts/Northwind_Schema_2007_5_7.sql
  117. +4,223 −0 SubSonic.Tests/DBScripts/Northwind_Schema_Data_MySQL.sql
  118. +1,845 −0 SubSonic.Tests/DBScripts/Pubs_Data_2007_5_7.sql
  119. +371 −0 SubSonic.Tests/DBScripts/Pubs_Schema_2007_5_7.sql
  120. +77 −0 SubSonic.Tests/DataServiceTest.cs
  121. +96 −0 SubSonic.Tests/ETL.cs
  122. +74 −0 SubSonic.Tests/ForeignKeyTests.cs
  123. +1,065 −0 SubSonic.Tests/Generated/AllStructs.cs
  124. +663 −0 SubSonic.Tests/Generated/Northwind/AlphabeticalListOfProduct.cs
  125. +436 −0 SubSonic.Tests/Generated/Northwind/Category.cs
  126. +118 −0 SubSonic.Tests/Generated/Northwind/CategoryController.cs
  127. +187 −0 SubSonic.Tests/Generated/Northwind/CategorySalesFor1997.cs
  128. +187 −0 SubSonic.Tests/Generated/Northwind/CurrentProductList.cs
  129. +669 −0 SubSonic.Tests/Generated/Northwind/Customer.cs
  130. +243 −0 SubSonic.Tests/Generated/Northwind/CustomerAndSuppliersByCity.cs
  131. +148 −0 SubSonic.Tests/Generated/Northwind/CustomerController.cs
  132. +297 −0 SubSonic.Tests/Generated/Northwind/CustomerCustomerDemo.cs
  133. +124 −0 SubSonic.Tests/Generated/Northwind/CustomerCustomerDemoController.cs
  134. +368 −0 SubSonic.Tests/Generated/Northwind/CustomerDemographic.cs
  135. +112 −0 SubSonic.Tests/Generated/Northwind/CustomerDemographicController.cs
  136. +950 −0 SubSonic.Tests/Generated/Northwind/Employee.cs
  137. +178 −0 SubSonic.Tests/Generated/Northwind/EmployeeController.cs
  138. +297 −0 SubSonic.Tests/Generated/Northwind/EmployeeTerritory.cs
  139. +124 −0 SubSonic.Tests/Generated/Northwind/EmployeeTerritoryController.cs
  140. +859 −0 SubSonic.Tests/Generated/Northwind/Invoice.cs
  141. +238 −0 SubSonic.Tests/Generated/Northwind/MyTb.cs
  142. +108 −0 SubSonic.Tests/Generated/Northwind/MyTbController.cs
  143. +801 −0 SubSonic.Tests/Generated/Northwind/Order.cs
  144. +158 −0 SubSonic.Tests/Generated/Northwind/OrderController.cs
  145. +399 −0 SubSonic.Tests/Generated/Northwind/OrderDetail.cs
  146. +136 −0 SubSonic.Tests/Generated/Northwind/OrderDetailController.cs
  147. +327 −0 SubSonic.Tests/Generated/Northwind/OrderDetailsExtended.cs
  148. +187 −0 SubSonic.Tests/Generated/Northwind/OrderSubtotal.cs
  149. +691 −0 SubSonic.Tests/Generated/Northwind/OrdersQry.cs
  150. +1,005 −0 SubSonic.Tests/Generated/Northwind/Product.cs
  151. +297 −0 SubSonic.Tests/Generated/Northwind/ProductCategoryMap.cs
  152. +124 −0 SubSonic.Tests/Generated/Northwind/ProductCategoryMapController.cs
  153. +174 −0 SubSonic.Tests/Generated/Northwind/ProductController.cs
  154. +215 −0 SubSonic.Tests/Generated/Northwind/ProductSalesFor1997.cs
  155. +187 −0 SubSonic.Tests/Generated/Northwind/ProductsAboveAveragePrice.cs
  156. +271 −0 SubSonic.Tests/Generated/Northwind/ProductsByCategory.cs
  157. +243 −0 SubSonic.Tests/Generated/Northwind/QuarterlyOrder.cs
  158. +293 −0 SubSonic.Tests/Generated/Northwind/Region.cs
  159. +110 −0 SubSonic.Tests/Generated/Northwind/RegionController.cs
  160. +243 −0 SubSonic.Tests/Generated/Northwind/SalesByCategory.cs
  161. +243 −0 SubSonic.Tests/Generated/Northwind/SalesTotalsByAmount.cs
  162. +326 −0 SubSonic.Tests/Generated/Northwind/Shipper.cs
  163. +114 −0 SubSonic.Tests/Generated/Northwind/ShipperController.cs
Sorry, we could not display the entire diff because too many files (1,057) changed.
BIN Dependencies/ComponentFactory.Krypton.Toolkit.dll
Binary file not shown.
BIN Dependencies/MbUnit.Framework.dll
Binary file not shown.
10,995 Dependencies/MbUnit.Framework.xml
10,995 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
BIN Dependencies/Microsoft.Practices.EnterpriseLibrary.Common.dll
Binary file not shown.
BIN Dependencies/Microsoft.Practices.EnterpriseLibrary.Data.dll
Binary file not shown.
BIN Dependencies/Microsoft.SqlServer.ConnectionInfo.dll
Binary file not shown.
BIN Dependencies/Microsoft.SqlServer.Management.Sdk.Sfc.dll
Binary file not shown.
BIN Dependencies/Microsoft.SqlServer.Smo.dll
Binary file not shown.
BIN Dependencies/Microsoft.SqlServer.SmoExtended.dll
Binary file not shown.
BIN Dependencies/MySql.Data.dll
Binary file not shown.
BIN Dependencies/PropertyGridEx.dll
Binary file not shown.
BIN Dependencies/QuickGraph.Algorithms.dll
Binary file not shown.
BIN Dependencies/QuickGraph.dll
Binary file not shown.
BIN Dependencies/Refly.dll
Binary file not shown.
BIN Dependencies/System.Data.SQLite.DLL
Binary file not shown.
BIN Dependencies/System.Data.SqlServerCe.dll
Binary file not shown.
BIN Dependencies/TestFu.dll
Binary file not shown.
5,483 Dependencies/TestFu.xml
5,483 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
BIN Dependencies/Wilco.WebServer.dll
Binary file not shown.
BIN GhostDocSettings.gdc
Binary file not shown.
28 SolutionInfo.cs
@@ -0,0 +1,28 @@
+#region Disclaimer/Info
+/*
+ * SubSonic - http://subsonicproject.com
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an
+ * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+*/
+#endregion
+
+using System.Reflection;
+[assembly: AssemblyDelaySign(false)]
+[assembly: AssemblyCulture("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyInformationalVersion("2.1.1")]
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
53 SubCommander/Arguments.cs
@@ -0,0 +1,53 @@
+/*
+ * SubSonic - http://subsonicproject.com
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an
+ * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+*/
+
+using System.Collections.Specialized;
+using System.Text.RegularExpressions;
+
+namespace SubSonic.SubCommander
+{
+ /// <summary>
+ /// Command Line Parsing Library.
+ /// </summary>
+ public class Arguments
+ {
+ private readonly StringDictionary parameters = new StringDictionary();
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Arguments"/> class.
+ /// </summary>
+ /// <param name="commandLine">The command line.</param>
+ public Arguments(string commandLine)
+ {
+ const string pattern = @"/(?<arg>((?!/).)*?)(\s*""(?<value>[^""]*)""|\s+(?<value>(?!/).*?)([\s]|$)|(?<value>\s+))";
+ Regex regex = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
+ MatchCollection matches = regex.Matches(commandLine);
+ foreach(Match match in matches)
+ {
+ string arg = match.Groups["arg"].Value;
+ string value = match.Groups["value"].Value;
+ parameters.Add(arg, value);
+ }
+ }
+
+ /// <summary>
+ /// Retrieve a parameter value if it exists (overriding C# indexer property)
+ /// </summary>
+ /// <value></value>
+ public string this[string Param]
+ {
+ get { return (parameters[Param]); }
+ }
+ }
+}
87 SubCommander/CodeRunner.cs
@@ -0,0 +1,87 @@
+/*
+ * SubSonic - http://subsonicproject.com
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an
+ * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+*/
+
+using System;
+using System.CodeDom.Compiler;
+using System.Reflection;
+using System.Text;
+
+namespace SubSonic.SubCommander
+{
+ /// <summary>
+ /// Runs and executes code for use with our scripted bits - like Migrations
+ /// </summary>
+ public class CodeRunner
+ {
+ /// <summary>
+ /// Executes the passed-in code
+ /// </summary>
+ /// <param name="lang">ICodeLanguage</param>
+ /// <param name="sourceCode">the code</param>
+ /// <param name="methodName">the entry point method</param>
+ /// <param name="parameters">the params</param>
+ public static void RunAndExecute(ICodeLanguage lang, string sourceCode, string methodName, object[] parameters)
+ {
+ Console.WriteLine("Compiling source code...");
+ string[] source = new string[1];
+ source[0] = sourceCode;
+ CompilerParameters compileParams = new CompilerParameters();
+
+ //Gonna create an assembly on the fly
+ //so we need all the standard DLL's referenced from the GAC
+ compileParams.ReferencedAssemblies.Add("System.Configuration.dll");
+ compileParams.ReferencedAssemblies.Add("System.Web.dll");
+ compileParams.ReferencedAssemblies.Add("System.Data.dll");
+ compileParams.ReferencedAssemblies.Add("System.dll");
+ compileParams.ReferencedAssemblies.Add("System.Xml.dll");
+
+ //add a dash of COM interop
+ compileParams.ReferencedAssemblies.Add("mscorlib.dll");
+
+ //have to make sure SubSonic is added in
+ compileParams.ReferencedAssemblies.Add("SubSonic.dll");
+
+ CompilerResults results = lang.CreateCodeProvider().CompileAssemblyFromSource(compileParams, source);
+
+ if(results.Errors.Count > 0 || results.CompiledAssembly == null)
+ {
+ if(results.Errors.Count > 0)
+ {
+ StringBuilder sbError = new StringBuilder();
+ foreach(CompilerError error in results.Errors)
+ sbError.AppendLine(error.ErrorText);
+
+ //fails
+ throw new Exception("Compile errors: \r\n" + sbError);
+ }
+ if(results.CompiledAssembly == null)
+ throw new Exception("Compiler errors: the code won't compile");
+ return;
+ }
+
+ Console.WriteLine("Done!");
+ Console.WriteLine("Executing " + methodName);
+
+ const string stubTypeName = "SubSonic.MigrationRunner";
+ //instance up the class
+ object instance = results.CompiledAssembly.CreateInstance(stubTypeName);
+ Type instanceType = instance.GetType();
+
+ //grab the method we're looking for
+ MethodInfo method = instanceType.GetMethod(methodName);
+
+ method.Invoke(instance, parameters);
+ }
+ }
+}
84 SubCommander/DBScripter.cs
@@ -0,0 +1,84 @@
+/*
+ * SubSonic - http://subsonicproject.com
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an
+ * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+*/
+
+using System.Collections.Specialized;
+using System.Data.SqlClient;
+using System.Text;
+using Microsoft.SqlServer.Management.Common;
+using Microsoft.SqlServer.Management.Smo;
+
+namespace SubSonic.SubCommander
+{
+ /// <summary>
+ ///
+ /// </summary>
+ public class DBScripter
+ {
+ /// <summary>
+ /// Scripts the data.
+ /// </summary>
+ /// <param name="tableName">Name of the table.</param>
+ /// <param name="providerName">Name of the provider.</param>
+ /// <returns></returns>
+ public static string ScriptData(string tableName, string providerName)
+ {
+ return DataService.ScriptData(tableName, providerName);
+ }
+
+ /// <summary>
+ /// Scripts the schema.
+ /// </summary>
+ /// <param name="connectionString">The connection string.</param>
+ /// <returns></returns>
+ public static string ScriptSchema(string connectionString)
+ {
+ StringBuilder result = new StringBuilder();
+
+ SqlConnection conn = new SqlConnection(connectionString);
+ SqlConnectionStringBuilder cString = new SqlConnectionStringBuilder(connectionString);
+ ServerConnection sconn = new ServerConnection(conn);
+ Server server = new Server(sconn);
+ Database db = server.Databases[cString.InitialCatalog];
+ Transfer trans = new Transfer(db);
+
+ //set the objects to copy
+ trans.CopyAllTables = true;
+ trans.CopyAllDefaults = true;
+ trans.CopyAllUserDefinedFunctions = true;
+ trans.CopyAllStoredProcedures = true;
+ trans.CopyAllViews = true;
+ trans.CopyData = true;
+ trans.CopySchema = true;
+ trans.DropDestinationObjectsFirst = true;
+ trans.UseDestinationTransaction = true;
+
+ trans.Options.AnsiFile = true;
+ trans.Options.ClusteredIndexes = true;
+ trans.Options.DriAll = true;
+ trans.Options.IncludeHeaders = true;
+ trans.Options.IncludeIfNotExists = true;
+ trans.Options.SchemaQualify = true;
+
+ StringCollection script = trans.ScriptTransfer();
+
+ foreach(string s in script)
+ result.AppendLine(s);
+
+ result.AppendLine();
+ result.AppendLine();
+
+ return result.ToString();
+ }
+ }
+}
1,148 SubCommander/Program.cs
@@ -0,0 +1,1148 @@
+/*
+ * SubSonic - http://subsonicproject.com
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an
+ * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.Configuration;
+using System.Configuration.Provider;
+using System.Diagnostics;
+using System.IO;
+using System.Reflection;
+using System.Web.Configuration;
+using SubSonic.Migrations;
+using SubSonic.Sugar;
+using SubSonic.Utilities;
+
+namespace SubSonic.SubCommander
+{
+ /// <summary>
+ ///
+ /// </summary>
+ internal class Program
+ {
+ private delegate void ActionDelegate();
+ private static readonly TurboCompiler turboCompiler = new TurboCompiler();
+ private static string[] ArgList = new string[0];
+ private static Arguments arguments;
+ private static ICodeLanguage language = new CSharpCodeLanguage();
+
+ /// <summary>
+ /// Main
+ /// </summary>
+ /// <param name="args">The args.</param>
+ private static void Main(string[] args)
+ {
+ Stopwatch timer = new Stopwatch();
+ timer.Start();
+ arguments = new Arguments(Environment.CommandLine);
+ ArgList = args;
+ //the first args gonna tell us what to do
+ string command = String.Empty;
+ if(args.Length > 0)
+ command = args[0];
+
+ // Set DataDirectory macro for compatibility with ASP.NET's App_Data folder
+ AppDomain.CurrentDomain.SetData("DataDirectory",
+ Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "App_Data");
+
+ try
+ {
+ Dictionary<string, ActionDelegate> commandsToActions = new Dictionary<string, ActionDelegate>();
+ commandsToActions["scriptdata"] = ScriptData;
+ commandsToActions["migrate"] = Migrate;
+ commandsToActions["scriptschema"] = ScriptSchema;
+ commandsToActions["version"] = VersionDB;
+ commandsToActions["generatetables"] = GenerateTables;
+ commandsToActions["generateods"] = GenerateODSControllers;
+ commandsToActions["generateviews"] = GenerateViews;
+ commandsToActions["generatesps"] = GenerateSPs;
+ commandsToActions["generate"] = GenerateAll;
+ commandsToActions["generateall"] = GenerateAll;
+ commandsToActions["generateeditor"] = GenerateEditor;
+ commandsToActions["editor"] = GenerateEditor;
+ commandsToActions["help"] = delegate { ThrowHelp(true); };
+ commandsToActions["dir"] = delegate
+ {
+ Console.WriteLine(Directory.GetCurrentDirectory());
+ Console.WriteLine("");
+ Console.WriteLine("Press any key to exit...");
+ Console.Read();
+ };
+
+ //find appropriate command
+ string key = command.ToLower();
+ if(commandsToActions.ContainsKey(key))
+ {
+ //execute it!
+ ActionDelegate action = commandsToActions[key];
+ action();
+ }
+ else
+ {
+ Console.WriteLine("ERROR: No Command Specified");
+ ThrowHelp(true);
+ }
+
+ if(turboCompiler.Templates.Count > 0)
+ {
+ Console.WriteLine("Running Compiler...");
+ turboCompiler.Run();
+ Console.WriteLine("Writing Files...");
+ foreach(TurboTemplate template in turboCompiler.Templates)
+ {
+ Utility.WriteTrace(String.Concat("Writing ", template.TemplateName, " as ", template.OutputPath.Substring(template.OutputPath.LastIndexOf("\\") + 1)));
+ Files.CreateToFile(template.OutputPath, template.FinalCode);
+ }
+ Console.WriteLine("Done!");
+ }
+ }
+ catch(Exception x)
+ {
+ Console.WriteLine("ERROR: Trying to execute {0}{1}Error Message: {2}", command, Environment.NewLine, x);
+ }
+ timer.Stop();
+ Console.WriteLine("Execution Time: {0}ms", timer.ElapsedMilliseconds);
+ }
+
+ /// <summary>
+ /// Throws the help.
+ /// </summary>
+ /// <param name="verbose">if set to <c>true</c> [verbose].</param>
+ private static void ThrowHelp(bool verbose)
+ {
+ WriteVersionInformation("sonic.exe v{0} - Command Line Interface to SubSonic v{1}");
+ Console.WriteLine("Usage: sonic command [options]");
+ Console.WriteLine("Sample: sonic generate /server localhost /db northwind /out GeneratedFiles");
+ Console.WriteLine("Help: sonic help");
+ Console.WriteLine("TIP: SubSonic will read your App.Config or Web.Config - just select the project ");
+ Console.WriteLine("and run your command.");
+ Console.WriteLine(String.Empty);
+ if(!verbose)
+ return;
+
+ Console.WriteLine("******************** Commands *********************************");
+ Console.WriteLine("version: Scripts out the schema/data of your db to file");
+ Console.WriteLine("scriptdata: Scripts the data to file for your database");
+ Console.WriteLine("scriptschema: Scripts your Database schema to file");
+ Console.WriteLine("generate: Generates output code for tables, views, and SPs");
+ Console.WriteLine("generatetables: Generates output code for your tables");
+ Console.WriteLine("generateODS: Generates and ObjectDataSource controller for each table");
+ Console.WriteLine("generateviews: Generates output code for your views");
+ Console.WriteLine("generatesps: Generates output code for your SPs");
+ Console.WriteLine("editor: Creates an Editor for a particular table");
+ Console.WriteLine("migrate: Migrate the database using migrations in \\Migrations folder");
+ Console.WriteLine(String.Empty);
+ Console.WriteLine("******************** Argument List ****************************");
+ Console.WriteLine("####### Required For all commands (these can be read from config files)");
+ Console.WriteLine("if you don't have a Web or App.config, these need to be set");
+ Console.WriteLine("/override SubCommander won't try to find a config - instead it will use what you pass in");
+ Console.WriteLine("/server - the database server - ALWAYS REQUIRED");
+ Console.WriteLine("/db - the database to use");
+ Console.WriteLine(String.Empty);
+ Console.WriteLine("####### Other Commands (some may be required for specific commands)");
+ Console.WriteLine("/userid - the User ID for your database (blank = use SSPI)");
+ Console.WriteLine("/password - the password for your DB (blank = use SSPI)");
+ Console.WriteLine("/out - the output directory for generated items. (default = current)");
+
+ List<string> languages = new List<string>();
+ foreach(ICodeLanguage codeLanguage in CodeLanguageFactory.AllCodeLanguages)
+ languages.Add(codeLanguage.ShortName);
+
+ Console.WriteLine(
+ String.Format("/lang - generated code language: {0} (default = {1})",
+ String.Join(", ", languages.ToArray()), CodeLanguageFactory.DefaultCodeLanguage.ShortName));
+ Console.WriteLine("/provider - the name of the provider to use");
+ Console.WriteLine("/includeTableList - used for generating classes. A comma-delimited list that ");
+ Console.WriteLine(" defines which tables should be used to generate classes");
+ Console.WriteLine("/config - the path your App/Web.Config - used to instance SubSonic ");
+ Console.WriteLine("/excludeTableList -the opposite of tablelist. These tables will NOT be ");
+ Console.WriteLine(" used to generate classes");
+ Console.WriteLine("/version - Version to migrate database to");
+ Console.WriteLine("/migrationDirectory - Directory containing migration files. Defaults to \\Migrations");
+ Console.WriteLine("/groupOutput - Allows you to group your generated code into subfolders. Options are schema, type, schemaAndType.");
+ Console.WriteLine(" 'schema' refers to SQL database schema (i.e. dbo) and 'type' refers to Models/Controllers/Views");
+ Console.WriteLine("/migrationDirectory - Directory containing migration files. Defaults to \\Migrations");
+
+
+ Console.WriteLine(String.Empty);
+ Console.WriteLine("******** Arguments Matching SubSonic web.config Settings ********");
+ Console.WriteLine("Just add a '/' in front");
+ Console.WriteLine("/generatedNamespace - the namespace to use for generated code");
+ Console.WriteLine("/templateDirectory - the directory containing template overrides");
+ Console.WriteLine("/fixDatabaseObjectCasing - fix the capitilization of object generated from database? true/false (default is true)");
+ Console.WriteLine("/fixPluralClassNames - reset all plural table names to singular? true/false");
+ Console.WriteLine("/useSPs - whether to generate SP wrapper (true/false)");
+ Console.WriteLine("/spClassName - default is 'StoredProcedures' - this will override that");
+ Console.WriteLine("/stripTableText - replace table text with this command");
+ Console.WriteLine("/stripColumnText - replace column text with this command");
+ Console.WriteLine("/stripParamText - replace SP param text with this command");
+ Console.WriteLine("/appendWith - when you have reserved words in your table columns");
+ Console.WriteLine(" we need to append it with something. Our default is 'X'.");
+ Console.WriteLine(" You can change that here.");
+ Console.WriteLine("/spStartsWith - use SPs that start with this");
+ Console.WriteLine("/viewStartsWith - use Views that start with this");
+ Console.WriteLine("/relatedTableLoadPrefix - prefix related table loaders");
+ Console.WriteLine("/removeUnderscores - whether to remove underscores from generated object");
+ Console.WriteLine(" names (true/false) default is false");
+ Console.WriteLine("/templateDirectory The path to your custom templates. This is a directory reference");
+ Console.WriteLine("/regexMatchExpression");
+ Console.WriteLine("/regexReplaceExpression");
+ Console.WriteLine("/regexIgnoreCase");
+ Console.WriteLine("/regexDictionaryReplace");
+ Console.WriteLine("/generateLazyLoads");
+ Console.WriteLine("/generateRelatedTablesAsProperties");
+ Console.WriteLine("/extractClassNameFromSPName");
+ Console.WriteLine("/includeProcedureList");
+ Console.WriteLine("/excludeProcedureList");
+ Console.WriteLine("/useExtendedProperties");
+ Console.WriteLine("/useUtc");
+ Console.WriteLine("/additionalNamespaces");
+ }
+
+ /// <summary>
+ /// Writes the version information.
+ /// </summary>
+ /// <param name="formatString">The format string.</param>
+ private static void WriteVersionInformation(string formatString)
+ {
+ Assembly asm = Assembly.GetExecutingAssembly();
+ string sonicVersion = asm.GetName().Version.ToString();
+ string subSonicVersion = "---";
+
+ AssemblyName[] asmNames = asm.GetReferencedAssemblies();
+ foreach(AssemblyName nm in asmNames)
+ {
+ if(nm.Name == "SubSonic")
+ {
+ subSonicVersion = nm.Version.ToString();
+ break;
+ }
+ }
+
+ Console.WriteLine(formatString, sonicVersion, subSonicVersion);
+ }
+
+
+ #region Migrations
+
+ /// <summary>
+ /// Migrates the specified migration directory.
+ /// </summary>
+ public static void Migrate()
+ {
+ SetProvider();
+
+ string providerName = GetArg("provider");
+ if(String.IsNullOrEmpty(providerName))
+ providerName = DataService.Provider.Name;
+
+ string migrationDirectory = GetArg("migrationDirectory");
+ if(String.IsNullOrEmpty(migrationDirectory))
+ migrationDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Migrations");
+
+ string sVersion = GetArg("version");
+ int? toVersion = null;
+ if(!String.IsNullOrEmpty(sVersion))
+ {
+ int version;
+ if(int.TryParse(sVersion, out version))
+ toVersion = version;
+ }
+
+ Migrator.Migrate(providerName, migrationDirectory, toVersion);
+ }
+
+ #endregion
+
+
+ #region Provider Startup
+
+ /// <summary>
+ /// Gets the config path.
+ /// </summary>
+ /// <returns></returns>
+ private static string GetConfigPath()
+ {
+ // Try cmd line arg first.
+ string configArg = GetArg("config");
+
+ string configPath = GetConfigInDir(configArg);
+ if(configPath != null)
+ return configPath;
+
+ string thisDir = Directory.GetCurrentDirectory();
+
+ configPath = GetConfigInDir(Path.Combine(thisDir, configArg));
+ if(configPath != null)
+ return configPath;
+
+ return GetConfigInDir(thisDir);
+ }
+
+ /// <summary>
+ /// Tries to find the config file in the specified directory.
+ /// </summary>
+ /// <param name="directory">The directory.</param>
+ /// <returns></returns>
+ private static string GetConfigInDir(string directory)
+ {
+ if(File.Exists(directory))
+ return directory;
+
+ string webConfigPath = Path.Combine(directory, "Web.config");
+ if(File.Exists(webConfigPath))
+ return webConfigPath;
+
+ string appConfigPath = Path.Combine(directory, "App.config");
+ if(File.Exists(appConfigPath))
+ return appConfigPath;
+
+ return null;
+ }
+
+ /// <summary>
+ /// Sets the provider.
+ /// </summary>
+ private static void SetProvider()
+ {
+ string overrideFlag = GetArg("override");
+ bool configSet = false;
+ if(String.IsNullOrEmpty(overrideFlag))
+ {
+ string configPath = GetConfigPath();
+ if(File.Exists(configPath))
+ {
+ configSet = true;
+ Console.WriteLine("Setting ConfigPath: '{0}'", configPath);
+ SetProvider(configPath);
+ }
+ }
+
+ if(!configSet)
+ SetProviderManually();
+ }
+
+ /// <summary>
+ /// Sets the provider manually.
+ /// </summary>
+ private static void SetProviderManually()
+ {
+ string traceFlag = GetArg(ConfigurationPropertyName.ENABLE_TRACE);
+
+ if(!String.IsNullOrEmpty(traceFlag))
+ DataService.EnableTrace = Convert.ToBoolean(traceFlag);
+
+ Utility.WriteTrace("Setting config manually - need AT LEAST a /server and /db");
+
+ //clear the providers and reset
+ DataService.Provider = new SqlDataProvider();
+ DataService.Providers = new DataProviderCollection();
+
+ //instance a section - we'll set this manually for the DataService
+ SubSonicSection section = new SubSonicSection();
+ section.TemplateDirectory = GetArg(ConfigurationPropertyName.TEMPLATE_DIRECTORY);
+ CodeService.TemplateDirectory = section.TemplateDirectory;
+
+ string providerName = GetArg(ConfigurationPropertyName.PROVIDER_TO_USE);
+ if(string.IsNullOrEmpty(providerName))
+ providerName = "Default";
+ section.DefaultProvider = providerName;
+
+ section.DefaultProvider = "Default";
+
+ CodeService.TemplateDirectory = section.TemplateDirectory;
+
+ //set the properties
+ DataProvider provider = DataService.Provider;
+ NameValueCollection config = new NameValueCollection();
+
+ //need to add this for now
+ config.Add("connectionStringName", "Default");
+
+ if(!string.IsNullOrEmpty(GetArg(ConfigurationPropertyName.TEMPLATE_DIRECTORY)))
+ config.Add(ConfigurationPropertyName.TEMPLATE_DIRECTORY, GetArg(ConfigurationPropertyName.TEMPLATE_DIRECTORY));
+
+ //setup the config
+ SetConfig(config, ConfigurationPropertyName.APPEND_WITH);
+ SetConfig(config, ConfigurationPropertyName.ADDITIONAL_NAMESPACES);
+ SetConfig(config, ConfigurationPropertyName.EXCLUDE_PROCEDURE_LIST);
+ SetConfig(config, ConfigurationPropertyName.EXCLUDE_TABLE_LIST);
+ SetConfig(config, ConfigurationPropertyName.EXTRACT_CLASS_NAME_FROM_SP_NAME);
+ SetConfig(config, ConfigurationPropertyName.FIX_DATABASE_OBJECT_CASING);
+ SetConfig(config, ConfigurationPropertyName.FIX_PLURAL_CLASS_NAMES);
+ SetConfig(config, ConfigurationPropertyName.GENERATED_NAMESPACE);
+ SetConfig(config, ConfigurationPropertyName.GENERATE_LAZY_LOADS);
+ SetConfig(config, ConfigurationPropertyName.GENERATE_NULLABLE_PROPERTIES);
+ SetConfig(config, ConfigurationPropertyName.GENERATE_ODS_CONTROLLERS);
+ SetConfig(config, ConfigurationPropertyName.GENERATE_RELATED_TABLES_AS_PROPERTIES);
+ SetConfig(config, ConfigurationPropertyName.INCLUDE_PROCEDURE_LIST);
+ SetConfig(config, ConfigurationPropertyName.INCLUDE_TABLE_LIST);
+ SetConfig(config, ConfigurationPropertyName.REGEX_DICTIONARY_REPLACE);
+ SetConfig(config, ConfigurationPropertyName.REGEX_IGNORE_CASE);
+ SetConfig(config, ConfigurationPropertyName.REGEX_MATCH_EXPRESSION);
+ SetConfig(config, ConfigurationPropertyName.REGEX_REPLACE_EXPRESSION);
+ SetConfig(config, ConfigurationPropertyName.RELATED_TABLE_LOAD_PREFIX);
+ SetConfig(config, ConfigurationPropertyName.REMOVE_UNDERSCORES);
+ SetConfig(config, ConfigurationPropertyName.SET_PROPERTY_DEFAULTS_FROM_DATABASE);
+ SetConfig(config, ConfigurationPropertyName.SP_STARTS_WITH);
+ SetConfig(config, ConfigurationPropertyName.STORED_PROCEDURE_CLASS_NAME);
+ SetConfig(config, ConfigurationPropertyName.STRIP_COLUMN_TEXT);
+ SetConfig(config, ConfigurationPropertyName.STRIP_PARAM_TEXT);
+ SetConfig(config, ConfigurationPropertyName.STRIP_STORED_PROCEDURE_TEXT);
+ SetConfig(config, ConfigurationPropertyName.STRIP_TABLE_TEXT);
+ SetConfig(config, ConfigurationPropertyName.STRIP_VIEW_TEXT);
+ SetConfig(config, ConfigurationPropertyName.USE_EXTENDED_PROPERTIES);
+ SetConfig(config, ConfigurationPropertyName.USE_STORED_PROCEDURES);
+ SetConfig(config, ConfigurationPropertyName.USE_UTC_TIMES);
+ SetConfig(config, ConfigurationPropertyName.VIEW_STARTS_WITH);
+ SetConfig(config, ConfigurationPropertyName.GROUP_OUTPUT);
+
+ //initialize the provider
+ Utility.WriteTrace("Initializing the provider with the passed in configuration >>> hold on to your hats...");
+ provider.Initialize(providerName, config);
+
+ //first, make sure there's a connection
+ Utility.WriteTrace("Overriding the connection string...");
+ provider.DefaultConnectionString = GetConnnectionString();
+ Utility.WriteTrace("Set connection string to " + provider.DefaultConnectionString);
+
+ DataService.Providers.Add(provider);
+ }
+
+ /// <summary>
+ /// Sets the config.
+ /// </summary>
+ /// <param name="config">The config.</param>
+ /// <param name="key">The key.</param>
+ private static void SetConfig(NameValueCollection config, string key)
+ {
+ string setting = GetArg(key);
+ if(!String.IsNullOrEmpty(setting))
+ {
+ Utility.WriteTrace("Setting " + key + " to " + setting);
+ config.Add(key, setting);
+ }
+ }
+
+ /// <summary>
+ /// Sets the provider.
+ /// </summary>
+ /// <param name="appConfigPath">The app config path.</param>
+ private static void SetProvider(string appConfigPath)
+ {
+ //clear the providers and reset
+ DataService.Provider = new SqlDataProvider();
+ DataService.Providers = new DataProviderCollection();
+
+ //if present, get the connection strings and the SubSonic config
+ if(File.Exists(appConfigPath))
+ {
+ ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
+ Console.WriteLine("Building configuration from " + Path.Combine(Directory.GetCurrentDirectory(), appConfigPath));
+ fileMap.ExeConfigFilename = appConfigPath;
+
+ // Open another config file
+ Configuration subConfig = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
+
+ try
+ {
+ SubSonicSection section = (SubSonicSection)subConfig.GetSection(ConfigurationSectionName.SUB_SONIC_SERVICE);
+
+ if(section != null)
+ {
+ DataService.ConfigSection = section;
+ string argTemplateDirectory = GetArg(ConfigurationPropertyName.TEMPLATE_DIRECTORY);
+ string activeTemplateDirectory = String.IsNullOrEmpty(argTemplateDirectory) ? section.TemplateDirectory : argTemplateDirectory;
+
+ string argTraceFlag = GetArg(ConfigurationPropertyName.ENABLE_TRACE);
+ string activeTraceFlag = String.IsNullOrEmpty(argTraceFlag) ? section.EnableTrace : argTraceFlag;
+
+ if(!String.IsNullOrEmpty(activeTraceFlag))
+ DataService.EnableTrace = Convert.ToBoolean(activeTraceFlag);
+
+ if(!String.IsNullOrEmpty(activeTemplateDirectory))
+ {
+ Console.WriteLine("Overriding default templates with those from " + section.TemplateDirectory);
+ CodeService.TemplateDirectory = activeTemplateDirectory;
+ }
+
+ //initialize
+ //need to pull out the default connection string
+ //since this application doesn't have a config file, the target one does
+ //so reconciling connection string won't work
+ string connectionStringName = section.Providers[0].Parameters["connectionStringName"];
+ if(connectionStringName == null)
+ throw new ConfigurationErrorsException("The Parameter 'connectionStringName' was not specified");
+
+ ConnectionStringSettings connSettings = subConfig.ConnectionStrings.ConnectionStrings[connectionStringName];
+ if(connSettings == null)
+ throw new ConfigurationErrorsException(string.Format("ConnectionStrings section missing connection string with the name '{0}'", connectionStringName));
+
+ string connString = subConfig.ConnectionStrings.ConnectionStrings[connectionStringName].ConnectionString;
+ //DataService.ConnectionString = connString;
+
+ ProvidersHelper.InstantiateProviders(section.Providers, DataService.Providers, typeof(DataProvider));
+
+ //this is a tad backwards, but it's what needs to happen since our application
+ //is configuring another application's providers
+ //go back and reset the provider's connection strings
+
+ //int counter = 0;
+ foreach(DataProvider provider in DataService.Providers)
+ {
+ Console.WriteLine("Adding connection to " + provider.Name);
+
+ provider.SetDefaultConnectionString(subConfig.ConnectionStrings.ConnectionStrings[provider.ConnectionStringName].ConnectionString);
+ //provider.ConnectionString = subConfig.ConnectionStrings.ConnectionStrings[provider.ConnectionStringName].ConnectionString;
+ }
+
+ //reset the default provider
+ string providerName = GetArg("provider");
+ if(providerName != String.Empty)
+ {
+ try
+ {
+ DataService.Provider = DataService.Providers[providerName];
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("ERROR: There is no provider with the name '{0}'. Exception: {1}", providerName, e);
+ }
+ }
+ else
+ DataService.Provider = DataService.Providers[section.DefaultProvider];
+ }
+ }
+ catch(ConfigurationErrorsException x)
+ {
+ //let the user know the config was problematic...
+ Console.WriteLine(
+ "Can't set the configuration for the providers. There is an error with your config setup (did you remember to configure SubSonic in your config file?). '{0}'",
+ x.Message);
+ }
+ }
+ else
+ throw new Exception("There's no config file present at " + appConfigPath);
+ }
+
+ /// <summary>
+ /// Gets the output directory.
+ /// </summary>
+ /// <returns></returns>
+ private static string GetOutputDirectory()
+ {
+ string result;
+
+ //this can be an absolute reference, or a partial name of a directory
+ //like "App_Code/Generated"
+
+ //see if this path is absolute
+ string thisOutput = GetArg("out");
+
+ //if there's a drive specified, then it's absolute
+ result = thisOutput.Contains(":") ? thisOutput : Path.Combine(Directory.GetCurrentDirectory(), thisOutput);
+
+ //now, if the output directory doesn't exist, create it
+ if(!Directory.Exists(result))
+ Directory.CreateDirectory(result);
+
+ return result;
+ }
+
+ #endregion
+
+
+ #region Utility
+
+ /// <summary>
+ /// Outputs the file.
+ /// </summary>
+ /// <param name="filePath">The file path.</param>
+ /// <param name="fileText">The file text.</param>
+ private static void OutputFile(string filePath, string fileText)
+ {
+ using(StreamWriter sw = File.CreateText(filePath))
+ sw.Write(fileText);
+ }
+
+ /// <summary>
+ /// Gets the arg.
+ /// </summary>
+ /// <param name="argSwitch">The arg switch.</param>
+ /// <returns></returns>
+ private static string GetArg(string argSwitch)
+ {
+ return arguments[argSwitch] ?? String.Empty;
+ }
+
+ /// <summary>
+ /// Gets the connnection string.
+ /// </summary>
+ /// <returns></returns>
+ private static string GetConnnectionString()
+ {
+ bool haveError = false;
+
+ string server = GetArg("server");
+ string db = GetArg("db");
+
+ if(server == String.Empty)
+ {
+ Console.WriteLine("No server name was passed in - please specify using /s MyServerName");
+ haveError = true;
+ }
+ if(db == String.Empty)
+ {
+ Console.WriteLine("No Database name was passed in - please specify using /db MyDatabaseName");
+ haveError = true;
+ }
+
+ //optional
+ //string tableList = GetArg("tablelist"); //Not being used.
+ string userID = GetArg("userid");
+ string pasword = GetArg("password");
+ string sConn = String.Empty;
+ if(!haveError)
+ {
+ sConn = "Server=" + server + ";Database=" + db + ";";
+ if(userID == String.Empty)
+ sConn += "Integrated Security=SSPI;";
+ else
+ sConn += "User ID=" + userID + ";Password=" + pasword;
+ }
+ else
+ ThrowHelp(false);
+
+ return sConn;
+ }
+
+ #endregion
+
+
+ #region Scripters
+
+ /// <summary>
+ /// Versions the DB.
+ /// </summary>
+ private static void VersionDB()
+ {
+ ScriptSchema();
+ ScriptData();
+ }
+
+ /// <summary>
+ /// Scripts the data.
+ /// </summary>
+ private static void ScriptData()
+ {
+ SetProvider();
+ //for this to work, we need a Servername, DB, and output. Optional elements are table list and user id/password
+ //string[] tables = DataService.GetTableNames(SubSonicConfig.ProviderName);
+ foreach(DataProvider provider in DataService.Providers)
+ {
+ //string[] tables = DataService.GetTableNames(provider.Name);
+ string[] tables = DataService.GetOrderedTableNames(provider.Name);
+
+ string outDir = GetOutputDirectory();
+ if(outDir == String.Empty)
+ outDir = Directory.GetCurrentDirectory();
+
+ Utility.WriteTrace("Scripting Data");
+ Utility.WriteTrace("#####################################");
+
+ string outFileName = string.Format("{0}_Data_{1}_{2}_{3}.sql", provider.Name, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
+ string outPath = Path.Combine(outDir, outFileName);
+
+ using(StreamWriter sw = File.CreateText(outPath))
+ {
+ foreach(string tbl in tables)
+ {
+ if(IsInList(tbl) || CodeService.ShouldGenerate(tbl, provider.Name))
+ {
+ Utility.WriteTrace(String.Format("Scripting Table: {0}", tbl));
+ string dataScript = DBScripter.ScriptData(tbl, provider.Name);
+ sw.Write(dataScript);
+ sw.Write(Environment.NewLine);
+ }
+ }
+ }
+
+ Utility.WriteTrace("Finished!");
+ }
+ }
+
+ /// <summary>
+ /// Scripts the schema.
+ /// </summary>
+ private static void ScriptSchema()
+ {
+ SetProvider();
+
+ foreach(DataProvider provider in DataService.Providers)
+ {
+ string sConn = provider.DefaultConnectionString; //GetConnnectionString();
+
+ if(sConn != String.Empty)
+ {
+ Utility.WriteTrace("Scripting Schema:" + provider.Name);
+ Utility.WriteTrace("#####################################");
+ //string db = GetArg("db");
+ string outDir = GetOutputDirectory();
+
+ string schema = DBScripter.ScriptSchema(sConn);
+ string outFileName =
+ string.Format("{0}_{1}_{2}_{3}_{4}_Schema.sql", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, Environment.UserName, provider.Name);
+ string outPath = Path.Combine(outDir, outFileName);
+
+ OutputFile(outPath, schema);
+ Console.WriteLine("Finished!");
+ }
+ }
+ }
+
+ #endregion
+
+
+ #region Generators
+
+ /// <summary>
+ /// Generates the editor.
+ /// </summary>
+ private static void GenerateEditor()
+ {
+ string table = GetArg("table");
+ string outDir = GetOutputDirectory();
+ GenerateEditor(table, outDir);
+ }
+
+ /// <summary>
+ /// Generates the editor.
+ /// </summary>
+ /// <param name="table">The table.</param>
+ /// <param name="outDir">The out dir.</param>
+ private static void GenerateEditor(string table, string outDir)
+ {
+ bool haveError = false;
+ WriteVersionInformation(String.Empty);
+
+ if(table == String.Empty)
+ {
+ Console.WriteLine("No table name was entered; please specify the name of the table using /table");
+ haveError = true;
+ }
+
+ if(!haveError)
+ {
+ Console.WriteLine("Generating editor for " + table);
+
+ if(DataService.Provider == null)
+ SetProvider();
+
+ language = CodeLanguageFactory.GetByShortName(GetArg("lang"));
+
+ TableSchema.Table tableSchema = DataService.GetSchema(table, DataService.Provider.Name, TableType.Table);
+ string pageName = tableSchema.ClassName + "Editor.aspx";
+ string codePageName = pageName + language.FileExtension;
+ string pageFile = Path.Combine(outDir, pageName);
+ string codeFile = Path.Combine(outDir, codePageName);
+
+ //generate up the editor
+ try
+ {
+ //string page = ScaffoldCodeGenerator.GeneratePage(DataService.Provider.Name, table, pageName, "", langType);
+ //string code = ScaffoldCodeGenerator.GenerateCode(pageName, DataService.Provider.Name, table, langType);
+ //string page = "";
+ //string code = "";
+ //Clipboard.SetData(System.Windows.Forms.DataFormats.StringFormat, page);
+ //OutputFile(pageFile, page);
+ //OutputFile(codeFile, code);
+ //Console.WriteLine("Copied to clipboard" + pageName);
+ }
+ catch
+ {
+ Console.WriteLine("ERROR: Can't generate editor for " + table + ".");
+ Console.WriteLine("Please check the table name and that the you specified the right provider (you can set the provider by using /provider)");
+ }
+ }
+ else
+ ThrowHelp(false);
+ }
+
+ /// <summary>
+ /// Generates all.
+ /// </summary>
+ private static void GenerateAll()
+ {
+ GenerateTables();
+ GenerateODSControllers();
+ GenerateViews();
+ GenerateSPs();
+ GenerateStructs();
+ }
+
+ /// <summary>
+ /// Determines whether the specified table name is excluded.
+ /// </summary>
+ /// <param name="tableName">Name of the table.</param>
+ /// <returns>
+ /// <c>true</c> if the specified table name is excluded; otherwise, <c>false</c>.
+ /// </returns>
+ private static bool IsExcluded(string tableName)
+ {
+ bool bOut = false;
+ string excludeList = GetArg("excludelist");
+
+ if(excludeList != String.Empty)
+ {
+ string[] tables = excludeList.Split(',');
+ foreach(string tbl in tables)
+ {
+ if(tbl.ToLower() == tableName.ToLower())
+ {
+ bOut = true;
+ break;
+ }
+ }
+ }
+ return bOut;
+ }
+
+ /// <summary>
+ /// Determines whether [is in list] [the specified table name].
+ /// </summary>
+ /// <param name="tableName">Name of the table.</param>
+ /// <returns>
+ /// <c>true</c> if [is in list] [the specified table name]; otherwise, <c>false</c>.
+ /// </returns>
+ private static bool IsInList(string tableName)
+ {
+ string tableList = GetArg("tablelist");
+ bool bOut = false;
+
+ if(tableList.Trim() == "*")
+ bOut = true;
+ else
+ {
+ if(tableList != String.Empty)
+ {
+ string[] tables = tableList.Split(',');
+ foreach(string tbl in tables)
+ {
+ if(tbl.ToLower() == tableName.ToLower())
+ {
+ bOut = true;
+ break;
+ }
+ }
+ }
+ else
+ {
+ //it's not set, default it to true
+ bOut = true;
+ }
+ }
+
+ return bOut;
+ }
+
+ /// <summary>
+ /// Gets the out sub dir.
+ /// </summary>
+ /// <param name="provider">The provider.</param>
+ /// <returns></returns>
+ private static string GetOutSubDir(ProviderBase provider)
+ {
+ string outDir = GetOutputDirectory();
+ if(outDir == String.Empty)
+ outDir = Directory.GetCurrentDirectory();
+
+ if(DataService.Providers.Count > 1)
+ {
+ //this is set by the routines
+ outDir = Path.Combine(outDir, provider.Name);
+ }
+ if(!Directory.Exists(outDir))
+ Directory.CreateDirectory(outDir);
+
+ return outDir;
+ }
+
+ /// <summary>
+ /// Generates the tables.
+ /// </summary>
+ private static void GenerateTables()
+ {
+ //if (DataService.Provider == null)
+ SetProvider();
+
+ language = CodeLanguageFactory.GetByShortName(GetArg("lang"));
+ //string usings = ParseUtility.GetUsings(language);
+
+ if(DataService.Providers.Count == 0)
+ Console.WriteLine("There's a problem with the providers - none were loaded and no exceptions where thrown.");
+ else
+ {
+ //loop the providers, and if there's more than one, output to their own folder
+ //for tidiness
+ foreach(DataProvider provider in DataService.Providers)
+ {
+ //get the table list
+ string[] tables = DataService.GetTableNames(provider.Name);
+
+ int tableCount = 0;
+
+ //adjust based on IsExcluded
+ foreach(string tbl in tables)
+ {
+ if(IsInList(tbl) && !IsExcluded(tbl) && CodeService.ShouldGenerate(tbl, provider.Name))
+ tableCount++;
+ }
+
+ string message = "Generating classes for " + provider.Name + " (" + tables.Length + " total)";
+ if(tableCount > 200)
+ {
+ message +=
+ " that's a serious amount of tables to generate. But we can handle it. You just will need to be patient and go get some coffee while we do this thang...";
+ }
+ else if(tableCount > 100)
+ message += " that's a lot of tables. This could take a few minutes...";
+ else if(tableCount > 50)
+ message += " - moderate amount of tables... this could take 30 seconds or so...";
+
+ Console.WriteLine(message);
+ string baseDir = GetOutSubDir(provider);
+
+ foreach(string tbl in tables)
+ {
+ if(IsInList(tbl) && !IsExcluded(tbl) && CodeService.ShouldGenerate(tbl, provider.Name))
+ {
+ TableSchema.Table tableSchema = DataService.GetSchema(tbl, provider.Name, TableType.Table);
+ string className = tableSchema.ClassName;
+ TurboTemplate tt = CodeService.BuildClassTemplate(tbl, language, provider);
+
+ string additionalPath = GetAdditionalPath(tableSchema, GenerationType.Models);
+ string outDir = Path.Combine(baseDir, additionalPath);
+ EnsureDirectoryExists(outDir);
+
+ tt.OutputPath = Path.Combine(outDir, className + language.FileExtension);
+
+ turboCompiler.AddTemplate(tt);
+ }
+ }
+ }
+ Console.WriteLine("Finished");
+ }
+ }
+
+ private static string GetAdditionalPath(TableSchema.Table tableSchema, string generationType)
+ {
+ string groupOutputValue = GetArg("groupOutput");
+ if (!string.IsNullOrEmpty(groupOutputValue))
+ {
+ return GetOutputGroupingPath(tableSchema, groupOutputValue, generationType);
+ }
+
+ return string.Empty;
+ }
+
+ private static string GetOutputGroupingPath(TableSchema.Table tableSchema, string groupOutputValue, string typeOfGeneration)
+ {
+ switch(groupOutputValue.ToLower())
+ {
+ case "schema":
+ return tableSchema.SchemaName;
+
+ case "type":
+ return typeOfGeneration;
+
+ case "schemaandtype":
+ return tableSchema.SchemaName + "\\" + typeOfGeneration;
+
+ default:
+ throw new ArgumentOutOfRangeException("Valid values for /groupOutput are [schema,type,schemaAndType]");
+ }
+ }
+
+ /// <summary>
+ /// Generates the ODS controllers.
+ /// </summary>
+ private static void GenerateODSControllers()
+ {
+ SetProvider();
+
+ language = CodeLanguageFactory.GetByShortName(GetArg("lang"));
+
+ if(DataService.Providers.Count == 0)
+ Console.WriteLine("There's a problem with the providers - none were loaded and no exceptions where thrown.");
+ else
+ {
+ //loop the providers, and if there's more than one, output to their own folder
+ //for tidiness
+ foreach(DataProvider provider in DataService.Providers)
+ {
+ if(provider.TableBaseClass == "ActiveRecord")
+ {
+ //get the table list
+ string[] tables = DataService.GetTableNames(provider.Name);
+ string message = "Generating ODS Controllers for " + provider.Name + " (" + tables.Length + " total)";
+
+ if(tables.Length > 200)
+ {
+ message +=
+ " that's a serious amount of tables to generate. But we can handle it. You just will need to be patient and go get some coffee while we do this thang...";
+ }
+ else if(tables.Length > 100)
+ message += " that's a lot of tables. This could take a few minutes...";
+ else if(tables.Length > 50)
+ message += " - moderate amount of tables... this could take 30 seconds or so...";
+
+ Console.WriteLine(message);
+ string baseDir = GetOutSubDir(provider);
+
+ if(!Directory.Exists(baseDir))
+ Directory.CreateDirectory(baseDir);
+
+ foreach(string tbl in tables)
+ {
+ if(IsInList(tbl) && !IsExcluded(tbl) && CodeService.ShouldGenerate(tbl, provider.Name))
+ {
+ TableSchema.Table tableSchema = DataService.GetSchema(tbl, provider.Name, TableType.Table);
+ string className = tableSchema.ClassName;
+ TurboTemplate tt = CodeService.BuildODSTemplate(tbl, language, provider);
+
+ string additionalPath = GetAdditionalPath(tableSchema, GenerationType.Controllers);
+ string outDir = Path.Combine(baseDir, additionalPath);
+ EnsureDirectoryExists(outDir);
+
+ if(tt != null)
+ {
+ tt.OutputPath = Path.Combine(outDir, className + "Controller" + language.FileExtension);
+ turboCompiler.AddTemplate(tt);
+ }
+ }
+ }
+ }
+ }
+ Console.WriteLine("Finished");
+ }
+ }
+
+ private static void EnsureDirectoryExists(string outDir)
+ {
+ if (!Directory.Exists(outDir))
+ Directory.CreateDirectory(outDir);
+ }
+
+ /// <summary>
+ /// Generates the views.
+ /// </summary>
+ private static void GenerateViews()
+ {
+ SetProvider();
+
+ language = CodeLanguageFactory.GetByShortName(GetArg("lang"));
+
+ //loop the providers, and if there's more than one, output to their own folder
+ //for tidiness
+ foreach(DataProvider provider in DataService.Providers)
+ {
+ //get the view list
+ string[] views = DataService.GetViewNames(provider.Name);
+ string baseDir = GetOutSubDir(provider);
+
+ foreach(string tbl in views)
+ {
+ if(IsInList(tbl) && !IsExcluded(tbl) && CodeService.ShouldGenerate(tbl, provider.Name))
+ {
+ TableSchema.Table tableSchema = DataService.GetSchema(tbl, provider.Name, TableType.View);
+ string className = tableSchema.ClassName;
+ TurboTemplate tt = CodeService.BuildViewTemplate(tbl, language, provider);
+
+ string additionalPath = GetAdditionalPath(tableSchema, GenerationType.Views);
+ string outDir = Path.Combine(baseDir, additionalPath);
+ EnsureDirectoryExists(outDir);
+
+ tt.OutputPath = Path.Combine(outDir, className + language.FileExtension);
+ turboCompiler.AddTemplate(tt);
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// Generates the S ps.
+ /// </summary>
+ private static void GenerateSPs()
+ {
+ SetProvider();
+
+ language = CodeLanguageFactory.GetByShortName(GetArg("lang"));
+
+ //loop the providers, and if there's more than one, output to their own folder
+ //for tidiness
+ foreach(DataProvider provider in DataService.Providers)
+ {
+ string outDir = GetOutSubDir(provider);
+ if(outDir == String.Empty)
+ outDir = Directory.GetCurrentDirectory();
+
+ if(!Directory.Exists(outDir))
+ Directory.CreateDirectory(outDir);
+ string outPath = Path.Combine(outDir, "StoredProcedures" + language.FileExtension);
+ Console.WriteLine("Generating SPs to " + outPath);
+
+ TurboTemplate tt = CodeService.BuildSPTemplate(language, provider);
+ tt.OutputPath = outPath;
+ turboCompiler.AddTemplate(tt);
+ }
+
+ Console.WriteLine("Finished");
+ }
+
+ /// <summary>
+ /// Generates the structs.
+ /// </summary>
+ private static void GenerateStructs()
+ {
+ SetProvider();
+
+ language = CodeLanguageFactory.GetByShortName(GetArg("lang"));
+
+ string outDir = GetOutputDirectory();
+ if(outDir == String.Empty)
+ outDir = Directory.GetCurrentDirectory();
+
+ if(!Directory.Exists(outDir))
+ Directory.CreateDirectory(outDir);
+
+ string outPath = Path.Combine(outDir, "AllStructs" + language.FileExtension);
+ Console.WriteLine("Generating Structs to " + outPath);
+ TurboTemplate tt = CodeService.BuildStructsTemplate(language, DataService.Provider);
+ tt.OutputPath = outPath;
+ turboCompiler.AddTemplate(tt);
+
+ Console.WriteLine("Finished");
+ }
+
+ private static class GenerationType
+ {
+ public const string Models = "Models";
+ public const string Controllers = "Controllers";
+ public const string Views = "Views";
+ }
+
+ #endregion
+ }
+}
22 SubCommander/Properties/App.config
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <configSections>
+ <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null" requirePermission="false"/>
+ <section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" allowDefinition="MachineToApplication" restartOnExternalChanges="true" requirePermission="false"/>
+ </configSections>
+ <appSettings/>
+ <connectionStrings>
+ <add name="Northwind" connectionString="Data Source=localhost; Database=northwind; Integrated Security=true;"/>
+ <add name="Pubs" connectionString="Data Source=localhost; Database=pubs; Integrated Security=true;"/>
+
+ </connectionStrings>
+ <dataConfiguration defaultDatabase="NorthwindConnection"/>
+ <SubSonicService defaultProvider="Northwind" >
+ <providers>
+ <clear/>
+ <add name="Pubs" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="Pubs" generatedNamespace="Pubs" />
+
+ <add name="Northwind" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="Northwind" generatedNamespace="Northwind" />
+ </providers>
+ </SubSonicService>
+</configuration>
21 SubCommander/Properties/AssemblyInfo.cs
@@ -0,0 +1,21 @@
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("SubCommander")]
+[assembly: AssemblyDescription("The Command Line utility for SubSonic")]
+[assembly: AssemblyConfiguration("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("f9dd1ee0-78d5-4db9-98c1-0d520c2669ce")]
+[assembly: AssemblyProductAttribute("SubCommander")]
+[assembly: AssemblyCopyrightAttribute("Copyright ©2006-2008 The SubSonic Project")]
+[assembly: AssemblyVersionAttribute("2.1.1.0")]
+[assembly: AssemblyFileVersionAttribute("2.1.1.0")]
126 SubCommander/SubSonic.SubCommander.csproj
@@ -0,0 +1,126 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{39AED956-4929-4A20-9641-6612B9998B31}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>SubSonic.SubCommander</RootNamespace>
+ <AssemblyName>sonic</AssemblyName>
+ <SccProjectName>
+ </SccProjectName>
+ <SccLocalPath>
+ </SccLocalPath>
+ <SccAuxPath>
+ </SccAuxPath>
+ <SccProvider>
+ </SccProvider>
+ <StartupObject>SubSonic.SubCommander.Program</StartupObject>
+ <PublishUrl>http://localhost/sonic/</PublishUrl>
+ <Install>true</Install>
+ <InstallFrom>Web</InstallFrom>
+ <UpdateEnabled>true</UpdateEnabled>
+ <UpdateMode>Foreground</UpdateMode>
+ <UpdateInterval>7</UpdateInterval>
+ <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+ <UpdatePeriodically>false</UpdatePeriodically>
+ <UpdateRequired>false</UpdateRequired>
+ <MapFileExtensions>true</MapFileExtensions>
+ <ApplicationVersion>2.0.0.%2a</ApplicationVersion>
+ <IsWebBootstrapper>true</IsWebBootstrapper>
+ <BootstrapperEnabled>true</BootstrapperEnabled>
+ <FileUpgradeFlags>
+ </FileUpgradeFlags>
+ <OldToolsVersion>2.0</OldToolsVersion>
+ <UpgradeBackupLocation>
+ </UpgradeBackupLocation>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
+ <DocumentationFile>
+ </DocumentationFile>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Microsoft.SqlServer.ConnectionInfo, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\Dependencies\Microsoft.SqlServer.ConnectionInfo.dll</HintPath>
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="Microsoft.SqlServer.Management.Sdk.Sfc, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\Dependencies\Microsoft.SqlServer.Management.Sdk.Sfc.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.SqlServer.Smo, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\Dependencies\Microsoft.SqlServer.Smo.dll</HintPath>
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="Microsoft.SqlServer.SmoExtended, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\Dependencies\Microsoft.SqlServer.SmoExtended.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Configuration" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Web" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Arguments.cs" />
+ <Compile Include="CodeRunner.cs" />
+ <Compile Include="DBScripter.cs" />
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\SubSonic.Migrations\SubSonic.Migrations.csproj">
+ <Project>{0E82F4EB-BA66-474C-A5F9-3D10D1EE2206}</Project>
+ <Name>SubSonic.Migrations</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\SubSonic\SubSonic.csproj">
+ <Project>{EE4A10E7-92C3-4EAC-B6DF-5DA1C26F4D1D}</Project>
+ <Name>SubSonic</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Properties\App.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 2.0</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{B4F97281-0DBD-4835-9ED8-7DFB966E87FF}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="bin\Debug\" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
5 SubCommander/SubSonic.SubCommander.csproj.user
@@ -0,0 +1,5 @@
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <StartArguments>migrate /migrationDirectory D:\@SubSonic\MigrationSample\MigrationSample\Migrations /config D:\@SubSonic\MigrationSample\MigrationSample</StartArguments>
+ </PropertyGroup>
+</Project>
BIN SubCommander/bin/Debug/Microsoft.Practices.EnterpriseLibrary.Common.dll
Binary file not shown.
BIN SubCommander/bin/Debug/Microsoft.Practices.EnterpriseLibrary.Data.dll
Binary file not shown.
BIN SubCommander/bin/Debug/Microsoft.SqlServer.ConnectionInfo.dll
Binary file not shown.
BIN SubCommander/bin/Debug/Microsoft.SqlServer.Smo.dll
Binary file not shown.
BIN SubCommander/bin/Debug/MySql.Data.dll
Binary file not shown.
BIN SubCommander/bin/Debug/SubSonic.Migrations.dll
Binary file not shown.
BIN SubCommander/bin/Debug/SubSonic.Migrations.pdb
Binary file not shown.
BIN SubCommander/bin/Debug/SubSonic.dll
Binary file not shown.
BIN SubCommander/bin/Debug/SubSonic.pdb
Binary file not shown.
BIN SubCommander/bin/Debug/System.Data.SQLite.dll
Binary file not shown.
BIN SubCommander/bin/Debug/sonic.exe
Binary file not shown.
22 SubCommander/bin/Debug/sonic.exe.config
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <configSections>
+ <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null" requirePermission="false"/>
+ <section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" allowDefinition="MachineToApplication" restartOnExternalChanges="true" requirePermission="false"/>
+ </configSections>
+ <appSettings/>
+ <connectionStrings>
+ <add name="Northwind" connectionString="Data Source=localhost; Database=northwind; Integrated Security=true;"/>
+ <add name="Pubs" connectionString="Data Source=localhost; Database=pubs; Integrated Security=true;"/>
+
+ </connectionStrings>
+ <dataConfiguration defaultDatabase="NorthwindConnection"/>
+ <SubSonicService defaultProvider="Northwind" >
+ <providers>
+ <clear/>
+ <add name="Pubs" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="Pubs" generatedNamespace="Pubs" />
+
+ <add name="Northwind" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="Northwind" generatedNamespace="Northwind" />
+ </providers>
+ </SubSonicService>
+</configuration>
BIN SubCommander/bin/Debug/sonic.pdb
Binary file not shown.
BIN SubCommander/bin/Debug/sonic.vshost.exe
Binary file not shown.
22 SubCommander/bin/Debug/sonic.vshost.exe.config
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <configSections>
+ <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null" requirePermission="false"/>
+ <section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" allowDefinition="MachineToApplication" restartOnExternalChanges="true" requirePermission="false"/>
+ </configSections>
+ <appSettings/>
+ <connectionStrings>
+ <add name="Northwind" connectionString="Data Source=localhost; Database=northwind; Integrated Security=true;"/>
+ <add name="Pubs" connectionString="Data Source=localhost; Database=pubs; Integrated Security=true;"/>
+
+ </connectionStrings>
+ <dataConfiguration defaultDatabase="NorthwindConnection"/>
+ <SubSonicService defaultProvider="Northwind" >
+ <providers>
+ <clear/>
+ <add name="Pubs" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="Pubs" generatedNamespace="Pubs" />
+
+ <add name="Northwind" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="Northwind" generatedNamespace="Northwind" />
+ </providers>
+ </SubSonicService>
+</configuration>
11 SubCommander/bin/Debug/sonic.vshost.exe.manifest
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+ <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
+ <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
+ <security>
+ <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
+ <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
+ </requestedPrivileges>
+ </security>
+ </trustInfo>
+</assembly>
231 SubCommander/bin/Debug/vs5BB7.tmp
@@ -0,0 +1,231 @@
+<?xml version="1.0"?>
+<doc>
+ <assembly>
+ <name>sonic</name>
+ </assembly>
+ <members>
+ <member name="T:SubSonic.SubCommander.DBScripter">
+ <summary>
+
+ </summary>
+ </member>
+ <member name="M:SubSonic.SubCommander.DBScripter.ScriptData(System.String,System.String)">
+ <summary>
+ Scripts the data.
+ </summary>
+ <param name="tableName">Name of the table.</param>
+ <param name="providerName">Name of the provider.</param>
+ <returns></returns>
+ </member>
+ <member name="M:SubSonic.SubCommander.DBScripter.ScriptSchema(System.String)">
+ <summary>
+ Scripts the schema.
+ </summary>
+ <param name="connectionString">The connection string.</param>
+ <returns></returns>
+ </member>
+ <member name="T:SubSonic.SubCommander.Arguments">
+ <summary>
+ Command Line Parsing Library.
+ </summary>
+ </member>
+ <member name="M:SubSonic.SubCommander.Arguments.#ctor(System.String)">
+ <summary>
+ Initializes a new instance of the <see cref="T:SubSonic.SubCommander.Arguments"/> class.
+ </summary>
+ <param name="commandLine">The command line.</param>
+ </member>
+ <member name="P:SubSonic.SubCommander.Arguments.Item(System.String)">
+ <summary>
+ Retrieve a parameter value if it exists (overriding C# indexer property)
+ </summary>
+ <value></value>
+ </member>
+ <member name="T:SubSonic.SubCommander.CodeRunner">
+ <summary>
+ Runs and executes code for use with our scripted bits - like Migrations
+ </summary>
+ </member>
+ <member name="M:SubSonic.SubCommander.CodeRunner.RunAndExecute(SubSonic.ICodeLanguage,System.String,System.String,System.Object[])">
+ <summary>
+ Executes the passed-in code
+ </summary>
+ <param name="lang">ICodeLanguage</param>
+ <param name="sourceCode">the code</param>
+ <param name="methodName">the entry point method</param>
+ <param name="parameters">the params</param>
+ </member>
+ <member name="T:SubSonic.SubCommander.Program">
+ <summary>
+
+ </summary>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.Main(System.String[])">
+ <summary>
+ Main
+ </summary>
+ <param name="args">The args.</param>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.ThrowHelp(System.Boolean)">
+ <summary>
+ Throws the help.
+ </summary>
+ <param name="verbose">if set to <c>true</c> [verbose].</param>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.WriteVersionInformation(System.String)">
+ <summary>
+ Writes the version information.
+ </summary>
+ <param name="formatString">The format string.</param>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.Migrate">
+ <summary>
+ Migrates the specified migration directory.
+ </summary>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.GetConfigPath">
+ <summary>
+ Gets the config path.
+ </summary>
+ <returns></returns>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.GetConfigInDir(System.String)">
+ <summary>
+ Tries to find the config file in the specified directory.
+ </summary>
+ <param name="directory">The directory.</param>
+ <returns></returns>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.SetProvider">
+ <summary>
+ Sets the provider.
+ </summary>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.SetProviderManually">
+ <summary>
+ Sets the provider manually.
+ </summary>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.SetConfig(System.Collections.Specialized.NameValueCollection,System.String)">
+ <summary>
+ Sets the config.
+ </summary>
+ <param name="config">The config.</param>
+ <param name="key">The key.</param>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.SetProvider(System.String)">
+ <summary>
+ Sets the provider.
+ </summary>
+ <param name="appConfigPath">The app config path.</param>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.GetOutputDirectory">
+ <summary>
+ Gets the output directory.
+ </summary>
+ <returns></returns>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.OutputFile(System.String,System.String)">
+ <summary>
+ Outputs the file.
+ </summary>
+ <param name="filePath">The file path.</param>
+ <param name="fileText">The file text.</param>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.GetArg(System.String)">
+ <summary>
+ Gets the arg.
+ </summary>
+ <param name="argSwitch">The arg switch.</param>
+ <returns></returns>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.GetConnnectionString">
+ <summary>
+ Gets the connnection string.
+ </summary>
+ <returns></returns>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.VersionDB">
+ <summary>
+ Versions the DB.
+ </summary>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.ScriptData">
+ <summary>
+ Scripts the data.
+ </summary>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.ScriptSchema">
+ <summary>
+ Scripts the schema.
+ </summary>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.GenerateEditor">
+ <summary>
+ Generates the editor.
+ </summary>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.GenerateEditor(System.String,System.String)">
+ <summary>
+ Generates the editor.
+ </summary>
+ <param name="table">The table.</param>
+ <param name="outDir">The out dir.</param>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.GenerateAll">
+ <summary>
+ Generates all.
+ </summary>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.IsExcluded(System.String)">
+ <summary>
+ Determines whether the specified table name is excluded.
+ </summary>
+ <param name="tableName">Name of the table.</param>
+ <returns>
+ <c>true</c> if the specified table name is excluded; otherwise, <c>false</c>.
+ </returns>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.IsInList(System.String)">
+ <summary>
+ Determines whether [is in list] [the specified table name].
+ </summary>
+ <param name="tableName">Name of the table.</param>
+ <returns>
+ <c>true</c> if [is in list] [the specified table name]; otherwise, <c>false</c>.
+ </returns>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.GetOutSubDir(System.Configuration.Provider.ProviderBase)">
+ <summary>
+ Gets the out sub dir.
+ </summary>
+ <param name="provider">The provider.</param>
+ <returns></returns>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.GenerateTables">
+ <summary>
+ Generates the tables.
+ </summary>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.GenerateODSControllers">
+ <summary>
+ Generates the ODS controllers.
+ </summary>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.GenerateViews">
+ <summary>
+ Generates the views.
+ </summary>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.GenerateSPs">
+ <summary>
+ Generates the S ps.
+ </summary>
+ </member>
+ <member name="M:SubSonic.SubCommander.Program.GenerateStructs">
+ <summary>
+ Generates the structs.
+ </summary>
+ </member>
+ </members>
+</doc>
BIN SubCommander/bin/Release/Microsoft.Practices.EnterpriseLibrary.Common.dll
Binary file not shown.
BIN SubCommander/bin/Release/Microsoft.Practices.EnterpriseLibrary.Data.dll
Binary file not shown.
BIN SubCommander/bin/Release/Microsoft.SqlServer.ConnectionInfo.dll
Binary file not shown.
BIN SubCommander/bin/Release/Microsoft.SqlServer.Smo.dll
Binary file not shown.
BIN SubCommander/bin/Release/MySql.Data.dll
Binary file not shown.
BIN SubCommander/bin/Release/SubSonic.Migrations.dll
Binary file not shown.
BIN SubCommander/bin/Release/SubSonic.Migrations.pdb
Binary file not shown.
103 SubCommander/bin/Release/SubSonic.Migrations.xml
@@ -0,0 +1,103 @@
+<?xml version="1.0"?>
+<doc>
+ <assembly>
+ <name>SubSonic.Migrations</name>
+ </assembly>
+ <members>
+ <member name="T:SubSonic.Migrations.Migrator">
+ <summary>
+ The Migrator class is responsible for running through a collection of migrationFiles
+ and applying them towards the specified provider.
+
+ This class is very similiar to the Rails Migrator class. They did something very
+ interesting with a static method acting as a mini-factory for itself, notice how
+ the static Migrate() method in turn creates a Migrator instance and calls methods
+ on that. Thought that was very neat, so I borrowed it.
+ </summary>
+ </member>
+ <member name="M:SubSonic.Migrations.Migrator.#ctor(SubSonic.Migration.MigrationDirection,System.String,System.String,System.Nullable{System.Int32})">
+ <summary>
+ Constructor
+ </summary>
+ <param name="direction">Direction to migrate.</param>
+ <param name="providerName">Name of the provider.</param>
+ <param name="migrationDirectory">Directory to find the migrations.</param>
+ <param name="toVersion">Version to migrate up to.</param>
+ </member>
+ <member name="M:SubSonic.Migrations.Migrator.Migrate(System.String,System.String,System.Nullable{System.Int32})">
+ <summary>
+ Begins the migration.
+ </summary>
+ <param name="providerName">Name of the provider.</param>
+ <param name="migrationDirectory">Directory to find the migrations.</param>
+ <param name="toVersion">Version to migrate to.</param>
+ </member>
+ <member name="M:SubSonic.Migrations.Migrator.Up(System.String,System.String,System.Nullable{System.Int32})">
+ <summary>
+ Migreate Up
+ </summary>
+ <param name="providerName">Name of the provider.</param>
+ <param name="migrationDirectory">Directory to find the migrations.</param>
+ <param name="toVersion">Version to migrate up to.</param>
+ </member>
+ <member name="M:SubSonic.Migrations.Migrator.Down(System.String,System.String,System.Nullable{System.Int32})">
+ <summary>
+ Migreate Down
+ </summary>
+ <param name="providerName">Name of the provider.</param>
+ <param name="migrationDirectory">Directory to find the migrations.</param>
+ <param name="toVersion">Version to migrate down to.</param>
+ </member>
+ <member name="M:SubSonic.Migrations.Migrator.Migrate">
+ <summary>
+ Start migration.
+ </summary>
+ </member>
+ <member name="M:SubSonic.Migrations.Migrator.GetMigrationVersion(System.String)">
+ <summary>
+ Gets the version of the migration file.
+ </summary>
+ <param name="migration">Migration file name.</param>
+ <returns></returns>
+ </member>
+ <member name="M:SubSonic.Migrations.Migrator.GetCurrentVersion(System.String)">
+ <summary>
+ Gets the current schema version for the named provider.
+ </summary>
+ <param name="providerName">Name of the provider.</param>
+ <returns>Current version of the schema as stored in the schema info table.</returns>
+ </member>
+ <