From d059f6d6f4de2678555f23a357d69686e595ad29 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 27 Feb 2019 18:56:38 +0200 Subject: Added machine service downloads site. --- .../Controllers/DownloadsController.cs | 67 ++++++++++++++++++---- 1 file changed, 57 insertions(+), 10 deletions(-) (limited to 'Software/Visual_Studio/Web/Tango.MachineService/Controllers') diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/DownloadsController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/DownloadsController.cs index ecdbf662c..a46cab3c2 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/DownloadsController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/DownloadsController.cs @@ -3,9 +3,19 @@ using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; +using Tango.BL; using Tango.MachineService.Filters; using Tango.MachineService.Models; using Tango.MachineService.Views.Downloads; +using Tango.Web.Helpers; +using System.Data.Entity; +using Tango.Web.Storage; +using System.IO; +using Microsoft.WindowsAzure.Storage.Blob; +using System.Net.Http; +using System.Net; +using System.Net.Http.Headers; +using System.Net.Mime; namespace Tango.MachineService.Controllers { @@ -15,18 +25,40 @@ namespace Tango.MachineService.Controllers public ActionResult Index() { List downloads = new List(); - for (int i = 0; i < 10; i++) + + using (ObservablesContext db = ObservablesContextHelper.CreateContext()) { - downloads.Add(new DownloadModel() + foreach (var item in db.MachineStudioVersions.Where(x => x.InstallerBlobName != null).Include(x => x.User).Include(x => x.User.Contact).ToList()) + { + DownloadModel download = new DownloadModel(); + download.App = DownloadModel.DownloadApp.MachineStudio; + download.ID = item.InstallerBlobName; + download.Name = $"Machine Studio v{item.Version}.exe"; + download.Version = item.Version; + download.User = item.User.Contact.FullName; + download.Date = item.LastUpdated; + download.Comments = item.Comments; + + downloads.Add(download); + } + + foreach (var item in db.TangoVersions.Where(x => x.InstallerBlobName != null).Include(x => x.User).Include(x => x.User.Contact).ToList()) { - Name = "Downloads " + i, - Comments = "Some comments...\nWith a new line", - Date = DateTime.Now.ToString(), - User = "Roy", - ID = i.ToString(), - }); + DownloadModel download = new DownloadModel(); + download.App = DownloadModel.DownloadApp.PPC; + download.ID = item.InstallerBlobName; + download.Name = $"PPC v{item.Version}.exe"; + download.Version = item.Version; + download.User = item.User.Contact.FullName; + download.Date = item.LastUpdated; + download.Comments = item.Comments; + + downloads.Add(download); + } } + downloads = downloads.OrderByDescending(x => x.Date).ToList(); + IndexViewModel model = new IndexViewModel(); model.Downloads = downloads; @@ -34,9 +66,24 @@ namespace Tango.MachineService.Controllers } [Authorize] - public ActionResult Download(String id) + public ActionResult Download(String blobName, DownloadModel.DownloadApp downloadApp) { - return File(new byte[] { 25, 255, 255 }, System.Net.Mime.MediaTypeNames.Application.Octet,"Machine Studio v1.0.exe"); + CloudBlobContainer container = null; + + var manager = new BlobStorageManager(); + + if (downloadApp == DownloadModel.DownloadApp.MachineStudio) + { + container = manager.GetContainer(MachineServiceConfig.MACHINE_STUDIO_VERSIONS_CONTAINER); + } + else + { + container = manager.GetContainer(MachineServiceConfig.TANGO_VERSIONS_CONTAINER); + } + + var blob = container.GetBlockBlobReference(blobName); + var signature = blob.GenerateReadSignature(TimeSpan.FromMinutes(10)); + return Redirect(signature); } } } \ No newline at end of file -- cgit v1.3.1 From 56b984bf7c4785cd0bcfd45a174ea802c6d0d471 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 4 Mar 2019 13:48:35 +0200 Subject: Fixed issue with machine service not including exception messages on azure. --- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 53673984 -> 53673984 bytes .../MachineService/PPC_Controller_TST.cs | 2 +- .../Visual_Studio/Tango.Web/TangoWebApplication.cs | 1 - .../Controllers/PPCController.cs | 1 - .../Web/Tango.MachineService/Global.asax.cs | 2 ++ .../Web/Tango.MachineService/Web.config | 10 ++++++++++ 7 files changed, 13 insertions(+), 3 deletions(-) (limited to 'Software/Visual_Studio/Web/Tango.MachineService/Controllers') diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index bac8a7680..d6f6f7df9 100644 Binary files a/Software/DB/PPC/Tango.mdf and b/Software/DB/PPC/Tango.mdf differ diff --git a/Software/DB/PPC/Tango_log.ldf b/Software/DB/PPC/Tango_log.ldf index fc15dcc93..0d66b5a3b 100644 Binary files a/Software/DB/PPC/Tango_log.ldf and b/Software/DB/PPC/Tango_log.ldf differ diff --git a/Software/Visual_Studio/Tango.UnitTesting/MachineService/PPC_Controller_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/MachineService/PPC_Controller_TST.cs index 7c3d497b8..68232e512 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/MachineService/PPC_Controller_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/MachineService/PPC_Controller_TST.cs @@ -13,7 +13,7 @@ namespace Tango.UnitTesting.MachineService [TestCategory("Machine Service - PPC")] public class PPC_Controller_TST { - private const string address = "http://localhost:51581"; + private const string address = "https://machineservice-test.twine-srv.com"; [TestMethod] public void Login_and_setup() diff --git a/Software/Visual_Studio/Tango.Web/TangoWebApplication.cs b/Software/Visual_Studio/Tango.Web/TangoWebApplication.cs index c9fea1678..f168fe9a4 100644 --- a/Software/Visual_Studio/Tango.Web/TangoWebApplication.cs +++ b/Software/Visual_Studio/Tango.Web/TangoWebApplication.cs @@ -26,7 +26,6 @@ namespace Tango.Web protected virtual void Application_Start() { LogManager.Default.RegisterLogger(new AzureCloudLogger()); - GlobalConfiguration.Configuration.Filters.Add(new LogExceptionFilterAttribute()); } diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs index a2016d4e0..a2c761824 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs @@ -65,7 +65,6 @@ namespace Tango.MachineService.Controllers using (ObservablesContext db = ObservablesContextHelper.CreateContext()) { - db.Configuration.LazyLoadingEnabled = false; String machine_guid = RequestToken.Object.MachineGuid; var machine = db.Machines.SingleOrDefault(x => x.Guid == machine_guid); diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Global.asax.cs b/Software/Visual_Studio/Web/Tango.MachineService/Global.asax.cs index 56561e4ce..07d1514eb 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Global.asax.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Global.asax.cs @@ -21,6 +21,8 @@ namespace Tango.MachineService FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); + + GlobalConfiguration.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; } } } diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Web.config b/Software/Visual_Studio/Web/Tango.MachineService/Web.config index 4a694f320..58a8c48af 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Web.config +++ b/Software/Visual_Studio/Web/Tango.MachineService/Web.config @@ -48,7 +48,17 @@ + + + + + + + + + + -- cgit v1.3.1