aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.CodeGeneration/EntityInheritedDTOCodeFile.cs
blob: 297050d69e029abc2acf426b40cee0916b78d579 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tango.CodeGeneration
{
    /// <summary>
    /// Represents a database entity DTO code file.
    /// </summary>
    /// <seealso cref="Tango.CodeGeneration.Class" />
    public class EntityInheritedDTOCodeFile : Class
    {
        public String BaseClass { get; set; }

        public EntityInheritedDTOCodeFile(String name, String baseClass)
        {
            Name = name;
            BaseClass = baseClass;
        }
    }
}
go.Synchronization.Local; namespace Tango.Synchronization.Remote { /// <summary> /// Represents a remote database to SQLite file synchronizer. /// </summary> public class RemoteDBSynchronizer { /// <summary> /// Synchronizes the specified SQLite file by a machine serial number. /// </summary> /// <param name="sqliteDbFile">The SQLite database file.</param> /// <param name="serialNumber">The machine serial number.</param> /// <param name="overrideLocal">if set to <c>true</c> will erase the SQLite file before performing the synchronization.</param> /// <returns></returns> public static List<Diff> Synchronize(String sqliteDbFile, String serialNumber, bool overrideLocal = false) { if (overrideLocal) { SQLiteDataBase sqlite = new SQLiteDataBase(sqliteDbFile); sqlite.LoadTables(); sqlite.ClearDataBase(); } using (var remoteDB = new remote.RemoteDB(SettingsManager.Default.DataBase.SQLServerAddress, false)) { using (var localDB = new local.LocalDB(sqliteDbFile)) { RemoteDBComparer comparer = new RemoteDBComparer(remoteDB, localDB, serialNumber); var diffs = comparer.Compare(); foreach (var diff in diffs) { diff.Commit(); } remoteDB.SaveChanges(); localDB.SaveChanges(); return diffs; } } } /// <summary> /// Synchronizes the specified SQLite file by a machine serial number. /// </summary> /// <param name="sqliteDbFile">The SQLite database file.</param> /// <param name="serialNumber">The machine serial number.</param> /// <param name="overrideLocal">if set to <c>true</c> will erase the SQLite file before performing the synchronization.</param> /// <returns></returns> public static Task<List<Diff>> SynchronizeAsync(String sqliteDBFile, String serialNumber, bool overrideLocal = false) { return Task.Factory.StartNew<List<Diff>>(() => { return Synchronize(sqliteDBFile, serialNumber, overrideLocal); }); } } }