From d1fa1f1a2e26469a6bbb5b82ab614079beffcb52 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 14 Jan 2018 13:19:03 +0200 Subject: Added code comments for: Synchronization. --- .../Remote/RemoteDBComparer.cs | 53 ++++++++++++++++++++++ .../Remote/RemoteDBSynchronizer.cs | 17 +++++++ 2 files changed, 70 insertions(+) (limited to 'Software/Visual_Studio/Tango.Synchronization/Remote') diff --git a/Software/Visual_Studio/Tango.Synchronization/Remote/RemoteDBComparer.cs b/Software/Visual_Studio/Tango.Synchronization/Remote/RemoteDBComparer.cs index 5985eb393..3d9667676 100644 --- a/Software/Visual_Studio/Tango.Synchronization/Remote/RemoteDBComparer.cs +++ b/Software/Visual_Studio/Tango.Synchronization/Remote/RemoteDBComparer.cs @@ -11,6 +11,10 @@ using System.Collections; namespace Tango.Synchronization.Remote { + /// + /// Represents a Remote database to SQLite database comparison engine. + /// + /// public class RemoteDBComparer : IDBComparer { private remote.RemoteDB _remoteDB; @@ -18,6 +22,12 @@ namespace Tango.Synchronization.Remote private String _machineSerial; private List _diffs; + /// + /// Initializes a new instance of the class. + /// + /// The remote database. + /// The local database. + /// The machine serial number. public RemoteDBComparer(remote.RemoteDB remoteDB, local.LocalDB localDB, String machineSerial) { _machineSerial = machineSerial; @@ -25,6 +35,11 @@ namespace Tango.Synchronization.Remote _localDB = localDB; } + /// + /// Performs a database comparison and returns a set of differences. + /// + /// + /// Could not locate machine on remote server " + _machineSerial public List Compare() { _diffs = new List(); @@ -164,12 +179,21 @@ namespace Tango.Synchronization.Remote return _diffs; } + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// public void Dispose() { _remoteDB.Dispose(); _localDB.Dispose(); } + /// + /// Copies source entity properties to the destination entity. + /// + /// The source entity. + /// The destination entity. + /// private void CopyEntity(Object source, Object destination) { foreach (var prop in source.GetType().GetProperties().Where(x => x.PropertyType.IsPrimitive || x.PropertyType == typeof(String) || x.PropertyType == typeof(DateTime) || x.PropertyType == typeof(byte[]))) @@ -190,6 +214,15 @@ namespace Tango.Synchronization.Remote } } + /// + /// Compares a collection of source entities to a collection of destination entities. + /// + /// The type of the aster. + /// The type of the lave. + /// The master collection. + /// The slave collection. + /// The master set. + /// The slave set. private void CompareCollections(List masterCollection, List slaveCollection, DbSet masterSet, DbSet slaveSet) where Master : class where Slave : class { var slaveProp = typeof(Slave).GetProperty("GUID"); @@ -214,6 +247,10 @@ namespace Tango.Synchronization.Remote } } + /// + /// Overrides the table by the specified synchronization configuration. + /// + /// The configuration. private void OverrideTable(remote.SYNC_CONFIGURATIONS config) { LogManager.Log("Generating table override difference for " + config.TABLE_NAME + "..."); @@ -237,6 +274,13 @@ namespace Tango.Synchronization.Remote }, null)); } + /// + /// Compares the specified entities. + /// + /// The type of the master. + /// The type of the slave. + /// The master. + /// The slave. private void CompareEntities(Master master, Slave slave) where Master : class where Slave : class { Diff diff = null; @@ -267,6 +311,15 @@ namespace Tango.Synchronization.Remote } } + /// + /// Compares the entities. + /// + /// The type of the master. + /// The type of the slave. + /// The master. + /// The slave. + /// The master set. + /// The slave set. private void CompareEntities(Master master, Slave slave, DbSet masterSet, DbSet slaveSet) where Master : class where Slave : class { if (slave == null) diff --git a/Software/Visual_Studio/Tango.Synchronization/Remote/RemoteDBSynchronizer.cs b/Software/Visual_Studio/Tango.Synchronization/Remote/RemoteDBSynchronizer.cs index 7abd8ad7e..75d28af5b 100644 --- a/Software/Visual_Studio/Tango.Synchronization/Remote/RemoteDBSynchronizer.cs +++ b/Software/Visual_Studio/Tango.Synchronization/Remote/RemoteDBSynchronizer.cs @@ -10,8 +10,18 @@ using Tango.Synchronization.Local; namespace Tango.Synchronization.Remote { + /// + /// Represents a remote database to SQLite file synchronizer. + /// public class RemoteDBSynchronizer { + /// + /// Synchronizes the specified SQLite file by a machine serial number. + /// + /// The SQLite database file. + /// The machine serial number. + /// if set to true will erase the SQLite file before performing the synchronization. + /// public static List Synchronize(String sqliteDbFile, String serialNumber, bool overrideLocal = false) { if (overrideLocal) @@ -41,6 +51,13 @@ namespace Tango.Synchronization.Remote } } + /// + /// Synchronizes the specified SQLite file by a machine serial number. + /// + /// The SQLite database file. + /// The machine serial number. + /// if set to true will erase the SQLite file before performing the synchronization. + /// public static Task> SynchronizeAsync(String sqliteDBFile, String serialNumber, bool overrideLocal = false) { return Task.Factory.StartNew>(() => -- cgit v1.3.1