blob: a46cab3c2649e622b97d7073b634a6f41c1b6002 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; bacusing System;
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
{
public class DownloadsController : Controller
{
[Authorize]
public ActionResult Index()
{
List<DownloadModel> downloads = new List<DownloadModel>();
using (ObservablesContext db = ObservablesContextHelper.CreateContext())
{
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())
{
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;
return View(model);
}
[Authorize]
public ActionResult Download(String blobName, DownloadModel.DownloadApp downloadApp)
{
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);
}
}
}
|