From d33c19b3ac6803de4b5c8d475832efef131c1a45 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Wed, 30 Dec 2020 15:11:34 +0000 Subject: Revert "Hope it is fine" --- .../PPC/Tango.PPC.DataSynchronizer.CLI/App.config | 28 ++++++ .../PPC/Tango.PPC.DataSynchronizer.CLI/Program.cs | 107 +++++++++++++++++++++ .../Properties/AssemblyInfo.cs | 36 +++++++ .../Tango.PPC.DataSynchronizer.CLI.csproj | 75 +++++++++++++++ .../Tango.PPC.DataSynchronizer.CLI/packages.config | 4 + 5 files changed, 250 insertions(+) create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.DataSynchronizer.CLI/App.config create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.DataSynchronizer.CLI/Program.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.DataSynchronizer.CLI/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.DataSynchronizer.CLI/Tango.PPC.DataSynchronizer.CLI.csproj create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.DataSynchronizer.CLI/packages.config (limited to 'Software/Visual_Studio/PPC/Tango.PPC.DataSynchronizer.CLI') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.DataSynchronizer.CLI/App.config b/Software/Visual_Studio/PPC/Tango.PPC.DataSynchronizer.CLI/App.config new file mode 100644 index 000000000..a46da65da --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.DataSynchronizer.CLI/App.config @@ -0,0 +1,28 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.DataSynchronizer.CLI/Program.cs b/Software/Visual_Studio/PPC/Tango.PPC.DataSynchronizer.CLI/Program.cs new file mode 100644 index 000000000..091ef8f13 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.DataSynchronizer.CLI/Program.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.SQLExaminer; + +namespace Tango.PPC.DataSynchronizer.CLI +{ + class Program + { + static void Main(string[] args) + { + DataSynchronizer synchronizer = new DataSynchronizer(); + synchronizer.Synchronize(); + Console.ReadLine(); + } + } + + public class DataSynchronizer + { + private Core.DataSource source; + private Core.DataSource target; + private String machineGuid; + + public void Synchronize() + { + try + { + Console.WriteLine("Starting PPC data synchronization..."); + + source = new Core.DataSource(); + source.IntegratedSecurity = false; + source.Address = "twine.database.windows.net"; + source.Catalog = "Tango_DEV"; + source.UserName = "Roy"; + source.Password = "Aa123456"; + + using (ObservablesContext db = ObservablesContext.CreateDefault(source)) + { + machineGuid = db.Machines.Where(x => x.SerialNumber == "LENA_TABLET").Take(1).Select(x => x.Guid).First(); + } + + target = new Core.DataSource(); + target.Address = "localhost\\SQLPPC"; + target.Catalog = "Tango"; + + OverrideData(); + UpdateMachine(); + + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine("Synchronization Completed Successfully."); + } + catch (Exception ex) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine(ex.ToString()); + } + } + + private void OverrideData() + { + Console.WriteLine("Executing override data script..."); + + ExaminerConfigurationBuilder builder = new ExaminerConfigurationBuilder(ExaminerConfigurationType.OverrideData); + builder.SetSource(source).SetTarget(target).Synchronize(); + var process = new ExaminerProcess(builder.Build(), ExaminerProcessType.Data); + process.Progress += (x, msg) => + { + if (msg != null && !msg.Contains("SQL Examiner")) + { + Console.WriteLine(msg); + } + }; + var result = process.Execute().Result; + + if (result.ExitCode != ExaminerProcessExitCode.Success) + { + throw new InvalidOperationException(result.Output); + } + } + + private void UpdateMachine() + { + Console.WriteLine("Executing update machine script..."); + + ExaminerConfigurationBuilder builder = new ExaminerConfigurationBuilder(ExaminerConfigurationType.UpdateMachine); + builder.SetSource(source).SetTarget(target).SetMachineSerialNumber(machineGuid).Synchronize(); + var process = new ExaminerProcess(builder.Build(), ExaminerProcessType.Data); + process.Progress += (x, msg) => + { + if (msg != null && !msg.Contains("SQL Examiner")) + { + Console.WriteLine(msg); + } + }; + var result = process.Execute().Result; + + if (result.ExitCode != ExaminerProcessExitCode.Success) + { + throw new InvalidOperationException(result.Output); + } + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.DataSynchronizer.CLI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Tango.PPC.DataSynchronizer.CLI/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..450b7dc72 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.DataSynchronizer.CLI/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Tango.PPC.DataSynchronizer.CLI")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tango.PPC.DataSynchronizer.CLI")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("3e07ed4e-a755-443f-b18c-3775555a2dd7")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Software/Visual_Studio/PPC/Tango.PPC.DataSynchronizer.CLI/Tango.PPC.DataSynchronizer.CLI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.DataSynchronizer.CLI/Tango.PPC.DataSynchronizer.CLI.csproj new file mode 100644 index 000000000..aeab763bc --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.DataSynchronizer.CLI/Tango.PPC.DataSynchronizer.CLI.csproj @@ -0,0 +1,75 @@ + + + + + Debug + AnyCPU + {3E07ED4E-A755-443F-B18C-3775555A2DD7} + Exe + Tango.PPC.DataSynchronizer.CLI + Tango.PPC.DataSynchronizer.CLI + v4.6.1 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + + ..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + + + + + + + + + + + + + + + + + + + + + {f441feee-322a-4943-b566-110e12fd3b72} + Tango.BL + + + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} + Tango.Core + + + {e1e66ed9-597d-45fa-8048-de90a6930484} + Tango.SQLExaminer + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.DataSynchronizer.CLI/packages.config b/Software/Visual_Studio/PPC/Tango.PPC.DataSynchronizer.CLI/packages.config new file mode 100644 index 000000000..b3daf0d6c --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.DataSynchronizer.CLI/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file -- cgit v1.3.1