aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-09-05 17:28:54 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-09-05 17:28:54 +0300
commit5c330a1d78b9d6108544b94e756a6457f162a468 (patch)
tree305c0d6cc05c8f70b2e848f7536a31c54fa0ded3 /Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs
parent2dff0c785e0ac326d01337b5399a8ab5766e611e (diff)
downloadTango-5c330a1d78b9d6108544b94e756a6457f162a468.tar.gz
Tango-5c330a1d78b9d6108544b94e756a6457f162a468.zip
Added missing event type.
Working on PPC DB update..
Diffstat (limited to 'Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs')
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs46
1 files changed, 46 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs
index d713be97b..b817d5dcd 100644
--- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs
+++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs
@@ -221,7 +221,53 @@ namespace Tango.MachineService.Controllers
return response;
}
+ [HttpPost]
+ public UpdateDBResponse UpdateDB(UpdateDBRequest request)
+ {
+ UpdateDBResponse response = new UpdateDBResponse();
+
+ try
+ {
+ using (ObservablesContext db = ObservablesContext.CreateDefault(GetLocalServerAddress()))
+ {
+ db.Configuration.LazyLoadingEnabled = false;
+ String serial_number = request.SerialNumber;
+
+ var machine = db.Machines.SingleOrDefault(x => x.SerialNumber == serial_number);
+
+ if (machine == null)
+ {
+ OnError(HttpStatusCode.NotFound, "The specified serial number could not be found.");
+ }
+
+ DbCredentials credentials = new DbCredentials();
+
+ using (DbManager manager = DbManager.FromAddressAndName(GetDbAddress(), "Tango"))
+ {
+ credentials = manager.CreateRandomLoginAndUser("Tango");
+ Task.Delay(TimeSpan.FromMinutes(10)).ContinueWith((x) =>
+ {
+ using (DbManager m = DbManager.FromAddressAndName(GetDbAddress(), "Tango"))
+ {
+ m.DeleteLoginAndUser(credentials.UserName, "Tango");
+ }
+ });
+ }
+
+ response.DbAddress = GetDbAddress();
+ response.DbUserName = credentials.UserName;
+ response.DbPassword = credentials.Password;
+ }
+ }
+ catch (Exception ex)
+ {
+ OnError(HttpStatusCode.InternalServerError, ex.Message);
+ }
+
+ return response;
+ }
+
#region Helpers
private void OnError(HttpStatusCode code, String message)