From 0f5a0b13fc4408952d90d2450c642a7948b88879 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 19 Dec 2018 10:02:27 +0200 Subject: Starting working on improving web api's access... --- .../Web/Tango.MachineService/Tango.MachineService.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj') diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj index 9f0b2cba2..c7fdab45c 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj +++ b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj @@ -279,7 +279,7 @@ - + Global.asax @@ -365,7 +365,7 @@ False - + -- cgit v1.3.1 From de762e7e5b346af5a12eff04cbaa0696eec15b8c Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 19 Dec 2018 12:57:04 +0200 Subject: Moved all web transport to json :/ --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 20578304 -> 20578304 bytes .../Synchronization/CheckForUpdateRequest.proto | 10 - .../Synchronization/CheckForUpdateResponse.proto | 10 - .../Synchronization/DownloadUpdateRequest.proto | 9 - .../Synchronization/DownloadUpdateResponse.proto | 15 - .../Synchronization/MachineSetupRequest.proto | 9 - .../Synchronization/MachineSetupResponse.proto | 23 -- .../Synchronization/SynchronizeDBRequest.proto | 10 - .../Synchronization/SynchronizeDBResponse.proto | 9 - .../Messages/Synchronization/UpdateDBRequest.proto | 9 - .../Synchronization/UpdateDBResponse.proto | 11 - .../Build/Shortcuts/Machine Emulator.lnk | Bin 1530 -> 1471 bytes .../Build/Shortcuts/Machine Studio.lnk | Bin 1516 -> 1532 bytes .../Build/Shortcuts/Proto Compiler GUI.lnk | Bin 1529 -> 1464 bytes .../MachineSetup/MachineSetupManager.cs | 4 +- .../MachineSetup/MachineSetupRequest.cs | 14 + .../MachineSetup/MachineSetupResponse.cs | 28 ++ .../MachineUpdate/CheckForUpdateRequest.cs | 15 + .../MachineUpdate/CheckForUpdateResponse.cs | 15 + .../MachineUpdate/DownloadUpdateRequest.cs | 14 + .../MachineUpdate/DownloadUpdateResponse.cs | 20 + .../MachineUpdate/MachineUpdateManager.cs | 12 +- .../MachineUpdate/UpdateDBRequest.cs | 14 + .../MachineUpdate/UpdateDBResponse.cs | 16 + .../PPC/Tango.PPC.Common/PPCSettings.cs | 6 - .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 8 + .../Update/LatestVersionRequest.cs | 5 +- .../Update/LatestVersionResponse.cs | 5 +- .../Tango.PPC.Common/Update/PPCUpdateService.cs | 8 +- .../Update/UploadCompletedRequest.cs | 5 +- .../Update/UploadCompletedResponse.cs | 4 +- .../Update/UploadVersionRequest.cs | 9 +- .../Update/UploadVersionResponse.cs | 6 +- .../Visual_Studio/Tango.Core/Tango.Core.csproj | 2 +- .../Synchronization/CheckForUpdateRequest.cs | 188 --------- .../Synchronization/CheckForUpdateResponse.cs | 188 --------- .../Synchronization/DownloadUpdateRequest.cs | 160 -------- .../Synchronization/DownloadUpdateResponse.cs | 274 ------------- .../Synchronization/MachineSetupRequest.cs | 160 -------- .../Synchronization/MachineSetupResponse.cs | 444 --------------------- .../Synchronization/SynchronizeDBRequest.cs | 188 --------- .../Synchronization/SynchronizeDBResponse.cs | 160 -------- .../Tango.PMR/Synchronization/UpdateDBRequest.cs | 160 -------- .../Tango.PMR/Synchronization/UpdateDBResponse.cs | 216 ---------- Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj | 12 +- .../Tango.Transport/Tango.Transport.csproj | 13 +- .../Tango.Transport/TransporterBase.cs | 1 + .../Tango.Transport/Web/ITransportWebClient.cs | 14 - .../Tango.Transport/Web/IWebRequestMessage.cs | 12 + .../Tango.Transport/Web/IWebResponseMessage.cs | 12 + .../Tango.Transport/Web/IWebTransportClient.cs | 15 + .../Tango.Transport/Web/IWebTransportMessage.cs | 12 + .../Tango.Transport/Web/JsonWebClient.cs | 69 ---- .../Tango.Transport/Web/ProtoWebClient.cs | 51 --- .../Tango.Transport/Web/WebRequestMessage.cs | 12 + .../Tango.Transport/Web/WebResponseMessage.cs | 12 + .../Tango.Transport/Web/WebTransportClient.cs | 84 ++++ .../Tango.Transport/Web/WebTransportMessage.cs | 12 + .../Tango.UnitTesting/MachineService_TST.cs | 2 +- .../Controllers/HomeController.cs | 16 - .../Controllers/PPCController.cs | 152 ++++++- .../Controllers/ValuesController.cs | 45 --- .../Controllers/VersionUpdateController.cs | 168 -------- .../Tango.MachineService/Models/PendingUpload.cs | 22 + .../Tango.MachineService.csproj | 8 +- 66 files changed, 531 insertions(+), 2676 deletions(-) delete mode 100644 Software/PMR/Messages/Synchronization/CheckForUpdateRequest.proto delete mode 100644 Software/PMR/Messages/Synchronization/CheckForUpdateResponse.proto delete mode 100644 Software/PMR/Messages/Synchronization/DownloadUpdateRequest.proto delete mode 100644 Software/PMR/Messages/Synchronization/DownloadUpdateResponse.proto delete mode 100644 Software/PMR/Messages/Synchronization/MachineSetupRequest.proto delete mode 100644 Software/PMR/Messages/Synchronization/MachineSetupResponse.proto delete mode 100644 Software/PMR/Messages/Synchronization/SynchronizeDBRequest.proto delete mode 100644 Software/PMR/Messages/Synchronization/SynchronizeDBResponse.proto delete mode 100644 Software/PMR/Messages/Synchronization/UpdateDBRequest.proto delete mode 100644 Software/PMR/Messages/Synchronization/UpdateDBResponse.proto create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupRequest.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupResponse.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/CheckForUpdateRequest.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/CheckForUpdateResponse.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DownloadUpdateRequest.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DownloadUpdateResponse.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/UpdateDBRequest.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/UpdateDBResponse.cs delete mode 100644 Software/Visual_Studio/Tango.PMR/Synchronization/CheckForUpdateRequest.cs delete mode 100644 Software/Visual_Studio/Tango.PMR/Synchronization/CheckForUpdateResponse.cs delete mode 100644 Software/Visual_Studio/Tango.PMR/Synchronization/DownloadUpdateRequest.cs delete mode 100644 Software/Visual_Studio/Tango.PMR/Synchronization/DownloadUpdateResponse.cs delete mode 100644 Software/Visual_Studio/Tango.PMR/Synchronization/MachineSetupRequest.cs delete mode 100644 Software/Visual_Studio/Tango.PMR/Synchronization/MachineSetupResponse.cs delete mode 100644 Software/Visual_Studio/Tango.PMR/Synchronization/SynchronizeDBRequest.cs delete mode 100644 Software/Visual_Studio/Tango.PMR/Synchronization/SynchronizeDBResponse.cs delete mode 100644 Software/Visual_Studio/Tango.PMR/Synchronization/UpdateDBRequest.cs delete mode 100644 Software/Visual_Studio/Tango.PMR/Synchronization/UpdateDBResponse.cs delete mode 100644 Software/Visual_Studio/Tango.Transport/Web/ITransportWebClient.cs create mode 100644 Software/Visual_Studio/Tango.Transport/Web/IWebRequestMessage.cs create mode 100644 Software/Visual_Studio/Tango.Transport/Web/IWebResponseMessage.cs create mode 100644 Software/Visual_Studio/Tango.Transport/Web/IWebTransportClient.cs create mode 100644 Software/Visual_Studio/Tango.Transport/Web/IWebTransportMessage.cs delete mode 100644 Software/Visual_Studio/Tango.Transport/Web/JsonWebClient.cs delete mode 100644 Software/Visual_Studio/Tango.Transport/Web/ProtoWebClient.cs create mode 100644 Software/Visual_Studio/Tango.Transport/Web/WebRequestMessage.cs create mode 100644 Software/Visual_Studio/Tango.Transport/Web/WebResponseMessage.cs create mode 100644 Software/Visual_Studio/Tango.Transport/Web/WebTransportClient.cs create mode 100644 Software/Visual_Studio/Tango.Transport/Web/WebTransportMessage.cs delete mode 100644 Software/Visual_Studio/Web/Tango.MachineService/Controllers/HomeController.cs delete mode 100644 Software/Visual_Studio/Web/Tango.MachineService/Controllers/ValuesController.cs delete mode 100644 Software/Visual_Studio/Web/Tango.MachineService/Controllers/VersionUpdateController.cs create mode 100644 Software/Visual_Studio/Web/Tango.MachineService/Models/PendingUpload.cs (limited to 'Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 81ed33c36..5b346239d 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 76a2f4509..1801b28f7 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/PMR/Messages/Synchronization/CheckForUpdateRequest.proto b/Software/PMR/Messages/Synchronization/CheckForUpdateRequest.proto deleted file mode 100644 index 4b1da8764..000000000 --- a/Software/PMR/Messages/Synchronization/CheckForUpdateRequest.proto +++ /dev/null @@ -1,10 +0,0 @@ -syntax = "proto3"; - -package Tango.PMR.Synchronization; -option java_package = "com.twine.tango.pmr.synchronization"; - -message CheckForUpdateRequest -{ - string SerialNumber = 1; - string Version = 2; -} \ No newline at end of file diff --git a/Software/PMR/Messages/Synchronization/CheckForUpdateResponse.proto b/Software/PMR/Messages/Synchronization/CheckForUpdateResponse.proto deleted file mode 100644 index 30e2b6fbb..000000000 --- a/Software/PMR/Messages/Synchronization/CheckForUpdateResponse.proto +++ /dev/null @@ -1,10 +0,0 @@ -syntax = "proto3"; - -package Tango.PMR.Synchronization; -option java_package = "com.twine.tango.pmr.synchronization"; - -message CheckForUpdateResponse -{ - bool IsUpdateAvailable = 1; - string Version = 2; -} \ No newline at end of file diff --git a/Software/PMR/Messages/Synchronization/DownloadUpdateRequest.proto b/Software/PMR/Messages/Synchronization/DownloadUpdateRequest.proto deleted file mode 100644 index 98b302f85..000000000 --- a/Software/PMR/Messages/Synchronization/DownloadUpdateRequest.proto +++ /dev/null @@ -1,9 +0,0 @@ -syntax = "proto3"; - -package Tango.PMR.Synchronization; -option java_package = "com.twine.tango.pmr.synchronization"; - -message DownloadUpdateRequest -{ - string SerialNumber = 1; -} \ No newline at end of file diff --git a/Software/PMR/Messages/Synchronization/DownloadUpdateResponse.proto b/Software/PMR/Messages/Synchronization/DownloadUpdateResponse.proto deleted file mode 100644 index d48639398..000000000 --- a/Software/PMR/Messages/Synchronization/DownloadUpdateResponse.proto +++ /dev/null @@ -1,15 +0,0 @@ -syntax = "proto3"; - -package Tango.PMR.Synchronization; -option java_package = "com.twine.tango.pmr.synchronization"; - -message DownloadUpdateResponse -{ - string Version = 1; - - string BlobAddress = 2; - - string DbAddress = 3; - string DbUserName = 4; - string DbPassword = 5; -} \ No newline at end of file diff --git a/Software/PMR/Messages/Synchronization/MachineSetupRequest.proto b/Software/PMR/Messages/Synchronization/MachineSetupRequest.proto deleted file mode 100644 index 578e3a194..000000000 --- a/Software/PMR/Messages/Synchronization/MachineSetupRequest.proto +++ /dev/null @@ -1,9 +0,0 @@ -syntax = "proto3"; - -package Tango.PMR.Synchronization; -option java_package = "com.twine.tango.pmr.synchronization"; - -message MachineSetupRequest -{ - string SerialNumber = 1; -} \ No newline at end of file diff --git a/Software/PMR/Messages/Synchronization/MachineSetupResponse.proto b/Software/PMR/Messages/Synchronization/MachineSetupResponse.proto deleted file mode 100644 index cc0d675b9..000000000 --- a/Software/PMR/Messages/Synchronization/MachineSetupResponse.proto +++ /dev/null @@ -1,23 +0,0 @@ -syntax = "proto3"; - -package Tango.PMR.Synchronization; -option java_package = "com.twine.tango.pmr.synchronization"; - -message MachineSetupResponse -{ - string Version = 1; - - string BlobAddress = 2; - - string DbAddress = 3; - string DbUserName = 4; - string DbPassword = 5; - - string OSKey = 6; - - bool SetupActivation = 7; - bool SetupRemoteAssistance = 8; - bool SetupUWF = 9; - bool SetupFirmware = 10; - bool IsDemo = 11; -} \ No newline at end of file diff --git a/Software/PMR/Messages/Synchronization/SynchronizeDBRequest.proto b/Software/PMR/Messages/Synchronization/SynchronizeDBRequest.proto deleted file mode 100644 index b3b6d542f..000000000 --- a/Software/PMR/Messages/Synchronization/SynchronizeDBRequest.proto +++ /dev/null @@ -1,10 +0,0 @@ -syntax = "proto3"; - -package Tango.PMR.Synchronization; -option java_package = "com.twine.tango.pmr.synchronization"; - -message SynchronizeDBRequest -{ - string SerialNumber = 1; - bytes LocalDB = 2; -} \ No newline at end of file diff --git a/Software/PMR/Messages/Synchronization/SynchronizeDBResponse.proto b/Software/PMR/Messages/Synchronization/SynchronizeDBResponse.proto deleted file mode 100644 index 091934027..000000000 --- a/Software/PMR/Messages/Synchronization/SynchronizeDBResponse.proto +++ /dev/null @@ -1,9 +0,0 @@ -syntax = "proto3"; - -package Tango.PMR.Synchronization; -option java_package = "com.twine.tango.pmr.synchronization"; - -message SynchronizeDBResponse -{ - bytes RemoteDB = 1; -} \ No newline at end of file diff --git a/Software/PMR/Messages/Synchronization/UpdateDBRequest.proto b/Software/PMR/Messages/Synchronization/UpdateDBRequest.proto deleted file mode 100644 index da3fe74c5..000000000 --- a/Software/PMR/Messages/Synchronization/UpdateDBRequest.proto +++ /dev/null @@ -1,9 +0,0 @@ -syntax = "proto3"; - -package Tango.PMR.Synchronization; -option java_package = "com.twine.tango.pmr.synchronization"; - -message UpdateDBRequest -{ - string SerialNumber = 1; -} \ No newline at end of file diff --git a/Software/PMR/Messages/Synchronization/UpdateDBResponse.proto b/Software/PMR/Messages/Synchronization/UpdateDBResponse.proto deleted file mode 100644 index fbc8e1ec3..000000000 --- a/Software/PMR/Messages/Synchronization/UpdateDBResponse.proto +++ /dev/null @@ -1,11 +0,0 @@ -syntax = "proto3"; - -package Tango.PMR.Synchronization; -option java_package = "com.twine.tango.pmr.synchronization"; - -message UpdateDBResponse -{ - string DbAddress = 1; - string DbUserName = 2; - string DbPassword = 3; -} \ No newline at end of file diff --git a/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk b/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk index 391bb5fd2..612ccab34 100644 Binary files a/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk and b/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk differ diff --git a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk index 8f85b4556..09ae17244 100644 Binary files a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk and b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk differ diff --git a/Software/Visual_Studio/Build/Shortcuts/Proto Compiler GUI.lnk b/Software/Visual_Studio/Build/Shortcuts/Proto Compiler GUI.lnk index 98e7572e8..6f203ca29 100644 Binary files a/Software/Visual_Studio/Build/Shortcuts/Proto Compiler GUI.lnk and b/Software/Visual_Studio/Build/Shortcuts/Proto Compiler GUI.lnk differ diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs index eb47ae231..1f86e0953 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs @@ -112,9 +112,9 @@ namespace Tango.PPC.Common.MachineSetup try { - using (var http = new ProtoWebClient()) + using (var http = new WebTransportClient()) { - setup_response = await http.Post(machineServiceAddress + "/api/PPC/MachineSetup", request); + setup_response = await http.PostJson(machineServiceAddress + "/api/PPC/MachineSetup", request); } } catch (Exception ex) diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupRequest.cs new file mode 100644 index 000000000..4c8039544 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupRequest.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.MachineSetup +{ + public class MachineSetupRequest : WebRequestMessage + { + public String SerialNumber { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupResponse.cs new file mode 100644 index 000000000..89450a1d1 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupResponse.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.MachineSetup +{ + public class MachineSetupResponse : WebResponseMessage + { + public String Version { get; set; } + + public String BlobAddress { get; set; } + + public String DbAddress { get; set; } + public String DbUserName { get; set; } + public String DbPassword { get; set; } + + public String OSKey { get; set; } + + public bool SetupActivation { get; set; } + public bool SetupRemoteAssistance { get; set; } + public bool SetupUWF { get; set; } + public bool SetupFirmware { get; set; } + public bool IsDemo { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/CheckForUpdateRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/CheckForUpdateRequest.cs new file mode 100644 index 000000000..cd5789393 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/CheckForUpdateRequest.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.MachineUpdate +{ + public class CheckForUpdateRequest : WebRequestMessage + { + public String SerialNumber { get; set; } + public String Version { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/CheckForUpdateResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/CheckForUpdateResponse.cs new file mode 100644 index 000000000..cbf6c8c64 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/CheckForUpdateResponse.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.MachineUpdate +{ + public class CheckForUpdateResponse : WebResponseMessage + { + public bool IsUpdateAvailable { get; set; } + public String Version { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DownloadUpdateRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DownloadUpdateRequest.cs new file mode 100644 index 000000000..9369a2a94 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DownloadUpdateRequest.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.MachineUpdate +{ + public class DownloadUpdateRequest : WebRequestMessage + { + public String SerialNumber { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DownloadUpdateResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DownloadUpdateResponse.cs new file mode 100644 index 000000000..c42c06f3b --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DownloadUpdateResponse.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.MachineUpdate +{ + public class DownloadUpdateResponse : WebResponseMessage + { + public String Version { get; set; } + + public String BlobAddress { get; set; } + + public String DbAddress { get; set; } + public String DbUserName { get; set; } + public String DbPassword { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs index ce45258f5..6df7117d7 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs @@ -111,9 +111,9 @@ namespace Tango.PPC.Common.MachineUpdate DownloadUpdateResponse update_response = null; - using (var http = new ProtoWebClient()) + using (var http = new WebTransportClient()) { - update_response = await http.Post(machineServiceAddress + "/api/PPC/MachineUpdate", request); + update_response = await http.PostJson(machineServiceAddress + "/api/PPC/MachineUpdate", request); } LogManager.Log($"Machine update response received: {Environment.NewLine}{update_response.ToJsonString()}"); @@ -292,9 +292,9 @@ namespace Tango.PPC.Common.MachineUpdate CheckForUpdateResponse update_response = null; - using (var http = new ProtoWebClient()) + using (var http = new WebTransportClient()) { - update_response = http.Post(machineServiceAddress + "/api/PPC/CheckForUpdate", request).Result; + update_response = http.PostJson(machineServiceAddress + "/api/PPC/CheckForUpdate", request).Result; } LogManager.Log($"Check for update response received: {Environment.NewLine}{update_response.ToJsonString()}"); @@ -403,9 +403,9 @@ namespace Tango.PPC.Common.MachineUpdate UpdateDBResponse update_response = null; - using (var http = new ProtoWebClient()) + using (var http = new WebTransportClient()) { - update_response = http.Post(machineServiceAddress + "/api/PPC/UpdateDB", request).Result; + update_response = http.PostJson(machineServiceAddress + "/api/PPC/UpdateDB", request).Result; } LogManager.Log($"Update DB response received: {Environment.NewLine}{update_response.ToJsonString()}"); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/UpdateDBRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/UpdateDBRequest.cs new file mode 100644 index 000000000..1d0caa5a9 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/UpdateDBRequest.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.MachineUpdate +{ + public class UpdateDBRequest : WebRequestMessage + { + public String SerialNumber { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/UpdateDBResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/UpdateDBResponse.cs new file mode 100644 index 000000000..212cd02d2 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/UpdateDBResponse.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.MachineUpdate +{ + public class UpdateDBResponse : WebResponseMessage + { + public String DbAddress { get; set; } + public String DbUserName { get; set; } + public String DbPassword { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs index c33db4854..d6fa39af0 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs @@ -25,11 +25,6 @@ namespace Tango.PPC.Common /// public ApplicationStates ApplicationState { get; set; } - /// - /// Gets the update service address. - /// - public String UpdateServiceAddress { get; internal set; } - /// /// Gets or sets the machine service address. /// @@ -82,7 +77,6 @@ namespace Tango.PPC.Common { MachineScanningTimeoutSeconds = 20; LoggingCategories = new List(); - UpdateServiceAddress = "http://twine01/PPCUpdateService/PPCUpdateService.svc"; MachineServiceAddress = "http://machineservice.twine-srv.com/"; EmbeddedComPort = null; ExternalBridgePassword = "Aa123456"; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index 79c970e5a..790f69ff8 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -136,11 +136,19 @@ + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/LatestVersionRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/LatestVersionRequest.cs index caa857abc..6a6dab1b4 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/LatestVersionRequest.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/LatestVersionRequest.cs @@ -4,13 +4,12 @@ using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; +using Tango.Transport.Web; namespace Tango.PPC.Common.Update { - [DataContract] - public class LatestVersionRequest + public class LatestVersionRequest : WebRequestMessage { - [DataMember] public String MachineVersionGuid { get; set; } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/LatestVersionResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/LatestVersionResponse.cs index aa753fb18..8e97a8177 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/LatestVersionResponse.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/LatestVersionResponse.cs @@ -4,13 +4,12 @@ using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; +using Tango.Transport.Web; namespace Tango.PPC.Common.Update { - [DataContract] - public class LatestVersionResponse + public class LatestVersionResponse : WebResponseMessage { - [DataMember] public String Version { get; set; } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/PPCUpdateService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/PPCUpdateService.cs index 282e4d627..b6654ef59 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/PPCUpdateService.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/PPCUpdateService.cs @@ -3,18 +3,20 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.Settings; using Tango.Transport.Web; namespace Tango.PPC.Common.Update { public class PPCUpdateService : IPPCUpdateService { - private string address = "http://localhost:51581/api/VersionUpdate/"; - private JsonWebClient _client; + private string address; + private WebTransportClient _client; public PPCUpdateService() { - _client = new JsonWebClient(); + address = SettingsManager.Default.GetOrCreate().MachineServiceAddress + "/api/PPC/"; + _client = new WebTransportClient(); } public Task UploadVersion(UploadVersionRequest request) diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadCompletedRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadCompletedRequest.cs index ce30a9d7c..55e733e04 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadCompletedRequest.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadCompletedRequest.cs @@ -4,13 +4,12 @@ using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; +using Tango.Transport.Web; namespace Tango.PPC.Common.Update { - [DataContract] - public class UploadCompletedRequest + public class UploadCompletedRequest : WebRequestMessage { - [DataMember] public String Token { get; set; } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadCompletedResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadCompletedResponse.cs index 171c92172..1cce32e7d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadCompletedResponse.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadCompletedResponse.cs @@ -4,11 +4,11 @@ using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; +using Tango.Transport.Web; namespace Tango.PPC.Common.Update { - [DataContract] - public class UploadCompletedResponse + public class UploadCompletedResponse : WebResponseMessage { } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadVersionRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadVersionRequest.cs index 5672e8fd9..0b496d7be 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadVersionRequest.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadVersionRequest.cs @@ -4,25 +4,20 @@ using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; +using Tango.Transport.Web; namespace Tango.PPC.Common.Update { - [DataContract] - public class UploadVersionRequest + public class UploadVersionRequest : WebRequestMessage { - [DataMember] public String Email { get; set; } - [DataMember] public String Password { get; set; } - [DataMember] public String Version { get; set; } - [DataMember] public String MachineVersionGuid { get; set; } - [DataMember] public String Comments { get; set; } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadVersionResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadVersionResponse.cs index ca40617f1..4543261e7 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadVersionResponse.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadVersionResponse.cs @@ -4,16 +4,14 @@ using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; +using Tango.Transport.Web; namespace Tango.PPC.Common.Update { - [DataContract] - public class UploadVersionResponse + public class UploadVersionResponse : WebResponseMessage { - [DataMember] public String Token { get; set; } - [DataMember] public String BlobAddress { get; set; } } } diff --git a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj index 469a17cd9..1fe53252f 100644 --- a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj +++ b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj @@ -192,7 +192,7 @@ - + diff --git a/Software/Visual_Studio/Tango.PMR/Synchronization/CheckForUpdateRequest.cs b/Software/Visual_Studio/Tango.PMR/Synchronization/CheckForUpdateRequest.cs deleted file mode 100644 index c873c62a5..000000000 --- a/Software/Visual_Studio/Tango.PMR/Synchronization/CheckForUpdateRequest.cs +++ /dev/null @@ -1,188 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: CheckForUpdateRequest.proto -#pragma warning disable 1591, 0612, 3021 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -namespace Tango.PMR.Synchronization { - - /// Holder for reflection information generated from CheckForUpdateRequest.proto - public static partial class CheckForUpdateRequestReflection { - - #region Descriptor - /// File descriptor for CheckForUpdateRequest.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static CheckForUpdateRequestReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "ChtDaGVja0ZvclVwZGF0ZVJlcXVlc3QucHJvdG8SGVRhbmdvLlBNUi5TeW5j", - "aHJvbml6YXRpb24iPgoVQ2hlY2tGb3JVcGRhdGVSZXF1ZXN0EhQKDFNlcmlh", - "bE51bWJlchgBIAEoCRIPCgdWZXJzaW9uGAIgASgJQiUKI2NvbS50d2luZS50", - "YW5nby5wbXIuc3luY2hyb25pemF0aW9uYgZwcm90bzM=")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Synchronization.CheckForUpdateRequest), global::Tango.PMR.Synchronization.CheckForUpdateRequest.Parser, new[]{ "SerialNumber", "Version" }, null, null, null) - })); - } - #endregion - - } - #region Messages - public sealed partial class CheckForUpdateRequest : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CheckForUpdateRequest()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Tango.PMR.Synchronization.CheckForUpdateRequestReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public CheckForUpdateRequest() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public CheckForUpdateRequest(CheckForUpdateRequest other) : this() { - serialNumber_ = other.serialNumber_; - version_ = other.version_; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public CheckForUpdateRequest Clone() { - return new CheckForUpdateRequest(this); - } - - /// Field number for the "SerialNumber" field. - public const int SerialNumberFieldNumber = 1; - private string serialNumber_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string SerialNumber { - get { return serialNumber_; } - set { - serialNumber_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "Version" field. - public const int VersionFieldNumber = 2; - private string version_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string Version { - get { return version_; } - set { - version_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as CheckForUpdateRequest); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(CheckForUpdateRequest other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (SerialNumber != other.SerialNumber) return false; - if (Version != other.Version) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (SerialNumber.Length != 0) hash ^= SerialNumber.GetHashCode(); - if (Version.Length != 0) hash ^= Version.GetHashCode(); - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (SerialNumber.Length != 0) { - output.WriteRawTag(10); - output.WriteString(SerialNumber); - } - if (Version.Length != 0) { - output.WriteRawTag(18); - output.WriteString(Version); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (SerialNumber.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(SerialNumber); - } - if (Version.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Version); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(CheckForUpdateRequest other) { - if (other == null) { - return; - } - if (other.SerialNumber.Length != 0) { - SerialNumber = other.SerialNumber; - } - if (other.Version.Length != 0) { - Version = other.Version; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 10: { - SerialNumber = input.ReadString(); - break; - } - case 18: { - Version = input.ReadString(); - break; - } - } - } - } - - } - - #endregion - -} - -#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Synchronization/CheckForUpdateResponse.cs b/Software/Visual_Studio/Tango.PMR/Synchronization/CheckForUpdateResponse.cs deleted file mode 100644 index 736c653e5..000000000 --- a/Software/Visual_Studio/Tango.PMR/Synchronization/CheckForUpdateResponse.cs +++ /dev/null @@ -1,188 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: CheckForUpdateResponse.proto -#pragma warning disable 1591, 0612, 3021 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -namespace Tango.PMR.Synchronization { - - /// Holder for reflection information generated from CheckForUpdateResponse.proto - public static partial class CheckForUpdateResponseReflection { - - #region Descriptor - /// File descriptor for CheckForUpdateResponse.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static CheckForUpdateResponseReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "ChxDaGVja0ZvclVwZGF0ZVJlc3BvbnNlLnByb3RvEhlUYW5nby5QTVIuU3lu", - "Y2hyb25pemF0aW9uIkQKFkNoZWNrRm9yVXBkYXRlUmVzcG9uc2USGQoRSXNV", - "cGRhdGVBdmFpbGFibGUYASABKAgSDwoHVmVyc2lvbhgCIAEoCUIlCiNjb20u", - "dHdpbmUudGFuZ28ucG1yLnN5bmNocm9uaXphdGlvbmIGcHJvdG8z")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Synchronization.CheckForUpdateResponse), global::Tango.PMR.Synchronization.CheckForUpdateResponse.Parser, new[]{ "IsUpdateAvailable", "Version" }, null, null, null) - })); - } - #endregion - - } - #region Messages - public sealed partial class CheckForUpdateResponse : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CheckForUpdateResponse()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Tango.PMR.Synchronization.CheckForUpdateResponseReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public CheckForUpdateResponse() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public CheckForUpdateResponse(CheckForUpdateResponse other) : this() { - isUpdateAvailable_ = other.isUpdateAvailable_; - version_ = other.version_; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public CheckForUpdateResponse Clone() { - return new CheckForUpdateResponse(this); - } - - /// Field number for the "IsUpdateAvailable" field. - public const int IsUpdateAvailableFieldNumber = 1; - private bool isUpdateAvailable_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool IsUpdateAvailable { - get { return isUpdateAvailable_; } - set { - isUpdateAvailable_ = value; - } - } - - /// Field number for the "Version" field. - public const int VersionFieldNumber = 2; - private string version_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string Version { - get { return version_; } - set { - version_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as CheckForUpdateResponse); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(CheckForUpdateResponse other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (IsUpdateAvailable != other.IsUpdateAvailable) return false; - if (Version != other.Version) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (IsUpdateAvailable != false) hash ^= IsUpdateAvailable.GetHashCode(); - if (Version.Length != 0) hash ^= Version.GetHashCode(); - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (IsUpdateAvailable != false) { - output.WriteRawTag(8); - output.WriteBool(IsUpdateAvailable); - } - if (Version.Length != 0) { - output.WriteRawTag(18); - output.WriteString(Version); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (IsUpdateAvailable != false) { - size += 1 + 1; - } - if (Version.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Version); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(CheckForUpdateResponse other) { - if (other == null) { - return; - } - if (other.IsUpdateAvailable != false) { - IsUpdateAvailable = other.IsUpdateAvailable; - } - if (other.Version.Length != 0) { - Version = other.Version; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 8: { - IsUpdateAvailable = input.ReadBool(); - break; - } - case 18: { - Version = input.ReadString(); - break; - } - } - } - } - - } - - #endregion - -} - -#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Synchronization/DownloadUpdateRequest.cs b/Software/Visual_Studio/Tango.PMR/Synchronization/DownloadUpdateRequest.cs deleted file mode 100644 index 26a0eb8ff..000000000 --- a/Software/Visual_Studio/Tango.PMR/Synchronization/DownloadUpdateRequest.cs +++ /dev/null @@ -1,160 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: DownloadUpdateRequest.proto -#pragma warning disable 1591, 0612, 3021 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -namespace Tango.PMR.Synchronization { - - /// Holder for reflection information generated from DownloadUpdateRequest.proto - public static partial class DownloadUpdateRequestReflection { - - #region Descriptor - /// File descriptor for DownloadUpdateRequest.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static DownloadUpdateRequestReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "ChtEb3dubG9hZFVwZGF0ZVJlcXVlc3QucHJvdG8SGVRhbmdvLlBNUi5TeW5j", - "aHJvbml6YXRpb24iLQoVRG93bmxvYWRVcGRhdGVSZXF1ZXN0EhQKDFNlcmlh", - "bE51bWJlchgBIAEoCUIlCiNjb20udHdpbmUudGFuZ28ucG1yLnN5bmNocm9u", - "aXphdGlvbmIGcHJvdG8z")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Synchronization.DownloadUpdateRequest), global::Tango.PMR.Synchronization.DownloadUpdateRequest.Parser, new[]{ "SerialNumber" }, null, null, null) - })); - } - #endregion - - } - #region Messages - public sealed partial class DownloadUpdateRequest : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DownloadUpdateRequest()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Tango.PMR.Synchronization.DownloadUpdateRequestReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public DownloadUpdateRequest() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public DownloadUpdateRequest(DownloadUpdateRequest other) : this() { - serialNumber_ = other.serialNumber_; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public DownloadUpdateRequest Clone() { - return new DownloadUpdateRequest(this); - } - - /// Field number for the "SerialNumber" field. - public const int SerialNumberFieldNumber = 1; - private string serialNumber_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string SerialNumber { - get { return serialNumber_; } - set { - serialNumber_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as DownloadUpdateRequest); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(DownloadUpdateRequest other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (SerialNumber != other.SerialNumber) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (SerialNumber.Length != 0) hash ^= SerialNumber.GetHashCode(); - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (SerialNumber.Length != 0) { - output.WriteRawTag(10); - output.WriteString(SerialNumber); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (SerialNumber.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(SerialNumber); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(DownloadUpdateRequest other) { - if (other == null) { - return; - } - if (other.SerialNumber.Length != 0) { - SerialNumber = other.SerialNumber; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 10: { - SerialNumber = input.ReadString(); - break; - } - } - } - } - - } - - #endregion - -} - -#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Synchronization/DownloadUpdateResponse.cs b/Software/Visual_Studio/Tango.PMR/Synchronization/DownloadUpdateResponse.cs deleted file mode 100644 index ef91448ff..000000000 --- a/Software/Visual_Studio/Tango.PMR/Synchronization/DownloadUpdateResponse.cs +++ /dev/null @@ -1,274 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: DownloadUpdateResponse.proto -#pragma warning disable 1591, 0612, 3021 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -namespace Tango.PMR.Synchronization { - - /// Holder for reflection information generated from DownloadUpdateResponse.proto - public static partial class DownloadUpdateResponseReflection { - - #region Descriptor - /// File descriptor for DownloadUpdateResponse.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static DownloadUpdateResponseReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "ChxEb3dubG9hZFVwZGF0ZVJlc3BvbnNlLnByb3RvEhlUYW5nby5QTVIuU3lu", - "Y2hyb25pemF0aW9uInkKFkRvd25sb2FkVXBkYXRlUmVzcG9uc2USDwoHVmVy", - "c2lvbhgBIAEoCRITCgtCbG9iQWRkcmVzcxgCIAEoCRIRCglEYkFkZHJlc3MY", - "AyABKAkSEgoKRGJVc2VyTmFtZRgEIAEoCRISCgpEYlBhc3N3b3JkGAUgASgJ", - "QiUKI2NvbS50d2luZS50YW5nby5wbXIuc3luY2hyb25pemF0aW9uYgZwcm90", - "bzM=")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Synchronization.DownloadUpdateResponse), global::Tango.PMR.Synchronization.DownloadUpdateResponse.Parser, new[]{ "Version", "BlobAddress", "DbAddress", "DbUserName", "DbPassword" }, null, null, null) - })); - } - #endregion - - } - #region Messages - public sealed partial class DownloadUpdateResponse : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DownloadUpdateResponse()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Tango.PMR.Synchronization.DownloadUpdateResponseReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public DownloadUpdateResponse() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public DownloadUpdateResponse(DownloadUpdateResponse other) : this() { - version_ = other.version_; - blobAddress_ = other.blobAddress_; - dbAddress_ = other.dbAddress_; - dbUserName_ = other.dbUserName_; - dbPassword_ = other.dbPassword_; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public DownloadUpdateResponse Clone() { - return new DownloadUpdateResponse(this); - } - - /// Field number for the "Version" field. - public const int VersionFieldNumber = 1; - private string version_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string Version { - get { return version_; } - set { - version_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "BlobAddress" field. - public const int BlobAddressFieldNumber = 2; - private string blobAddress_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string BlobAddress { - get { return blobAddress_; } - set { - blobAddress_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "DbAddress" field. - public const int DbAddressFieldNumber = 3; - private string dbAddress_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string DbAddress { - get { return dbAddress_; } - set { - dbAddress_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "DbUserName" field. - public const int DbUserNameFieldNumber = 4; - private string dbUserName_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string DbUserName { - get { return dbUserName_; } - set { - dbUserName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "DbPassword" field. - public const int DbPasswordFieldNumber = 5; - private string dbPassword_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string DbPassword { - get { return dbPassword_; } - set { - dbPassword_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as DownloadUpdateResponse); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(DownloadUpdateResponse other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Version != other.Version) return false; - if (BlobAddress != other.BlobAddress) return false; - if (DbAddress != other.DbAddress) return false; - if (DbUserName != other.DbUserName) return false; - if (DbPassword != other.DbPassword) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (Version.Length != 0) hash ^= Version.GetHashCode(); - if (BlobAddress.Length != 0) hash ^= BlobAddress.GetHashCode(); - if (DbAddress.Length != 0) hash ^= DbAddress.GetHashCode(); - if (DbUserName.Length != 0) hash ^= DbUserName.GetHashCode(); - if (DbPassword.Length != 0) hash ^= DbPassword.GetHashCode(); - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (Version.Length != 0) { - output.WriteRawTag(10); - output.WriteString(Version); - } - if (BlobAddress.Length != 0) { - output.WriteRawTag(18); - output.WriteString(BlobAddress); - } - if (DbAddress.Length != 0) { - output.WriteRawTag(26); - output.WriteString(DbAddress); - } - if (DbUserName.Length != 0) { - output.WriteRawTag(34); - output.WriteString(DbUserName); - } - if (DbPassword.Length != 0) { - output.WriteRawTag(42); - output.WriteString(DbPassword); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (Version.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Version); - } - if (BlobAddress.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(BlobAddress); - } - if (DbAddress.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(DbAddress); - } - if (DbUserName.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(DbUserName); - } - if (DbPassword.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(DbPassword); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(DownloadUpdateResponse other) { - if (other == null) { - return; - } - if (other.Version.Length != 0) { - Version = other.Version; - } - if (other.BlobAddress.Length != 0) { - BlobAddress = other.BlobAddress; - } - if (other.DbAddress.Length != 0) { - DbAddress = other.DbAddress; - } - if (other.DbUserName.Length != 0) { - DbUserName = other.DbUserName; - } - if (other.DbPassword.Length != 0) { - DbPassword = other.DbPassword; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 10: { - Version = input.ReadString(); - break; - } - case 18: { - BlobAddress = input.ReadString(); - break; - } - case 26: { - DbAddress = input.ReadString(); - break; - } - case 34: { - DbUserName = input.ReadString(); - break; - } - case 42: { - DbPassword = input.ReadString(); - break; - } - } - } - } - - } - - #endregion - -} - -#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Synchronization/MachineSetupRequest.cs b/Software/Visual_Studio/Tango.PMR/Synchronization/MachineSetupRequest.cs deleted file mode 100644 index d332f5bf8..000000000 --- a/Software/Visual_Studio/Tango.PMR/Synchronization/MachineSetupRequest.cs +++ /dev/null @@ -1,160 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: MachineSetupRequest.proto -#pragma warning disable 1591, 0612, 3021 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -namespace Tango.PMR.Synchronization { - - /// Holder for reflection information generated from MachineSetupRequest.proto - public static partial class MachineSetupRequestReflection { - - #region Descriptor - /// File descriptor for MachineSetupRequest.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static MachineSetupRequestReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "ChlNYWNoaW5lU2V0dXBSZXF1ZXN0LnByb3RvEhlUYW5nby5QTVIuU3luY2hy", - "b25pemF0aW9uIisKE01hY2hpbmVTZXR1cFJlcXVlc3QSFAoMU2VyaWFsTnVt", - "YmVyGAEgASgJQiUKI2NvbS50d2luZS50YW5nby5wbXIuc3luY2hyb25pemF0", - "aW9uYgZwcm90bzM=")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Synchronization.MachineSetupRequest), global::Tango.PMR.Synchronization.MachineSetupRequest.Parser, new[]{ "SerialNumber" }, null, null, null) - })); - } - #endregion - - } - #region Messages - public sealed partial class MachineSetupRequest : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MachineSetupRequest()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Tango.PMR.Synchronization.MachineSetupRequestReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public MachineSetupRequest() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public MachineSetupRequest(MachineSetupRequest other) : this() { - serialNumber_ = other.serialNumber_; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public MachineSetupRequest Clone() { - return new MachineSetupRequest(this); - } - - /// Field number for the "SerialNumber" field. - public const int SerialNumberFieldNumber = 1; - private string serialNumber_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string SerialNumber { - get { return serialNumber_; } - set { - serialNumber_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as MachineSetupRequest); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(MachineSetupRequest other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (SerialNumber != other.SerialNumber) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (SerialNumber.Length != 0) hash ^= SerialNumber.GetHashCode(); - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (SerialNumber.Length != 0) { - output.WriteRawTag(10); - output.WriteString(SerialNumber); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (SerialNumber.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(SerialNumber); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(MachineSetupRequest other) { - if (other == null) { - return; - } - if (other.SerialNumber.Length != 0) { - SerialNumber = other.SerialNumber; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 10: { - SerialNumber = input.ReadString(); - break; - } - } - } - } - - } - - #endregion - -} - -#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Synchronization/MachineSetupResponse.cs b/Software/Visual_Studio/Tango.PMR/Synchronization/MachineSetupResponse.cs deleted file mode 100644 index e2650cf2b..000000000 --- a/Software/Visual_Studio/Tango.PMR/Synchronization/MachineSetupResponse.cs +++ /dev/null @@ -1,444 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: MachineSetupResponse.proto -#pragma warning disable 1591, 0612, 3021 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -namespace Tango.PMR.Synchronization { - - /// Holder for reflection information generated from MachineSetupResponse.proto - public static partial class MachineSetupResponseReflection { - - #region Descriptor - /// File descriptor for MachineSetupResponse.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static MachineSetupResponseReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "ChpNYWNoaW5lU2V0dXBSZXNwb25zZS5wcm90bxIZVGFuZ28uUE1SLlN5bmNo", - "cm9uaXphdGlvbiL3AQoUTWFjaGluZVNldHVwUmVzcG9uc2USDwoHVmVyc2lv", - "bhgBIAEoCRITCgtCbG9iQWRkcmVzcxgCIAEoCRIRCglEYkFkZHJlc3MYAyAB", - "KAkSEgoKRGJVc2VyTmFtZRgEIAEoCRISCgpEYlBhc3N3b3JkGAUgASgJEg0K", - "BU9TS2V5GAYgASgJEhcKD1NldHVwQWN0aXZhdGlvbhgHIAEoCBIdChVTZXR1", - "cFJlbW90ZUFzc2lzdGFuY2UYCCABKAgSEAoIU2V0dXBVV0YYCSABKAgSFQoN", - "U2V0dXBGaXJtd2FyZRgKIAEoCBIOCgZJc0RlbW8YCyABKAhCJQojY29tLnR3", - "aW5lLnRhbmdvLnBtci5zeW5jaHJvbml6YXRpb25iBnByb3RvMw==")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Synchronization.MachineSetupResponse), global::Tango.PMR.Synchronization.MachineSetupResponse.Parser, new[]{ "Version", "BlobAddress", "DbAddress", "DbUserName", "DbPassword", "OSKey", "SetupActivation", "SetupRemoteAssistance", "SetupUWF", "SetupFirmware", "IsDemo" }, null, null, null) - })); - } - #endregion - - } - #region Messages - public sealed partial class MachineSetupResponse : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MachineSetupResponse()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Tango.PMR.Synchronization.MachineSetupResponseReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public MachineSetupResponse() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public MachineSetupResponse(MachineSetupResponse other) : this() { - version_ = other.version_; - blobAddress_ = other.blobAddress_; - dbAddress_ = other.dbAddress_; - dbUserName_ = other.dbUserName_; - dbPassword_ = other.dbPassword_; - oSKey_ = other.oSKey_; - setupActivation_ = other.setupActivation_; - setupRemoteAssistance_ = other.setupRemoteAssistance_; - setupUWF_ = other.setupUWF_; - setupFirmware_ = other.setupFirmware_; - isDemo_ = other.isDemo_; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public MachineSetupResponse Clone() { - return new MachineSetupResponse(this); - } - - /// Field number for the "Version" field. - public const int VersionFieldNumber = 1; - private string version_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string Version { - get { return version_; } - set { - version_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "BlobAddress" field. - public const int BlobAddressFieldNumber = 2; - private string blobAddress_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string BlobAddress { - get { return blobAddress_; } - set { - blobAddress_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "DbAddress" field. - public const int DbAddressFieldNumber = 3; - private string dbAddress_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string DbAddress { - get { return dbAddress_; } - set { - dbAddress_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "DbUserName" field. - public const int DbUserNameFieldNumber = 4; - private string dbUserName_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string DbUserName { - get { return dbUserName_; } - set { - dbUserName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "DbPassword" field. - public const int DbPasswordFieldNumber = 5; - private string dbPassword_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string DbPassword { - get { return dbPassword_; } - set { - dbPassword_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "OSKey" field. - public const int OSKeyFieldNumber = 6; - private string oSKey_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string OSKey { - get { return oSKey_; } - set { - oSKey_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "SetupActivation" field. - public const int SetupActivationFieldNumber = 7; - private bool setupActivation_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool SetupActivation { - get { return setupActivation_; } - set { - setupActivation_ = value; - } - } - - /// Field number for the "SetupRemoteAssistance" field. - public const int SetupRemoteAssistanceFieldNumber = 8; - private bool setupRemoteAssistance_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool SetupRemoteAssistance { - get { return setupRemoteAssistance_; } - set { - setupRemoteAssistance_ = value; - } - } - - /// Field number for the "SetupUWF" field. - public const int SetupUWFFieldNumber = 9; - private bool setupUWF_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool SetupUWF { - get { return setupUWF_; } - set { - setupUWF_ = value; - } - } - - /// Field number for the "SetupFirmware" field. - public const int SetupFirmwareFieldNumber = 10; - private bool setupFirmware_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool SetupFirmware { - get { return setupFirmware_; } - set { - setupFirmware_ = value; - } - } - - /// Field number for the "IsDemo" field. - public const int IsDemoFieldNumber = 11; - private bool isDemo_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool IsDemo { - get { return isDemo_; } - set { - isDemo_ = value; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as MachineSetupResponse); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(MachineSetupResponse other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Version != other.Version) return false; - if (BlobAddress != other.BlobAddress) return false; - if (DbAddress != other.DbAddress) return false; - if (DbUserName != other.DbUserName) return false; - if (DbPassword != other.DbPassword) return false; - if (OSKey != other.OSKey) return false; - if (SetupActivation != other.SetupActivation) return false; - if (SetupRemoteAssistance != other.SetupRemoteAssistance) return false; - if (SetupUWF != other.SetupUWF) return false; - if (SetupFirmware != other.SetupFirmware) return false; - if (IsDemo != other.IsDemo) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (Version.Length != 0) hash ^= Version.GetHashCode(); - if (BlobAddress.Length != 0) hash ^= BlobAddress.GetHashCode(); - if (DbAddress.Length != 0) hash ^= DbAddress.GetHashCode(); - if (DbUserName.Length != 0) hash ^= DbUserName.GetHashCode(); - if (DbPassword.Length != 0) hash ^= DbPassword.GetHashCode(); - if (OSKey.Length != 0) hash ^= OSKey.GetHashCode(); - if (SetupActivation != false) hash ^= SetupActivation.GetHashCode(); - if (SetupRemoteAssistance != false) hash ^= SetupRemoteAssistance.GetHashCode(); - if (SetupUWF != false) hash ^= SetupUWF.GetHashCode(); - if (SetupFirmware != false) hash ^= SetupFirmware.GetHashCode(); - if (IsDemo != false) hash ^= IsDemo.GetHashCode(); - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (Version.Length != 0) { - output.WriteRawTag(10); - output.WriteString(Version); - } - if (BlobAddress.Length != 0) { - output.WriteRawTag(18); - output.WriteString(BlobAddress); - } - if (DbAddress.Length != 0) { - output.WriteRawTag(26); - output.WriteString(DbAddress); - } - if (DbUserName.Length != 0) { - output.WriteRawTag(34); - output.WriteString(DbUserName); - } - if (DbPassword.Length != 0) { - output.WriteRawTag(42); - output.WriteString(DbPassword); - } - if (OSKey.Length != 0) { - output.WriteRawTag(50); - output.WriteString(OSKey); - } - if (SetupActivation != false) { - output.WriteRawTag(56); - output.WriteBool(SetupActivation); - } - if (SetupRemoteAssistance != false) { - output.WriteRawTag(64); - output.WriteBool(SetupRemoteAssistance); - } - if (SetupUWF != false) { - output.WriteRawTag(72); - output.WriteBool(SetupUWF); - } - if (SetupFirmware != false) { - output.WriteRawTag(80); - output.WriteBool(SetupFirmware); - } - if (IsDemo != false) { - output.WriteRawTag(88); - output.WriteBool(IsDemo); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (Version.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Version); - } - if (BlobAddress.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(BlobAddress); - } - if (DbAddress.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(DbAddress); - } - if (DbUserName.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(DbUserName); - } - if (DbPassword.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(DbPassword); - } - if (OSKey.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(OSKey); - } - if (SetupActivation != false) { - size += 1 + 1; - } - if (SetupRemoteAssistance != false) { - size += 1 + 1; - } - if (SetupUWF != false) { - size += 1 + 1; - } - if (SetupFirmware != false) { - size += 1 + 1; - } - if (IsDemo != false) { - size += 1 + 1; - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(MachineSetupResponse other) { - if (other == null) { - return; - } - if (other.Version.Length != 0) { - Version = other.Version; - } - if (other.BlobAddress.Length != 0) { - BlobAddress = other.BlobAddress; - } - if (other.DbAddress.Length != 0) { - DbAddress = other.DbAddress; - } - if (other.DbUserName.Length != 0) { - DbUserName = other.DbUserName; - } - if (other.DbPassword.Length != 0) { - DbPassword = other.DbPassword; - } - if (other.OSKey.Length != 0) { - OSKey = other.OSKey; - } - if (other.SetupActivation != false) { - SetupActivation = other.SetupActivation; - } - if (other.SetupRemoteAssistance != false) { - SetupRemoteAssistance = other.SetupRemoteAssistance; - } - if (other.SetupUWF != false) { - SetupUWF = other.SetupUWF; - } - if (other.SetupFirmware != false) { - SetupFirmware = other.SetupFirmware; - } - if (other.IsDemo != false) { - IsDemo = other.IsDemo; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 10: { - Version = input.ReadString(); - break; - } - case 18: { - BlobAddress = input.ReadString(); - break; - } - case 26: { - DbAddress = input.ReadString(); - break; - } - case 34: { - DbUserName = input.ReadString(); - break; - } - case 42: { - DbPassword = input.ReadString(); - break; - } - case 50: { - OSKey = input.ReadString(); - break; - } - case 56: { - SetupActivation = input.ReadBool(); - break; - } - case 64: { - SetupRemoteAssistance = input.ReadBool(); - break; - } - case 72: { - SetupUWF = input.ReadBool(); - break; - } - case 80: { - SetupFirmware = input.ReadBool(); - break; - } - case 88: { - IsDemo = input.ReadBool(); - break; - } - } - } - } - - } - - #endregion - -} - -#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Synchronization/SynchronizeDBRequest.cs b/Software/Visual_Studio/Tango.PMR/Synchronization/SynchronizeDBRequest.cs deleted file mode 100644 index 54efa1062..000000000 --- a/Software/Visual_Studio/Tango.PMR/Synchronization/SynchronizeDBRequest.cs +++ /dev/null @@ -1,188 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: SynchronizeDBRequest.proto -#pragma warning disable 1591, 0612, 3021 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -namespace Tango.PMR.Synchronization { - - /// Holder for reflection information generated from SynchronizeDBRequest.proto - public static partial class SynchronizeDBRequestReflection { - - #region Descriptor - /// File descriptor for SynchronizeDBRequest.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static SynchronizeDBRequestReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "ChpTeW5jaHJvbml6ZURCUmVxdWVzdC5wcm90bxIZVGFuZ28uUE1SLlN5bmNo", - "cm9uaXphdGlvbiI9ChRTeW5jaHJvbml6ZURCUmVxdWVzdBIUCgxTZXJpYWxO", - "dW1iZXIYASABKAkSDwoHTG9jYWxEQhgCIAEoDEIlCiNjb20udHdpbmUudGFu", - "Z28ucG1yLnN5bmNocm9uaXphdGlvbmIGcHJvdG8z")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Synchronization.SynchronizeDBRequest), global::Tango.PMR.Synchronization.SynchronizeDBRequest.Parser, new[]{ "SerialNumber", "LocalDB" }, null, null, null) - })); - } - #endregion - - } - #region Messages - public sealed partial class SynchronizeDBRequest : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SynchronizeDBRequest()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Tango.PMR.Synchronization.SynchronizeDBRequestReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public SynchronizeDBRequest() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public SynchronizeDBRequest(SynchronizeDBRequest other) : this() { - serialNumber_ = other.serialNumber_; - localDB_ = other.localDB_; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public SynchronizeDBRequest Clone() { - return new SynchronizeDBRequest(this); - } - - /// Field number for the "SerialNumber" field. - public const int SerialNumberFieldNumber = 1; - private string serialNumber_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string SerialNumber { - get { return serialNumber_; } - set { - serialNumber_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "LocalDB" field. - public const int LocalDBFieldNumber = 2; - private pb::ByteString localDB_ = pb::ByteString.Empty; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pb::ByteString LocalDB { - get { return localDB_; } - set { - localDB_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as SynchronizeDBRequest); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(SynchronizeDBRequest other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (SerialNumber != other.SerialNumber) return false; - if (LocalDB != other.LocalDB) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (SerialNumber.Length != 0) hash ^= SerialNumber.GetHashCode(); - if (LocalDB.Length != 0) hash ^= LocalDB.GetHashCode(); - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (SerialNumber.Length != 0) { - output.WriteRawTag(10); - output.WriteString(SerialNumber); - } - if (LocalDB.Length != 0) { - output.WriteRawTag(18); - output.WriteBytes(LocalDB); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (SerialNumber.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(SerialNumber); - } - if (LocalDB.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeBytesSize(LocalDB); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(SynchronizeDBRequest other) { - if (other == null) { - return; - } - if (other.SerialNumber.Length != 0) { - SerialNumber = other.SerialNumber; - } - if (other.LocalDB.Length != 0) { - LocalDB = other.LocalDB; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 10: { - SerialNumber = input.ReadString(); - break; - } - case 18: { - LocalDB = input.ReadBytes(); - break; - } - } - } - } - - } - - #endregion - -} - -#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Synchronization/SynchronizeDBResponse.cs b/Software/Visual_Studio/Tango.PMR/Synchronization/SynchronizeDBResponse.cs deleted file mode 100644 index e25a903b9..000000000 --- a/Software/Visual_Studio/Tango.PMR/Synchronization/SynchronizeDBResponse.cs +++ /dev/null @@ -1,160 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: SynchronizeDBResponse.proto -#pragma warning disable 1591, 0612, 3021 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -namespace Tango.PMR.Synchronization { - - /// Holder for reflection information generated from SynchronizeDBResponse.proto - public static partial class SynchronizeDBResponseReflection { - - #region Descriptor - /// File descriptor for SynchronizeDBResponse.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static SynchronizeDBResponseReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "ChtTeW5jaHJvbml6ZURCUmVzcG9uc2UucHJvdG8SGVRhbmdvLlBNUi5TeW5j", - "aHJvbml6YXRpb24iKQoVU3luY2hyb25pemVEQlJlc3BvbnNlEhAKCFJlbW90", - "ZURCGAEgASgMQiUKI2NvbS50d2luZS50YW5nby5wbXIuc3luY2hyb25pemF0", - "aW9uYgZwcm90bzM=")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Synchronization.SynchronizeDBResponse), global::Tango.PMR.Synchronization.SynchronizeDBResponse.Parser, new[]{ "RemoteDB" }, null, null, null) - })); - } - #endregion - - } - #region Messages - public sealed partial class SynchronizeDBResponse : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SynchronizeDBResponse()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Tango.PMR.Synchronization.SynchronizeDBResponseReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public SynchronizeDBResponse() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public SynchronizeDBResponse(SynchronizeDBResponse other) : this() { - remoteDB_ = other.remoteDB_; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public SynchronizeDBResponse Clone() { - return new SynchronizeDBResponse(this); - } - - /// Field number for the "RemoteDB" field. - public const int RemoteDBFieldNumber = 1; - private pb::ByteString remoteDB_ = pb::ByteString.Empty; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pb::ByteString RemoteDB { - get { return remoteDB_; } - set { - remoteDB_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as SynchronizeDBResponse); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(SynchronizeDBResponse other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (RemoteDB != other.RemoteDB) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (RemoteDB.Length != 0) hash ^= RemoteDB.GetHashCode(); - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (RemoteDB.Length != 0) { - output.WriteRawTag(10); - output.WriteBytes(RemoteDB); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (RemoteDB.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeBytesSize(RemoteDB); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(SynchronizeDBResponse other) { - if (other == null) { - return; - } - if (other.RemoteDB.Length != 0) { - RemoteDB = other.RemoteDB; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 10: { - RemoteDB = input.ReadBytes(); - break; - } - } - } - } - - } - - #endregion - -} - -#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Synchronization/UpdateDBRequest.cs b/Software/Visual_Studio/Tango.PMR/Synchronization/UpdateDBRequest.cs deleted file mode 100644 index b55b41571..000000000 --- a/Software/Visual_Studio/Tango.PMR/Synchronization/UpdateDBRequest.cs +++ /dev/null @@ -1,160 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: UpdateDBRequest.proto -#pragma warning disable 1591, 0612, 3021 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -namespace Tango.PMR.Synchronization { - - /// Holder for reflection information generated from UpdateDBRequest.proto - public static partial class UpdateDBRequestReflection { - - #region Descriptor - /// File descriptor for UpdateDBRequest.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static UpdateDBRequestReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "ChVVcGRhdGVEQlJlcXVlc3QucHJvdG8SGVRhbmdvLlBNUi5TeW5jaHJvbml6", - "YXRpb24iJwoPVXBkYXRlREJSZXF1ZXN0EhQKDFNlcmlhbE51bWJlchgBIAEo", - "CUIlCiNjb20udHdpbmUudGFuZ28ucG1yLnN5bmNocm9uaXphdGlvbmIGcHJv", - "dG8z")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Synchronization.UpdateDBRequest), global::Tango.PMR.Synchronization.UpdateDBRequest.Parser, new[]{ "SerialNumber" }, null, null, null) - })); - } - #endregion - - } - #region Messages - public sealed partial class UpdateDBRequest : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new UpdateDBRequest()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Tango.PMR.Synchronization.UpdateDBRequestReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public UpdateDBRequest() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public UpdateDBRequest(UpdateDBRequest other) : this() { - serialNumber_ = other.serialNumber_; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public UpdateDBRequest Clone() { - return new UpdateDBRequest(this); - } - - /// Field number for the "SerialNumber" field. - public const int SerialNumberFieldNumber = 1; - private string serialNumber_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string SerialNumber { - get { return serialNumber_; } - set { - serialNumber_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as UpdateDBRequest); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(UpdateDBRequest other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (SerialNumber != other.SerialNumber) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (SerialNumber.Length != 0) hash ^= SerialNumber.GetHashCode(); - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (SerialNumber.Length != 0) { - output.WriteRawTag(10); - output.WriteString(SerialNumber); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (SerialNumber.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(SerialNumber); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(UpdateDBRequest other) { - if (other == null) { - return; - } - if (other.SerialNumber.Length != 0) { - SerialNumber = other.SerialNumber; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 10: { - SerialNumber = input.ReadString(); - break; - } - } - } - } - - } - - #endregion - -} - -#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Synchronization/UpdateDBResponse.cs b/Software/Visual_Studio/Tango.PMR/Synchronization/UpdateDBResponse.cs deleted file mode 100644 index 9ab596bc2..000000000 --- a/Software/Visual_Studio/Tango.PMR/Synchronization/UpdateDBResponse.cs +++ /dev/null @@ -1,216 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: UpdateDBResponse.proto -#pragma warning disable 1591, 0612, 3021 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -namespace Tango.PMR.Synchronization { - - /// Holder for reflection information generated from UpdateDBResponse.proto - public static partial class UpdateDBResponseReflection { - - #region Descriptor - /// File descriptor for UpdateDBResponse.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static UpdateDBResponseReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "ChZVcGRhdGVEQlJlc3BvbnNlLnByb3RvEhlUYW5nby5QTVIuU3luY2hyb25p", - "emF0aW9uIk0KEFVwZGF0ZURCUmVzcG9uc2USEQoJRGJBZGRyZXNzGAEgASgJ", - "EhIKCkRiVXNlck5hbWUYAiABKAkSEgoKRGJQYXNzd29yZBgDIAEoCUIlCiNj", - "b20udHdpbmUudGFuZ28ucG1yLnN5bmNocm9uaXphdGlvbmIGcHJvdG8z")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Synchronization.UpdateDBResponse), global::Tango.PMR.Synchronization.UpdateDBResponse.Parser, new[]{ "DbAddress", "DbUserName", "DbPassword" }, null, null, null) - })); - } - #endregion - - } - #region Messages - public sealed partial class UpdateDBResponse : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new UpdateDBResponse()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Tango.PMR.Synchronization.UpdateDBResponseReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public UpdateDBResponse() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public UpdateDBResponse(UpdateDBResponse other) : this() { - dbAddress_ = other.dbAddress_; - dbUserName_ = other.dbUserName_; - dbPassword_ = other.dbPassword_; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public UpdateDBResponse Clone() { - return new UpdateDBResponse(this); - } - - /// Field number for the "DbAddress" field. - public const int DbAddressFieldNumber = 1; - private string dbAddress_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string DbAddress { - get { return dbAddress_; } - set { - dbAddress_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "DbUserName" field. - public const int DbUserNameFieldNumber = 2; - private string dbUserName_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string DbUserName { - get { return dbUserName_; } - set { - dbUserName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "DbPassword" field. - public const int DbPasswordFieldNumber = 3; - private string dbPassword_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string DbPassword { - get { return dbPassword_; } - set { - dbPassword_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as UpdateDBResponse); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(UpdateDBResponse other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (DbAddress != other.DbAddress) return false; - if (DbUserName != other.DbUserName) return false; - if (DbPassword != other.DbPassword) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (DbAddress.Length != 0) hash ^= DbAddress.GetHashCode(); - if (DbUserName.Length != 0) hash ^= DbUserName.GetHashCode(); - if (DbPassword.Length != 0) hash ^= DbPassword.GetHashCode(); - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (DbAddress.Length != 0) { - output.WriteRawTag(10); - output.WriteString(DbAddress); - } - if (DbUserName.Length != 0) { - output.WriteRawTag(18); - output.WriteString(DbUserName); - } - if (DbPassword.Length != 0) { - output.WriteRawTag(26); - output.WriteString(DbPassword); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (DbAddress.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(DbAddress); - } - if (DbUserName.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(DbUserName); - } - if (DbPassword.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(DbPassword); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(UpdateDBResponse other) { - if (other == null) { - return; - } - if (other.DbAddress.Length != 0) { - DbAddress = other.DbAddress; - } - if (other.DbUserName.Length != 0) { - DbUserName = other.DbUserName; - } - if (other.DbPassword.Length != 0) { - DbPassword = other.DbPassword; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 10: { - DbAddress = input.ReadString(); - break; - } - case 18: { - DbUserName = input.ReadString(); - break; - } - case 26: { - DbPassword = input.ReadString(); - break; - } - } - } - } - - } - - #endregion - -} - -#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj index 790d0e3e5..1d8d5e16c 100644 --- a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj +++ b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj @@ -228,21 +228,11 @@ - - - - - - - - - - @@ -260,7 +250,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj b/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj index 02457471d..02e5381ee 100644 --- a/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj +++ b/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj @@ -107,9 +107,14 @@ - - - + + + + + + + + @@ -136,7 +141,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs index 05a892b37..581e62cc7 100644 --- a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs +++ b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs @@ -880,6 +880,7 @@ namespace Tango.Transport continue; } + LogManager.Log("Sending message on adapter: " + Adapter.Address + "...", LogCategory.Debug, message.Message); Adapter.Write(message.Serialize()); LogManager.Log("Message sent on adapter: " + Adapter.Address + "...", LogCategory.Debug, message.Message); } diff --git a/Software/Visual_Studio/Tango.Transport/Web/ITransportWebClient.cs b/Software/Visual_Studio/Tango.Transport/Web/ITransportWebClient.cs deleted file mode 100644 index 81d443671..000000000 --- a/Software/Visual_Studio/Tango.Transport/Web/ITransportWebClient.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.Transport.Web -{ - public interface ITransportWebClient : IDisposable - { - Task Post(String url, Request request) where Request : class, IMessage where Response : class, IMessage; - } -} diff --git a/Software/Visual_Studio/Tango.Transport/Web/IWebRequestMessage.cs b/Software/Visual_Studio/Tango.Transport/Web/IWebRequestMessage.cs new file mode 100644 index 000000000..7a8f293f4 --- /dev/null +++ b/Software/Visual_Studio/Tango.Transport/Web/IWebRequestMessage.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Transport.Web +{ + public interface IWebRequestMessage : IWebTransportMessage + { + } +} diff --git a/Software/Visual_Studio/Tango.Transport/Web/IWebResponseMessage.cs b/Software/Visual_Studio/Tango.Transport/Web/IWebResponseMessage.cs new file mode 100644 index 000000000..eba39959f --- /dev/null +++ b/Software/Visual_Studio/Tango.Transport/Web/IWebResponseMessage.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Transport.Web +{ + public interface IWebResponseMessage : IWebTransportMessage + { + } +} diff --git a/Software/Visual_Studio/Tango.Transport/Web/IWebTransportClient.cs b/Software/Visual_Studio/Tango.Transport/Web/IWebTransportClient.cs new file mode 100644 index 000000000..8ab0f9305 --- /dev/null +++ b/Software/Visual_Studio/Tango.Transport/Web/IWebTransportClient.cs @@ -0,0 +1,15 @@ +using Google.Protobuf; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Transport.Web +{ + public interface IWebTransportClient : IDisposable + { + Task PostProto(String url, Request request) where Request : class, IMessage where Response : class, IMessage; + Task PostJson(String url, Request request) where Request : class, IWebRequestMessage where Response : class, IWebResponseMessage; + } +} diff --git a/Software/Visual_Studio/Tango.Transport/Web/IWebTransportMessage.cs b/Software/Visual_Studio/Tango.Transport/Web/IWebTransportMessage.cs new file mode 100644 index 000000000..48d9960d9 --- /dev/null +++ b/Software/Visual_Studio/Tango.Transport/Web/IWebTransportMessage.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Transport.Web +{ + public interface IWebTransportMessage + { + } +} diff --git a/Software/Visual_Studio/Tango.Transport/Web/JsonWebClient.cs b/Software/Visual_Studio/Tango.Transport/Web/JsonWebClient.cs deleted file mode 100644 index 8b654dd61..000000000 --- a/Software/Visual_Studio/Tango.Transport/Web/JsonWebClient.cs +++ /dev/null @@ -1,69 +0,0 @@ -using Google.Protobuf; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Http; -using System.Text; -using System.Threading.Tasks; -using System.Web; -using Tango.PMR.Synchronization; - -namespace Tango.Transport.Web -{ - public class JsonWebClient : ITransportWebClient - { - private HttpClient _httpClient; - - public JsonWebClient() - { - _httpClient = new HttpClient(); - } - - public void Dispose() - { - throw new NotImplementedException(); - } - - public Task Post(String url, Request request) where Request : class, IMessage where Response : class, IMessage - { - return Task.Factory.StartNew(() => - { - var req = new ByteArrayContent(Encoding.UTF8.GetBytes(request.ToString())); - req.Headers.Add("Content-Type", "application/json"); - - var response = _httpClient.PostAsync(url, req).Result; - - var data = response.Content.ReadAsStringAsync().Result; - - Response dummy = Activator.CreateInstance() as Response; - - return dummy.GetParser().ParseJson(data) as Response; - }); - } - - public Task PostJson(String url, Request request) where Request : class where Response : class - { - return Task.Factory.StartNew(() => - { - var req = new ByteArrayContent(Encoding.UTF8.GetBytes(request.ToJsonString())); - req.Headers.Add("Content-Type", "application/json"); - - var response = _httpClient.PostAsync(url, req).Result; - var data = response.Content.ReadAsStringAsync().Result; - - try - { - response.EnsureSuccessStatusCode(); - } - catch (HttpRequestException ex) - { - throw new HttpRequestException(ex.Message + " " + JObject.Parse(data).GetValue("Message")); - } - - return JsonConvert.DeserializeObject(data); - }); - } - } -} diff --git a/Software/Visual_Studio/Tango.Transport/Web/ProtoWebClient.cs b/Software/Visual_Studio/Tango.Transport/Web/ProtoWebClient.cs deleted file mode 100644 index 7f8beef04..000000000 --- a/Software/Visual_Studio/Tango.Transport/Web/ProtoWebClient.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Http; -using System.Text; -using System.Threading.Tasks; -using System.Web; -using Tango.PMR.Synchronization; - -namespace Tango.Transport.Web -{ - public class ProtoWebClient : ITransportWebClient - { - private HttpClient _httpClient; - - public ProtoWebClient() - { - _httpClient = new HttpClient(); - } - - public Task Post(String url, Request request) where Request : class, IMessage where Response : class, IMessage - { - return Task.Factory.StartNew(() => - { - - var req = new ByteArrayContent(request.ToByteArray()); - req.Headers.Add("Content-Type", "application/x-protobuf"); - - var response = _httpClient.PostAsync(url, req).Result; - - var data = response.Content.ReadAsByteArrayAsync().Result; - - if (response.StatusCode != System.Net.HttpStatusCode.OK) - { - HttpProtoException exception = HttpProtoException.Parser.ParseFrom(data); - throw new HttpException(exception.StatusCode, exception.Message); - } - - Response dummy = Activator.CreateInstance() as Response; - - return dummy.GetParser().ParseFrom(data) as Response; - }); - } - - public void Dispose() - { - _httpClient.Dispose(); - } - } -} diff --git a/Software/Visual_Studio/Tango.Transport/Web/WebRequestMessage.cs b/Software/Visual_Studio/Tango.Transport/Web/WebRequestMessage.cs new file mode 100644 index 000000000..a7bdd87ad --- /dev/null +++ b/Software/Visual_Studio/Tango.Transport/Web/WebRequestMessage.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Transport.Web +{ + public abstract class WebRequestMessage : WebTransportMessage, IWebRequestMessage + { + } +} diff --git a/Software/Visual_Studio/Tango.Transport/Web/WebResponseMessage.cs b/Software/Visual_Studio/Tango.Transport/Web/WebResponseMessage.cs new file mode 100644 index 000000000..adaf3b0eb --- /dev/null +++ b/Software/Visual_Studio/Tango.Transport/Web/WebResponseMessage.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Transport.Web +{ + public abstract class WebResponseMessage : WebTransportMessage, IWebResponseMessage + { + } +} diff --git a/Software/Visual_Studio/Tango.Transport/Web/WebTransportClient.cs b/Software/Visual_Studio/Tango.Transport/Web/WebTransportClient.cs new file mode 100644 index 000000000..227ecefa3 --- /dev/null +++ b/Software/Visual_Studio/Tango.Transport/Web/WebTransportClient.cs @@ -0,0 +1,84 @@ +using Google.Protobuf; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; +using System.Web; +using Tango.PMR.Synchronization; + +namespace Tango.Transport.Web +{ + public class WebTransportClient : IWebTransportClient + { + private HttpClient _httpClient; + private static JsonSerializerSettings _settings; + + static WebTransportClient() + { + _settings = new JsonSerializerSettings() + { + + }; + } + + public WebTransportClient() + { + _httpClient = new HttpClient(); + } + + public Task PostProto(String url, Request request) where Request : class, IMessage where Response : class, IMessage + { + return Task.Factory.StartNew(() => + { + + var req = new ByteArrayContent(request.ToByteArray()); + req.Headers.Add("Content-Type", "application/x-protobuf"); + + var response = _httpClient.PostAsync(url, req).Result; + + var data = response.Content.ReadAsByteArrayAsync().Result; + + if (response.StatusCode != System.Net.HttpStatusCode.OK) + { + HttpProtoException exception = HttpProtoException.Parser.ParseFrom(data); + throw new HttpException(exception.StatusCode, exception.Message); + } + + Response dummy = Activator.CreateInstance() as Response; + + return dummy.GetParser().ParseFrom(data) as Response; + }); + } + + public Task PostJson(string url, Request request) where Request : class, IWebRequestMessage where Response : class, IWebResponseMessage + { + return Task.Factory.StartNew(() => + { + var req = new ByteArrayContent(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(request, _settings))); + req.Headers.Add("Content-Type", "application/json"); + var response = _httpClient.PostAsync(url, req).Result; + var data = response.Content.ReadAsStringAsync().Result; + + try + { + response.EnsureSuccessStatusCode(); + } + catch (HttpRequestException ex) + { + throw new HttpRequestException(ex.Message + " " + JObject.Parse(data).GetValue("Message")); + } + + return JsonConvert.DeserializeObject(data); + }); + } + + public void Dispose() + { + _httpClient.Dispose(); + } + } +} diff --git a/Software/Visual_Studio/Tango.Transport/Web/WebTransportMessage.cs b/Software/Visual_Studio/Tango.Transport/Web/WebTransportMessage.cs new file mode 100644 index 000000000..3f886d9d2 --- /dev/null +++ b/Software/Visual_Studio/Tango.Transport/Web/WebTransportMessage.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Transport.Web +{ + public abstract class WebTransportMessage : IWebTransportMessage + { + } +} diff --git a/Software/Visual_Studio/Tango.UnitTesting/MachineService_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/MachineService_TST.cs index 954d53da8..94d30df98 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/MachineService_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/MachineService_TST.cs @@ -16,7 +16,7 @@ namespace Tango.UnitTesting [TestMethod] public void Check_For_Updates() { - ITransportWebClient client = new ProtoWebClient(); + IWebTransportClient client = new WebTransportClient(); var result = client.Post("http://localhost:51581/api/PPC/CheckForUpdate", new CheckForUpdateRequest() { SerialNumber = "0000", diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/HomeController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/HomeController.cs deleted file mode 100644 index a7c526f67..000000000 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/HomeController.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Mvc; - -namespace Tango.MachineService.Controllers -{ - public class HomeController : Controller - { - public String Index() - { - return "Machine Service Started!"; - } - } -} diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs index c5e85f819..45396e47a 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs @@ -17,6 +17,7 @@ using System.Web.Http; using Tango.BL; using Tango.BL.Builders; using Tango.BL.Entities; +using Tango.BL.Enumerations; using Tango.Core.DB; using Tango.Core.Helpers; using Tango.Core.IO; @@ -26,13 +27,29 @@ using Tango.MachineService.Models; using Tango.MachineService.SMO; using Tango.PMR.Stubs; using Tango.PMR.Synchronization; +using Tango.PPC.Common.MachineSetup; +using Tango.PPC.Common.MachineUpdate; +using Tango.PPC.Common.Update; using Tango.Synchronization.Local; using Tango.Synchronization.Remote; namespace Tango.MachineService.Controllers { - public class PPCController : ProtoController + public class PPCController : JsonController { + private static List _pendingUploads; + + #region Constructors + + static PPCController() + { + _pendingUploads = new List(); + } + + #endregion + + #region Setup & Update + [HttpPost] public MachineSetupResponse MachineSetup(MachineSetupRequest request) { @@ -222,6 +239,139 @@ namespace Tango.MachineService.Controllers return response; } + #endregion + + #region Version Upload + + [HttpPost] + public LatestVersionResponse GetLatestVersion(LatestVersionRequest request) + { + LatestVersionResponse response = new LatestVersionResponse(); + + using (ObservablesContext db = ObservablesContextHelper.CreateContext()) + { + var versions = db.TangoVersions.ToList(); + + if (versions.Count == 0) + { + return new LatestVersionResponse() + { + Version = "0.0.0.0", + }; + } + + var machine_versions = versions.Where(x => x.MachineVersionGuid == request.MachineVersionGuid).ToList(); + + if (machine_versions.Count > 0) + { + response.Version = db.TangoVersions.Where(x => x.MachineVersionGuid == request.MachineVersionGuid).ToList().OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault().Version; + } + else + { + throw new ArgumentException("The specified machine version was not found!"); + } + } + + return response; + } + + [HttpPost] + public UploadVersionResponse UploadVersion(UploadVersionRequest request) + { + UploadVersionResponse response = new UploadVersionResponse(); + + using (ObservablesContext db = ObservablesContextHelper.CreateContext()) + { + //Load relations first... + db.Roles.ToList(); + db.Permissions.ToList(); + db.UsersRoles.ToList(); + db.RolesPermissions.ToList(); + + var user = db.Users.SingleOrDefault(x => x.Email.ToLower() == request.Email.ToLower() && x.Password == request.Password); + + if (user != null && user.HasPermission(Permissions.PublishMachineStudioVersion)) + { + var versions = db.TangoVersions.ToList().Where(x => x.MachineVersionGuid == request.MachineVersionGuid).OrderByDescending(x => Version.Parse(x.Version)).ToList(); + + TangoVersion latestVersion = new TangoVersion(); + latestVersion.Version = "0.0.0.0"; + + if (versions.Count > 0) + { + latestVersion = versions.FirstOrDefault(); + } + + Version currentVersion = Version.Parse(request.Version); + + if (currentVersion > Version.Parse(latestVersion.Version)) + { + String newVersionFileName = "Tango Version" + " " + currentVersion.ToString() + ".zip"; + + var client = StorageHelper.GetStorageBlobClient(); + var container = StorageHelper.GetTangoVersionsContainer(client); + var blob = StorageHelper.CreateEmptyBlob(container, newVersionFileName); + + response.Token = Guid.NewGuid().ToString(); + response.BlobAddress = StorageHelper.GenerateBlobWriteSignature(blob, TimeSpan.FromMinutes(30)); + + _pendingUploads.Add(new PendingUpload() + { + UserGuid = user.Guid, + Comments = request.Comments, + Token = response.Token, + Version = request.Version, + BlobName = blob.Name, + MachineVersionGuid = request.MachineVersionGuid, + }); + } + else + { + throw new ArgumentException("New version must be greater than latest version."); + } + } + else + { + throw new AuthenticationException("Invalid user credentials."); + } + } + + return response; + } + + [HttpPost] + public UploadCompletedResponse NotifyUploadCompleted(UploadCompletedRequest request) + { + PendingUpload upload = _pendingUploads.FirstOrDefault(x => x.Token == request.Token); + + if (upload != null) + { + _pendingUploads.RemoveAll(x => x.Token == upload.Token); + + using (ObservablesContext db = ObservablesContextHelper.CreateContext()) + { + db.TangoVersions.Add(new TangoVersion() + { + Comments = upload.Comments, + BlobName = upload.BlobName, + UserGuid = upload.UserGuid, + Version = upload.Version, + MachineVersionGuid = upload.MachineVersionGuid + }); + + db.SaveChanges(); + } + + return new UploadCompletedResponse(); + } + else + { + throw new AuthenticationException("Invalid upload token."); + } + } + + #endregion + [HttpPost] public Machine PersonTest(Person p) { diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/ValuesController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/ValuesController.cs deleted file mode 100644 index f76d66836..000000000 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/ValuesController.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Web.Http; -using Tango.MachineService.Models; - -namespace Tango.MachineService.Controllers -{ - public class ValuesController : ApiController - { - private static List persons = new List(); - - // GET api/values - public IEnumerable Get() - { - return persons; - } - - // GET api/values/5 - public Person Get(int id) - { - return persons[id]; - } - - // POST api/values - public Person Post([FromBody]Person person) - { - persons.Add(person); - return person; - } - - // PUT api/values/5 - public void Put(Person person) - { - - } - - // DELETE api/values/5 - public void Delete(int id) - { - } - } -} diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/VersionUpdateController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/VersionUpdateController.cs deleted file mode 100644 index 2ad8bd735..000000000 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/VersionUpdateController.cs +++ /dev/null @@ -1,168 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Security.Authentication; -using System.Web.Http; -using Tango.BL; -using Tango.BL.Entities; -using Tango.BL.Enumerations; -using Tango.Logging; -using Tango.MachineService.Helpers; -using Tango.PPC.Common.Update; - -namespace Tango.MachineService.Controllers -{ - public class VersionUpdateController : JsonController - { - private class PendingUpload - { - public String Token { get; set; } - - public String Version { get; set; } - - public String UserGuid { get; set; } - - public String Comments { get; set; } - - public String MachineVersionGuid { get; set; } - - public String BlobName { get; set; } - } - - private static List _pendingUploads; - - static VersionUpdateController() - { - _pendingUploads = new List(); - } - - [HttpPost] - public LatestVersionResponse GetLatestVersion(LatestVersionRequest request) - { - LatestVersionResponse response = new LatestVersionResponse(); - - using (ObservablesContext db = ObservablesContextHelper.CreateContext()) - { - var versions = db.TangoVersions.ToList(); - - if (versions.Count == 0) - { - return new LatestVersionResponse() - { - Version = "0.0.0.0", - }; - } - - var machine_versions = versions.Where(x => x.MachineVersionGuid == request.MachineVersionGuid).ToList(); - - if (machine_versions.Count > 0) - { - response.Version = db.TangoVersions.Where(x => x.MachineVersionGuid == request.MachineVersionGuid).ToList().OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault().Version; - } - else - { - throw new ArgumentException("The specified machine version was not found!"); - } - } - - return response; - } - - [HttpPost] - public UploadVersionResponse UploadVersion(UploadVersionRequest request) - { - UploadVersionResponse response = new UploadVersionResponse(); - - using (ObservablesContext db = ObservablesContextHelper.CreateContext()) - { - //Load relations first... - db.Roles.ToList(); - db.Permissions.ToList(); - db.UsersRoles.ToList(); - db.RolesPermissions.ToList(); - - var user = db.Users.SingleOrDefault(x => x.Email.ToLower() == request.Email.ToLower() && x.Password == request.Password); - - if (user != null && user.HasPermission(Permissions.PublishMachineStudioVersion)) - { - var versions = db.TangoVersions.ToList().Where(x => x.MachineVersionGuid == request.MachineVersionGuid).OrderByDescending(x => Version.Parse(x.Version)).ToList(); - - TangoVersion latestVersion = new TangoVersion(); - latestVersion.Version = "0.0.0.0"; - - if (versions.Count > 0) - { - latestVersion = versions.FirstOrDefault(); - } - - Version currentVersion = Version.Parse(request.Version); - - if (currentVersion > Version.Parse(latestVersion.Version)) - { - String newVersionFileName = "Tango Version" + " " + currentVersion.ToString() + ".zip"; - - var client = StorageHelper.GetStorageBlobClient(); - var container = StorageHelper.GetTangoVersionsContainer(client); - var blob = StorageHelper.CreateEmptyBlob(container, newVersionFileName); - - response.Token = Guid.NewGuid().ToString(); - response.BlobAddress = StorageHelper.GenerateBlobWriteSignature(blob, TimeSpan.FromMinutes(30)); - - _pendingUploads.Add(new PendingUpload() - { - UserGuid = user.Guid, - Comments = request.Comments, - Token = response.Token, - Version = request.Version, - BlobName = blob.Name, - MachineVersionGuid = request.MachineVersionGuid, - }); - } - else - { - throw new ArgumentException("New version must be greater than latest version."); - } - } - else - { - throw new AuthenticationException("Invalid user credentials."); - } - } - - return response; - } - - [HttpPost] - public UploadCompletedResponse NotifyUploadCompleted(UploadCompletedRequest request) - { - PendingUpload upload = _pendingUploads.FirstOrDefault(x => x.Token == request.Token); - - if (upload != null) - { - _pendingUploads.RemoveAll(x => x.Token == upload.Token); - - using (ObservablesContext db = ObservablesContextHelper.CreateContext()) - { - db.TangoVersions.Add(new TangoVersion() - { - Comments = upload.Comments, - BlobName = upload.BlobName, - UserGuid = upload.UserGuid, - Version = upload.Version, - MachineVersionGuid = upload.MachineVersionGuid - }); - - db.SaveChanges(); - } - - return new UploadCompletedResponse(); - } - else - { - throw new AuthenticationException("Invalid upload token."); - } - } - } -} diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Models/PendingUpload.cs b/Software/Visual_Studio/Web/Tango.MachineService/Models/PendingUpload.cs new file mode 100644 index 000000000..f18b3756a --- /dev/null +++ b/Software/Visual_Studio/Web/Tango.MachineService/Models/PendingUpload.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace Tango.MachineService.Models +{ + public class PendingUpload + { + public String Token { get; set; } + + public String Version { get; set; } + + public String UserGuid { get; set; } + + public String Comments { get; set; } + + public String MachineVersionGuid { get; set; } + + public String BlobName { get; set; } + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj index c7fdab45c..acb4ad84e 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj +++ b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj @@ -270,17 +270,15 @@ - + - - Global.asax @@ -331,6 +329,10 @@ {7ada4e86-cad7-4968-a210-3a8a9e5153ab} Tango.Synchronization + + {74e700b0-1156-4126-be40-ee450d3c3026} + Tango.Transport + -- cgit v1.3.1 From c3ed01b6c75c44cfeca650b43deb058b1551a9bb Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 19 Dec 2018 14:52:54 +0200 Subject: Moved machine studio update azure !!! --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 20578304 -> 20578304 bytes .../Build/Shortcuts/Machine Studio.lnk | Bin 1532 -> 1516 bytes .../MachineStudioSettings.cs | 3 + .../Tango.MachineStudio.Common.csproj | 6 +- .../Update/CheckForUpdatesRequest.cs | 8 +- .../Update/CheckForUpdatesResponse.cs | 23 +-- .../Update/IMachineStudioUpdateService.cs | 14 +- .../Update/LatestVersionRequest.cs | 15 ++ .../Update/LatestVersionResponse.cs | 15 ++ .../Update/MachineStudioUpdateService.cs | 42 +++++ .../Update/UploadCompletedRequest.cs | 5 +- .../Update/UploadCompletedResponse.cs | 14 ++ .../Update/UploadVersionRequest.cs | 10 +- .../Update/UploadVersionResponse.cs | 22 +-- .../Tango.MachineStudio.Publisher/MainWindowVM.cs | 40 ++--- .../Tango.MachineStudio.Publisher.csproj | 7 +- .../Tango.MachineStudio.UI.csproj | 3 +- .../ViewModels/LoadingViewVM.cs | 6 +- .../ViewModels/MainViewVM.cs | 5 +- .../ViewModels/UpdateViewVM.cs | 35 ++-- .../PPC/Tango.PPC.Publisher/MainWindowVM.cs | 25 ++- .../Tango.PPC.Publisher/Tango.PPC.Publisher.csproj | 4 + .../Tango.BL/Entities/MachineStudioVersion.cs | 20 +-- .../Tango.DAL.Remote/DB/MACHINE_STUDIO_VERSIONS.cs | 2 +- .../Tango.DAL.Remote/DB/RemoteADO.edmx | 6 +- .../Tango.DAL.Remote/DB/RemoteADO.edmx.diagram | 142 ++++++++-------- .../Tango.Transport/Tango.Transport.csproj | 4 + .../Tango.Transport/Web/StorageBlobDownloader.cs | 65 +++++++ .../Web/StorageBlobProgressEventArgs.cs | 14 ++ .../Tango.Transport/Web/StorageBlobUploader.cs | 61 +++++++ .../Controllers/MachineStudioController.cs | 186 +++++++++++++++++++++ .../Controllers/PPCController.cs | 8 +- .../Tango.MachineService/Helpers/StorageHelper.cs | 6 + .../Models/MachineStudioPendingUpload.cs | 26 +++ .../Models/PPCPendingUpload.cs | 22 +++ .../Tango.MachineService/Models/PendingUpload.cs | 22 --- .../Tango.MachineService.csproj | 8 +- 38 files changed, 651 insertions(+), 243 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/LatestVersionRequest.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/LatestVersionResponse.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/MachineStudioUpdateService.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadCompletedResponse.cs create mode 100644 Software/Visual_Studio/Tango.Transport/Web/StorageBlobDownloader.cs create mode 100644 Software/Visual_Studio/Tango.Transport/Web/StorageBlobProgressEventArgs.cs create mode 100644 Software/Visual_Studio/Tango.Transport/Web/StorageBlobUploader.cs create mode 100644 Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs create mode 100644 Software/Visual_Studio/Web/Tango.MachineService/Models/MachineStudioPendingUpload.cs create mode 100644 Software/Visual_Studio/Web/Tango.MachineService/Models/PPCPendingUpload.cs delete mode 100644 Software/Visual_Studio/Web/Tango.MachineService/Models/PendingUpload.cs (limited to 'Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 5b346239d..260afa6c7 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 1801b28f7..0c46ed4ec 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk index 09ae17244..adc17d481 100644 Binary files a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk and b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk differ diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs index 67e052ecc..cab3d2bfc 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs @@ -43,6 +43,8 @@ namespace Tango.MachineStudio.Common /// public String UpdateServiceAddress { get; set; } + public String MachineServiceAddress { get; set; } + /// /// Gets or sets the allow beta release. /// @@ -96,6 +98,7 @@ namespace Tango.MachineStudio.Common LastBounds = new Rect(); LoggingCategories = new List(); UpdateServiceAddress = "http://twine01/MachineStudioUpdateService/MachineStudioUpdateService.svc"; + MachineServiceAddress = "http://machineservice.twine-srv.com/"; DefaultIssueReportTags = new List(); StudioModulesBounds = new List(); } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj index 8cf65a13d..31d28def8 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj @@ -122,8 +122,12 @@ + + + + @@ -304,7 +308,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesRequest.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesRequest.cs index 0047e311b..11911dd7e 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesRequest.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesRequest.cs @@ -4,22 +4,18 @@ using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; +using Tango.Transport.Web; namespace Tango.MachineStudio.Common.Update { - [DataContract] - public class CheckForUpdatesRequest + public class CheckForUpdatesRequest : WebRequestMessage { - [DataMember] public String Email { get; set; } - [DataMember] public String Password { get; set; } - [DataMember] public String Version { get; set; } - [DataMember] public bool AcceptBetaRelease { get; set; } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesResponse.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesResponse.cs index f34f12d8f..b0577f40b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesResponse.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesResponse.cs @@ -4,37 +4,22 @@ using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; +using Tango.Transport.Web; namespace Tango.MachineStudio.Common.Update { - [DataContract] - public class CheckForUpdatesResponse + public class CheckForUpdatesResponse : WebResponseMessage { - [DataMember] public bool IsUpdateAvailable { get; set; } - [DataMember] public bool IsStable { get; set; } - [DataMember] public String Version { get; set; } - [DataMember] public String Comments { get; set; } - [DataMember] - public String FtpHost { get; set; } - - [DataMember] - public String FilePath { get; set; } - - [DataMember] - public String UserName { get; set; } - - [DataMember] - public String Password { get; set; } - - [DataMember] public bool ForcedUpdate { get; set; } + + public String BlobAddress { get; set; } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/IMachineStudioUpdateService.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/IMachineStudioUpdateService.cs index 53e49e52c..4a7df7caa 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/IMachineStudioUpdateService.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/IMachineStudioUpdateService.cs @@ -4,23 +4,19 @@ using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.Text; +using System.Threading.Tasks; using Tango.MachineStudio.Common.Update; namespace Tango.MachineStudio.Common.Update { - [ServiceContract] public interface IMachineStudioUpdateService { - [OperationContract] - CheckForUpdatesResponse CheckForUpdates(CheckForUpdatesRequest request); + Task CheckForUpdates(CheckForUpdatesRequest request); - [OperationContract] - UploadVersionResponse UploadVersion(UploadVersionRequest request); + Task UploadVersion(UploadVersionRequest request); - [OperationContract] - void NotifyUploadCompleted(UploadCompletedRequest request); + Task NotifyUploadCompleted(UploadCompletedRequest request); - [OperationContract] - String GetLatestVersion(); + Task GetLatestVersion(LatestVersionRequest request); } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/LatestVersionRequest.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/LatestVersionRequest.cs new file mode 100644 index 000000000..b4e7bd975 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/LatestVersionRequest.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.MachineStudio.Common.Update +{ + public class LatestVersionRequest : WebRequestMessage + { + + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/LatestVersionResponse.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/LatestVersionResponse.cs new file mode 100644 index 000000000..b90cbf370 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/LatestVersionResponse.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.MachineStudio.Common.Update +{ + public class LatestVersionResponse : WebResponseMessage + { + public String Version { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/MachineStudioUpdateService.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/MachineStudioUpdateService.cs new file mode 100644 index 000000000..aae1fe70d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/MachineStudioUpdateService.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Settings; +using Tango.Transport.Web; + +namespace Tango.MachineStudio.Common.Update +{ + public class MachineStudioUpdateService : IMachineStudioUpdateService + { + private string address; + private WebTransportClient _client; + + public MachineStudioUpdateService() + { + address = SettingsManager.Default.GetOrCreate().MachineServiceAddress + "/api/MachineStudio/"; + _client = new WebTransportClient(); + } + + public Task CheckForUpdates(CheckForUpdatesRequest request) + { + return _client.PostJson(address + "CheckForUpdates", request); + } + + public Task UploadVersion(UploadVersionRequest request) + { + return _client.PostJson(address + "UploadVersion", request); + } + + public Task NotifyUploadCompleted(UploadCompletedRequest request) + { + return _client.PostJson(address + "NotifyUploadCompleted", request); + } + + public Task GetLatestVersion(LatestVersionRequest request) + { + return _client.PostJson(address + "GetLatestVersion", request); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadCompletedRequest.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadCompletedRequest.cs index ce6096792..fc478db50 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadCompletedRequest.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadCompletedRequest.cs @@ -4,13 +4,12 @@ using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; +using Tango.Transport.Web; namespace Tango.MachineStudio.Common.Update { - [DataContract] - public class UploadCompletedRequest + public class UploadCompletedRequest : WebRequestMessage { - [DataMember] public String Token { get; set; } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadCompletedResponse.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadCompletedResponse.cs new file mode 100644 index 000000000..89850e3e5 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadCompletedResponse.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.MachineStudio.Common.Update +{ + public class UploadCompletedResponse : WebResponseMessage + { + + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionRequest.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionRequest.cs index 83739f615..c55cb9a22 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionRequest.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionRequest.cs @@ -4,28 +4,22 @@ using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; +using Tango.Transport.Web; namespace Tango.MachineStudio.Common.Update { - [DataContract] - public class UploadVersionRequest + public class UploadVersionRequest : WebRequestMessage { - [DataMember] public String Email { get; set; } - [DataMember] public String Password { get; set; } - [DataMember] public String Version { get; set; } - [DataMember] public String Comments { get; set; } - [DataMember] public bool ForcedUpdate { get; set; } - [DataMember] public bool IsStable { get; set; } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionResponse.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionResponse.cs index 36dc3df30..4d13fc6ad 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionResponse.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionResponse.cs @@ -4,28 +4,14 @@ using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; +using Tango.Transport.Web; namespace Tango.MachineStudio.Common.Update { - [DataContract] - public class UploadVersionResponse + public class UploadVersionResponse : WebResponseMessage { - [DataMember] - public String FtpHost { get; set; } - - [DataMember] - public String FilePath { get; set; } - - [DataMember] - public String FileName { get; set; } - - [DataMember] - public String UserName { get; set; } - - [DataMember] - public String Password { get; set; } - - [DataMember] public String Token { get; set; } + + public String BlobAddress { get; set; } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs index ffeefb820..73f3f5bed 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs @@ -19,6 +19,7 @@ using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.Update; using Tango.Settings; using Tango.SharedUI; +using Tango.Transport.Web; namespace Tango.MachineStudio.Publisher { @@ -26,7 +27,6 @@ namespace Tango.MachineStudio.Publisher { private BasicHashGenerator _hashGenerator; private String _appPath = AppDomain.CurrentDomain.BaseDirectory + "..\\Release"; - private ChannelFactory _service; private IMachineStudioUpdateService _client; private String _email; @@ -114,14 +114,15 @@ namespace Tango.MachineStudio.Publisher public MainWindowVM() { + _client = new MachineStudioUpdateService(); + MaxProgress = 100; _hashGenerator = new BasicHashGenerator(); PublishCommand = new RelayCommand(Publish, () => Email != null && Password != null && Comments != null && CurrentVersion != null && LatestVersion != null && !IsUpdating && Version.Parse(CurrentVersion) > Version.Parse(LatestVersion)); - _service = UpdateServiceHelper.GetUpdateServiceChannel(); - _client = _service.CreateChannel(); + var client = new MachineStudioUpdateService(); UpdateVersions(); @@ -136,7 +137,7 @@ namespace Tango.MachineStudio.Publisher private void UpdateVersions() { CurrentVersion = FileVersionInfo.GetVersionInfo(_appPath + "\\Tango.MachineStudio.UI.exe").ProductVersion; - LatestVersion = _client.GetLatestVersion(); + LatestVersion = _client.GetLatestVersion(new LatestVersionRequest()).Result.Version; } private void Publish() @@ -152,7 +153,7 @@ namespace Tango.MachineStudio.Publisher Task.Factory.StartNew(() => { IsUpdating = true; - String tempFile = String.Empty; + String tempFile = TemporaryManager.CreateFile(); try { @@ -164,9 +165,7 @@ namespace Tango.MachineStudio.Publisher Comments = Comments, ForcedUpdate = ForcedUpdate, IsStable = IsStable, - }); - - tempFile = Path.Combine(Path.GetTempPath(), response.FileName); + }).Result; using (ZipFile zip = new ZipFile()) { @@ -190,28 +189,23 @@ namespace Tango.MachineStudio.Publisher Progress = 0; MaxProgress = 100; - FileStreamWrapper fs = null; - - using (fs = new FileStreamWrapper(tempFile, FileMode.Open, (current) => - { - InvokeUINow(() => - { - Thread.Sleep(10); - Progress = ((double)current / (double)fs.Length) * 100d; - }); - })) + using (StorageBlobUploader uploader = new StorageBlobUploader(response.BlobAddress,tempFile)) { - using (FtpClient ftp = new FtpClient(response.FtpHost, response.UserName, response.Password)) + uploader.Progress += (x, e) => { - ftp.ConnectAsync().Wait(); - ftp.UploadAsync(fs, response.FilePath, FtpExists.Overwrite, true).Wait(); - } + InvokeUINow(() => + { + Progress = ((double)e.Current / (double)e.Total) * 100d; + }); + }; + + uploader.Upload().Wait(); } _client.NotifyUploadCompleted(new UploadCompletedRequest() { Token = response.Token, - }); + }).Wait(); Progress = 0; UpdateVersions(); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Tango.MachineStudio.Publisher.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Tango.MachineStudio.Publisher.csproj index c462c21f4..a7e3e045b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Tango.MachineStudio.Publisher.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Tango.MachineStudio.Publisher.csproj @@ -55,6 +55,7 @@ ..\..\packages\Ionic.Zip.1.9.1.8\lib\Ionic.Zip.dll + @@ -145,6 +146,10 @@ {8491d07b-c1f6-4b62-a412-41b9fd2d6538} Tango.SharedUI + + {74e700b0-1156-4126-be40-ee450d3c3026} + Tango.Transport + {cb0b0aa2-bb24-4bca-a720-45e397684e12} Tango.MachineStudio.Common @@ -165,7 +170,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj index b3926190f..d3c22341d 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj @@ -69,6 +69,7 @@ ..\..\packages\MaterialDesignThemes.2.3.1.953\lib\net45\MaterialDesignThemes.Wpf.dll + ..\..\packages\SimpleValidator.0.6.1.0\lib\net40\SimpleValidator.dll @@ -609,7 +610,7 @@ copy /Y "$(SolutionDir)Referenced Assemblies\Microsoft.WITDataStore32.dll" "$(Ta - + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs index cafd0328a..545d51ef2 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs @@ -94,15 +94,15 @@ namespace Tango.MachineStudio.UI.ViewModels Status = "Checking for critical updates..."; LogManager.Log("Checking for forced update..."); - var service = UpdateServiceHelper.GetUpdateServiceChannel(); - var client = service.CreateChannel(); + + var client = new MachineStudioUpdateService(); CheckForUpdatesResponse response = client.CheckForUpdates(new CheckForUpdatesRequest() { Email = "ForceUpdate", Password = "ForceUpdate", Version = ApplicationManager.Version.ToString(), - }); + }).Result; if (response.IsUpdateAvailable && response.ForcedUpdate) { diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs index c9cd3276f..befad162c 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -359,8 +359,7 @@ namespace Tango.MachineStudio.UI.ViewModels { if (_authenticationProvider.CurrentUser != null) { - var service = UpdateServiceHelper.GetUpdateServiceChannel(); - var client = service.CreateChannel(); + var client = new MachineStudioUpdateService(); CheckForUpdatesResponse response = client.CheckForUpdates(new CheckForUpdatesRequest() { @@ -368,7 +367,7 @@ namespace Tango.MachineStudio.UI.ViewModels Password = _authenticationProvider.CurrentUser.Password, Version = _applicationManager.Version.ToString(), AcceptBetaRelease = _settings.AcceptBetaRelease, - }); + }).Result; IsUpdateAvailable = response.IsUpdateAvailable; LatestVersion = response.Version; diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs index a9624da2d..af197ca3b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs @@ -24,6 +24,7 @@ using Tango.SharedUI; using Tango.MachineStudio.UI.Messages; using Tango.Settings; using Tango.MachineStudio.Common; +using Tango.Transport.Web; namespace Tango.MachineStudio.UI.ViewModels { @@ -193,8 +194,7 @@ namespace Tango.MachineStudio.UI.ViewModels { Thread.Sleep(2000); - service = UpdateServiceHelper.GetUpdateServiceChannel(); - var client = service.CreateChannel(); + var client = new MachineStudioUpdateService(); CheckForUpdatesResponse response = client.CheckForUpdates(new CheckForUpdatesRequest() { @@ -202,7 +202,7 @@ namespace Tango.MachineStudio.UI.ViewModels Password = _authentication.CurrentUser.Password, Version = _application.Version.ToString(), AcceptBetaRelease = settings.AcceptBetaRelease, - }); + }).Result; if (response.IsUpdateAvailable) { @@ -260,29 +260,18 @@ namespace Tango.MachineStudio.UI.ViewModels { logManager.Log("Creating temporary file " + tempFile); - int fileSize = 0; - - using (FileStreamWrapper fs = new FileStreamWrapper(tempFile.Path, FileMode.Create, (current) => - { - InvokeUINow(() => - { - Thread.Sleep(10); - DownloadProgress = ((double)current / (double)fileSize) * 100d; - }); - })) + using (StorageBlobDownloader downloader = new StorageBlobDownloader(_updateInfo.BlobAddress, tempFile.Path)) { - using (FtpClient ftp = new FtpClient(_updateInfo.FtpHost, _updateInfo.UserName, _updateInfo.Password)) + downloader.Progress += (x, e) => { - logManager.Log("Connecting to FTP site: " + _updateInfo.FtpHost); - ftp.ConnectAsync().Wait(); - logManager.Log("Retrieving download size..."); - fileSize = (int)ftp.GetFileSize(_updateInfo.FilePath); - logManager.Log("Download size: " + fileSize + " bytes."); - logManager.Log("Starting download..."); - ftp.DownloadAsync(fs, _updateInfo.FilePath).Wait(); - } - } + InvokeUINow(() => + { + DownloadProgress = ((double)e.Current / (double)e.Total) * 100d; + }); + }; + downloader.Download().Wait(); + } Status = UpdateStatus.Updating; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs index 881403ea8..4e7dd304e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs @@ -26,6 +26,7 @@ using Tango.PPC.Common.Update; using Tango.Settings; using Tango.SharedUI; using Tango.SQLExaminer; +using Tango.Transport.Web; namespace Tango.PPC.Publisher { @@ -234,20 +235,18 @@ namespace Tango.PPC.Publisher Progress = 0; MaxProgress = 100; - CloudBlockBlob blob = new CloudBlockBlob(new Uri(response.BlobAddress)); - - FileStreamWrapper fs = null; - - using (fs = new FileStreamWrapper(tempFile, FileMode.Open, (current) => + using (StorageBlobUploader uploader = new StorageBlobUploader(response.BlobAddress, tempFile)) { - InvokeUINow(() => + uploader.Progress += (x, e) => { - Thread.Sleep(10); - Progress = ((double)current / (double)fs.Length) * 100d; - }); - })) - { - await blob.UploadFromStreamAsync(fs); + InvokeUINow(() => + { + Thread.Sleep(10); + Progress = ((double)e.Current / (double)e.Total) * 100d; + }); + }; + + await uploader.Upload(); } await _client.NotifyUploadCompleted(new UploadCompletedRequest() @@ -277,7 +276,7 @@ namespace Tango.PPC.Publisher dlg.DefaultExt = ".tup"; if (dlg.ShowDialog().Value) { - Task.Factory.StartNew(() => + Task.Factory.StartNew(() => { try { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Tango.PPC.Publisher.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Tango.PPC.Publisher.csproj index ef692809f..9a4b8b595 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Tango.PPC.Publisher.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Tango.PPC.Publisher.csproj @@ -144,6 +144,10 @@ {e1e66ed9-597d-45fa-8048-de90a6930484} Tango.SQLExaminer + + {74e700b0-1156-4126-be40-ee450d3c3026} + Tango.Transport + {0be74eee-22cb-4dba-b896-793b9e1a3ac0} Tango.PPC.Common diff --git a/Software/Visual_Studio/Tango.BL/Entities/MachineStudioVersion.cs b/Software/Visual_Studio/Tango.BL/Entities/MachineStudioVersion.cs index 3167b3ccf..cc1425529 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/MachineStudioVersion.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/MachineStudioVersion.cs @@ -27,7 +27,7 @@ namespace Tango.BL.Entities public event EventHandler VersionChanged; - public event EventHandler FtpFilePathChanged; + public event EventHandler BlobNameChanged; public event EventHandler CommentsChanged; @@ -65,30 +65,30 @@ namespace Tango.BL.Entities } } - protected String _ftpfilepath; + protected String _blobname; /// - /// Gets or sets the machinestudioversion ftp file path. + /// Gets or sets the machinestudioversion blob name. /// - [Column("FTP_FILE_PATH")] + [Column("BLOB_NAME")] - public String FtpFilePath + public String BlobName { get { - return _ftpfilepath; + return _blobname; } set { - if (_ftpfilepath != value) + if (_blobname != value) { - _ftpfilepath = value; + _blobname = value; - FtpFilePathChanged?.Invoke(this, value); + BlobNameChanged?.Invoke(this, value); - RaisePropertyChanged(nameof(FtpFilePath)); + RaisePropertyChanged(nameof(BlobName)); } } } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE_STUDIO_VERSIONS.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE_STUDIO_VERSIONS.cs index eed787485..a4f10de26 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE_STUDIO_VERSIONS.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE_STUDIO_VERSIONS.cs @@ -18,7 +18,7 @@ namespace Tango.DAL.Remote.DB public string GUID { get; set; } public System.DateTime LAST_UPDATED { get; set; } public string VERSION { get; set; } - public string FTP_FILE_PATH { get; set; } + public string BLOB_NAME { get; set; } public string COMMENTS { get; set; } public string USER_GUID { get; set; } public bool FORCE_UPDATE { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx index 7a01d5db8..86cf4ed6a 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx @@ -669,7 +669,7 @@ - + @@ -3757,7 +3757,7 @@ - + @@ -6032,7 +6032,7 @@ - + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram index c16e38955..cf9ff4f22 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram @@ -5,81 +5,81 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - + + + + + + diff --git a/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj b/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj index 02e5381ee..4e677a041 100644 --- a/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj +++ b/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj @@ -34,6 +34,7 @@ ..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll + ..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll @@ -111,6 +112,9 @@ + + + diff --git a/Software/Visual_Studio/Tango.Transport/Web/StorageBlobDownloader.cs b/Software/Visual_Studio/Tango.Transport/Web/StorageBlobDownloader.cs new file mode 100644 index 000000000..603463823 --- /dev/null +++ b/Software/Visual_Studio/Tango.Transport/Web/StorageBlobDownloader.cs @@ -0,0 +1,65 @@ +using Microsoft.WindowsAzure.Storage.Blob; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.IO; + +namespace Tango.Transport.Web +{ + public class StorageBlobDownloader : IDisposable + { + private bool _disposed; + private FileStreamWrapper _stream; + private long _fileSize; + + public CloudBlockBlob Blob { get; private set; } + + public event EventHandler Progress; + + public StorageBlobDownloader(CloudBlockBlob blob, String fileName) + { + Blob = blob; + _stream = new FileStreamWrapper(fileName, FileMode.Create, OnProgress); + } + + public StorageBlobDownloader(String blobAddress, String fileName) : this(new CloudBlockBlob(new Uri(blobAddress)), fileName) + { + + } + + private void OnProgress(long current) + { + Progress?.Invoke(this, new StorageBlobProgressEventArgs() + { + Current = current, + Total = _fileSize, + }); + } + + public async Task Download() + { + if (_disposed) + { + throw new ObjectDisposedException("The storage blob downloader can only be used once."); + } + + await Blob.FetchAttributesAsync(); + _fileSize = Blob.Properties.Length; + + await Blob.DownloadToStreamAsync(_stream); + Dispose(); + } + + public void Dispose() + { + if (!_disposed) + { + _disposed = true; + _stream.Dispose(); + } + } + } +} diff --git a/Software/Visual_Studio/Tango.Transport/Web/StorageBlobProgressEventArgs.cs b/Software/Visual_Studio/Tango.Transport/Web/StorageBlobProgressEventArgs.cs new file mode 100644 index 000000000..ae48e34cf --- /dev/null +++ b/Software/Visual_Studio/Tango.Transport/Web/StorageBlobProgressEventArgs.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Transport.Web +{ + public class StorageBlobProgressEventArgs : EventArgs + { + public long Total { get; set; } + public long Current { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.Transport/Web/StorageBlobUploader.cs b/Software/Visual_Studio/Tango.Transport/Web/StorageBlobUploader.cs new file mode 100644 index 000000000..8d645f33f --- /dev/null +++ b/Software/Visual_Studio/Tango.Transport/Web/StorageBlobUploader.cs @@ -0,0 +1,61 @@ +using Microsoft.WindowsAzure.Storage.Blob; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.IO; + +namespace Tango.Transport.Web +{ + public class StorageBlobUploader : IDisposable + { + private bool _disposed; + private FileStreamWrapper _stream; + + public CloudBlockBlob Blob { get; private set; } + + public event EventHandler Progress; + + public StorageBlobUploader(CloudBlockBlob blob, String fileName) + { + Blob = blob; + _stream = new FileStreamWrapper(fileName, FileMode.Open, OnProgress); + } + + public StorageBlobUploader(String blobAddress, String fileName) : this(new CloudBlockBlob(new Uri(blobAddress)), fileName) + { + + } + + private void OnProgress(long current) + { + Progress?.Invoke(this, new StorageBlobProgressEventArgs() + { + Current = current, + Total = _stream.Length, + }); + } + + public async Task Upload() + { + if (_disposed) + { + throw new ObjectDisposedException("The storage blob uploader can only be used once."); + } + + await Blob.UploadFromStreamAsync(_stream); + Dispose(); + } + + public void Dispose() + { + if (!_disposed) + { + _disposed = true; + _stream.Dispose(); + } + } + } +} diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs new file mode 100644 index 000000000..245c18b9b --- /dev/null +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs @@ -0,0 +1,186 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Security.Authentication; +using System.Web.Http; +using Tango.BL; +using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.MachineService.Helpers; +using Tango.MachineService.Models; +using Tango.MachineStudio.Common.Update; + +namespace Tango.MachineService.Controllers +{ + public class MachineStudioController : JsonController + { + private static List _pendingUploads; + + static MachineStudioController() + { + _pendingUploads = new List(); + } + + [HttpPost] + public CheckForUpdatesResponse CheckForUpdates(CheckForUpdatesRequest request) + { + LogManager.Log("Request received..."); + + CheckForUpdatesResponse response = new CheckForUpdatesResponse(); + + using (ObservablesContext db = ObservablesContextHelper.CreateContext()) + { + //Load relation first... + db.Roles.ToList(); + db.Permissions.ToList(); + db.UsersRoles.ToList(); + db.RolesPermissions.ToList(); + + var user = db.Users.SingleOrDefault(x => x.Email.ToLower() == request.Email.ToLower() && x.Password == request.Password); + + if (user != null && user.HasPermission(Permissions.RunMachineStudio) || (request.Email == "ForceUpdate")) + { + var versions = db.MachineStudioVersions.ToList(); + + MachineStudioVersion latestVersion = null; + + if (request.AcceptBetaRelease) + { + latestVersion = versions.OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault(); + } + else + { + latestVersion = versions.Where(x => x.Stable).OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault(); + } + + Version currentVersion = Version.Parse(request.Version); + + bool isForcedUpdate = versions.Exists(x => x.ForceUpdate && Version.Parse(x.Version) > currentVersion); + + String comments = String.Join(Environment.NewLine, versions.OrderBy(x => Version.Parse(x.Version)).Where(x => Version.Parse(x.Version) > currentVersion).Select(x => x.Comments)); + + if (latestVersion != null && Version.Parse(latestVersion.Version) > currentVersion) + { + var client = StorageHelper.GetStorageBlobClient(); + var container = StorageHelper.GetMachineStudioVersionsContainer(client); + var blob = container.GetBlockBlobReference(latestVersion.BlobName); + + response.BlobAddress = StorageHelper.GenerateBlobReadSignature(blob, TimeSpan.FromMinutes(60)); + + response.IsUpdateAvailable = true; + response.Version = latestVersion.Version; + response.Comments = latestVersion.Comments; + response.ForcedUpdate = isForcedUpdate; + response.IsStable = latestVersion.Stable; + } + } + else + { + throw new AuthenticationException("Invalid user credentials."); + } + } + + return response; + } + + [HttpPost] + public UploadVersionResponse UploadVersion(UploadVersionRequest request) + { + UploadVersionResponse response = new UploadVersionResponse(); + + using (ObservablesContext db = ObservablesContextHelper.CreateContext()) + { + //Load relation first... + db.Roles.ToList(); + db.Permissions.ToList(); + db.UsersRoles.ToList(); + db.RolesPermissions.ToList(); + + var user = db.Users.SingleOrDefault(x => x.Email.ToLower() == request.Email.ToLower() && x.Password == request.Password); + + if (user != null && user.HasPermission(Permissions.PublishMachineStudioVersion)) + { + var latestVersion = db.MachineStudioVersions.ToList().OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault(); + Version currentVersion = Version.Parse(request.Version); + + if (latestVersion == null || currentVersion > Version.Parse(latestVersion.Version)) + { + String newVersionFileName = "Machine Studio Version" + " " + currentVersion.ToString() + ".zip"; + + var client = StorageHelper.GetStorageBlobClient(); + var container = StorageHelper.GetMachineStudioVersionsContainer(client); + var blob = StorageHelper.CreateEmptyBlob(container, newVersionFileName); + + response.Token = Guid.NewGuid().ToString(); + response.BlobAddress = StorageHelper.GenerateBlobWriteSignature(blob, TimeSpan.FromMinutes(30)); + + _pendingUploads.Add(new MachineStudioPendingUpload() + { + UserGuid = user.Guid, + Comments = request.Comments, + ForcedUpdate = request.ForcedUpdate, + Token = response.Token, + Version = request.Version, + IsStable = request.IsStable, + BlobName = blob.Name, + }); + } + else + { + throw new ArgumentException("New version must be greater than latest version."); + } + } + else + { + throw new AuthenticationException("Invalid user credentials."); + } + } + + return response; + } + + [HttpPost] + public UploadCompletedResponse NotifyUploadCompleted(UploadCompletedRequest request) + { + MachineStudioPendingUpload upload = _pendingUploads.FirstOrDefault(x => x.Token == request.Token); + + if (upload != null) + { + _pendingUploads.RemoveAll(x => x.Token == upload.Token); + + using (ObservablesContext db = ObservablesContextHelper.CreateContext()) + { + db.MachineStudioVersions.Add(new MachineStudioVersion() + { + Comments = upload.Comments, + BlobName = upload.BlobName, + UserGuid = upload.UserGuid, + Version = upload.Version, + ForceUpdate = upload.ForcedUpdate, + Stable = upload.IsStable, + }); + + db.SaveChanges(); + } + + return new UploadCompletedResponse(); + } + else + { + throw new ArgumentException("Invalid Token."); + } + } + + [HttpPost] + public LatestVersionResponse GetLatestVersion(LatestVersionRequest request) + { + using (ObservablesContext db = ObservablesContextHelper.CreateContext()) + { + var version = db.MachineStudioVersions.ToList().OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault(); + return new LatestVersionResponse() { Version = version != null ? version.Version : "0.0.0.0" }; + } + } + } +} diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs index 45396e47a..9ce22bbb0 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs @@ -37,13 +37,13 @@ namespace Tango.MachineService.Controllers { public class PPCController : JsonController { - private static List _pendingUploads; + private static List _pendingUploads; #region Constructors static PPCController() { - _pendingUploads = new List(); + _pendingUploads = new List(); } #endregion @@ -315,7 +315,7 @@ namespace Tango.MachineService.Controllers response.Token = Guid.NewGuid().ToString(); response.BlobAddress = StorageHelper.GenerateBlobWriteSignature(blob, TimeSpan.FromMinutes(30)); - _pendingUploads.Add(new PendingUpload() + _pendingUploads.Add(new PPCPendingUpload() { UserGuid = user.Guid, Comments = request.Comments, @@ -342,7 +342,7 @@ namespace Tango.MachineService.Controllers [HttpPost] public UploadCompletedResponse NotifyUploadCompleted(UploadCompletedRequest request) { - PendingUpload upload = _pendingUploads.FirstOrDefault(x => x.Token == request.Token); + PPCPendingUpload upload = _pendingUploads.FirstOrDefault(x => x.Token == request.Token); if (upload != null) { diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Helpers/StorageHelper.cs b/Software/Visual_Studio/Web/Tango.MachineService/Helpers/StorageHelper.cs index 04d5bbffe..a2cc2a0dc 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Helpers/StorageHelper.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Helpers/StorageHelper.cs @@ -24,6 +24,12 @@ namespace Tango.MachineService.Helpers return container; } + public static CloudBlobContainer GetMachineStudioVersionsContainer(CloudBlobClient client) + { + var container = client.GetContainerReference("machine-studio-versions"); + return container; + } + public static CloudBlockBlob CreateEmptyBlob(CloudBlobContainer container, String name) { CloudBlockBlob emptyBlob = container.GetBlockBlobReference(name); diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Models/MachineStudioPendingUpload.cs b/Software/Visual_Studio/Web/Tango.MachineService/Models/MachineStudioPendingUpload.cs new file mode 100644 index 000000000..0347d35ea --- /dev/null +++ b/Software/Visual_Studio/Web/Tango.MachineService/Models/MachineStudioPendingUpload.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace Tango.MachineService.Models +{ + public class MachineStudioPendingUpload + { + public String Token { get; set; } + + public String Version { get; set; } + + public String UserGuid { get; set; } + + public String Comments { get; set; } + + public bool ForcedUpdate { get; set; } + + public String FilePath { get; set; } + + public bool IsStable { get; set; } + + public String BlobName { get; set; } + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Models/PPCPendingUpload.cs b/Software/Visual_Studio/Web/Tango.MachineService/Models/PPCPendingUpload.cs new file mode 100644 index 000000000..10797e758 --- /dev/null +++ b/Software/Visual_Studio/Web/Tango.MachineService/Models/PPCPendingUpload.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace Tango.MachineService.Models +{ + public class PPCPendingUpload + { + public String Token { get; set; } + + public String Version { get; set; } + + public String UserGuid { get; set; } + + public String Comments { get; set; } + + public String MachineVersionGuid { get; set; } + + public String BlobName { get; set; } + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Models/PendingUpload.cs b/Software/Visual_Studio/Web/Tango.MachineService/Models/PendingUpload.cs deleted file mode 100644 index f18b3756a..000000000 --- a/Software/Visual_Studio/Web/Tango.MachineService/Models/PendingUpload.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; - -namespace Tango.MachineService.Models -{ - public class PendingUpload - { - public String Token { get; set; } - - public String Version { get; set; } - - public String UserGuid { get; set; } - - public String Comments { get; set; } - - public String MachineVersionGuid { get; set; } - - public String BlobName { get; set; } - } -} \ No newline at end of file diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj index acb4ad84e..c6245e18e 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj +++ b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj @@ -270,11 +270,13 @@ + - + + @@ -305,6 +307,10 @@ + + {CB0B0AA2-BB24-4BCA-A720-45E397684E12} + Tango.MachineStudio.Common + {0be74eee-22cb-4dba-b896-793b9e1a3ac0} Tango.PPC.Common -- cgit v1.3.1 From 5bec920df45bb79e5912a97f2d0afc1a849adbd2 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 23 Dec 2018 09:34:03 +0200 Subject: Fixed some issues with observables generator. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 20578304 -> 20578304 bytes .../Authentication/LoginRequest.cs | 15 ++ .../Authentication/LoginResponse.cs | 15 ++ .../Tango.MachineStudio.Common.csproj | 2 + .../Visual_Studio/Tango.BL/Entities/Machine.cs | 31 ----- Software/Visual_Studio/Tango.BL/Entities/Rml.cs | 30 ---- .../Components/DataBaseDescriptionsHelper.cs | 31 +++++ .../Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs | 1 - Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs | 3 - .../Tango.DAL.Remote/DB/RemoteADO.edmx | 46 +------ .../Tango.DAL.Remote/DB/RemoteADO.edmx.diagram | 153 ++++++++++----------- .../ObservablesGenerator.cs | 38 ++++- .../Controllers/MachineStudioController.cs | 60 +++++++- .../Tango.MachineService.csproj | 6 + .../Web/Tango.MachineService/Web.config | 4 + .../Web/Tango.MachineService/packages.config | 1 + 17 files changed, 251 insertions(+), 185 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/LoginRequest.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/LoginResponse.cs (limited to 'Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 952f63196..810f4b5c0 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 24819348d..9281ede10 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/LoginRequest.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/LoginRequest.cs new file mode 100644 index 000000000..762fb5dd5 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/LoginRequest.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.MachineStudio.Common.Authentication +{ + public class LoginRequest : WebRequestMessage + { + public String Email { get; set; } + public String Password { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/LoginResponse.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/LoginResponse.cs new file mode 100644 index 000000000..075a5ec10 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/LoginResponse.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; +using Tango.Transport.Web; + +namespace Tango.MachineStudio.Common.Authentication +{ + public class LoginResponse : WebResponseMessage + { + public DataSource DataSource { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj index 31d28def8..ca4d95805 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj @@ -75,6 +75,8 @@ GlobalVersionInfo.cs + + diff --git a/Software/Visual_Studio/Tango.BL/Entities/Machine.cs b/Software/Visual_Studio/Tango.BL/Entities/Machine.cs index 92ed46850..38926d3e4 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/Machine.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/Machine.cs @@ -80,8 +80,6 @@ namespace Tango.BL.Entities public event EventHandler DefaultRmlChanged; - public event EventHandler LoadedRmlChanged; - public event EventHandler DefaultSpoolTypeChanged; protected String _serialnumber; @@ -279,7 +277,6 @@ namespace Tango.BL.Entities /// [Column("LOADED_RML_GUID")] - [ForeignKey("LoadedRml")] public String LoadedRmlGuid { @@ -960,34 +957,6 @@ namespace Tango.BL.Entities } } - protected Rml _loadedrml; - - /// - /// Gets or sets the machine rml1. - /// - - [XmlIgnore] - [JsonIgnore] - public virtual Rml LoadedRml - { - get - { - return _loadedrml; - } - - set - { - if (_loadedrml != value) - { - _loadedrml = value; - - LoadedRmlChanged?.Invoke(this, value); - - RaisePropertyChanged(nameof(LoadedRml)); - } - } - } - protected SpoolType _defaultspooltype; /// diff --git a/Software/Visual_Studio/Tango.BL/Entities/Rml.cs b/Software/Visual_Studio/Tango.BL/Entities/Rml.cs index b79736ad4..3bbdd3fab 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/Rml.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/Rml.cs @@ -71,8 +71,6 @@ namespace Tango.BL.Entities public event EventHandler> MachinesChanged; - public event EventHandler> Machines1Changed; - public event EventHandler MediaColorChanged; public event EventHandler MediaConditionChanged; @@ -899,32 +897,6 @@ namespace Tango.BL.Entities } } - protected SynchronizedObservableCollection _machines1; - - /// - /// Gets or sets the rml machines1. - /// - - public virtual SynchronizedObservableCollection Machines1 - { - get - { - return _machines1; - } - - set - { - if (_machines1 != value) - { - _machines1 = value; - - Machines1Changed?.Invoke(this, value); - - RaisePropertyChanged(nameof(Machines1)); - } - } - } - protected MediaColor _mediacolor; /// @@ -1079,8 +1051,6 @@ namespace Tango.BL.Entities Machines = new SynchronizedObservableCollection(); - Machines1 = new SynchronizedObservableCollection(); - ProcessParametersTablesGroups = new SynchronizedObservableCollection(); } diff --git a/Software/Visual_Studio/Tango.Core/Components/DataBaseDescriptionsHelper.cs b/Software/Visual_Studio/Tango.Core/Components/DataBaseDescriptionsHelper.cs index 0f1193c6c..620fe9dbc 100644 --- a/Software/Visual_Studio/Tango.Core/Components/DataBaseDescriptionsHelper.cs +++ b/Software/Visual_Studio/Tango.Core/Components/DataBaseDescriptionsHelper.cs @@ -18,6 +18,12 @@ namespace Tango.Core.Components public String ColumnDescription { get; set; } } + public class ForeignKeyDescription + { + public String TableName { get; set; } + public String ColumnName { get; set; } + } + public static List GetDescriptions(DbConnection connection) { List dbDescriptions = new List(); @@ -67,5 +73,30 @@ ORDER BY t.name, c.colorder"; return dbDescriptions; } + + public static List GetForeignKeys(DbConnection connection) + { + List keys = new List(); + + var command = connection.CreateCommand(); + command.CommandText = "SELECT a.TABLE_NAME, a.COLUMN_NAME FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS b JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE a ON a.CONSTRAINT_CATALOG = b.CONSTRAINT_CATALOG AND a.CONSTRAINT_NAME = b.CONSTRAINT_NAME"; + + DataTable table = new DataTable(); + table.Load(command.ExecuteReader()); + + foreach (var row in table.Rows.OfType()) + { + String table_name = row.ItemArray.GetValue(0).ToString(); + String column_name = row.ItemArray.GetValue(1).ToString(); + + keys.Add(new ForeignKeyDescription() + { + TableName = table_name, + ColumnName = column_name + }); + } + + return keys; + } } } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs index 54b7a6231..f49eba95a 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs @@ -63,7 +63,6 @@ namespace Tango.DAL.Remote.DB public virtual ICollection MACHINES_EVENTS { get; set; } public virtual ORGANIZATION ORGANIZATION { get; set; } public virtual RML RML { get; set; } - public virtual RML RML1 { get; set; } public virtual SPOOL_TYPES SPOOL_TYPES { get; set; } } } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs index a7a5b1deb..5b4ca71ff 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs @@ -22,7 +22,6 @@ namespace Tango.DAL.Remote.DB this.JOBS = new HashSet(); this.LIQUID_TYPES_RMLS = new HashSet(); this.MACHINES = new HashSet(); - this.MACHINES1 = new HashSet(); this.PROCESS_PARAMETERS_TABLES_GROUPS = new HashSet(); } @@ -65,8 +64,6 @@ namespace Tango.DAL.Remote.DB public virtual ICollection LIQUID_TYPES_RMLS { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection MACHINES { get; set; } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] - public virtual ICollection MACHINES1 { get; set; } public virtual MEDIA_COLORS MEDIA_COLORS { get; set; } public virtual MEDIA_CONDITIONS MEDIA_CONDITIONS { get; set; } public virtual MEDIA_MATERIALS MEDIA_MATERIALS { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx index ed932c954..c51caf219 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx @@ -1869,7 +1869,7 @@ - + @@ -1881,18 +1881,6 @@ - - - - - - - - - - - - @@ -2496,11 +2484,7 @@ - - - - - + @@ -2946,11 +2930,7 @@ - - - - - + @@ -3841,8 +3821,7 @@ - - + @@ -4041,8 +4020,7 @@ - - + @@ -5149,7 +5127,7 @@ - + @@ -5161,18 +5139,6 @@ - - - - - - - - - - - - diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram index 886074e80..4c3b4610a 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram @@ -5,81 +5,81 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -148,8 +148,7 @@ - - + diff --git a/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/ObservablesGenerator.cs b/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/ObservablesGenerator.cs index e45815046..3a40dfd1f 100644 --- a/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/ObservablesGenerator.cs +++ b/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/ObservablesGenerator.cs @@ -16,6 +16,7 @@ using Tango.Core; using System.Data; using System.Diagnostics; using static Tango.Core.Components.DataBaseDescriptionsHelper; +using System.Threading; namespace Tango.DBObservablesGenerator.CLI { @@ -31,6 +32,7 @@ namespace Tango.DBObservablesGenerator.CLI public void GenerateCSharp(String targetPath) { List dbDescriptions = new List(); + List foreign_keys = new List(); //Get column descriptions... using (RemoteDB db = new RemoteDB(SettingsManager.Default.GetOrCreate().DataSource)) @@ -39,6 +41,7 @@ namespace Tango.DBObservablesGenerator.CLI db.Database.Connection.Open(); dbDescriptions = Core.Components.DataBaseDescriptionsHelper.GetDescriptions(db.Database.Connection); + foreign_keys = Core.Components.DataBaseDescriptionsHelper.GetForeignKeys(db.Database.Connection); } //Generate Entities... @@ -61,7 +64,38 @@ namespace Tango.DBObservablesGenerator.CLI Description = table_description, }; - List foreignKeys = table.PropertyType.GenericTypeArguments.First().GetProperties().Skip(3).Where(x => x.PropertyType == typeof(String)).Where(x => x.Name.ToLower().Contains("guid")).Select(x => DalNameToStandardName(x.Name).SingularizeMVC().Replace("Guid", "")).ToList(); + List guessed_keys = table.PropertyType.GenericTypeArguments.First().GetProperties().Skip(3).Where(x => x.PropertyType == typeof(String)).Where(x => x.Name.ToLower().Contains("guid")).Select(x => DalNameToStandardName(x.Name).SingularizeMVC().Replace("Guid", "")).OrderBy(x => x).ToList(); + + List foreignKeys = foreign_keys.Where(x => x.TableName == table.Name).Select(x => DalNameToStandardName(x.ColumnName).SingularizeMVC().Replace("Guid", "")).OrderBy(x => x).ToList(); + + String t_name = table.Name; + + if (guessed_keys.Count != foreignKeys.Count) + { + Console.ForegroundColor = ConsoleColor.Yellow; + + Console.WriteLine($"Specious entry at {table.Name}."); + for (int i = 0; i < Math.Max(guessed_keys.Count, foreignKeys.Count); i++) + { + if (i < guessed_keys.Count) + { + Console.Write(guessed_keys[i]); + } + + Console.Write(" <=> "); + + if (i < foreignKeys.Count) + { + Console.Write(foreignKeys[i]); + } + + Console.WriteLine(); + } + + Console.ForegroundColor = ConsoleColor.Gray; + + Thread.Sleep(2000); + } foreach (var field in table.PropertyType.GenericTypeArguments.First().GetProperties().Skip(3)) { @@ -117,7 +151,7 @@ namespace Tango.DBObservablesGenerator.CLI { codeField.Type = field.PropertyType.Name; - if (codeField.Name.EndsWith("Guid")) + if (foreignKeys.Contains(codeField.Name.Replace("Guid", ""))) { codeField.IsForeignKey = true; codeField.ForeignKeyName = codeField.Name.Replace("Guid", ""); diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs index ed1a807be..8225d75e1 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs @@ -1,4 +1,5 @@ -using System; +using Microsoft.IdentityModel.Clients.ActiveDirectory; +using System; using System.Collections.Generic; using System.Linq; using System.Net; @@ -6,10 +7,13 @@ using System.Net.Http; using System.Security.Authentication; using System.Web.Http; using Tango.BL; +using Tango.BL.Builders; using Tango.BL.Entities; using Tango.BL.Enumerations; +using Tango.Core.Cryptography; using Tango.MachineService.Helpers; using Tango.MachineService.Models; +using Tango.MachineStudio.Common.Authentication; using Tango.MachineStudio.Common.Update; namespace Tango.MachineService.Controllers @@ -23,6 +27,8 @@ namespace Tango.MachineService.Controllers _pendingUploads = new List(); } + #region Update + [HttpPost] public CheckForUpdatesResponse CheckForUpdates(CheckForUpdatesRequest request) { @@ -182,5 +188,57 @@ namespace Tango.MachineService.Controllers return new LatestVersionResponse() { Version = version != null ? version.Version : "0.0.0.0" }; } } + + #endregion + + public LoginResponse Login(LoginRequest request) + { + var authContext = new AuthenticationContext("https://login.microsoftonline.com/2ebd63a5-bc2f-41dc-9066-4409ed5e5dd4"); + UserCredential userCredential = new UserCredential(request.Email, request.Password); + AuthenticationResult authResult = authContext.AcquireToken("https://graph.windows.net/", "ec612854-7abc-457b-808a-5d0c5ba80c57", userCredential); + + using (ObservablesContext db = ObservablesContextHelper.CreateContext()) + { + + db.Roles.ToList(); + db.Permissions.ToList(); + db.UsersRoles.ToList(); + db.RolesPermissions.ToList(); + + var user = db.Users.SingleOrDefault(x => x.Email.ToLower() == request.Email.ToLower() && x.Password == request.Password); + + if (user == null) + { + //Than add the user !! + + IHashGenerator g = new BasicHashGenerator(); + + BL.Entities.User new_user = new User(); + new_user.Email = request.Email; + new_user.Password = g.Encrypt("Aa123456"); + new_user.Organization = db.Organizations.Single(x => x.Name == "Twine"); + new_user.Address = new Address() { }; + new_user.Contact = new Contact() + { + FirstName = authResult.UserInfo.GivenName, + LastName = authResult.UserInfo.FamilyName, + }; + new_user.Roles.Add(db.Roles.Single(x => (Roles)x.Code == Roles.User)); + } + } + + return new LoginResponse() + { + DataSource = new Core.DataSource() + { + Address = Config.DB_ADDRESS, + Catalog = Config.DB_CATALOG, + Type = Core.DataSourceType.Azure, + UserName = request.Email, + Password = request.Password, + } + }; + } + } } diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj index c6245e18e..5b13d8afd 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj +++ b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj @@ -64,6 +64,12 @@ ..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll + + ..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.7.10707.1513-rc\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll + + + ..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.7.10707.1513-rc\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll + ..\..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.AzureStorageEnum.dll diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Web.config b/Software/Visual_Studio/Web/Tango.MachineService/Web.config index 3590b89d8..ef2420349 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Web.config +++ b/Software/Visual_Studio/Web/Tango.MachineService/Web.config @@ -125,6 +125,10 @@ + + + + diff --git a/Software/Visual_Studio/Web/Tango.MachineService/packages.config b/Software/Visual_Studio/Web/Tango.MachineService/packages.config index ede4fa80d..080382800 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/packages.config +++ b/Software/Visual_Studio/Web/Tango.MachineService/packages.config @@ -20,6 +20,7 @@ + -- cgit v1.3.1 From 4e496467dcc8549605917a44263d78cef40f71bb Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sun, 23 Dec 2018 12:44:08 +0200 Subject: Implemented machine studio active directory secure login. --- .../Build/Shortcuts/Machine Studio.lnk | Bin 1516 -> 1581 bytes .../MachineStudioSettings.cs | 5 +--- .../Tango.MachineStudio.Common.csproj | 4 +-- .../DefaultAuthenticationProvider.cs | 19 +++++++++++-- .../ViewModels/LoadingViewVM.cs | 5 ++-- .../ViewModels/LoginViewVM.cs | 16 +++++++---- .../Controllers/MachineStudioController.cs | 31 +++++++++++++-------- .../Controllers/PPCController.cs | 3 ++ .../Helpers/AzureDirectoryHelper.cs | 19 +++++++++++++ .../Tango.MachineService.csproj | 3 +- 10 files changed, 75 insertions(+), 30 deletions(-) create mode 100644 Software/Visual_Studio/Web/Tango.MachineService/Helpers/AzureDirectoryHelper.cs (limited to 'Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj') diff --git a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk index adc17d481..9c594a6b0 100644 Binary files a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk and b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk differ diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs index cab3d2bfc..1d3660c5f 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs @@ -39,10 +39,8 @@ namespace Tango.MachineStudio.Common public String LastVirtualMachineSerialNumber { get; set; } /// - /// Gets or sets the update service address. + /// Gets or sets the machine service address. /// - public String UpdateServiceAddress { get; set; } - public String MachineServiceAddress { get; set; } /// @@ -97,7 +95,6 @@ namespace Tango.MachineStudio.Common { LastBounds = new Rect(); LoggingCategories = new List(); - UpdateServiceAddress = "http://twine01/MachineStudioUpdateService/MachineStudioUpdateService.svc"; MachineServiceAddress = "http://machineservice.twine-srv.com/"; DefaultIssueReportTags = new List(); StudioModulesBounds = new List(); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj index ca4d95805..cd99b00d0 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj @@ -127,7 +127,7 @@ - + @@ -310,7 +310,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs index fd68ed8d1..3293dab3f 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs @@ -10,6 +10,9 @@ using Tango.MachineStudio.Common.Authentication; using Tango.BL; using Tango.BL.Enumerations; using System.Data.Entity; +using Tango.Transport.Web; +using Tango.Settings; +using Tango.MachineStudio.Common; namespace Tango.MachineStudio.UI.Authentication { @@ -49,11 +52,21 @@ namespace Tango.MachineStudio.UI.Authentication /// Login failed for user " + email public User Login(string email, string password) { - using (ObservablesContext db = ObservablesContext.CreateDefault()) + var settings = SettingsManager.Default.GetOrCreate(); + + IWebTransportClient service = new WebTransportClient(); + var response = service.PostJson(settings.MachineServiceAddress + "/api/MachineStudio/Login", new LoginRequest() { - String hash = User.GetPasswordHash(password); + Email = email, + Password = password, + + }).Result; + ObservablesContext.OverrideSettingsDataSource(response.DataSource); + + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { db.Roles.Load(); db.Permissions.Load(); db.RolesPermissions.Load(); @@ -62,7 +75,7 @@ namespace Tango.MachineStudio.UI.Authentication .Include(x => x.UsersRoles) .Include(x => x.Contact) .Include(x => x.Address) - .Include(x => x.Organization).SingleOrDefault(x => x.Email.ToLower() == email.ToLower() && x.Password == hash); + .Include(x => x.Organization).SingleOrDefault(x => x.Email.ToLower() == email.ToLower()); if (user == null) { diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs index 545d51ef2..6e8d0488b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs @@ -144,9 +144,8 @@ namespace Tango.MachineStudio.UI.ViewModels Status = "Loading, please wait..."; - ObservablesStaticCollections.Instance.Initialize(); - - _eventLogger.Log(EventTypes.ApplicationStarted, "Application Started!"); + //ObservablesStaticCollections.Instance.Initialize(); + //_eventLogger.Log(EventTypes.ApplicationStarted, "Application Started!"); Status = "Starting application..."; diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs index a37879a5e..4e659d46a 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs @@ -6,6 +6,8 @@ using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Enumerations; using Tango.Core.Commands; using Tango.Core.Cryptography; using Tango.MachineStudio.Common; @@ -90,7 +92,7 @@ namespace Tango.MachineStudio.UI.ViewModels _navigationManager = navigationManager; _authenticationProvider = authenticationProvider; _eventLogger = eventLogger; - LoginCommand = new RelayCommand(Login,() => !IsLogging); + LoginCommand = new RelayCommand(Login, () => !IsLogging); cryptographer = new Rfc2898Cryptographer(); Email = _settings.LastLoginEmail; @@ -121,6 +123,10 @@ namespace Tango.MachineStudio.UI.ViewModels await Task.Factory.StartNew(() => { _authenticationProvider.Login(Email, Password); + + ObservablesStaticCollections.Instance.Initialize(); + _eventLogger.Log(EventTypes.ApplicationStarted, "Application Started!"); + _navigationManager.NavigateTo(NavigationView.MainView); _settings.LastLoginEmail = Email; _settings.RememberMe = RememberMe; @@ -128,13 +134,13 @@ namespace Tango.MachineStudio.UI.ViewModels _settings.LastLoginPassword = RememberMe ? cryptographer.Encrypt(Password) : null; _settings.Save(); - _eventLogger.Log("User logged in"); + _eventLogger.Log("User logged in."); }); } - catch (Exception) + catch (Exception ex) { - - _notificationProvider.ShowError("Invalid credentials. Please try again."); + LogManager.Log(ex, "Login Error."); + _notificationProvider.ShowError($"The specified email or password was incorrect, or you don't have a permission to run this application.\nError: {ex.Message}"); } finally { diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs index 8225d75e1..8485cd67d 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs @@ -14,6 +14,7 @@ using Tango.Core.Cryptography; using Tango.MachineService.Helpers; using Tango.MachineService.Models; using Tango.MachineStudio.Common.Authentication; +using System.Data.Entity; using Tango.MachineStudio.Common.Update; namespace Tango.MachineService.Controllers @@ -191,40 +192,45 @@ namespace Tango.MachineService.Controllers #endregion + [HttpPost] public LoginResponse Login(LoginRequest request) { - var authContext = new AuthenticationContext("https://login.microsoftonline.com/2ebd63a5-bc2f-41dc-9066-4409ed5e5dd4"); - UserCredential userCredential = new UserCredential(request.Email, request.Password); - AuthenticationResult authResult = authContext.AcquireToken("https://graph.windows.net/", "ec612854-7abc-457b-808a-5d0c5ba80c57", userCredential); + AuthenticationResult authResult = AzureDirectoryHelper.AuthenticateUser(request.Email, request.Password); using (ObservablesContext db = ObservablesContextHelper.CreateContext()) { - db.Roles.ToList(); db.Permissions.ToList(); db.UsersRoles.ToList(); db.RolesPermissions.ToList(); - var user = db.Users.SingleOrDefault(x => x.Email.ToLower() == request.Email.ToLower() && x.Password == request.Password); + var user = db.Users.SingleOrDefault(x => x.Email.ToLower() == request.Email.ToLower()); + + IHashGenerator g = new BasicHashGenerator(); if (user == null) { //Than add the user !! - - IHashGenerator g = new BasicHashGenerator(); - - BL.Entities.User new_user = new User(); + User new_user = new User(); new_user.Email = request.Email; - new_user.Password = g.Encrypt("Aa123456"); - new_user.Organization = db.Organizations.Single(x => x.Name == "Twine"); - new_user.Address = new Address() { }; + new_user.Password = g.Encrypt(request.Password); + new_user.Organization = db.Organizations.Include(x => x.Address).Single(x => x.Name == "Twine"); + new_user.Address = new_user.Organization.Address.Clone(); new_user.Contact = new Contact() { FirstName = authResult.UserInfo.GivenName, LastName = authResult.UserInfo.FamilyName, + FullName = authResult.UserInfo.GivenName + " " + authResult.UserInfo.FamilyName, + Email = request.Email, }; new_user.Roles.Add(db.Roles.Single(x => (Roles)x.Code == Roles.User)); } + else + { + user.Password = g.Encrypt(request.Password); + } + + db.SaveChanges(); } return new LoginResponse() @@ -234,6 +240,7 @@ namespace Tango.MachineService.Controllers Address = Config.DB_ADDRESS, Catalog = Config.DB_CATALOG, Type = Core.DataSourceType.Azure, + IntegratedSecurity = false, UserName = request.Email, Password = request.Password, } diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs index 662883223..68f597fcc 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs @@ -108,6 +108,7 @@ namespace Tango.MachineService.Controllers Catalog = Config.DB_CATALOG, UserName = credentials.UserName, Password = credentials.Password, + IntegratedSecurity = false, Type = DataSourceType.SQLServer, }; @@ -173,6 +174,7 @@ namespace Tango.MachineService.Controllers Catalog = Config.DB_CATALOG, UserName = credentials.UserName, Password = credentials.Password, + IntegratedSecurity = false, Type = DataSourceType.SQLServer, }; } @@ -249,6 +251,7 @@ namespace Tango.MachineService.Controllers Catalog = Config.DB_CATALOG, UserName = credentials.UserName, Password = credentials.Password, + IntegratedSecurity = false, Type = DataSourceType.SQLServer, }; } diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Helpers/AzureDirectoryHelper.cs b/Software/Visual_Studio/Web/Tango.MachineService/Helpers/AzureDirectoryHelper.cs new file mode 100644 index 000000000..fe7733323 --- /dev/null +++ b/Software/Visual_Studio/Web/Tango.MachineService/Helpers/AzureDirectoryHelper.cs @@ -0,0 +1,19 @@ +using Microsoft.IdentityModel.Clients.ActiveDirectory; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace Tango.MachineService.Helpers +{ + public static class AzureDirectoryHelper + { + public static AuthenticationResult AuthenticateUser(String email, String password) + { + var authContext = new AuthenticationContext("https://login.microsoftonline.com/2ebd63a5-bc2f-41dc-9066-4409ed5e5dd4"); + UserCredential userCredential = new UserCredential(email, password); + AuthenticationResult authResult = authContext.AcquireToken("https://graph.windows.net/", "ec612854-7abc-457b-808a-5d0c5ba80c57", userCredential); + return authResult; + } + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj index 5b13d8afd..c05cb5fe7 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj +++ b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj @@ -277,6 +277,7 @@ + @@ -379,7 +380,7 @@ False - + -- cgit v1.3.1 From 0fb83fb3abb456ee6707b7f3cabc6b0c1ab2281b Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 24 Dec 2018 14:46:55 +0200 Subject: Moved all common web components to Tango.Web Changed app keys names. Fixed issue with machine studio and the initialization of observables static collections. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 20578304 -> 20578304 bytes .../Build/Shortcuts/Machine Studio.lnk | Bin 1581 -> 1516 bytes .../DefaultAuthenticationProvider.cs | 2 + .../ViewModels/LoginViewVM.cs | 1 - .../Tango.Web/ApplicationInsights.config | 2 + .../Tango.Web/Controllers/JsonController.cs | 72 ++++++ .../Tango.Web/Controllers/ProtoController.cs | 64 +++++ .../Tango.Web/Formatters/JsonNetFormatter.cs | 89 +++++++ .../Tango.Web/Formatters/ProtoBufFormatter.cs | 143 +++++++++++ .../Tango.Web/Helpers/AzureDirectoryHelper.cs | 19 ++ .../Tango.Web/Helpers/ObservablesContextHelper.cs | 26 ++ .../Tango.Web/Properties/AssemblyInfo.cs | 7 + Software/Visual_Studio/Tango.Web/SMO/SmoManager.cs | 73 ++++++ .../Tango.Web/Storage/ExtensionMethods.cs | 48 ++++ .../Tango.Web/Storage/StorageManager.cs | 27 ++ Software/Visual_Studio/Tango.Web/Tango.Web.csproj | 276 +++++++++++++++++++++ .../Visual_Studio/Tango.Web/WebApiException.cs | 18 ++ Software/Visual_Studio/Tango.Web/WebConfig.cs | 24 ++ Software/Visual_Studio/Tango.Web/packages.config | 31 +++ Software/Visual_Studio/Tango.sln | 54 +++- .../Tango.MachineService/App_Start/WebApiConfig.cs | 1 + .../Web/Tango.MachineService/Config.cs | 16 -- .../Controllers/MachineStudioController.cs | 22 +- .../Controllers/PPCController.cs | 46 ++-- .../Helpers/AzureDirectoryHelper.cs | 19 -- .../Helpers/ObservablesContextHelper.cs | 26 -- .../Tango.MachineService/Helpers/StorageHelper.cs | 68 ----- .../Web/Tango.MachineService/JsonController.cs | 72 ------ .../Web/Tango.MachineService/JsonNetFormatter.cs | 89 ------- .../Tango.MachineService/MachineServiceConfig.cs | 15 ++ .../Web/Tango.MachineService/ProtoBufFormatter.cs | 143 ----------- .../Web/Tango.MachineService/ProtoController.cs | 64 ----- .../Web/Tango.MachineService/SMO/SmoManager.cs | 73 ------ .../Tango.MachineService.csproj | 17 +- .../Web/Tango.MachineService/Web.config | 23 +- .../Web/Tango.MachineService/WebApiException.cs | 18 -- 37 files changed, 1041 insertions(+), 647 deletions(-) create mode 100644 Software/Visual_Studio/Tango.Web/ApplicationInsights.config create mode 100644 Software/Visual_Studio/Tango.Web/Controllers/JsonController.cs create mode 100644 Software/Visual_Studio/Tango.Web/Controllers/ProtoController.cs create mode 100644 Software/Visual_Studio/Tango.Web/Formatters/JsonNetFormatter.cs create mode 100644 Software/Visual_Studio/Tango.Web/Formatters/ProtoBufFormatter.cs create mode 100644 Software/Visual_Studio/Tango.Web/Helpers/AzureDirectoryHelper.cs create mode 100644 Software/Visual_Studio/Tango.Web/Helpers/ObservablesContextHelper.cs create mode 100644 Software/Visual_Studio/Tango.Web/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/Tango.Web/SMO/SmoManager.cs create mode 100644 Software/Visual_Studio/Tango.Web/Storage/ExtensionMethods.cs create mode 100644 Software/Visual_Studio/Tango.Web/Storage/StorageManager.cs create mode 100644 Software/Visual_Studio/Tango.Web/Tango.Web.csproj create mode 100644 Software/Visual_Studio/Tango.Web/WebApiException.cs create mode 100644 Software/Visual_Studio/Tango.Web/WebConfig.cs create mode 100644 Software/Visual_Studio/Tango.Web/packages.config delete mode 100644 Software/Visual_Studio/Web/Tango.MachineService/Config.cs delete mode 100644 Software/Visual_Studio/Web/Tango.MachineService/Helpers/AzureDirectoryHelper.cs delete mode 100644 Software/Visual_Studio/Web/Tango.MachineService/Helpers/ObservablesContextHelper.cs delete mode 100644 Software/Visual_Studio/Web/Tango.MachineService/Helpers/StorageHelper.cs delete mode 100644 Software/Visual_Studio/Web/Tango.MachineService/JsonController.cs delete mode 100644 Software/Visual_Studio/Web/Tango.MachineService/JsonNetFormatter.cs create mode 100644 Software/Visual_Studio/Web/Tango.MachineService/MachineServiceConfig.cs delete mode 100644 Software/Visual_Studio/Web/Tango.MachineService/ProtoBufFormatter.cs delete mode 100644 Software/Visual_Studio/Web/Tango.MachineService/ProtoController.cs delete mode 100644 Software/Visual_Studio/Web/Tango.MachineService/SMO/SmoManager.cs delete mode 100644 Software/Visual_Studio/Web/Tango.MachineService/WebApiException.cs (limited to 'Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 810f4b5c0..978deab2f 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 9281ede10..30de45e33 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk index 9c594a6b0..16360627d 100644 Binary files a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk and b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk differ diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs index 3293dab3f..450756705 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs @@ -65,6 +65,8 @@ namespace Tango.MachineStudio.UI.Authentication ObservablesContext.OverrideSettingsDataSource(response.DataSource); + ObservablesStaticCollections.Instance.Initialize(); + using (ObservablesContext db = ObservablesContext.CreateDefault()) { db.Roles.Load(); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs index 4e659d46a..59cc69a57 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs @@ -124,7 +124,6 @@ namespace Tango.MachineStudio.UI.ViewModels { _authenticationProvider.Login(Email, Password); - ObservablesStaticCollections.Instance.Initialize(); _eventLogger.Log(EventTypes.ApplicationStarted, "Application Started!"); _navigationManager.NavigateTo(NavigationView.MainView); diff --git a/Software/Visual_Studio/Tango.Web/ApplicationInsights.config b/Software/Visual_Studio/Tango.Web/ApplicationInsights.config new file mode 100644 index 000000000..75e12df9d --- /dev/null +++ b/Software/Visual_Studio/Tango.Web/ApplicationInsights.config @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Web/Controllers/JsonController.cs b/Software/Visual_Studio/Tango.Web/Controllers/JsonController.cs new file mode 100644 index 000000000..a581d9ec7 --- /dev/null +++ b/Software/Visual_Studio/Tango.Web/Controllers/JsonController.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Security.Authentication; +using System.Threading; +using System.Threading.Tasks; +using System.Web; +using System.Web.Http; +using System.Web.Http.Controllers; +using Tango.Logging; + +namespace Tango.Web.Controllers +{ + public class JsonController : ApiController + { + protected LogManager LogManager { get; private set; } + + public JsonController() + { + LogManager = LogManager.Default; + } + + public override async Task ExecuteAsync(HttpControllerContext context, CancellationToken cancellationToken) + { + string controllerName = String.Empty; + string actionName = String.Empty; + + try + { + var routeData = HttpContext.Current.Request.RequestContext.RouteData; + actionName = routeData.Values["action"].ToString(); + controllerName = routeData.Values["controller"].ToString(); + } + catch { } + + try + { + String request = String.Empty; + + try + { + request = context.Request.Content.ReadAsStringAsync().Result; + } + catch {} + + LogManager.Log($"Request Received on {controllerName + "/" + actionName}: \n{request}"); + + var result = await base.ExecuteAsync(context, cancellationToken); + return result; + } + catch (Exception ex) + { + LogManager.Log(ex, $"An error occurred while processing the request message on {controllerName + "/" + actionName}."); + + HttpStatusCode code = HttpStatusCode.InternalServerError; + + if (ex is ArgumentException) + { + code = HttpStatusCode.BadRequest; + } + else if (ex is AuthenticationException) + { + code = HttpStatusCode.Unauthorized; + } + + throw new HttpResponseException(Request.CreateErrorResponse(code, ex.Message)); + } + } + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Web/Controllers/ProtoController.cs b/Software/Visual_Studio/Tango.Web/Controllers/ProtoController.cs new file mode 100644 index 000000000..090638f3a --- /dev/null +++ b/Software/Visual_Studio/Tango.Web/Controllers/ProtoController.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Security.Authentication; +using System.Threading; +using System.Threading.Tasks; +using System.Web; +using System.Web.Http; +using System.Web.Http.Controllers; +using Tango.Logging; + +namespace Tango.Web.Controllers +{ + public class ProtoController : ApiController + { + protected LogManager LogManager { get; private set; } + + public ProtoController() + { + LogManager = LogManager.Default; + } + + public override async Task ExecuteAsync(HttpControllerContext context, CancellationToken cancellationToken) + { + string controllerName = String.Empty; + string actionName = String.Empty; + + try + { + var routeData = HttpContext.Current.Request.RequestContext.RouteData; + actionName = routeData.Values["action"].ToString(); + controllerName = routeData.Values["controller"].ToString(); + } + catch { } + + try + { + LogManager.Log($"Request Received on {controllerName + "/" + actionName}."); + + var result = await base.ExecuteAsync(context, cancellationToken); + return result; + } + catch (Exception ex) + { + LogManager.Log(ex, $"An error occurred while processing the request message on {controllerName + "/" + actionName}."); + + HttpStatusCode code = HttpStatusCode.InternalServerError; + + if (ex is ArgumentException) + { + code = HttpStatusCode.BadRequest; + } + else if (ex is AuthenticationException) + { + code = HttpStatusCode.Unauthorized; + } + + throw new HttpResponseException(Request.CreateErrorResponse(code, ex.Message)); + } + } + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Web/Formatters/JsonNetFormatter.cs b/Software/Visual_Studio/Tango.Web/Formatters/JsonNetFormatter.cs new file mode 100644 index 000000000..7912f810f --- /dev/null +++ b/Software/Visual_Studio/Tango.Web/Formatters/JsonNetFormatter.cs @@ -0,0 +1,89 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Net.Http.Formatting; +using System.Net.Http.Headers; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Web; +using Tango.BL; + +namespace Tango.Web.Formatters +{ + public class JsonNetFormatter : MediaTypeFormatter + { + private class JsonIgnoreAttributeIgnorerContractResolver : DefaultContractResolver + { + protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) + { + var property = base.CreateProperty(member, memberSerialization); + + if (typeof(IObservableEntity).IsAssignableFrom(property.PropertyType)) + { + property.Ignored = false; + } + return property; + } + } + + private JsonSerializerSettings _jsonSerializerSettings; + + public JsonNetFormatter(JsonSerializerSettings jsonSerializerSettings) + { + _jsonSerializerSettings = jsonSerializerSettings ?? new JsonSerializerSettings(); + _jsonSerializerSettings.ContractResolver = new JsonIgnoreAttributeIgnorerContractResolver(); + + SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json")); + } + + public override bool CanReadType(Type type) + { + return true; + } + + public override bool CanWriteType(Type type) + { + return true; + } + + public override Task ReadFromStreamAsync(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger) + { + // Create a serializer + JsonSerializer serializer = JsonSerializer.Create(_jsonSerializerSettings); + + // Create task reading the content + return Task.Factory.StartNew(() => + { + using (StreamReader streamReader = new StreamReader(readStream)) + { + using (JsonTextReader jsonTextReader = new JsonTextReader(streamReader)) + { + return serializer.Deserialize(jsonTextReader, type); + } + } + }); + } + + public override Task WriteToStreamAsync(Type type, object value, Stream writeStream, HttpContent content, TransportContext transportContext) + { + // Create a serializer + JsonSerializer serializer = JsonSerializer.Create(_jsonSerializerSettings); + + // Create task writing the serialized content + return Task.Factory.StartNew(() => + { + using (JsonTextWriter jsonTextWriter = new JsonTextWriter(new StreamWriter(writeStream)) { CloseOutput = false }) + { + serializer.Serialize(jsonTextWriter, value); + jsonTextWriter.Flush(); + } + }); + } + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Web/Formatters/ProtoBufFormatter.cs b/Software/Visual_Studio/Tango.Web/Formatters/ProtoBufFormatter.cs new file mode 100644 index 000000000..eee35ec6b --- /dev/null +++ b/Software/Visual_Studio/Tango.Web/Formatters/ProtoBufFormatter.cs @@ -0,0 +1,143 @@ +using Google.Protobuf; +using System; +using System.IO; +using System.Net; +using System.Net.Http; +using System.Net.Http.Formatting; +using System.Net.Http.Headers; +using System.Threading.Tasks; +using System.Web.Http; +using Tango.PMR.Stubs; +using Tango.PMR.Synchronization; + +namespace Tango.Web.Formatters +{ + /// + /// Represents a protobuf web request/response formatter capable of formatting messages using protobuf. + /// + /// + public class ProtoBufFormatter : MediaTypeFormatter + { + private static readonly MediaTypeHeaderValue mediaType = new MediaTypeHeaderValue("application/x-protobuf"); + + /// + /// Initializes a new instance of the class. + /// + public ProtoBufFormatter() + { + SupportedMediaTypes.Add(mediaType); + } + + /// + /// Gets the default type of the media. + /// + /// + /// The default type of the media. + /// + public static MediaTypeHeaderValue DefaultMediaType + { + get { return mediaType; } + } + + /// + /// Queries whether this can deserializean object of the specified type. + /// + /// The type to deserialize. + /// + /// true if the can deserialize the type; otherwise, false. + /// + public override bool CanReadType(Type type) + { + return true; + } + + /// + /// Queries whether this can serializean object of the specified type. + /// + /// The type to serialize. + /// + /// true if the can serialize the type; otherwise, false. + /// + public override bool CanWriteType(Type type) + { + return true; + } + + /// + /// Reads from stream asynchronous. + /// + /// The type. + /// The stream. + /// The content. + /// The formatter logger. + /// + public override Task ReadFromStreamAsync(Type type, Stream stream, HttpContent content, IFormatterLogger formatterLogger) + { + var tcs = new TaskCompletionSource(); + + try + { + MessageParser parser = type.GetProperty("Parser").GetValue(null, null) as MessageParser; + IMessage req = parser.ParseFrom(stream); + tcs.SetResult(req); + } + catch (Exception ex) + { + tcs.SetException(ex); + } + + return tcs.Task; + } + + /// + /// Writes to stream asynchronous. + /// + /// The type. + /// The value. + /// The stream. + /// The content. + /// The transport context. + /// + public override Task WriteToStreamAsync(Type type, object value, Stream stream, HttpContent content, TransportContext transportContext) + { + var tcs = new TaskCompletionSource(); + + if (value is IMessage) + { + try + { + (value as IMessage).WriteTo(stream); + tcs.SetResult(null); + } + catch (Exception ex) + { + tcs.SetException(ex); + } + + return tcs.Task; + } + else if (value is HttpError) + { + var httpError = value as HttpError; + + try + { + HttpProtoException msg = new HttpProtoException(); + msg.Message = httpError["Message"].ToString(); + msg.StatusCode = (int)HttpStatusCode.InternalServerError; + + msg.WriteTo(stream); + tcs.SetResult(null); + } + catch (Exception ex) + { + tcs.SetException(ex); + } + + return tcs.Task; + } + + return base.WriteToStreamAsync(type, value, stream, content, transportContext); + } + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Web/Helpers/AzureDirectoryHelper.cs b/Software/Visual_Studio/Tango.Web/Helpers/AzureDirectoryHelper.cs new file mode 100644 index 000000000..27b5e7cf5 --- /dev/null +++ b/Software/Visual_Studio/Tango.Web/Helpers/AzureDirectoryHelper.cs @@ -0,0 +1,19 @@ +using Microsoft.IdentityModel.Clients.ActiveDirectory; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace Tango.Web.Helpers +{ + public static class AzureDirectoryHelper + { + public static AuthenticationResult AuthenticateUser(String email, String password) + { + var authContext = new AuthenticationContext("https://login.microsoftonline.com/2ebd63a5-bc2f-41dc-9066-4409ed5e5dd4"); + UserCredential userCredential = new UserCredential(email, password); + AuthenticationResult authResult = authContext.AcquireToken("https://graph.windows.net/", "ec612854-7abc-457b-808a-5d0c5ba80c57", userCredential); + return authResult; + } + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Web/Helpers/ObservablesContextHelper.cs b/Software/Visual_Studio/Tango.Web/Helpers/ObservablesContextHelper.cs new file mode 100644 index 000000000..fcf6eb599 --- /dev/null +++ b/Software/Visual_Studio/Tango.Web/Helpers/ObservablesContextHelper.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Linq; +using System.Web; +using Tango.BL; +using Tango.Core; + +namespace Tango.Web.Helpers +{ + public static class ObservablesContextHelper + { + public static ObservablesContext CreateContext() + { + return new ObservablesContext(new DataSource() + { + Address = WebConfig.DB_ADDRESS, + Catalog = WebConfig.DB_CATALOG, + IntegratedSecurity = false, + Type = DataSourceType.SQLServer, + UserName = WebConfig.DB_USER_NAME, + Password = WebConfig.DB_PASSWORD + }); + } + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Web/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Tango.Web/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..1471db897 --- /dev/null +++ b/Software/Visual_Studio/Tango.Web/Properties/AssemblyInfo.cs @@ -0,0 +1,7 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Tango - Web Components")] +[assembly: AssemblyVersion("2.0.11.1608")] +[assembly: ComVisible(false)] \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Web/SMO/SmoManager.cs b/Software/Visual_Studio/Tango.Web/SMO/SmoManager.cs new file mode 100644 index 000000000..86953d233 --- /dev/null +++ b/Software/Visual_Studio/Tango.Web/SMO/SmoManager.cs @@ -0,0 +1,73 @@ +using Microsoft.SqlServer.Management.Common; +using Microsoft.SqlServer.Management.Smo; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using Tango.Core.DB; + +namespace Tango.Web.SMO +{ + public class SmoManager : IDisposable + { + private ServerConnection _connection; + private Server _server; + private static Random random = new Random(); + + public SmoManager() + { + _connection = new ServerConnection(WebConfig.DB_ADDRESS, WebConfig.DB_USER_NAME, WebConfig.DB_PASSWORD); + _server = new Server(_connection); + } + + public DbCredentials CreateRandomLoginAndUser() + { + var database = _server.Databases.OfType().SingleOrDefault(x => x.Name == WebConfig.DB_CATALOG); + + String userName = GetRandomString(36); + String password = System.Web.Security.Membership.GeneratePassword(16, 2); + + Login login = new Login(_server, userName); + login.LoginType = LoginType.SqlLogin; + login.DefaultDatabase = WebConfig.DB_CATALOG; + login.PasswordPolicyEnforced = false; + login.Create(password); + + User user = new User(database, userName); + user.Login = userName; + user.Create(); + user.AddToRole("db_datareader"); + + return new DbCredentials() { UserName = userName, Password = password }; + } + + public void DeleteLoginAndUser(String userName) + { + var database = _server.Databases.OfType().SingleOrDefault(x => x.Name == WebConfig.DB_CATALOG); + + var user = database.Users.OfType().SingleOrDefault(x => x.Name == userName); + + if (user != null) + { + user.Drop(); + } + + Login login = _server.Logins.OfType().SingleOrDefault(x => x.Name == userName); + if (login != null) + { + login.Drop(); + } + } + + public string GetRandomString(int length) + { + const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + return "TEMP_" + new string(Enumerable.Repeat(chars, length).Select(s => s[random.Next(s.Length)]).ToArray()); + } + + public void Dispose() + { + _connection.Disconnect(); + } + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Web/Storage/ExtensionMethods.cs b/Software/Visual_Studio/Tango.Web/Storage/ExtensionMethods.cs new file mode 100644 index 000000000..4acd10082 --- /dev/null +++ b/Software/Visual_Studio/Tango.Web/Storage/ExtensionMethods.cs @@ -0,0 +1,48 @@ +using Microsoft.WindowsAzure.Storage.Blob; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Web.Storage +{ + public static class ExtensionMethods + { + public static CloudBlockBlob CreateEmptyBlob(this CloudBlobContainer container, String name) + { + CloudBlockBlob emptyBlob = container.GetBlockBlobReference(name); + using (MemoryStream ms = new MemoryStream()) + { + emptyBlob.UploadFromStream(ms);//Empty memory stream. Will create an empty blob. + } + + return emptyBlob; + } + + public static String GenerateReadSignature(this CloudBlockBlob blob, TimeSpan duration) + { + String signature = blob.GetSharedAccessSignature(new SharedAccessBlobPolicy() + { + SharedAccessStartTime = DateTime.UtcNow, + SharedAccessExpiryTime = DateTime.UtcNow.Add(duration), + Permissions = SharedAccessBlobPermissions.Read + }); + + return new Uri(blob.Uri + signature).ToString(); + } + + public static String GenerateWriteSignature(this CloudBlockBlob blob, TimeSpan duration) + { + String signature = blob.GetSharedAccessSignature(new SharedAccessBlobPolicy() + { + SharedAccessStartTime = DateTime.UtcNow, + SharedAccessExpiryTime = DateTime.UtcNow.Add(duration), + Permissions = SharedAccessBlobPermissions.Write + }); + + return new Uri(blob.Uri + signature).ToString(); + } + } +} diff --git a/Software/Visual_Studio/Tango.Web/Storage/StorageManager.cs b/Software/Visual_Studio/Tango.Web/Storage/StorageManager.cs new file mode 100644 index 000000000..17b01d1e2 --- /dev/null +++ b/Software/Visual_Studio/Tango.Web/Storage/StorageManager.cs @@ -0,0 +1,27 @@ +using Microsoft.WindowsAzure.Storage; +using Microsoft.WindowsAzure.Storage.Blob; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Web.Storage +{ + public class StorageManager + { + private CloudBlobClient _client; + + public StorageManager() + { + CloudStorageAccount storageAccount = CloudStorageAccount.Parse(WebConfig.STORAGE_ACCOUNT); + _client = storageAccount.CreateCloudBlobClient(); + } + + public CloudBlobContainer GetContainer(String name) + { + var container = _client.GetContainerReference(name); + return container; + } + } +} diff --git a/Software/Visual_Studio/Tango.Web/Tango.Web.csproj b/Software/Visual_Studio/Tango.Web/Tango.Web.csproj new file mode 100644 index 000000000..9d199a409 --- /dev/null +++ b/Software/Visual_Studio/Tango.Web/Tango.Web.csproj @@ -0,0 +1,276 @@ + + + + + + + Debug + AnyCPU + {5001990F-977B-48FF-B217-0236A5022AD8} + Library + Properties + Tango.Web + Tango.Web + v4.6.1 + 512 + true + + + ..\packages\WebGrease.1.5.2\lib + + + true + full + false + ..\Build\Core\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + ..\Build\Core\Release\ + TRACE + prompt + 4 + + + + ..\packages\Antlr.3.4.1.9004\lib\Antlr3.Runtime.dll + + + ..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.dll + + + ..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.SqlServer.dll + + + ..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll + + + ..\packages\Microsoft.ApplicationInsights.Agent.Intercept.2.0.6\lib\net45\Microsoft.AI.Agent.Intercept.dll + + + ..\packages\Microsoft.ApplicationInsights.DependencyCollector.2.2.0\lib\net45\Microsoft.AI.DependencyCollector.dll + + + ..\packages\Microsoft.ApplicationInsights.PerfCounterCollector.2.2.0\lib\net45\Microsoft.AI.PerfCounterCollector.dll + + + ..\packages\Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.2.2.0\lib\net45\Microsoft.AI.ServerTelemetryChannel.dll + + + ..\packages\Microsoft.ApplicationInsights.Web.2.2.0\lib\net45\Microsoft.AI.Web.dll + + + ..\packages\Microsoft.ApplicationInsights.WindowsServer.2.2.0\lib\net45\Microsoft.AI.WindowsServer.dll + + + ..\packages\Microsoft.ApplicationInsights.2.2.0\lib\net46\Microsoft.ApplicationInsights.dll + + + + + ..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll + + + ..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.7.10707.1513-rc\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll + + + ..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.7.10707.1513-rc\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.AzureStorageEnum.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.BatchParserClient.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.ConnectionInfo.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.ConnectionInfoExtended.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.Diagnostics.Strace.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.Dmf.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.Dmf.Common.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.Management.Collector.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.Management.CollectorEnum.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.Management.RegisteredServers.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.Management.Sdk.Sfc.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.Management.SqlParser.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.Management.Utility.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.Management.UtilityEnum.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.Management.XEvent.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.Management.XEventDbScoped.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.Management.XEventDbScopedEnum.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.Management.XEventEnum.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.PolicyEnum.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.RegSvrEnum.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.ServiceBrokerEnum.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.Smo.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.SmoExtended.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.SqlClrProvider.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.SqlEnum.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.SqlTDiagm.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.SqlWmiManagement.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.SString.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.Types.dll + + + ..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.WmiEnum.dll + + + ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll + + + + ..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll + + + + + + + ..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll + + + + + + ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll + + + ..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll + + + ..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.3\lib\net45\System.Web.Http.WebHost.dll + + + ..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll + + + ..\packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll + + + ..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll + + + ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll + + + ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll + + + ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll + + + + + + + + + ..\packages\WebGrease.1.5.2\lib\WebGrease.dll + + + + + GlobalVersionInfo.cs + + + + + + + + + + + + + + + + + + + + {f441feee-322a-4943-b566-110e12fd3b72} + Tango.BL + + + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} + Tango.Core + + + {bc932dbd-7cdb-488c-99e4-f02cf441f55e} + Tango.Logging + + + {e4927038-348d-4295-aaf4-861c58cb3943} + Tango.PMR + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Web/WebApiException.cs b/Software/Visual_Studio/Tango.Web/WebApiException.cs new file mode 100644 index 000000000..c9b464c6f --- /dev/null +++ b/Software/Visual_Studio/Tango.Web/WebApiException.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Web; + +namespace Tango.Web +{ + public class WebApiException : Exception + { + public HttpStatusCode StatusCode { get; set; } + + public WebApiException(HttpStatusCode statusCode, String message) : base(message) + { + StatusCode = statusCode; + } + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Web/WebConfig.cs b/Software/Visual_Studio/Tango.Web/WebConfig.cs new file mode 100644 index 000000000..a10da3321 --- /dev/null +++ b/Software/Visual_Studio/Tango.Web/WebConfig.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Linq; +using System.Web; + +namespace Tango.Web +{ + public class WebConfig + { + public static String DB_ADDRESS => ConfigurationManager.AppSettings[nameof(DB_ADDRESS)].ToString(); + public static String DB_USER_NAME => ConfigurationManager.AppSettings[nameof(DB_USER_NAME)].ToString(); + public static String DB_PASSWORD => ConfigurationManager.AppSettings[nameof(DB_PASSWORD)].ToString(); + public static String DB_CATALOG => ConfigurationManager.AppSettings[nameof(DB_CATALOG)].ToString(); + + public static String STORAGE_ACCOUNT => ConfigurationManager.AppSettings[nameof(STORAGE_ACCOUNT)].ToString(); + + public static String TENANT_ID => ConfigurationManager.AppSettings[nameof(TENANT_ID)].ToString(); + public static String CLIENT_ID => ConfigurationManager.AppSettings[nameof(CLIENT_ID)].ToString(); + public static String APP_SECRET => ConfigurationManager.AppSettings[nameof(APP_SECRET)].ToString(); + + } +} + diff --git a/Software/Visual_Studio/Tango.Web/packages.config b/Software/Visual_Studio/Tango.Web/packages.config new file mode 100644 index 000000000..6266503ba --- /dev/null +++ b/Software/Visual_Studio/Tango.Web/packages.config @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index 387a9e1bf..01be05c3e 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -246,6 +246,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.PPC.BootScreen", "PPC EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.PPC.Logging", "PPC\Modules\Tango.PPC.Logging\Tango.PPC.Logging.csproj", "{D2EE865B-B006-487A-9487-60A663636AC3}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.Web", "Tango.Web\Tango.Web.csproj", "{5001990F-977B-48FF-B217-0236A5022AD8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution AppVeyor|Any CPU = AppVeyor|Any CPU @@ -4409,6 +4411,46 @@ Global {D2EE865B-B006-487A-9487-60A663636AC3}.Release|x64.Build.0 = Release|Any CPU {D2EE865B-B006-487A-9487-60A663636AC3}.Release|x86.ActiveCfg = Release|Any CPU {D2EE865B-B006-487A-9487-60A663636AC3}.Release|x86.Build.0 = Release|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.AppVeyor|Any CPU.ActiveCfg = Release|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.AppVeyor|Any CPU.Build.0 = Release|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.AppVeyor|ARM.ActiveCfg = Release|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.AppVeyor|ARM.Build.0 = Release|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.AppVeyor|ARM64.ActiveCfg = Release|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.AppVeyor|ARM64.Build.0 = Release|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.AppVeyor|x64.ActiveCfg = Release|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.AppVeyor|x64.Build.0 = Release|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.AppVeyor|x86.ActiveCfg = Release|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.AppVeyor|x86.Build.0 = Release|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.Debug|ARM.ActiveCfg = Debug|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.Debug|ARM.Build.0 = Debug|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.Debug|ARM64.Build.0 = Debug|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.Debug|x64.ActiveCfg = Debug|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.Debug|x64.Build.0 = Debug|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.Debug|x86.ActiveCfg = Debug|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.Debug|x86.Build.0 = Debug|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.DefaultBuild|Any CPU.ActiveCfg = Debug|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.DefaultBuild|Any CPU.Build.0 = Debug|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.DefaultBuild|ARM.ActiveCfg = Debug|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.DefaultBuild|ARM.Build.0 = Debug|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.DefaultBuild|ARM64.ActiveCfg = Debug|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.DefaultBuild|ARM64.Build.0 = Debug|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.DefaultBuild|x64.ActiveCfg = Debug|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.DefaultBuild|x64.Build.0 = Debug|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.DefaultBuild|x86.ActiveCfg = Debug|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.DefaultBuild|x86.Build.0 = Debug|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.Release|Any CPU.Build.0 = Release|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.Release|ARM.ActiveCfg = Release|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.Release|ARM.Build.0 = Release|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.Release|ARM64.ActiveCfg = Release|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.Release|ARM64.Build.0 = Release|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.Release|x64.ActiveCfg = Release|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.Release|x64.Build.0 = Release|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.Release|x86.ActiveCfg = Release|Any CPU + {5001990F-977B-48FF-B217-0236A5022AD8}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -4488,12 +4530,12 @@ Global {D2EE865B-B006-487A-9487-60A663636AC3} = {0048447D-1D94-4E60-9DAD-7349C777CB4E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - BuildVersion_UseGlobalSettings = False - BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs - BuildVersion_StartDate = 2000/1/1 - BuildVersion_UpdateFileVersion = False - BuildVersion_UpdateAssemblyVersion = True - BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear SolutionGuid = {7986F7F4-A86A-4994-B1B6-0988D7F057B6} + BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear + BuildVersion_UpdateAssemblyVersion = True + BuildVersion_UpdateFileVersion = False + BuildVersion_StartDate = 2000/1/1 + BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs + BuildVersion_UseGlobalSettings = False EndGlobalSection EndGlobal diff --git a/Software/Visual_Studio/Web/Tango.MachineService/App_Start/WebApiConfig.cs b/Software/Visual_Studio/Web/Tango.MachineService/App_Start/WebApiConfig.cs index 3129482cb..0a63e9acb 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/App_Start/WebApiConfig.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/App_Start/WebApiConfig.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Web.Http; +using Tango.Web.Formatters; namespace Tango.MachineService { diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Config.cs b/Software/Visual_Studio/Web/Tango.MachineService/Config.cs deleted file mode 100644 index b1d2dafca..000000000 --- a/Software/Visual_Studio/Web/Tango.MachineService/Config.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Linq; -using System.Web; - -namespace Tango.MachineService -{ - public class Config - { - public static String DB_ADDRESS => ConfigurationManager.AppSettings["DbAddress"].ToString(); - public static String DB_USER_NAME => ConfigurationManager.AppSettings["DbUserName"].ToString(); - public static String DB_PASSWORD => ConfigurationManager.AppSettings["DbPassword"].ToString(); - public static String DB_CATALOG => ConfigurationManager.AppSettings["DbCatalog"].ToString(); - } -} \ No newline at end of file diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs index 8485cd67d..8d46ed7d9 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs @@ -11,11 +11,13 @@ using Tango.BL.Builders; using Tango.BL.Entities; using Tango.BL.Enumerations; using Tango.Core.Cryptography; -using Tango.MachineService.Helpers; using Tango.MachineService.Models; using Tango.MachineStudio.Common.Authentication; using System.Data.Entity; using Tango.MachineStudio.Common.Update; +using Tango.Web.Controllers; +using Tango.Web.Helpers; +using Tango.Web.Storage; namespace Tango.MachineService.Controllers { @@ -70,11 +72,11 @@ namespace Tango.MachineService.Controllers if (latestVersion != null && Version.Parse(latestVersion.Version) > currentVersion) { - var client = StorageHelper.GetStorageBlobClient(); - var container = StorageHelper.GetMachineStudioVersionsContainer(client); + var manager = new StorageManager(); + var container = manager.GetContainer(MachineServiceConfig.MACHINE_STUDIO_VERSIONS_CONTAINER); var blob = container.GetBlockBlobReference(latestVersion.BlobName); - response.BlobAddress = StorageHelper.GenerateBlobReadSignature(blob, TimeSpan.FromMinutes(60)); + response.BlobAddress = blob.GenerateReadSignature(TimeSpan.FromMinutes(60)); response.IsUpdateAvailable = true; response.Version = latestVersion.Version; @@ -116,12 +118,12 @@ namespace Tango.MachineService.Controllers { String newVersionFileName = "Machine Studio Version" + " " + currentVersion.ToString() + ".zip"; - var client = StorageHelper.GetStorageBlobClient(); - var container = StorageHelper.GetMachineStudioVersionsContainer(client); - var blob = StorageHelper.CreateEmptyBlob(container, newVersionFileName); + var manager = new StorageManager(); + var container = manager.GetContainer(MachineServiceConfig.MACHINE_STUDIO_VERSIONS_CONTAINER); + var blob = container.CreateEmptyBlob(newVersionFileName); response.Token = Guid.NewGuid().ToString(); - response.BlobAddress = StorageHelper.GenerateBlobWriteSignature(blob, TimeSpan.FromMinutes(30)); + response.BlobAddress = blob.GenerateWriteSignature(TimeSpan.FromMinutes(30)); _pendingUploads.Add(new MachineStudioPendingUpload() { @@ -237,8 +239,8 @@ namespace Tango.MachineService.Controllers { DataSource = new Core.DataSource() { - Address = Config.DB_ADDRESS, - Catalog = Config.DB_CATALOG, + Address = MachineServiceConfig.DB_ADDRESS, + Catalog = MachineServiceConfig.DB_CATALOG, Type = Core.DataSourceType.Azure, IntegratedSecurity = false, UserName = request.Email, diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs index 68f597fcc..6b4190313 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs @@ -23,9 +23,7 @@ using Tango.Core.DB; using Tango.Core.Helpers; using Tango.Core.IO; using Tango.Logging; -using Tango.MachineService.Helpers; using Tango.MachineService.Models; -using Tango.MachineService.SMO; using Tango.PMR.Stubs; using Tango.PMR.Synchronization; using Tango.PPC.Common.MachineSetup; @@ -33,6 +31,10 @@ using Tango.PPC.Common.MachineUpdate; using Tango.PPC.Common.Update; using Tango.Synchronization.Local; using Tango.Synchronization.Remote; +using Tango.Web.Controllers; +using Tango.Web.Helpers; +using Tango.Web.SMO; +using Tango.Web.Storage; namespace Tango.MachineService.Controllers { @@ -81,17 +83,17 @@ namespace Tango.MachineService.Controllers response.Version = latest_machine_version.Version; - var client = StorageHelper.GetStorageBlobClient(); - var container = StorageHelper.GetTangoVersionsContainer(client); + var manager = new StorageManager(); + var container = manager.GetContainer(MachineServiceConfig.TANGO_VERSIONS_CONTAINER); var blob = container.GetBlockBlobReference(latest_machine_version.BlobName); - response.BlobAddress = StorageHelper.GenerateBlobReadSignature(blob, TimeSpan.FromMinutes(60)); + response.BlobAddress = blob.GenerateReadSignature(TimeSpan.FromMinutes(60)); DbCredentials credentials = new DbCredentials(); - using (SmoManager manager = new SmoManager()) + using (SmoManager smo = new SmoManager()) { - credentials = manager.CreateRandomLoginAndUser(); + credentials = smo.CreateRandomLoginAndUser(); Task.Delay(TimeSpan.FromMinutes(10)).ContinueWith((x) => { @@ -104,8 +106,8 @@ namespace Tango.MachineService.Controllers response.DataSource = new DataSource() { - Address = Config.DB_ADDRESS, - Catalog = Config.DB_CATALOG, + Address = MachineServiceConfig.DB_ADDRESS, + Catalog = MachineServiceConfig.DB_CATALOG, UserName = credentials.UserName, Password = credentials.Password, IntegratedSecurity = false, @@ -147,17 +149,17 @@ namespace Tango.MachineService.Controllers response.Version = latest_machine_version.Version; - var client = StorageHelper.GetStorageBlobClient(); - var container = StorageHelper.GetTangoVersionsContainer(client); + var manager = new StorageManager(); + var container = manager.GetContainer(MachineServiceConfig.TANGO_VERSIONS_CONTAINER); var blob = container.GetBlockBlobReference(latest_machine_version.BlobName); - response.BlobAddress = StorageHelper.GenerateBlobReadSignature(blob, TimeSpan.FromMinutes(60)); + response.BlobAddress = blob.GenerateReadSignature(TimeSpan.FromMinutes(60)); DbCredentials credentials = new DbCredentials(); - using (SmoManager manager = new SmoManager()) + using (SmoManager smo = new SmoManager()) { - credentials = manager.CreateRandomLoginAndUser(); + credentials = smo.CreateRandomLoginAndUser(); Task.Delay(TimeSpan.FromMinutes(10)).ContinueWith((x) => { @@ -170,8 +172,8 @@ namespace Tango.MachineService.Controllers response.DataSource = new DataSource() { - Address = Config.DB_ADDRESS, - Catalog = Config.DB_CATALOG, + Address = MachineServiceConfig.DB_ADDRESS, + Catalog = MachineServiceConfig.DB_CATALOG, UserName = credentials.UserName, Password = credentials.Password, IntegratedSecurity = false, @@ -247,8 +249,8 @@ namespace Tango.MachineService.Controllers response.DataSource = new DataSource() { - Address = Config.DB_ADDRESS, - Catalog = Config.DB_CATALOG, + Address = MachineServiceConfig.DB_ADDRESS, + Catalog = MachineServiceConfig.DB_CATALOG, UserName = credentials.UserName, Password = credentials.Password, IntegratedSecurity = false, @@ -328,12 +330,12 @@ namespace Tango.MachineService.Controllers { String newVersionFileName = "Tango Version" + " " + currentVersion.ToString() + ".zip"; - var client = StorageHelper.GetStorageBlobClient(); - var container = StorageHelper.GetTangoVersionsContainer(client); - var blob = StorageHelper.CreateEmptyBlob(container, newVersionFileName); + var manager = new StorageManager(); + var container = manager.GetContainer(MachineServiceConfig.TANGO_VERSIONS_CONTAINER); + var blob = container.CreateEmptyBlob(newVersionFileName); response.Token = Guid.NewGuid().ToString(); - response.BlobAddress = StorageHelper.GenerateBlobWriteSignature(blob, TimeSpan.FromMinutes(30)); + response.BlobAddress = blob.GenerateWriteSignature(TimeSpan.FromMinutes(30)); _pendingUploads.Add(new PPCPendingUpload() { diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Helpers/AzureDirectoryHelper.cs b/Software/Visual_Studio/Web/Tango.MachineService/Helpers/AzureDirectoryHelper.cs deleted file mode 100644 index fe7733323..000000000 --- a/Software/Visual_Studio/Web/Tango.MachineService/Helpers/AzureDirectoryHelper.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Microsoft.IdentityModel.Clients.ActiveDirectory; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; - -namespace Tango.MachineService.Helpers -{ - public static class AzureDirectoryHelper - { - public static AuthenticationResult AuthenticateUser(String email, String password) - { - var authContext = new AuthenticationContext("https://login.microsoftonline.com/2ebd63a5-bc2f-41dc-9066-4409ed5e5dd4"); - UserCredential userCredential = new UserCredential(email, password); - AuthenticationResult authResult = authContext.AcquireToken("https://graph.windows.net/", "ec612854-7abc-457b-808a-5d0c5ba80c57", userCredential); - return authResult; - } - } -} \ No newline at end of file diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Helpers/ObservablesContextHelper.cs b/Software/Visual_Studio/Web/Tango.MachineService/Helpers/ObservablesContextHelper.cs deleted file mode 100644 index fff0eebea..000000000 --- a/Software/Visual_Studio/Web/Tango.MachineService/Helpers/ObservablesContextHelper.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Linq; -using System.Web; -using Tango.BL; -using Tango.Core; - -namespace Tango.MachineService.Helpers -{ - public static class ObservablesContextHelper - { - public static ObservablesContext CreateContext() - { - return new ObservablesContext(new DataSource() - { - Address = Config.DB_ADDRESS, - Catalog = Config.DB_CATALOG, - IntegratedSecurity = false, - Type = DataSourceType.SQLServer, - UserName = Config.DB_USER_NAME, - Password = Config.DB_PASSWORD - }); - } - } -} \ No newline at end of file diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Helpers/StorageHelper.cs b/Software/Visual_Studio/Web/Tango.MachineService/Helpers/StorageHelper.cs deleted file mode 100644 index a2cc2a0dc..000000000 --- a/Software/Visual_Studio/Web/Tango.MachineService/Helpers/StorageHelper.cs +++ /dev/null @@ -1,68 +0,0 @@ -using Microsoft.WindowsAzure.Storage; -using Microsoft.WindowsAzure.Storage.Blob; -using System; -using System.Collections.Generic; -using System.Configuration; -using System.IO; -using System.Linq; -using System.Web; - -namespace Tango.MachineService.Helpers -{ - public static class StorageHelper - { - public static CloudBlobClient GetStorageBlobClient() - { - String storageAddress = ConfigurationManager.AppSettings["Storage"].ToString(); - CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageAddress); - return storageAccount.CreateCloudBlobClient(); - } - - public static CloudBlobContainer GetTangoVersionsContainer(CloudBlobClient client) - { - var container = client.GetContainerReference("tango-versions"); - return container; - } - - public static CloudBlobContainer GetMachineStudioVersionsContainer(CloudBlobClient client) - { - var container = client.GetContainerReference("machine-studio-versions"); - return container; - } - - public static CloudBlockBlob CreateEmptyBlob(CloudBlobContainer container, String name) - { - CloudBlockBlob emptyBlob = container.GetBlockBlobReference(name); - using (MemoryStream ms = new MemoryStream()) - { - emptyBlob.UploadFromStream(ms);//Empty memory stream. Will create an empty blob. - } - - return emptyBlob; - } - - public static String GenerateBlobReadSignature(CloudBlockBlob blob, TimeSpan duration) - { - String signature = blob.GetSharedAccessSignature(new SharedAccessBlobPolicy() - { - SharedAccessStartTime = DateTime.UtcNow, - SharedAccessExpiryTime = DateTime.UtcNow.Add(duration), - Permissions = SharedAccessBlobPermissions.Read - }); - - return new Uri(blob.Uri + signature).ToString(); - } - - public static String GenerateBlobWriteSignature(CloudBlockBlob blob, TimeSpan duration) - { - String signature = blob.GetSharedAccessSignature(new SharedAccessBlobPolicy() - { - SharedAccessStartTime = DateTime.UtcNow, - SharedAccessExpiryTime = DateTime.UtcNow.Add(duration), - Permissions = SharedAccessBlobPermissions.Write - }); - - return new Uri(blob.Uri + signature).ToString(); - } - } -} \ No newline at end of file diff --git a/Software/Visual_Studio/Web/Tango.MachineService/JsonController.cs b/Software/Visual_Studio/Web/Tango.MachineService/JsonController.cs deleted file mode 100644 index 163a89589..000000000 --- a/Software/Visual_Studio/Web/Tango.MachineService/JsonController.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Security.Authentication; -using System.Threading; -using System.Threading.Tasks; -using System.Web; -using System.Web.Http; -using System.Web.Http.Controllers; -using Tango.Logging; - -namespace Tango.MachineService -{ - public class JsonController : ApiController - { - protected LogManager LogManager { get; private set; } - - public JsonController() - { - LogManager = LogManager.Default; - } - - public override async Task ExecuteAsync(HttpControllerContext context, CancellationToken cancellationToken) - { - string controllerName = String.Empty; - string actionName = String.Empty; - - try - { - var routeData = HttpContext.Current.Request.RequestContext.RouteData; - actionName = routeData.Values["action"].ToString(); - controllerName = routeData.Values["controller"].ToString(); - } - catch { } - - try - { - String request = String.Empty; - - try - { - request = context.Request.Content.ReadAsStringAsync().Result; - } - catch {} - - LogManager.Log($"Request Received on {controllerName + "/" + actionName}: \n{request}"); - - var result = await base.ExecuteAsync(context, cancellationToken); - return result; - } - catch (Exception ex) - { - LogManager.Log(ex, $"An error occurred while processing the request message on {controllerName + "/" + actionName}."); - - HttpStatusCode code = HttpStatusCode.InternalServerError; - - if (ex is ArgumentException) - { - code = HttpStatusCode.BadRequest; - } - else if (ex is AuthenticationException) - { - code = HttpStatusCode.Unauthorized; - } - - throw new HttpResponseException(Request.CreateErrorResponse(code, ex.Message)); - } - } - } -} \ No newline at end of file diff --git a/Software/Visual_Studio/Web/Tango.MachineService/JsonNetFormatter.cs b/Software/Visual_Studio/Web/Tango.MachineService/JsonNetFormatter.cs deleted file mode 100644 index 7cadceb0b..000000000 --- a/Software/Visual_Studio/Web/Tango.MachineService/JsonNetFormatter.cs +++ /dev/null @@ -1,89 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Net.Http.Formatting; -using System.Net.Http.Headers; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using System.Web; -using Tango.BL; - -namespace Tango.MachineService -{ - public class JsonNetFormatter : MediaTypeFormatter - { - private class JsonIgnoreAttributeIgnorerContractResolver : DefaultContractResolver - { - protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) - { - var property = base.CreateProperty(member, memberSerialization); - - if (typeof(IObservableEntity).IsAssignableFrom(property.PropertyType)) - { - property.Ignored = false; - } - return property; - } - } - - private JsonSerializerSettings _jsonSerializerSettings; - - public JsonNetFormatter(JsonSerializerSettings jsonSerializerSettings) - { - _jsonSerializerSettings = jsonSerializerSettings ?? new JsonSerializerSettings(); - _jsonSerializerSettings.ContractResolver = new JsonIgnoreAttributeIgnorerContractResolver(); - - SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json")); - } - - public override bool CanReadType(Type type) - { - return true; - } - - public override bool CanWriteType(Type type) - { - return true; - } - - public override Task ReadFromStreamAsync(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger) - { - // Create a serializer - JsonSerializer serializer = JsonSerializer.Create(_jsonSerializerSettings); - - // Create task reading the content - return Task.Factory.StartNew(() => - { - using (StreamReader streamReader = new StreamReader(readStream)) - { - using (JsonTextReader jsonTextReader = new JsonTextReader(streamReader)) - { - return serializer.Deserialize(jsonTextReader, type); - } - } - }); - } - - public override Task WriteToStreamAsync(Type type, object value, Stream writeStream, HttpContent content, TransportContext transportContext) - { - // Create a serializer - JsonSerializer serializer = JsonSerializer.Create(_jsonSerializerSettings); - - // Create task writing the serialized content - return Task.Factory.StartNew(() => - { - using (JsonTextWriter jsonTextWriter = new JsonTextWriter(new StreamWriter(writeStream)) { CloseOutput = false }) - { - serializer.Serialize(jsonTextWriter, value); - jsonTextWriter.Flush(); - } - }); - } - } -} \ No newline at end of file diff --git a/Software/Visual_Studio/Web/Tango.MachineService/MachineServiceConfig.cs b/Software/Visual_Studio/Web/Tango.MachineService/MachineServiceConfig.cs new file mode 100644 index 000000000..6039f55ac --- /dev/null +++ b/Software/Visual_Studio/Web/Tango.MachineService/MachineServiceConfig.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Linq; +using System.Web; +using Tango.Web; + +namespace Tango.MachineService +{ + public class MachineServiceConfig : WebConfig + { + public static String TANGO_VERSIONS_CONTAINER => ConfigurationManager.AppSettings[nameof(TANGO_VERSIONS_CONTAINER)].ToString(); + public static String MACHINE_STUDIO_VERSIONS_CONTAINER => ConfigurationManager.AppSettings[nameof(MACHINE_STUDIO_VERSIONS_CONTAINER)].ToString(); + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/Web/Tango.MachineService/ProtoBufFormatter.cs b/Software/Visual_Studio/Web/Tango.MachineService/ProtoBufFormatter.cs deleted file mode 100644 index b82f1adef..000000000 --- a/Software/Visual_Studio/Web/Tango.MachineService/ProtoBufFormatter.cs +++ /dev/null @@ -1,143 +0,0 @@ -using Google.Protobuf; -using System; -using System.IO; -using System.Net; -using System.Net.Http; -using System.Net.Http.Formatting; -using System.Net.Http.Headers; -using System.Threading.Tasks; -using System.Web.Http; -using Tango.PMR.Stubs; -using Tango.PMR.Synchronization; - -namespace Tango.MachineService -{ - /// - /// Represents a protobuf web request/response formatter capable of formatting messages using protobuf. - /// - /// - public class ProtoBufFormatter : MediaTypeFormatter - { - private static readonly MediaTypeHeaderValue mediaType = new MediaTypeHeaderValue("application/x-protobuf"); - - /// - /// Initializes a new instance of the class. - /// - public ProtoBufFormatter() - { - SupportedMediaTypes.Add(mediaType); - } - - /// - /// Gets the default type of the media. - /// - /// - /// The default type of the media. - /// - public static MediaTypeHeaderValue DefaultMediaType - { - get { return mediaType; } - } - - /// - /// Queries whether this can deserializean object of the specified type. - /// - /// The type to deserialize. - /// - /// true if the can deserialize the type; otherwise, false. - /// - public override bool CanReadType(Type type) - { - return true; - } - - /// - /// Queries whether this can serializean object of the specified type. - /// - /// The type to serialize. - /// - /// true if the can serialize the type; otherwise, false. - /// - public override bool CanWriteType(Type type) - { - return true; - } - - /// - /// Reads from stream asynchronous. - /// - /// The type. - /// The stream. - /// The content. - /// The formatter logger. - /// - public override Task ReadFromStreamAsync(Type type, Stream stream, HttpContent content, IFormatterLogger formatterLogger) - { - var tcs = new TaskCompletionSource(); - - try - { - MessageParser parser = type.GetProperty("Parser").GetValue(null, null) as MessageParser; - IMessage req = parser.ParseFrom(stream); - tcs.SetResult(req); - } - catch (Exception ex) - { - tcs.SetException(ex); - } - - return tcs.Task; - } - - /// - /// Writes to stream asynchronous. - /// - /// The type. - /// The value. - /// The stream. - /// The content. - /// The transport context. - /// - public override Task WriteToStreamAsync(Type type, object value, Stream stream, HttpContent content, TransportContext transportContext) - { - var tcs = new TaskCompletionSource(); - - if (value is IMessage) - { - try - { - (value as IMessage).WriteTo(stream); - tcs.SetResult(null); - } - catch (Exception ex) - { - tcs.SetException(ex); - } - - return tcs.Task; - } - else if (value is HttpError) - { - var httpError = value as HttpError; - - try - { - HttpProtoException msg = new HttpProtoException(); - msg.Message = httpError["Message"].ToString(); - msg.StatusCode = (int)HttpStatusCode.InternalServerError; - - msg.WriteTo(stream); - tcs.SetResult(null); - } - catch (Exception ex) - { - tcs.SetException(ex); - } - - return tcs.Task; - } - - return base.WriteToStreamAsync(type, value, stream, content, transportContext); - } - } -} \ No newline at end of file diff --git a/Software/Visual_Studio/Web/Tango.MachineService/ProtoController.cs b/Software/Visual_Studio/Web/Tango.MachineService/ProtoController.cs deleted file mode 100644 index 572604d3c..000000000 --- a/Software/Visual_Studio/Web/Tango.MachineService/ProtoController.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Security.Authentication; -using System.Threading; -using System.Threading.Tasks; -using System.Web; -using System.Web.Http; -using System.Web.Http.Controllers; -using Tango.Logging; - -namespace Tango.MachineService -{ - public class ProtoController : ApiController - { - protected LogManager LogManager { get; private set; } - - public ProtoController() - { - LogManager = LogManager.Default; - } - - public override async Task ExecuteAsync(HttpControllerContext context, CancellationToken cancellationToken) - { - string controllerName = String.Empty; - string actionName = String.Empty; - - try - { - var routeData = HttpContext.Current.Request.RequestContext.RouteData; - actionName = routeData.Values["action"].ToString(); - controllerName = routeData.Values["controller"].ToString(); - } - catch { } - - try - { - LogManager.Log($"Request Received on {controllerName + "/" + actionName}."); - - var result = await base.ExecuteAsync(context, cancellationToken); - return result; - } - catch (Exception ex) - { - LogManager.Log(ex, $"An error occurred while processing the request message on {controllerName + "/" + actionName}."); - - HttpStatusCode code = HttpStatusCode.InternalServerError; - - if (ex is ArgumentException) - { - code = HttpStatusCode.BadRequest; - } - else if (ex is AuthenticationException) - { - code = HttpStatusCode.Unauthorized; - } - - throw new HttpResponseException(Request.CreateErrorResponse(code, ex.Message)); - } - } - } -} \ No newline at end of file diff --git a/Software/Visual_Studio/Web/Tango.MachineService/SMO/SmoManager.cs b/Software/Visual_Studio/Web/Tango.MachineService/SMO/SmoManager.cs deleted file mode 100644 index d2ee0ed5f..000000000 --- a/Software/Visual_Studio/Web/Tango.MachineService/SMO/SmoManager.cs +++ /dev/null @@ -1,73 +0,0 @@ -using Microsoft.SqlServer.Management.Common; -using Microsoft.SqlServer.Management.Smo; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using Tango.Core.DB; - -namespace Tango.MachineService.SMO -{ - public class SmoManager : IDisposable - { - private ServerConnection _connection; - private Server _server; - private static Random random = new Random(); - - public SmoManager() - { - _connection = new ServerConnection(Config.DB_ADDRESS, Config.DB_USER_NAME, Config.DB_PASSWORD); - _server = new Server(_connection); - } - - public DbCredentials CreateRandomLoginAndUser() - { - var database = _server.Databases.OfType().SingleOrDefault(x => x.Name == Config.DB_CATALOG); - - String userName = GetRandomString(36); - String password = System.Web.Security.Membership.GeneratePassword(16, 2); - - Login login = new Login(_server, userName); - login.LoginType = LoginType.SqlLogin; - login.DefaultDatabase = Config.DB_CATALOG; - login.PasswordPolicyEnforced = false; - login.Create(password); - - User user = new User(database, userName); - user.Login = userName; - user.Create(); - user.AddToRole("db_datareader"); - - return new DbCredentials() { UserName = userName, Password = password }; - } - - public void DeleteLoginAndUser(String userName) - { - var database = _server.Databases.OfType().SingleOrDefault(x => x.Name == Config.DB_CATALOG); - - var user = database.Users.OfType().SingleOrDefault(x => x.Name == userName); - - if (user != null) - { - user.Drop(); - } - - Login login = _server.Logins.OfType().SingleOrDefault(x => x.Name == userName); - if (login != null) - { - login.Drop(); - } - } - - public string GetRandomString(int length) - { - const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - return "TEMP_" + new string(Enumerable.Repeat(chars, length).Select(s => s[random.Next(s.Length)]).ToArray()); - } - - public void Dispose() - { - _connection.Disconnect(); - } - } -} \ No newline at end of file diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj index c05cb5fe7..ca1376ff7 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj +++ b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj @@ -275,16 +275,10 @@ - + - - - - - - @@ -293,9 +287,6 @@ - - - @@ -346,6 +337,10 @@ {74e700b0-1156-4126-be40-ee450d3c3026} Tango.Transport + + {5001990f-977b-48ff-b217-0236a5022ad8} + Tango.Web + @@ -380,7 +375,7 @@ False - + diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Web.config b/Software/Visual_Studio/Web/Tango.MachineService/Web.config index ef2420349..77d9a1bb3 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Web.config +++ b/Software/Visual_Studio/Web/Tango.MachineService/Web.config @@ -13,15 +13,20 @@ - - - - - - - - - + + + + + + + + + + + + + + + + + MSDeploy + /subscriptions/10c8aa60-3b15-4e0d-b412-6aeef90e5e91/resourceGroups/Tango/providers/Microsoft.Web/sites/machineservice/slots/MachineService-DEV + Tango + AzureWebSite + Debug + Any CPU + http://machineservice-machineservice-dev.azurewebsites.net + True + False + machineservice-machineservice-dev.scm.azurewebsites.net:443 + machineservice__MachineService-DEV + + True + False + WMSVC + True + $machineservice__MachineService-DEV + <_SavePWD>True + <_DestinationType>AzureWebSite + + \ No newline at end of file diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/MachineService - Web Deploy.pubxml b/Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/MachineService - Web Deploy.pubxml deleted file mode 100644 index 612e38bfb..000000000 --- a/Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/MachineService - Web Deploy.pubxml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - MSDeploy - /subscriptions/10c8aa60-3b15-4e0d-b412-6aeef90e5e91/resourceGroups/Tango/providers/Microsoft.Web/sites/MachineService - Tango - AzureWebSite - Debug - Any CPU - http://machineservice.azurewebsites.net - True - False - machineservice.scm.azurewebsites.net:443 - MachineService - - True - False - WMSVC - True - $MachineService - <_SavePWD>True - <_DestinationType>AzureWebSite - - \ No newline at end of file diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/Production.pubxml b/Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/Production.pubxml new file mode 100644 index 000000000..a611d5ffd --- /dev/null +++ b/Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/Production.pubxml @@ -0,0 +1,28 @@ + + + + + MSDeploy + /subscriptions/10c8aa60-3b15-4e0d-b412-6aeef90e5e91/resourceGroups/Tango/providers/Microsoft.Web/sites/MachineService + Tango + AzureWebSite + Release + Any CPU + https://machineservice.twine-srv.com + True + False + machineservice.scm.azurewebsites.net:443 + MachineService + + True + False + WMSVC + True + $MachineService + <_SavePWD>True + <_DestinationType>AzureWebSite + + \ No newline at end of file diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/Testing.pubxml b/Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/Testing.pubxml new file mode 100644 index 000000000..12e2de377 --- /dev/null +++ b/Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/Testing.pubxml @@ -0,0 +1,28 @@ + + + + + MSDeploy + /subscriptions/10c8aa60-3b15-4e0d-b412-6aeef90e5e91/resourceGroups/Tango/providers/Microsoft.Web/sites/machineservice/slots/MachineService-TEST + Tango + AzureWebSite + Release + Any CPU + http://machineservice-machineservice-test.azurewebsites.net + True + False + machineservice-machineservice-test.scm.azurewebsites.net:443 + machineservice__MachineService-TEST + + True + False + WMSVC + True + $machineservice__MachineService-TEST + <_SavePWD>True + <_DestinationType>AzureWebSite + + \ No newline at end of file diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj index ca1376ff7..63c8521da 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj +++ b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj @@ -346,7 +346,9 @@ - + + + diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Web.config b/Software/Visual_Studio/Web/Tango.MachineService/Web.config index 097943016..2d700244b 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Web.config +++ b/Software/Visual_Studio/Web/Tango.MachineService/Web.config @@ -27,6 +27,9 @@ + + +