aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common/Modules/IPPCModuleLoader.cs
blob: 52527fb337a5202f53b65fc8907a3585ecb23d18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tango.PPC.Common.Modules
{
    /// <summary>
    /// Represents a PPC <see cref="IPPCModule"/> modules loading engine.
    /// </summary>
    public interface IPPCModuleLoader
    {
        /// <summary>
        /// Occurs when the user has logged in and user modules are loaded.
        /// </summary>
        event EventHandler ModulesLoaded;

        /// <summary>
        /// Gets all loaded modules.
        /// </summary>
        ObservableCollection<IPPCModule> AllModules { get; }

        /// <summary>
        /// Gets all the user permitted modules.
        /// </summary>
        ObservableCollection<IPPCModule> UserModules { get; }

        /// <summary>
        /// Gets the PPC module of type T if loaded.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        T GetPPCModule<T>() where T : IPPCModule;

        /// <summary>
        /// Loads all available PPC modules.
        /// </summary>
        void LoadModules();
    }
}
class="w"> new string[] { Path.GetFullPath( "..\\..\\..\\..\\DB\\Tango.db"), "CopyAll" }; #endif String sqlitePath = args[0]; Config conf = args.Length > 1 ? (Config)Enum.Parse(typeof(Config), args[1]) : Config.Default; sqlitePath = Path.GetFullPath(sqlitePath); Console.WriteLine("Generating " + sqlitePath + "..."); bool completed = false; String connectionString = SettingsManager.Default.GetOrCreate<CoreSettings>().DataSource.ToConnection().ConnectionString; 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 = new RemoteDB(SettingsManager.Default.GetOrCreate<CoreSettings>().DataSource)) { 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(); if (conf == Config.Default) { 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); } else if (conf == Config.CopyAll) { updated.ForEach(x => x.CopyData = true); } return updated; }); SqlServerToSQLiteConverter converter = new SqlServerToSQLiteConverter(); converter.GenerateForeignKeys = true; converter.GenerateIndexes = true; converter.ConvertSqlServerToSQLiteDatabase(connectionString, sqlitePath, null, handler, selectionHandler, null, false, false); while (!completed) { Console.ReadLine(); } } } }