From 6a8a50b01383cf724822c3eb0135c1729fb2daed Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 25 Jan 2018 16:17:55 +0200 Subject: Implemented SQL Server To SQLite Conversion Utility!!! Added missing synchronization tables to remote synchronization. Updated DAL.Local. --- .../Utilities/Tango.SQLiteGenerator.CLI/App.config | 16 +++++ .../Utilities/Tango.SQLiteGenerator.CLI/Program.cs | 79 ++++++++++++++++++++++ .../Properties/AssemblyInfo.cs | 36 ++++++++++ .../Tango.SQLiteGenerator.CLI.csproj | 74 ++++++++++++++++++++ .../Tango.SQLiteGenerator.CLI/packages.config | 4 ++ 5 files changed, 209 insertions(+) create mode 100644 Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/App.config create mode 100644 Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/Program.cs create mode 100644 Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/Tango.SQLiteGenerator.CLI.csproj create mode 100644 Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/packages.config (limited to 'Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI') diff --git a/Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/App.config b/Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/App.config new file mode 100644 index 000000000..92aa00bf9 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/App.config @@ -0,0 +1,16 @@ + + + + +
+ + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/Program.cs b/Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/Program.cs new file mode 100644 index 000000000..242cdcfa9 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/Program.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DAL.Remote.DB; +using Tango.Settings; +using Tango.Synchronization; +using Tango.Synchronization.Conversion; + +namespace Tango.SQLiteGenerator.CLI +{ + class Program + { + static void Main(string[] args) + { + String sqlitePath = args[0]; + + sqlitePath = Path.GetFullPath(sqlitePath); + + bool completed = false; + + String connectionString = SettingsManager.Default.DataBase.SQLServerAddress; + + Console.WriteLine("Connecting to " + connectionString + "..."); + + connectionString = String.Format("Data Source={0};Initial Catalog=Tango;Integrated Security=SSPI;", connectionString); + + List sync_configurations = new List(); + + using (RemoteDB db = RemoteDB.CreateDefault()) + { + sync_configurations = db.SYNC_CONFIGURATIONS.ToList(); + } + + SqlConversionHandler handler = new SqlConversionHandler(delegate (bool done, bool success, int percent, string msg) + { + Console.WriteLine(String.Format("{0} [%{1}]", msg, percent)); + + if (done) + { + if (success) + { + Console.WriteLine("SQLite database has been generated successfully on " + sqlitePath); + Environment.Exit(0); + } + else + { + Console.WriteLine("SQLite database generation failed!"); + Environment.Exit(-1); + } + + completed = true; + } + }); + + SqlTableSelectionHandler selectionHandler = new SqlTableSelectionHandler(delegate (List schema) + { + List updated = schema.Where(x => x.TableName.ToLower() != "sysdiagrams").ToList(); + + updated + .Where(table => sync_configurations.Where(config => (SyncConfiguration)config.SYNC_TYPE == SyncConfiguration.OverwriteLocal).ToList() + .Exists(config => config.TABLE_NAME == table.TableName)).ToList().ForEach(x => x.CopyData = true); + + return updated; + }); + + SqlServerToSQLiteConverter converter = new SqlServerToSQLiteConverter(); + + converter.ConvertSqlServerToSQLiteDatabase(connectionString, sqlitePath, null, handler, selectionHandler, null, false, false); + + while (!completed) + { + Console.ReadLine(); + } + } + } +} diff --git a/Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..a050c5eff --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +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("Tango.SQLiteGenerator.CLI")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tango.SQLiteGenerator.CLI")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 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("8a03adc0-991b-4da8-8a19-e1d03f92e81c")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/Tango.SQLiteGenerator.CLI.csproj b/Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/Tango.SQLiteGenerator.CLI.csproj new file mode 100644 index 000000000..2e9420527 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/Tango.SQLiteGenerator.CLI.csproj @@ -0,0 +1,74 @@ + + + + + Debug + AnyCPU + {8A03ADC0-991B-4DA8-8A19-E1D03F92E81C} + Exe + Tango.SQLiteGenerator.CLI + sqlitegen + v4.6 + 512 + true + + + AnyCPU + true + full + false + ..\..\Build\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.dll + + + ..\..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.SqlServer.dll + + + + + + + + + + + + + + + + + + + + + + {38197109-8610-4d3f-92b9-16d48df94d7c} + Tango.DAL.Remote + + + {d8f1ad85-526a-4f50-b6dc-d437af63d8d8} + Tango.Settings + + + {7ada4e86-cad7-4968-a210-3a8a9e5153ab} + Tango.Synchronization + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/packages.config b/Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/packages.config new file mode 100644 index 000000000..9256e1591 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file -- cgit v1.3.1