aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Managers/ViewsManager.cs
blob: e136c5983cb529ec7ffe1382e9162984677b6583 (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
43
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using Tango.Core.Commands;
using Tango.MachineStudio.DB.CustomAttributes;
using Tango.MachineStudio.DB.Views.DBViews;

namespace Tango.MachineStudio.DB.Managers
{
    /// <summary>
    /// Represents the data table views manager.
    /// </summary>
    public static class ViewsManager
    {
        /// <summary>
        /// Gets or sets the displayed views.
        /// </summary>
        public static ObservableCollection<RegisteredView> DisplayedViews { get; set; }

        /// <summary>
        /// Gets or sets all the views.
        /// </summary>
        public static ObservableCollection<RegisteredView> DbViews { get; set; }

        /// <summary>
        /// Initializes the <see cref="ViewsManager"/> class.
        /// </summary>
        static ViewsManager()
        {
            DisplayedViews = new ObservableCollection<RegisteredView>();
            DbViews = new ObservableCollection<RegisteredView>();

            foreach (var type in typeof(ViewsManager).Assembly.GetTypes().Where(x => x.CustomAttributes.Count() > 0 && x.CustomAttributes.First().AttributeType == typeof(DBViewAttribute)).OrderBy(x => x.Name))
            {
                DbViews.Add(new RegisteredView(type.Name.Replace("View", "").ToTitle(), Activator.CreateInstance(type) as FrameworkElement));
            }
        }
    }
}
.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); } } }