#34 Feature: Detailed Device Exporting

Many additional device properties are available to export. The previous
export configuration is remembered.
This commit is contained in:
Gary Sharp
2014-05-22 01:22:57 +10:00
parent 53ca13c7f4
commit 3fdb4f1053
54 changed files with 1750 additions and 397 deletions
+35 -2
View File
@@ -1,5 +1,6 @@
using Disco.BI.Extensions;
using Disco.Models.Repository;
using Disco.Models.Services.Devices.Exporting;
using Disco.Models.Services.Jobs.JobLists;
using Disco.Models.UI.Device;
using Disco.Services;
@@ -9,6 +10,8 @@ using Disco.Services.Plugins.Features.UIExtension;
using Disco.Services.Users;
using Disco.Services.Web;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web.Mvc;
@@ -37,10 +40,10 @@ namespace Disco.Web.Controllers
{
DefaultDeviceProfileId = Database.DiscoConfiguration.DeviceProfiles.DefaultAddDeviceOfflineDeviceProfileId
};
if (Authorization.Has(Claims.Device.Properties.DeviceBatch))
m.DeviceBatches = Database.DeviceBatches.ToList();
if (Authorization.Has(Claims.Device.Properties.DeviceProfile))
{
m.DeviceProfiles = Database.DeviceProfiles.ToList();
@@ -81,6 +84,36 @@ namespace Disco.Web.Controllers
}
#endregion
#region Export
[DiscoAuthorizeAny(Claims.Device.Actions.Export), HttpGet]
public virtual ActionResult Export(string DownloadId, DeviceExportTypes? ExportType, int? ExportTypeTargetId)
{
var m = new Models.Device.ExportModel()
{
Options = Database.DiscoConfiguration.Devices.LastExportOptions,
DeviceBatches = Database.DeviceBatches.OrderBy(db => db.Name).Select(db => new { Key = db.Id, Value = db.Name }).ToList().Select(i => new KeyValuePair<int, string>(i.Key, i.Value)),
DeviceModels = Database.DeviceModels.OrderBy(dm => dm.Description).Select(dm => new { Key = dm.Id, Value = dm.Description }).ToList().Select(i => new KeyValuePair<int, string>(i.Key, i.Value)),
DeviceProfiles = Database.DeviceProfiles.OrderBy(dp => dp.Name).Select(dp => new { Key = dp.Id, Value = dp.Name }).ToList().Select(i => new KeyValuePair<int, string>(i.Key, i.Value))
};
if (!string.IsNullOrWhiteSpace(DownloadId))
m.DownloadExportSessionId = DownloadId;
if (ExportType.HasValue && ExportTypeTargetId.HasValue)
{
m.Options.ExportType = ExportType.Value;
m.Options.ExportTypeTargetId = ExportTypeTargetId.Value;
}
// UI Extensions
UIExtensions.ExecuteExtensions<DeviceExportModel>(this.ControllerContext, m);
return View(m);
}
#endregion
#region Import/Export
[DiscoAuthorizeAny(Claims.Device.Actions.Import, Claims.Device.Actions.Export), HttpGet]
public virtual ActionResult ImportExport()