diff options
| author | Avi Levkovich <avi@twine-s.com> | 2020-04-21 14:21:19 +0300 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2020-04-21 14:21:19 +0300 |
| commit | cd728bf3a7d1db76747cb18bcfe396c83d690e86 (patch) | |
| tree | 99347262eef3f175a7ff1441b6c5a031be74d26f /Software/Visual_Studio/Web/Tango.MachineService | |
| parent | 7fe23e68512e2462de107e76ae3a92ddd381ac77 (diff) | |
| parent | 97a784b6ce43960bdb92465b08f26d3562a4f202 (diff) | |
| download | Tango-cd728bf3a7d1db76747cb18bcfe396c83d690e86.tar.gz Tango-cd728bf3a7d1db76747cb18bcfe396c83d690e86.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/Web/Tango.MachineService')
4 files changed, 83 insertions, 2 deletions
diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/FSEController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/FSEController.cs index 95a26d78e..27d93f467 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/FSEController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/FSEController.cs @@ -4,16 +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 { @@ -104,5 +110,74 @@ namespace Tango.MachineService.Controllers PasswordChangeRequired = user.PasswordChangeRequired }; } + + [HttpPost] + [JwtTokenFilter] + public BugReportingInfoResponse GetBugReportInfo(BugReportingInfoRequest request) + { + return new BugReportingInfoResponse() + { + CollectionUrl = MachineServiceConfig.FSE_TFS_COLLECTION_URL, + PersonalToken = MachineServiceConfig.FSE_TFS_PERSONAL_TOKEN, + 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; + } } } diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs index f508fea15..5f697f979 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs @@ -120,8 +120,6 @@ namespace Tango.MachineService.Controllers [JwtTokenFilter] public DownloadLatestVersionResponse DownloadLatestVersion(DownloadLatestVersionRequest request) { - LogManager.Log("Request received..."); - DownloadLatestVersionResponse response = new DownloadLatestVersionResponse(); using (ObservablesContext db = ObservablesContextHelper.CreateContext()) diff --git a/Software/Visual_Studio/Web/Tango.MachineService/MachineServiceConfig.cs b/Software/Visual_Studio/Web/Tango.MachineService/MachineServiceConfig.cs index 014ef68ba..f781dbb89 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/MachineServiceConfig.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/MachineServiceConfig.cs @@ -17,5 +17,9 @@ namespace Tango.MachineService public static String REFRESH_TOKENS_TABLE_PARTITION => ConfigurationManager.AppSettings[nameof(REFRESH_TOKENS_TABLE_PARTITION)].ToString(); public static bool USE_DB_ACCESS_TOKENS => bool.Parse(ConfigurationManager.AppSettings[nameof(USE_DB_ACCESS_TOKENS)].ToString()); public static String CDN_ENDPOINT => ConfigurationManager.AppSettings[nameof(CDN_ENDPOINT)].ToString(); + + public static String FSE_TFS_COLLECTION_URL => ConfigurationManager.AppSettings[nameof(FSE_TFS_COLLECTION_URL)].ToString(); + public static String FSE_TFS_PERSONAL_TOKEN => ConfigurationManager.AppSettings[nameof(FSE_TFS_PERSONAL_TOKEN)].ToString(); + public static String FSE_TFS_USER_EMAIL => ConfigurationManager.AppSettings[nameof(FSE_TFS_USER_EMAIL)].ToString(); } }
\ No newline at end of file diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Web.config b/Software/Visual_Studio/Web/Tango.MachineService/Web.config index 1da22f45b..2c6408e50 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Web.config +++ b/Software/Visual_Studio/Web/Tango.MachineService/Web.config @@ -31,6 +31,10 @@ <add key="REFRESH_TOKENS_TABLE_PARTITION" value="REFRESH_TOKENS_PART" /> <add key="USE_DB_ACCESS_TOKENS" value="false" /> <add key="CDN_ENDPOINT" value="https://tango.azureedge.net" /> + + <add key="FSE_TFS_COLLECTION_URL" value="https://twinetfs.visualstudio.com" /> + <add key="FSE_TFS_PERSONAL_TOKEN" value="szzfokrceo4rhd4eqi5qpmxn3pa5iwl3q7tlqd36l2m7smz2ynoa" /> + <add key="FSE_TFS_USER_EMAIL" value="fse@twine-s.com" /> </appSettings> <!-- For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367. |
