diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-01-25 16:17:55 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-01-25 16:17:55 +0200 |
| commit | 6a8a50b01383cf724822c3eb0135c1729fb2daed (patch) | |
| tree | d4af0105f0167c3443370af9dc906d92aea9f740 /Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/Program.cs | |
| parent | dc11398ba5728af943256ca99eba8c9d66e1b6e2 (diff) | |
| download | Tango-6a8a50b01383cf724822c3eb0135c1729fb2daed.tar.gz Tango-6a8a50b01383cf724822c3eb0135c1729fb2daed.zip | |
Implemented SQL Server To SQLite Conversion Utility!!!
Added missing synchronization tables to remote synchronization.
Updated DAL.Local.
Diffstat (limited to 'Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/Program.cs')
| -rw-r--r-- | Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/Program.cs | 79 |
1 files changed, 79 insertions, 0 deletions
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> sync_configurations = new List<SYNC_CONFIGURATIONS>(); + + 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<TableSchema> schema) + { + List<TableSchema> 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(); + } + } + } +} |
