diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2018-11-01 18:31:01 +0200 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2018-11-01 18:31:01 +0200 |
| commit | 6cfa1584d682e3b92236fa34ebd8587332dcb70f (patch) | |
| tree | 68774d3c079360fa20eaeeab78f7e370bbb847b6 /Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs | |
| parent | 7fba72a44fa184c6c0bbbd0bd1b788863fe12cf0 (diff) | |
| parent | e8c0d909a7a1a1dcfc5620096a37205088ab727f (diff) | |
| download | Tango-6cfa1584d682e3b92236fa34ebd8587332dcb70f.tar.gz Tango-6cfa1584d682e3b92236fa34ebd8587332dcb70f.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs')
| -rw-r--r-- | Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs index 06c1a4a23..51cf6f96b 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs @@ -1,4 +1,5 @@ using Google.Protobuf; +using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Configuration; @@ -10,10 +11,13 @@ using System.Threading.Tasks; using System.Web.Hosting; using System.Web.Http; using Tango.BL; +using Tango.BL.Builders; +using Tango.BL.Entities; using Tango.Core.DB; using Tango.Core.Helpers; using Tango.Core.IO; using Tango.Logging; +using Tango.MachineService.Models; using Tango.PMR.Stubs; using Tango.PMR.Synchronization; using Tango.Synchronization.Local; @@ -86,13 +90,14 @@ namespace Tango.MachineService.Controllers String serial_number = request.SerialNumber; var machine = db.Machines.SingleOrDefault(x => x.SerialNumber == serial_number); - var machine_version = db.MachineVersions.SingleOrDefault(x => x.Guid == machine.MachineVersionGuid); if (machine == null) { - OnError(HttpStatusCode.NotFound, "The specified serial number could not be found."); + ThrowError(HttpStatusCode.NotFound, "The specified serial number could not be found."); } + var machine_version = db.MachineVersions.SingleOrDefault(x => x.Guid == machine.MachineVersionGuid); + var latest_machine_version = db.TangoVersions.Where(x => x.MachineVersionGuid == machine_version.Guid).ToList().OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault(); response.Version = latest_machine_version.Version; @@ -125,7 +130,7 @@ namespace Tango.MachineService.Controllers catch (Exception ex) { logManager.Log(ex); - OnError(HttpStatusCode.InternalServerError, ex.Message); + throw; } return response; @@ -274,8 +279,27 @@ namespace Tango.MachineService.Controllers return response; } + [HttpPost] + public Machine PersonTest(Person p) + { + using (var db = ObservablesContext.CreateDefault(GetLocalServerAddress())) + { + var machine = new MachineBuilder(db) + .Set(x => x.SerialNumber == "1111") + .WithOrganization() + .WithConfiguration().Build(); + + return machine; + } + } + #region Helpers + private void ThrowError(HttpStatusCode code, String message) + { + throw new WebApiException(code, message); + } + private void OnError(HttpStatusCode code, String message) { throw new HttpResponseException(Request.CreateErrorResponse(code, message)); |
