aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Web/Tango.MachineService/Controllers/FSEController.cs
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-04-11 05:02:18 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-04-11 05:02:18 +0300
commitbf5cbf5a6972cd8d725cc03fd6375b1eccbfe31c (patch)
tree0902fda382956c1b749cf856d2a4d950f0196190 /Software/Visual_Studio/Web/Tango.MachineService/Controllers/FSEController.cs
parentcb1b51c238c64f570d73b7dca6a2eee205b2da01 (diff)
downloadTango-bf5cbf5a6972cd8d725cc03fd6375b1eccbfe31c.tar.gz
Tango-bf5cbf5a6972cd8d725cc03fd6375b1eccbfe31c.zip
Started working on FSE TUP management.
Diffstat (limited to 'Software/Visual_Studio/Web/Tango.MachineService/Controllers/FSEController.cs')
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService/Controllers/FSEController.cs62
1 files changed, 62 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/FSEController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/FSEController.cs
index dccf2d24c..27d93f467 100644
--- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/FSEController.cs
+++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/FSEController.cs
@@ -4,17 +4,22 @@ using System.Linq;
using System.Net;
using System.Net.Http;
using System.Security.Authentication;
+using System.Threading.Tasks;
using System.Web.Http;
+using Tango.BL;
using Tango.BL.Builders;
using Tango.BL.Entities;
using Tango.Core;
using Tango.Core.Cryptography;
+using Tango.Core.DB;
using Tango.FSE.Web.Messages;
using Tango.MachineService.Filters;
using Tango.Web.Controllers;
using Tango.Web.Helpers;
using Tango.Web.Security;
+using Tango.Web.SMO;
using Tango.Web.SQLServer;
+using Tango.Web.Storage;
namespace Tango.MachineService.Controllers
{
@@ -117,5 +122,62 @@ namespace Tango.MachineService.Controllers
UserEmail = MachineServiceConfig.FSE_TFS_USER_EMAIL
};
}
+
+ [HttpPost]
+ [JwtTokenFilter]
+ public DownloadTangoVersionResponse DownloadTangoVersion(DownloadTangoVersionRequest request)
+ {
+ DownloadTangoVersionResponse response = new DownloadTangoVersionResponse();
+
+ using (ObservablesContext db = ObservablesContextHelper.CreateContext())
+ {
+ var tangoVersion = db.TangoVersions.SingleOrDefault(x => x.Guid == request.TangoVersionGuid);
+
+ if (tangoVersion == null)
+ {
+ throw new ArgumentException("Could not locate the specified Tango version.");
+ }
+
+ response.Version = tangoVersion.Version;
+
+ var manager = new BlobStorageManager();
+ var container = manager.GetContainer(MachineServiceConfig.TANGO_VERSIONS_CONTAINER);
+ var blob = container.GetBlockBlobReference(tangoVersion.BlobName);
+
+ response.BlobAddress = blob.GenerateReadSignature(TimeSpan.FromMinutes(60));
+
+ if (!String.IsNullOrWhiteSpace(MachineServiceConfig.CDN_ENDPOINT))
+ {
+ response.CdnAddress = MachineServiceConfig.CDN_ENDPOINT + blob.Uri.AbsolutePath;
+ }
+
+ DbCredentials credentials = new DbCredentials();
+
+ using (SmoManager smo = new SmoManager())
+ {
+ credentials = smo.CreateRandomLoginAndUser();
+
+ Task.Delay(TimeSpan.FromMinutes(PPCController.SQL_TEMP_CREDENTIALS_EXP_MINUTS)).ContinueWith((x) =>
+ {
+ using (SmoManager m = new SmoManager())
+ {
+ m.DeleteLoginAndUser(credentials.UserName);
+ }
+ });
+ }
+
+ response.DataSource = new DataSource()
+ {
+ Address = MachineServiceConfig.DB_ADDRESS,
+ Catalog = MachineServiceConfig.DB_CATALOG,
+ UserName = credentials.UserName,
+ Password = credentials.Password,
+ IntegratedSecurity = false,
+ Type = DataSourceType.SQLServer,
+ };
+ }
+
+ return response;
+ }
}
}