aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2018-08-13 15:22:25 +0300
committerAvi Levkovich <avi@twine-s.com>2018-08-13 15:22:25 +0300
commitfe8111ccce920b73b47b6af657f1ee4bcac11120 (patch)
tree1f7226ee6bae6572e498ad4ec704cad0e45efa1c /Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs
parent7073aec25282e6a5a7f1171c3f56d0c57f440fb5 (diff)
parent67b80be819c29407dc07f80a7f61e5da2995ba93 (diff)
downloadTango-fe8111ccce920b73b47b6af657f1ee4bcac11120.tar.gz
Tango-fe8111ccce920b73b47b6af657f1ee4bcac11120.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/_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.cs33
1 files changed, 26 insertions, 7 deletions
diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs
index c377afb97..8054aae8c 100644
--- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs
+++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs
@@ -10,6 +10,7 @@ using System.Threading.Tasks;
using System.Web.Hosting;
using System.Web.Http;
using Tango.BL;
+using Tango.Core.DB;
using Tango.Core.Helpers;
using Tango.Core.IO;
using Tango.PMR.Stubs;
@@ -90,12 +91,30 @@ namespace Tango.MachineService.Controllers
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;
- response.FilePath = latest_machine_version.FtpFilePath;
- response.DbAddress = GetRemoteServerAddress();
response.FtpAddress = GetFtpAddress();
- response.UserName = GetFtpUserName();
- response.Password = GetFtpPassword();
+ response.FtpFilePath = latest_machine_version.FtpFilePath;
+ response.FtpUserName = GetFtpUserName();
+ response.FtpPassword = GetFtpPassword();
+
+ 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)
@@ -118,9 +137,9 @@ namespace Tango.MachineService.Controllers
return ConfigurationManager.AppSettings["LocalServerAddress"].ToString();
}
- private String GetRemoteServerAddress()
+ private String GetDbAddress()
{
- return ConfigurationManager.AppSettings["RemoteServerAddress"].ToString();
+ return ConfigurationManager.AppSettings["DbAddress"].ToString();
}
private String GetFtpAddress()
@@ -136,7 +155,7 @@ namespace Tango.MachineService.Controllers
private String GetFtpPassword()
{
return ConfigurationManager.AppSettings["FtpPassword"].ToString();
- }
+ }
#endregion
}