From ccc6add5ea66565453283d7df0f6fbf2324b9264 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 18 Feb 2019 13:21:20 +0200 Subject: Refactored machine studio service. --- .../Web/CheckForUpdatesRequest.cs | 15 ++++++ .../Web/CheckForUpdatesResponse.cs | 21 ++++++++ .../Web/DownloadLatestVersionRequest.cs | 14 +++++ .../Web/DownloadLatestVersionResponse.cs | 16 ++++++ .../Web/IMachineStudioService.cs | 28 ++++++++++ .../Web/LatestVersionRequest.cs | 15 ++++++ .../Web/LatestVersionResponse.cs | 15 ++++++ .../Tango.MachineStudio.Common/Web/LoginRequest.cs | 16 ++++++ .../Web/LoginResponse.cs | 18 +++++++ .../Web/MachineStudioService.cs | 60 ++++++++++++++++++++++ .../Web/UploadCompletedRequest.cs | 15 ++++++ .../Web/UploadCompletedResponse.cs | 14 +++++ .../Web/UploadVersionRequest.cs | 17 ++++++ .../Web/UploadVersionResponse.cs | 17 ++++++ 14 files changed, 281 insertions(+) create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/CheckForUpdatesRequest.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/CheckForUpdatesResponse.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/DownloadLatestVersionRequest.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/DownloadLatestVersionResponse.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/IMachineStudioService.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/LatestVersionRequest.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/LatestVersionResponse.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/LoginRequest.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/LoginResponse.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/MachineStudioService.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/UploadCompletedRequest.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/UploadCompletedResponse.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/UploadVersionRequest.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/UploadVersionResponse.cs (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/CheckForUpdatesRequest.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/CheckForUpdatesRequest.cs new file mode 100644 index 000000000..4f9576f50 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/CheckForUpdatesRequest.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.Web +{ + public class CheckForUpdatesRequest : WebRequestSecureMessage + { + public String Version { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/CheckForUpdatesResponse.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/CheckForUpdatesResponse.cs new file mode 100644 index 000000000..51608e6c4 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/CheckForUpdatesResponse.cs @@ -0,0 +1,21 @@ +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.Web +{ + public class CheckForUpdatesResponse : WebResponseMessage + { + public bool IsUpdateAvailable { get; set; } + + public String Version { get; set; } + + public String Comments { get; set; } + + public String BlobAddress { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/DownloadLatestVersionRequest.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/DownloadLatestVersionRequest.cs new file mode 100644 index 000000000..d63654726 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/DownloadLatestVersionRequest.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.Web +{ + public class DownloadLatestVersionRequest : WebRequestSecureMessage + { + + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/DownloadLatestVersionResponse.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/DownloadLatestVersionResponse.cs new file mode 100644 index 000000000..3209b9a2f --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/DownloadLatestVersionResponse.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.MachineStudio.Common.Web +{ + public class DownloadLatestVersionResponse : WebResponseMessage + { + public String Version { get; set; } + + public String BlobAddress { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/IMachineStudioService.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/IMachineStudioService.cs new file mode 100644 index 000000000..748df4644 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/IMachineStudioService.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.ServiceModel; +using System.Text; +using System.Threading.Tasks; +using Tango.Web; + +namespace Tango.MachineStudio.Common.Web +{ + public interface IMachineStudioService + { + DeploymentSlot Environment { get; set; } + + Task CheckForUpdates(CheckForUpdatesRequest request); + + Task DownloadLatestVersion(DownloadLatestVersionRequest request); + + Task UploadVersion(UploadVersionRequest request); + + Task NotifyUploadCompleted(UploadCompletedRequest request); + + Task GetLatestVersion(LatestVersionRequest request); + + Task Login(LoginRequest request); + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/LatestVersionRequest.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/LatestVersionRequest.cs new file mode 100644 index 000000000..59bb71db4 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/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.Web +{ + public class LatestVersionRequest : WebRequestMessage + { + + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/LatestVersionResponse.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/LatestVersionResponse.cs new file mode 100644 index 000000000..7d43128f1 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/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.Web +{ + public class LatestVersionResponse : WebResponseMessage + { + public String Version { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/LoginRequest.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/LoginRequest.cs new file mode 100644 index 000000000..577f5e208 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/LoginRequest.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.MachineStudio.Common.Web +{ + public class LoginRequest : WebRequestMessage + { + public String Version { get; set; } + public String Email { get; set; } + public String Password { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/LoginResponse.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/LoginResponse.cs new file mode 100644 index 000000000..0379c458b --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/LoginResponse.cs @@ -0,0 +1,18 @@ +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.Web +{ + public class LoginResponse : WebResponseMessage + { + public DataSource DataSource { get; set; } + public String Token { get; set; } + public bool VersionChangeRequired { get; set; } + public String RequiredVersion { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/MachineStudioService.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/MachineStudioService.cs new file mode 100644 index 000000000..8b43146e1 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/MachineStudioService.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.MachineStudio.Common.Authentication; +using Tango.Settings; +using Tango.Transport.Web; +using Tango.Web; + +namespace Tango.MachineStudio.Common.Web +{ + public class MachineStudioService : IMachineStudioService + { + private WebTransportClient _client; + + public DeploymentSlot Environment { get; set; } + + public MachineStudioService() + { + Environment = SettingsManager.Default.GetOrCreate().DeploymentSlot; + _client = new WebTransportClient(); + } + + public Task CheckForUpdates(CheckForUpdatesRequest request) + { + return _client.PostJson(GetAddress() + "CheckForUpdates", request); + } + + public Task UploadVersion(UploadVersionRequest request) + { + return _client.PostJson(GetAddress() + "UploadVersion", request); + } + + public Task NotifyUploadCompleted(UploadCompletedRequest request) + { + return _client.PostJson(GetAddress() + "NotifyUploadCompleted", request); + } + + public Task GetLatestVersion(LatestVersionRequest request) + { + return _client.PostJson(GetAddress() + "GetLatestVersion", request); + } + + public Task DownloadLatestVersion(DownloadLatestVersionRequest request) + { + return _client.PostJson(GetAddress() + "DownloadLatestVersion", request); + } + + public Task Login(LoginRequest request) + { + return _client.PostJson(GetAddress() + "Login", request); + } + + private String GetAddress() + { + return Environment.ToAddress() + "/api/MachineStudio/"; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/UploadCompletedRequest.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/UploadCompletedRequest.cs new file mode 100644 index 000000000..48f5b2a6e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/UploadCompletedRequest.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.Web +{ + public class UploadCompletedRequest : WebRequestSecureMessage + { + public String Token { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/UploadCompletedResponse.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/UploadCompletedResponse.cs new file mode 100644 index 000000000..a290cf642 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/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.Web +{ + public class UploadCompletedResponse : WebResponseMessage + { + + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/UploadVersionRequest.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/UploadVersionRequest.cs new file mode 100644 index 000000000..33577deb2 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/UploadVersionRequest.cs @@ -0,0 +1,17 @@ +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.Web +{ + public class UploadVersionRequest : WebRequestSecureMessage + { + public String Version { get; set; } + + public String Comments { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/UploadVersionResponse.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/UploadVersionResponse.cs new file mode 100644 index 000000000..9fb3ab94d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/UploadVersionResponse.cs @@ -0,0 +1,17 @@ +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.Web +{ + public class UploadVersionResponse : WebResponseMessage + { + public String Token { get; set; } + + public String BlobAddress { get; set; } + } +} -- cgit v1.3.1