aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Synchronization
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2017-11-27 21:51:38 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2017-11-27 21:51:38 +0200
commitdf2f9b27b12356d6e92c64a72049f0fc4e6b86c0 (patch)
tree049ced63087ef30986cc998f8546071e5894e37e /Software/Visual_Studio/Tango.Synchronization
parent7060dc80c707fc0441ff69fe4f899107cb3f6fc1 (diff)
downloadTango-df2f9b27b12356d6e92c64a72049f0fc4e6b86c0.tar.gz
Tango-df2f9b27b12356d6e92c64a72049f0fc4e6b86c0.zip
Started Remote <=> Local Synchronization... /;
Diffstat (limited to 'Software/Visual_Studio/Tango.Synchronization')
-rw-r--r--Software/Visual_Studio/Tango.Synchronization/Diff.cs (renamed from Software/Visual_Studio/Tango.Synchronization/SqlDiff.cs)10
-rw-r--r--Software/Visual_Studio/Tango.Synchronization/DiffAction.cs (renamed from Software/Visual_Studio/Tango.Synchronization/SqlDiffAction.cs)4
-rw-r--r--Software/Visual_Studio/Tango.Synchronization/Local/Constants.cs (renamed from Software/Visual_Studio/Tango.Synchronization/Constants.cs)2
-rw-r--r--Software/Visual_Studio/Tango.Synchronization/Local/ExtensionMethods.cs (renamed from Software/Visual_Studio/Tango.Synchronization/ExtensionMethods.cs)2
-rw-r--r--Software/Visual_Studio/Tango.Synchronization/Local/ILocalDataBase.cs (renamed from Software/Visual_Studio/Tango.Synchronization/ISqlDataBase.cs)12
-rw-r--r--Software/Visual_Studio/Tango.Synchronization/Local/LocalDBComparer.cs (renamed from Software/Visual_Studio/Tango.Synchronization/SqlDataBaseComparer.cs)32
-rw-r--r--Software/Visual_Studio/Tango.Synchronization/Local/SqliteDataBase.cs (renamed from Software/Visual_Studio/Tango.Synchronization/SqliteDataBase.cs)16
-rw-r--r--Software/Visual_Studio/Tango.Synchronization/Remote/RemoteDBComparer.cs45
-rw-r--r--Software/Visual_Studio/Tango.Synchronization/Tango.Synchronization.csproj24
9 files changed, 101 insertions, 46 deletions
diff --git a/Software/Visual_Studio/Tango.Synchronization/SqlDiff.cs b/Software/Visual_Studio/Tango.Synchronization/Diff.cs
index b5a274cdc..45bd1581c 100644
--- a/Software/Visual_Studio/Tango.Synchronization/SqlDiff.cs
+++ b/Software/Visual_Studio/Tango.Synchronization/Diff.cs
@@ -7,16 +7,16 @@ using System.Threading.Tasks;
namespace Tango.Synchronization
{
/// <summary>
- /// Represents an <see cref="SqlDataBaseComparer.Compare"/> result.
+ /// Represents an <see cref="LocalDBComparer.Compare"/> result.
/// </summary>
- public class SqlDiff
+ public class Diff
{
private Action _action;
/// <summary>
/// Gets the difference action.
/// </summary>
- public SqlDiffAction Action { get; private set; }
+ public DiffAction Action { get; private set; }
/// <summary>
/// Gets the difference description.
@@ -29,13 +29,13 @@ namespace Tango.Synchronization
public String Command { get; private set; }
/// <summary>
- /// Initializes a new instance of the <see cref="SqlDiff"/> class.
+ /// Initializes a new instance of the <see cref="Diff"/> class.
/// </summary>
/// <param name="dataBaseAction">The data base action.</param>
/// <param name="description">The description.</param>
/// <param name="action">The action.</param>
/// <param name="command">The command.</param>
- public SqlDiff(SqlDiffAction dataBaseAction, String description, Action action, String command)
+ public Diff(DiffAction dataBaseAction, String description, Action action, String command)
{
Action = dataBaseAction;
Description = description;
diff --git a/Software/Visual_Studio/Tango.Synchronization/SqlDiffAction.cs b/Software/Visual_Studio/Tango.Synchronization/DiffAction.cs
index 798be78d8..2395d819c 100644
--- a/Software/Visual_Studio/Tango.Synchronization/SqlDiffAction.cs
+++ b/Software/Visual_Studio/Tango.Synchronization/DiffAction.cs
@@ -8,9 +8,9 @@ using System.Threading.Tasks;
namespace Tango.Synchronization
{
/// <summary>
- /// Represents the type of <see cref="SqlDiff"/>.
+ /// Represents the type of <see cref="Diff"/>.
/// </summary>
- public enum SqlDiffAction
+ public enum DiffAction
{
/// <summary>
/// Add table to slave
diff --git a/Software/Visual_Studio/Tango.Synchronization/Constants.cs b/Software/Visual_Studio/Tango.Synchronization/Local/Constants.cs
index 3558fd506..ed8084301 100644
--- a/Software/Visual_Studio/Tango.Synchronization/Constants.cs
+++ b/Software/Visual_Studio/Tango.Synchronization/Local/Constants.cs
@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace Tango.Synchronization
+namespace Tango.Synchronization.Local
{
internal static class Constants
{
diff --git a/Software/Visual_Studio/Tango.Synchronization/ExtensionMethods.cs b/Software/Visual_Studio/Tango.Synchronization/Local/ExtensionMethods.cs
index 7f16f7006..8746f9146 100644
--- a/Software/Visual_Studio/Tango.Synchronization/ExtensionMethods.cs
+++ b/Software/Visual_Studio/Tango.Synchronization/Local/ExtensionMethods.cs
@@ -6,7 +6,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace Tango.Synchronization
+namespace Tango.Synchronization.Local
{
internal static class SQLExtensions
{
diff --git a/Software/Visual_Studio/Tango.Synchronization/ISqlDataBase.cs b/Software/Visual_Studio/Tango.Synchronization/Local/ILocalDataBase.cs
index fa4e018be..7e53aeb1c 100644
--- a/Software/Visual_Studio/Tango.Synchronization/ISqlDataBase.cs
+++ b/Software/Visual_Studio/Tango.Synchronization/Local/ILocalDataBase.cs
@@ -5,13 +5,13 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace Tango.Synchronization
+namespace Tango.Synchronization.Local
{
/// <summary>
- /// Represents an SQL data base adapter used by <see cref="SqlDataBaseComparer"/>.
+ /// Represents an SQL data base adapter used by <see cref="LocalDBComparer"/>.
/// </summary>
/// <seealso cref="System.IDisposable" />
- public interface ISqlDataBase : IDisposable
+ public interface ILocalDataBase : IDisposable
{
/// <summary>
/// Gets the database source URL/File.
@@ -34,15 +34,15 @@ namespace Tango.Synchronization
/// <param name="otherDB">The other database.</param>
/// <param name="otherTable">The other table.</param>
/// <returns></returns>
- DataTable CloneTableFrom(ISqlDataBase otherDB, DataTable otherTable);
+ DataTable CloneTableFrom(ILocalDataBase otherDB, DataTable otherTable);
/// <summary>
- /// Gets the SQL command for <see cref="CloneTableFrom(ISqlDataBase, DataTable)"/>.
+ /// Gets the SQL command for <see cref="CloneTableFrom(ILocalDataBase, DataTable)"/>.
/// </summary>
/// <param name="otherDB">The other database.</param>
/// <param name="otherTable">The other table.</param>
/// <returns></returns>
- String GetCloneTableFromCommand(ISqlDataBase otherDB, DataTable otherTable);
+ String GetCloneTableFromCommand(ILocalDataBase otherDB, DataTable otherTable);
/// <summary>
/// Adds the specified column to the specified table.
diff --git a/Software/Visual_Studio/Tango.Synchronization/SqlDataBaseComparer.cs b/Software/Visual_Studio/Tango.Synchronization/Local/LocalDBComparer.cs
index 980a23f1e..63f2ecfaa 100644
--- a/Software/Visual_Studio/Tango.Synchronization/SqlDataBaseComparer.cs
+++ b/Software/Visual_Studio/Tango.Synchronization/Local/LocalDBComparer.cs
@@ -7,40 +7,40 @@ using System.Text;
using System.Threading.Tasks;
using Tango.Logging;
-namespace Tango.Synchronization
+namespace Tango.Synchronization.Local
{
/// <summary>
- /// Represents an <see cref="ISqlDataBase"/> synchronization engine.
+ /// Represents an <see cref="ILocalDataBase"/> synchronization engine.
/// </summary>
/// <seealso cref="System.IDisposable" />
- public class SqlDataBaseComparer : IDisposable
+ public class LocalDBComparer : IDisposable
{
/// <summary>
/// Gets the master SQL.
/// </summary>
- public ISqlDataBase MasterSQL { get; private set; }
+ public ILocalDataBase MasterSQL { get; private set; }
/// <summary>
/// Gets the slave SQL.
/// </summary>
- public ISqlDataBase SlaveSQL { get; private set; }
+ public ILocalDataBase SlaveSQL { get; private set; }
/// <summary>
- /// Initializes a new instance of the <see cref="SqlDataBaseComparer"/> class.
+ /// Initializes a new instance of the <see cref="LocalDBComparer"/> class.
/// </summary>
/// <param name="masterSQL">The master SQL.</param>
/// <param name="slaveSQL">The slave SQL.</param>
- public SqlDataBaseComparer(ISqlDataBase masterSQL, ISqlDataBase slaveSQL)
+ public LocalDBComparer(ILocalDataBase masterSQL, ILocalDataBase slaveSQL)
{
MasterSQL = masterSQL;
SlaveSQL = slaveSQL;
}
/// <summary>
- /// Compares the master and slave SQL data base and returns a collection of <see cref="SqlDiff"/>.
+ /// Compares the master and slave SQL data base and returns a collection of <see cref="Diff"/>.
/// </summary>
/// <returns></returns>
- public List<SqlDiff> Compare()
+ public List<Diff> Compare()
{
LogManager.Log("Comparing databases " + Path.GetFileName(MasterSQL.Source) + " <=> " + Path.GetFileName(SlaveSQL.Source));
@@ -50,7 +50,7 @@ namespace Tango.Synchronization
LogManager.Log("Loading slave tables...");
SlaveSQL.LoadTables();
- List<SqlDiff> diffs = new List<SqlDiff>();
+ List<Diff> diffs = new List<Diff>();
foreach (var masterTable in MasterSQL.Tables)
{
@@ -63,7 +63,7 @@ namespace Tango.Synchronization
{
LogManager.Log("Table not found on slave, adding difference.");
//Clone table from slave db to master db including records!
- diffs.Add(new SqlDiff(SqlDiffAction.AddTableToSlave, String.Format("Add table {0} to slave", masterTable.TableName), () => SlaveSQL.CloneTableFrom(MasterSQL, masterTable), SlaveSQL.GetCloneTableFromCommand(MasterSQL, masterTable)));
+ diffs.Add(new Diff(DiffAction.AddTableToSlave, String.Format("Add table {0} to slave", masterTable.TableName), () => SlaveSQL.CloneTableFrom(MasterSQL, masterTable), SlaveSQL.GetCloneTableFromCommand(MasterSQL, masterTable)));
continue;
}
@@ -79,7 +79,7 @@ namespace Tango.Synchronization
{
LogManager.Log("Column not found on slave, adding difference.");
//Add column to slave table.
- diffs.Add(new SqlDiff(SqlDiffAction.AddColumnToSlave, String.Format("Add column {0} to slave table", masterColumn.ColumnName), () => SlaveSQL.AddColumn(masterTable, masterColumn), SlaveSQL.GetAddColumnCommand(masterTable, masterColumn)));
+ diffs.Add(new Diff(DiffAction.AddColumnToSlave, String.Format("Add column {0} to slave table", masterColumn.ColumnName), () => SlaveSQL.AddColumn(masterTable, masterColumn), SlaveSQL.GetAddColumnCommand(masterTable, masterColumn)));
}
LogManager.Log("Column found.");
@@ -162,22 +162,22 @@ namespace Tango.Synchronization
foreach (var row in addToSlave)
{
- diffs.Add(new SqlDiff(SqlDiffAction.AddRowToSlave, String.Format("Add row to slave table {0}", slaveTable.TableName), () => SlaveSQL.AddRow(slaveTable, row), SlaveSQL.GetAddRowCommand(slaveTable, row)));
+ diffs.Add(new Diff(DiffAction.AddRowToSlave, String.Format("Add row to slave table {0}", slaveTable.TableName), () => SlaveSQL.AddRow(slaveTable, row), SlaveSQL.GetAddRowCommand(slaveTable, row)));
}
foreach (var row in addToMaster)
{
- diffs.Add(new SqlDiff(SqlDiffAction.AddRowToMaster, String.Format("Add row to master table {0}", masterTable.TableName), () => MasterSQL.AddRow(masterTable, row), MasterSQL.GetAddRowCommand(masterTable, row)));
+ diffs.Add(new Diff(DiffAction.AddRowToMaster, String.Format("Add row to master table {0}", masterTable.TableName), () => MasterSQL.AddRow(masterTable, row), MasterSQL.GetAddRowCommand(masterTable, row)));
}
foreach (var row in updateSlave)
{
- diffs.Add(new SqlDiff(SqlDiffAction.UpdateRowInSlave, String.Format("Update row in slave table {0}", slaveTable.TableName), () => SlaveSQL.UpdateRow(slaveTable, row), SlaveSQL.GetUpdateRowCommand(slaveTable, row)));
+ diffs.Add(new Diff(DiffAction.UpdateRowInSlave, String.Format("Update row in slave table {0}", slaveTable.TableName), () => SlaveSQL.UpdateRow(slaveTable, row), SlaveSQL.GetUpdateRowCommand(slaveTable, row)));
}
foreach (var row in updateMaster)
{
- diffs.Add(new SqlDiff(SqlDiffAction.UpdateRowInMaster, String.Format("Update row in master table {0}", masterTable.TableName), () => MasterSQL.UpdateRow(masterTable, row), MasterSQL.GetUpdateRowCommand(masterTable, row)));
+ diffs.Add(new Diff(DiffAction.UpdateRowInMaster, String.Format("Update row in master table {0}", masterTable.TableName), () => MasterSQL.UpdateRow(masterTable, row), MasterSQL.GetUpdateRowCommand(masterTable, row)));
}
LogManager.Log("Done comparing table " + masterTable.TableName);
diff --git a/Software/Visual_Studio/Tango.Synchronization/SqliteDataBase.cs b/Software/Visual_Studio/Tango.Synchronization/Local/SqliteDataBase.cs
index 75259fc28..35e54c66a 100644
--- a/Software/Visual_Studio/Tango.Synchronization/SqliteDataBase.cs
+++ b/Software/Visual_Studio/Tango.Synchronization/Local/SqliteDataBase.cs
@@ -9,13 +9,13 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace Tango.Synchronization
+namespace Tango.Synchronization.Local
{
/// <summary>
- /// Represents an SQLite database adapter used for synchronization by <see cref="SqlDataBaseComparer"/>.
+ /// Represents an SQLite database adapter used for synchronization by <see cref="LocalDBComparer"/>.
/// </summary>
/// <seealso cref="Tango.Synchronization.ISqlDataBase" />
- public class SqliteDataBase : ISqlDataBase
+ public class SQLiteDataBase : ILocalDataBase
{
private SQLiteConnection _connection;
@@ -30,10 +30,10 @@ namespace Tango.Synchronization
public List<DataTable> Tables { get; private set; }
/// <summary>
- /// Initializes a new instance of the <see cref="SqliteDataBase"/> class.
+ /// Initializes a new instance of the <see cref="SQLiteDataBase"/> class.
/// </summary>
/// <param name="filePath">The file path.</param>
- public SqliteDataBase(String filePath)
+ public SQLiteDataBase(String filePath)
{
Source = filePath;
@@ -105,7 +105,7 @@ namespace Tango.Synchronization
/// <param name="otherDB">The other database.</param>
/// <param name="otherTable">The other table.</param>
/// <returns></returns>
- public DataTable CloneTableFrom(ISqlDataBase otherDB, DataTable otherTable)
+ public DataTable CloneTableFrom(ILocalDataBase otherDB, DataTable otherTable)
{
String cmd = String.Format("CREATE TABLE {0} (", otherTable.TableName);
@@ -148,12 +148,12 @@ namespace Tango.Synchronization
}
/// <summary>
- /// Gets the SQL command for <see cref="CloneTableFrom(ISqlDataBase, DataTable)" />.
+ /// Gets the SQL command for <see cref="CloneTableFrom(ILocalDataBase, DataTable)" />.
/// </summary>
/// <param name="otherDB">The other database.</param>
/// <param name="otherTable">The other table.</param>
/// <returns></returns>
- public String GetCloneTableFromCommand(ISqlDataBase otherDB, DataTable otherTable)
+ public String GetCloneTableFromCommand(ILocalDataBase otherDB, DataTable otherTable)
{
String cmd = String.Format("CREATE TABLE {0} (", otherTable.TableName);
diff --git a/Software/Visual_Studio/Tango.Synchronization/Remote/RemoteDBComparer.cs b/Software/Visual_Studio/Tango.Synchronization/Remote/RemoteDBComparer.cs
new file mode 100644
index 000000000..1635e6fa7
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Synchronization/Remote/RemoteDBComparer.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using remote = Tango.DAL.Remote.DB;
+using local = Tango.DAL.Local.DB;
+
+namespace Tango.Synchronization.Remote
+{
+ public class RemoteDBComparer : IDisposable
+ {
+ private remote.RemoteDB _remoteDB;
+ private local.LocalDB _localDB;
+ private String _machineSerial;
+
+ public RemoteDBComparer(remote.RemoteDB remoteDB, local.LocalDB localDB,String machineSerial)
+ {
+ _machineSerial = machineSerial;
+ _remoteDB = remoteDB;
+ _localDB = localDB;
+ }
+
+ public List<Diff> Compare()
+ {
+ List<Diff> diffs = new List<Diff>();
+
+ var remoteMachine = _remoteDB.MACHINES.SingleOrDefault(x => x.SERIAL_NUMBER == _machineSerial);
+
+
+ //var localMachine = _localDB.MACHINES.SingleOrDefault(x => x.Se)
+
+
+
+
+ return diffs;
+ }
+
+ public void Dispose()
+ {
+ _remoteDB.Dispose();
+ _localDB.Dispose();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Tango.Synchronization/Tango.Synchronization.csproj b/Software/Visual_Studio/Tango.Synchronization/Tango.Synchronization.csproj
index 98a5044ce..b94eec9fa 100644
--- a/Software/Visual_Studio/Tango.Synchronization/Tango.Synchronization.csproj
+++ b/Software/Visual_Studio/Tango.Synchronization/Tango.Synchronization.csproj
@@ -64,25 +64,35 @@
<Compile Include="..\Versioning\GlobalVersionInfo.cs">
<Link>GlobalVersionInfo.cs</Link>
</Compile>
- <Compile Include="Constants.cs" />
- <Compile Include="ExtensionMethods.cs" />
- <Compile Include="ISqlDataBase.cs" />
+ <Compile Include="Local\Constants.cs" />
+ <Compile Include="Local\ExtensionMethods.cs" />
+ <Compile Include="Local\ILocalDataBase.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="SqlDataBaseComparer.cs" />
- <Compile Include="SqlDiff.cs" />
- <Compile Include="SqlDiffAction.cs" />
- <Compile Include="SqliteDataBase.cs" />
+ <Compile Include="Local\LocalDBComparer.cs" />
+ <Compile Include="Diff.cs" />
+ <Compile Include="DiffAction.cs" />
+ <Compile Include="Local\SQLiteDataBase.cs" />
+ <Compile Include="Remote\RemoteDBComparer.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
+ <ProjectReference Include="..\Tango.DAL.Local\Tango.DAL.Local.csproj">
+ <Project>{0e0eef3e-8f4e-4f23-9d19-479fd8d76c12}</Project>
+ <Name>Tango.DAL.Local</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\Tango.DAL.Remote\Tango.DAL.Remote.csproj">
+ <Project>{38197109-8610-4d3f-92b9-16d48df94d7c}</Project>
+ <Name>Tango.DAL.Remote</Name>
+ </ProjectReference>
<ProjectReference Include="..\Tango.Logging\Tango.Logging.csproj">
<Project>{bc932dbd-7cdb-488c-99e4-f02cf441f55e}</Project>
<Name>Tango.Logging</Name>
</ProjectReference>
</ItemGroup>
+ <ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\System.Data.SQLite.Core.1.0.106.0\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.106.0\build\net46\System.Data.SQLite.Core.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">