#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
-102
View File
@@ -1,102 +0,0 @@
using Disco.Models.BI.Device;
using Disco.Models.Repository;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.BI.DeviceBI.Importing
{
public static class Export
{
private const string ExportHeader = "Serial Number,Device Model,Device Profile,Device Batch,Assigned User,Location,Asset Number";
public static MemoryStream GenerateExport(IQueryable<Device> Devices)
{
var devices = Devices.Select(d => new ImportDevice()
{
SerialNumber = d.SerialNumber,
DeviceModelId = d.DeviceModelId,
DeviceProfileId = d.DeviceProfileId,
DeviceBatchId = d.DeviceBatchId,
AssignedUserId = d.AssignedUserId,
Location = d.Location,
AssetNumber = d.AssetNumber
});
MemoryStream exportStream = new MemoryStream();
StreamWriter exportWriter = new StreamWriter(exportStream);
// Write Header
exportWriter.WriteLine(ExportHeader);
foreach (var device in devices)
device.ExportCsv(exportWriter);
exportWriter.Flush();
exportStream.Position = 0;
return exportStream;
}
private static void ExportCsv(this ImportDevice device, StreamWriter writer)
{
// SERIAL NUMBER
writer.Write('"');
writer.Write(device.SerialNumber.Replace("\"", "\"\""));
writer.Write('"');
writer.Write(',');
// DEVICE MODEL
if (device.DeviceModelId.HasValue)
writer.Write(device.DeviceModelId.Value);
writer.Write(',');
// DEVICE PROFILE
writer.Write(device.DeviceProfileId);
writer.Write(',');
// DEVICE BATCH
if (device.DeviceBatchId.HasValue)
writer.Write(device.DeviceBatchId.Value);
writer.Write(',');
// ASSIGNED USER
if (device.AssignedUserId != null)
{
writer.Write('"');
writer.Write(device.AssignedUserId.Replace("\"", "\"\""));
writer.Write('"');
}
writer.Write(',');
// LOCATION
if (!string.IsNullOrWhiteSpace(device.Location))
{
writer.Write('"');
writer.Write(device.Location.Replace("\"", "\"\""));
writer.Write('"');
}
writer.Write(',');
// ASSET NUMBER
if (!string.IsNullOrWhiteSpace(device.AssetNumber))
{
writer.Write('"');
writer.Write(device.AssetNumber.Replace("\"", "\"\""));
writer.Write('"');
}
writer.WriteLine();
}
}
}
@@ -79,7 +79,7 @@ namespace Disco.BI.Extensions
return true; return true;
} }
public static void OnDecommission(this Device d, Disco.Models.Repository.Device.DecommissionReasons Reason) public static void OnDecommission(this Device d, Disco.Models.Repository.DecommissionReasons Reason)
{ {
if (!d.CanDecommission()) if (!d.CanDecommission())
throw new InvalidOperationException("Decommission of Device is Denied"); throw new InvalidOperationException("Decommission of Device is Denied");
@@ -10,13 +10,6 @@ namespace Disco.BI.Extensions
{ {
public static class DeviceDetailExtensions public static class DeviceDetailExtensions
{ {
#region Scope Declaration
public const string ScopeHardware = "Hardware";
#endregion
#region Helpers #region Helpers
private static string GetDetail(this IEnumerable<DeviceDetail> details, string Scope, string Key) private static string GetDetail(this IEnumerable<DeviceDetail> details, string Scope, string Key)
{ {
@@ -77,59 +70,56 @@ namespace Disco.BI.Extensions
#endregion #endregion
#region LanMacAddress #region LanMacAddress
public const string KeyLanMacAddress = "LanMacAddress";
/// <summary> /// <summary>
/// Gets the LanMacAddress Device Detail Value /// Gets the LanMacAddress Device Detail Value
/// </summary> /// </summary>
/// <returns>The LanMacAddress or null</returns> /// <returns>The LanMacAddress or null</returns>
public static string LanMacAddress(this IEnumerable<DeviceDetail> details) public static string LanMacAddress(this IEnumerable<DeviceDetail> details)
{ {
return details.GetDetail(ScopeHardware, KeyLanMacAddress); return details.GetDetail(DeviceDetail.ScopeHardware, DeviceDetail.HardwareKeyLanMacAddress);
} }
/// <summary> /// <summary>
/// Sets the LanMacAddress Device Detail Value /// Sets the LanMacAddress Device Detail Value
/// </summary> /// </summary>
public static void LanMacAddress(this IEnumerable<DeviceDetail> details, Device device, string LanMacAddress) public static void LanMacAddress(this IEnumerable<DeviceDetail> details, Device device, string LanMacAddress)
{ {
device.SetDetail(ScopeHardware, KeyLanMacAddress, LanMacAddress); device.SetDetail(DeviceDetail.ScopeHardware, DeviceDetail.HardwareKeyLanMacAddress, LanMacAddress);
} }
#endregion #endregion
#region WLanMacAddress #region WLanMacAddress
public const string KeyWLanMacAddress = "WLanMacAddress";
/// <summary> /// <summary>
/// Gets the WLanMacAddress Device Detail Value /// Gets the WLanMacAddress Device Detail Value
/// </summary> /// </summary>
/// <returns>The WLanMacAddress or null</returns> /// <returns>The WLanMacAddress or null</returns>
public static string WLanMacAddress(this IEnumerable<DeviceDetail> details) public static string WLanMacAddress(this IEnumerable<DeviceDetail> details)
{ {
return details.GetDetail(ScopeHardware, KeyWLanMacAddress); return details.GetDetail(DeviceDetail.ScopeHardware, DeviceDetail.HardwareKeyWLanMacAddress);
} }
/// <summary> /// <summary>
/// Sets the WLanMacAddress Device Detail Value /// Sets the WLanMacAddress Device Detail Value
/// </summary> /// </summary>
public static void WLanMacAddress(this IEnumerable<DeviceDetail> details, Device device, string WLanMacAddress) public static void WLanMacAddress(this IEnumerable<DeviceDetail> details, Device device, string WLanMacAddress)
{ {
device.SetDetail(ScopeHardware, KeyWLanMacAddress, WLanMacAddress); device.SetDetail(DeviceDetail.ScopeHardware, DeviceDetail.HardwareKeyWLanMacAddress, WLanMacAddress);
} }
#endregion #endregion
#region ACAdapter #region ACAdapter
public const string KeyACAdapter = "ACAdapter";
/// <summary> /// <summary>
/// Gets the ACAdapter Device Detail Value /// Gets the ACAdapter Device Detail Value
/// </summary> /// </summary>
/// <returns>The ACAdapter or null</returns> /// <returns>The ACAdapter or null</returns>
public static string ACAdapter(this IEnumerable<DeviceDetail> details) public static string ACAdapter(this IEnumerable<DeviceDetail> details)
{ {
return details.GetDetail(ScopeHardware, KeyACAdapter); return details.GetDetail(DeviceDetail.ScopeHardware, DeviceDetail.HardwareKeyACAdapter);
} }
/// <summary> /// <summary>
/// Sets the ACAdapter Device Detail Value /// Sets the ACAdapter Device Detail Value
/// </summary> /// </summary>
public static void ACAdapter(this IEnumerable<DeviceDetail> details, Device device, string ACAdapter) public static void ACAdapter(this IEnumerable<DeviceDetail> details, Device device, string ACAdapter)
{ {
device.SetDetail(ScopeHardware, KeyACAdapter, ACAdapter); device.SetDetail(DeviceDetail.ScopeHardware, DeviceDetail.HardwareKeyACAdapter, ACAdapter);
} }
#endregion #endregion
+8 -8
View File
@@ -200,28 +200,28 @@ namespace Disco.BI.Extensions
return null; return null;
} }
public static string ReasonMessage(this Disco.Models.Repository.Device.DecommissionReasons r) public static string ReasonMessage(this Disco.Models.Repository.DecommissionReasons r)
{ {
switch (r) switch (r)
{ {
case Device.DecommissionReasons.EndOfLife: case DecommissionReasons.EndOfLife:
return "End of Life"; return "End of Life";
case Device.DecommissionReasons.Sold: case DecommissionReasons.Sold:
return "Sold"; return "Sold";
case Device.DecommissionReasons.Stolen: case DecommissionReasons.Stolen:
return "Stolen"; return "Stolen";
case Device.DecommissionReasons.Lost: case DecommissionReasons.Lost:
return "Lost"; return "Lost";
case Device.DecommissionReasons.Damaged: case DecommissionReasons.Damaged:
return "Damaged"; return "Damaged";
case Device.DecommissionReasons.Donated: case DecommissionReasons.Donated:
return "Donated"; return "Donated";
default: default:
return "Unknown"; return "Unknown";
} }
} }
public static string ReasonMessage(this Disco.Models.Repository.Device.DecommissionReasons? r) public static string ReasonMessage(this Disco.Models.Repository.DecommissionReasons? r)
{ {
if (!r.HasValue) if (!r.HasValue)
return "Not Decommissioned"; return "Not Decommissioned";
-1
View File
@@ -124,7 +124,6 @@
<Compile Include="BI\AttachmentBI\Utilities.cs" /> <Compile Include="BI\AttachmentBI\Utilities.cs" />
<Compile Include="BI\DeviceBI\BatchUtilities.cs" /> <Compile Include="BI\DeviceBI\BatchUtilities.cs" />
<Compile Include="BI\DeviceBI\DeviceModelBI.cs" /> <Compile Include="BI\DeviceBI\DeviceModelBI.cs" />
<Compile Include="BI\DeviceBI\Importing\Export.cs" />
<Compile Include="BI\DeviceBI\Importing\Import.cs" /> <Compile Include="BI\DeviceBI\Importing\Import.cs" />
<Compile Include="BI\DeviceBI\Importing\ImportParseTask.cs" /> <Compile Include="BI\DeviceBI\Importing\ImportParseTask.cs" />
<Compile Include="BI\DeviceBI\Importing\ImportProcessTask.cs" /> <Compile Include="BI\DeviceBI\Importing\ImportProcessTask.cs" />
@@ -0,0 +1,18 @@
using Disco.Data.Repository;
using Disco.Models.Services.Devices.Exporting;
namespace Disco.Data.Configuration.Modules
{
public class DevicesConfiguration : ConfigurationBase
{
public DevicesConfiguration(DiscoDataContext Database) : base(Database) { }
public override string Scope { get { return "Devices"; } }
public DeviceExportOptions LastExportOptions
{
get { return this.Get<DeviceExportOptions>(DeviceExportOptions.DefaultOptions()); }
set { this.Set(value); }
}
}
}
@@ -16,6 +16,7 @@ namespace Disco.Data.Configuration
this.moduleOrganisationAddressesConfiguration = new Lazy<Modules.OrganisationAddressesConfiguration>(() => new Modules.OrganisationAddressesConfiguration(Database)); this.moduleOrganisationAddressesConfiguration = new Lazy<Modules.OrganisationAddressesConfiguration>(() => new Modules.OrganisationAddressesConfiguration(Database));
this.moduleJobPreferencesConfiguration = new Lazy<Modules.JobPreferencesConfiguration>(() => new Modules.JobPreferencesConfiguration(Database)); this.moduleJobPreferencesConfiguration = new Lazy<Modules.JobPreferencesConfiguration>(() => new Modules.JobPreferencesConfiguration(Database));
this.moduleActiveDirectoryConfiguration = new Lazy<Modules.ActiveDirectoryConfiguration>(() => new Modules.ActiveDirectoryConfiguration(Database)); this.moduleActiveDirectoryConfiguration = new Lazy<Modules.ActiveDirectoryConfiguration>(() => new Modules.ActiveDirectoryConfiguration(Database));
this.moduleDevicesConfiguration = new Lazy<Modules.DevicesConfiguration>(() => new Modules.DevicesConfiguration(Database));
} }
#region Configuration Modules #region Configuration Modules
@@ -25,6 +26,7 @@ namespace Disco.Data.Configuration
private Lazy<Modules.OrganisationAddressesConfiguration> moduleOrganisationAddressesConfiguration; private Lazy<Modules.OrganisationAddressesConfiguration> moduleOrganisationAddressesConfiguration;
private Lazy<Modules.JobPreferencesConfiguration> moduleJobPreferencesConfiguration; private Lazy<Modules.JobPreferencesConfiguration> moduleJobPreferencesConfiguration;
private Lazy<Modules.ActiveDirectoryConfiguration> moduleActiveDirectoryConfiguration; private Lazy<Modules.ActiveDirectoryConfiguration> moduleActiveDirectoryConfiguration;
private Lazy<Modules.DevicesConfiguration> moduleDevicesConfiguration;
public Modules.BootstrapperConfiguration Bootstrapper public Modules.BootstrapperConfiguration Bootstrapper
{ {
@@ -61,6 +63,13 @@ namespace Disco.Data.Configuration
return moduleActiveDirectoryConfiguration.Value; return moduleActiveDirectoryConfiguration.Value;
} }
} }
public Modules.DevicesConfiguration Devices
{
get
{
return moduleDevicesConfiguration.Value;
}
}
#endregion #endregion
+1
View File
@@ -74,6 +74,7 @@
<Compile Include="Configuration\ConfigurationBase.cs" /> <Compile Include="Configuration\ConfigurationBase.cs" />
<Compile Include="Configuration\ConfigurationCache.cs" /> <Compile Include="Configuration\ConfigurationCache.cs" />
<Compile Include="Configuration\Modules\ActiveDirectoryConfiguration.cs" /> <Compile Include="Configuration\Modules\ActiveDirectoryConfiguration.cs" />
<Compile Include="Configuration\Modules\DevicesConfiguration.cs" />
<Compile Include="Configuration\Modules\JobPreferencesConfiguration.cs" /> <Compile Include="Configuration\Modules\JobPreferencesConfiguration.cs" />
<Compile Include="Configuration\SystemConfiguration.cs" /> <Compile Include="Configuration\SystemConfiguration.cs" />
<Compile Include="Configuration\Modules\BootstrapperConfiguration.cs" /> <Compile Include="Configuration\Modules\BootstrapperConfiguration.cs" />
+6 -1
View File
@@ -46,6 +46,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="BI\Job\LocationModes.cs" /> <Compile Include="BI\Job\LocationModes.cs" />
<Compile Include="Repository\Device\DeviceDecommissionReasons.cs" />
<Compile Include="Services\Authorization\IAuthorizationToken.cs" /> <Compile Include="Services\Authorization\IAuthorizationToken.cs" />
<Compile Include="Services\Authorization\IClaimNavigatorItem.cs" /> <Compile Include="Services\Authorization\IClaimNavigatorItem.cs" />
<Compile Include="Services\Authorization\IRoleToken.cs" /> <Compile Include="Services\Authorization\IRoleToken.cs" />
@@ -100,6 +101,9 @@
<Compile Include="Repository\User\UserAttachment.cs" /> <Compile Include="Repository\User\UserAttachment.cs" />
<Compile Include="Repository\User\UserDetail.cs" /> <Compile Include="Repository\User\UserDetail.cs" />
<Compile Include="Repository\User\AuthorizationRole.cs" /> <Compile Include="Repository\User\AuthorizationRole.cs" />
<Compile Include="Services\Devices\Exporting\DeviceExportRecord.cs" />
<Compile Include="Services\Devices\Exporting\DeviceExportTypes.cs" />
<Compile Include="Services\Devices\Exporting\DeviceExportOptions.cs" />
<Compile Include="Services\Jobs\JobLists\JobLocationReference.cs" /> <Compile Include="Services\Jobs\JobLists\JobLocationReference.cs" />
<Compile Include="Services\Jobs\JobLists\JobTableItemModel.cs" /> <Compile Include="Services\Jobs\JobLists\JobTableItemModel.cs" />
<Compile Include="Services\Jobs\JobLists\JobTableModel.cs" /> <Compile Include="Services\Jobs\JobLists\JobTableModel.cs" />
@@ -145,6 +149,7 @@
<Compile Include="UI\Config\Logging\ConfigLoggingTaskStatusModel.cs" /> <Compile Include="UI\Config\Logging\ConfigLoggingTaskStatusModel.cs" />
<Compile Include="UI\Config\Organisation\ConfigOrganisationIndexModel.cs" /> <Compile Include="UI\Config\Organisation\ConfigOrganisationIndexModel.cs" />
<Compile Include="UI\Device\DeviceAddOfflineModel.cs" /> <Compile Include="UI\Device\DeviceAddOfflineModel.cs" />
<Compile Include="UI\Device\DeviceExportModel.cs" />
<Compile Include="UI\Device\DeviceImportModel.cs" /> <Compile Include="UI\Device\DeviceImportModel.cs" />
<Compile Include="UI\Device\DeviceImportReviewModel.cs" /> <Compile Include="UI\Device\DeviceImportReviewModel.cs" />
<Compile Include="UI\Device\DeviceIndexModel.cs" /> <Compile Include="UI\Device\DeviceIndexModel.cs" />
@@ -164,7 +169,7 @@
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ProjectExtensions> <ProjectExtensions>
<VisualStudio> <VisualStudio>
<UserProperties BuildVersion_BuildAction="Both" BuildVersion_UseGlobalSettings="False" BuildVersion_DetectChanges="False" BuildVersion_StartDate="2011/7/1" BuildVersion_BuildVersioningStyle="None.DeltaBaseYear.MonthAndDayStamp.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_UpdateFileVersion="True" /> <UserProperties BuildVersion_UpdateFileVersion="True" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.DeltaBaseYear.MonthAndDayStamp.TimeStamp" BuildVersion_StartDate="2011/7/1" BuildVersion_DetectChanges="False" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildAction="Both" />
</VisualStudio> </VisualStudio>
</ProjectExtensions> </ProjectExtensions>
<PropertyGroup> <PropertyGroup>
+1 -18
View File
@@ -27,16 +27,8 @@ namespace Disco.Models.Repository
public string AssignedUserId { get; set; } public string AssignedUserId { get; set; }
public DateTime? LastNetworkLogonDate { get; set; } public DateTime? LastNetworkLogonDate { get; set; }
// 2012-06-21 - Removed
//[StringLength(24)]
//public string CertificateStoreReference { get; set; }
public bool AllowUnauthenticatedEnrol { get; set; } public bool AllowUnauthenticatedEnrol { get; set; }
// Removed 2013-02-21 G#: Redundant - See DecommissionedDate
//public bool Active { get; set; }
// End Removed 2013-02-21
public DateTime CreatedDate { get; set; } public DateTime CreatedDate { get; set; }
public DateTime? EnrolledDate { get; set; } public DateTime? EnrolledDate { get; set; }
public DateTime? LastEnrolDate { get; set; } public DateTime? LastEnrolDate { get; set; }
@@ -55,6 +47,7 @@ namespace Disco.Models.Repository
public virtual IList<DeviceUserAssignment> DeviceUserAssignments { get; set; } public virtual IList<DeviceUserAssignment> DeviceUserAssignments { get; set; }
public virtual IList<DeviceDetail> DeviceDetails { get; set; } public virtual IList<DeviceDetail> DeviceDetails { get; set; }
public virtual IList<DeviceAttachment> DeviceAttachments { get; set; } public virtual IList<DeviceAttachment> DeviceAttachments { get; set; }
public virtual IList<DeviceCertificate> DeviceCertificates { get; set; }
[InverseProperty("DeviceSerialNumber")] [InverseProperty("DeviceSerialNumber")]
public virtual IList<Job> Jobs { get; set; } public virtual IList<Job> Jobs { get; set; }
@@ -92,15 +85,5 @@ namespace Disco.Models.Repository
return index < 0 ? null : DeviceDomainId.Substring(0, index); return index < 0 ? null : DeviceDomainId.Substring(0, index);
} }
} }
public enum DecommissionReasons
{
EndOfLife = 0,
Sold = 10,
Stolen = 20,
Lost = 30,
Damaged = 40,
Donated = 50
}
} }
} }
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.Repository
{
public enum DecommissionReasons
{
EndOfLife = 0,
Sold = 10,
Stolen = 20,
Lost = 30,
Damaged = 40,
Donated = 50
}
}
@@ -9,6 +9,12 @@ namespace Disco.Models.Repository
{ {
public class DeviceDetail public class DeviceDetail
{ {
public const string ScopeHardware = "Hardware";
public const string HardwareKeyLanMacAddress = "LanMacAddress";
public const string HardwareKeyWLanMacAddress = "WLanMacAddress";
public const string HardwareKeyACAdapter = "ACAdapter";
[Column(Order = 0), Key] [Column(Order = 0), Key]
public string DeviceSerialNumber { get; set; } public string DeviceSerialNumber { get; set; }
@@ -0,0 +1,137 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.Services.Devices.Exporting
{
public class DeviceExportOptions
{
public DeviceExportTypes ExportType { get; set; }
public int? ExportTypeTargetId { get; set; }
// Device
[Display(ShortName = "Device", Name = "Serial Number", Description = "The device serial number")]
public bool DeviceSerialNumber { get; set; }
[Display(ShortName = "Device", Name = "Asset Number", Description = "The device asset number")]
public bool DeviceAssetNumber { get; set; }
[Display(ShortName = "Device", Name = "Location", Description = "The device location")]
public bool DeviceLocation { get; set; }
[Display(ShortName = "Device", Name = "Computer Name", Description = "The device computer name")]
public bool DeviceComputerName { get; set; }
[Display(ShortName = "Device", Name = "Last Network Logon", Description = "The last recorded time the device access the network")]
public bool DeviceLastNetworkLogon { get; set; }
[Display(ShortName = "Device", Name = "Created Date", Description = "The date the device was created in Disco")]
public bool DeviceCreatedDate { get; set; }
[Display(ShortName = "Device", Name = "First Enrolled Date", Description = "The date the device was first enrolled in Disco")]
public bool DeviceFirstEnrolledDate { get; set; }
[Display(ShortName = "Device", Name = "Last Enrolled Date", Description = "The date the device was last enrolled in Disco")]
public bool DeviceLastEnrolledDate { get; set; }
[Display(ShortName = "Device", Name = "Decommissioned Date", Description = "The date the device was decommissioned in Disco")]
public bool DeviceDecommissionedDate { get; set; }
[Display(ShortName = "Device", Name = "Decommissioned Reason", Description = "The reason the device was decommissioned")]
public bool DeviceDecommissionedReason { get; set; }
// Details
[Display(ShortName = "Details", Name = "LAN MAC Address", Description = "The LAN MAC Address associated with the device")]
public bool DetailLanMacAddress { get; set; }
[Display(ShortName = "Details", Name = "Wireless LAN MAC Address", Description = "The Wireless LAN MAC Address associated with the device")]
public bool DetailWLanMacAddress { get; set; }
[Display(ShortName = "Details", Name = "AC Adapter", Description = "The AC Adapter associated with the device")]
public bool DetailACAdapter { get; set; }
// Model
[Display(ShortName = "Model", Name = "Identifier", Description = "The identifier of the device model associated with the device")]
public bool ModelId { get; set; }
[Display(ShortName = "Model", Name = "Description", Description = "The description of the device model associated with the device")]
public bool ModelDescription { get; set; }
[Display(ShortName = "Model", Name = "Manufacturer", Description = "The manufacturer of the device model associated with the device")]
public bool ModelManufacturer { get; set; }
[Display(ShortName = "Model", Name = "Model", Description = "The model of the device model associated with the device")]
public bool ModelModel { get; set; }
[Display(ShortName = "Model", Name = "Type", Description = "The type of device model associated with the device")]
public bool ModelType { get; set; }
// Batch
[Display(ShortName = "Batch", Name = "Identifier", Description = "The identifier of the device batch associated with the device")]
public bool BatchId { get; set; }
[Display(ShortName = "Batch", Name = "Name", Description = "The name of the device batch associated with the device")]
public bool BatchName { get; set; }
[Display(ShortName = "Batch", Name = "Purchase Date", Description = "The purchase date of the device batch associated with the device")]
public bool BatchPurchaseDate { get; set; }
[Display(ShortName = "Batch", Name = "Supplier", Description = "The supplier of the device batch associated with the device")]
public bool BatchSupplier { get; set; }
[Display(ShortName = "Batch", Name = "Unit Cost", Description = "The unit cost of the device batch associated with the device")]
public bool BatchUnitCost { get; set; }
[Display(ShortName = "Batch", Name = "Warranty Valid Until Date", Description = "The warranty valid until date of the device batch associated with the device")]
public bool BatchWarrantyValidUntilDate { get; set; }
[Display(ShortName = "Batch", Name = "Insured Date", Description = "The insured date of the device batch associated with the device")]
public bool BatchInsuredDate { get; set; }
[Display(ShortName = "Batch", Name = "Insurance Supplier", Description = "The insurance supplier of the device batch associated with the device")]
public bool BatchInsuranceSupplier { get; set; }
[Display(ShortName = "Batch", Name = "Insured Until Date", Description = "The insured until date of the device batch associated with the device")]
public bool BatchInsuredUntilDate { get; set; }
// Profile
[Display(ShortName = "Profile", Name = "Identifier", Description = "The identifier of the device profile associated with the device")]
public bool ProfileId { get; set; }
[Display(ShortName = "Profile", Name = "Name", Description = "The name of the device profile associated with the device")]
public bool ProfileName { get; set; }
[Display(ShortName = "Profile", Name = "Short Name", Description = "The short name of the device profile associated with the device")]
public bool ProfileShortName { get; set; }
// User
[Display(ShortName = "Assigned User", Name = "Identifier", Description = "The identifier of the user assigned with the device")]
public bool AssignedUserId { get; set; }
[Display(ShortName = "Assigned User", Name = "Assigned Date", Description = "The date the device was assigned to the user")]
public bool AssignedUserDate { get; set; }
[Display(ShortName = "Assigned User", Name = "Display Name", Description = "The display name of the user assigned with the device")]
public bool AssignedUserDisplayName { get; set; }
[Display(ShortName = "Assigned User", Name = "Surname", Description = "The surname of the user assigned with the device")]
public bool AssignedUserSurname { get; set; }
[Display(ShortName = "Assigned User", Name = "Given Name", Description = "The given name of the user assigned with the device")]
public bool AssignedUserGivenName { get; set; }
[Display(ShortName = "Assigned User", Name = "Phone Number", Description = "The phone number of the user assigned with the device")]
public bool AssignedUserPhoneNumber { get; set; }
[Display(ShortName = "Assigned User", Name = "Email Address", Description = "The email address of the user assigned with the device")]
public bool AssignedUserEmailAddress { get; set; }
// Jobs
[Display(ShortName = "Jobs", Name = "Count", Description = "The total number of jobs associated with the device")]
public bool JobsTotalCount { get; set; }
[Display(ShortName = "Jobs", Name = "Count Open", Description = "The total number of open jobs associated with the device")]
public bool JobsOpenCount { get; set; }
// Attachments
[Display(ShortName = "Attachments", Name = "Count", Description = "The number of attachments associated with the device")]
public bool AttachmentsCount { get; set; }
// Certificates
[Display(ShortName = "Certificates", Name = "Name", Description = "The name of the most recently assigned active certificate associated with the device")]
public bool CertificateName { get; set; }
[Display(ShortName = "Certificates", Name = "Allocated Date", Description = "The allocated date of the most recently assigned active certificate associated with the device")]
public bool CertificateAllocatedDate { get; set; }
[Display(ShortName = "Certificates", Name = "Expiration Date", Description = "The expiration date of the most recently assigned active certificate associated with the device")]
public bool CertificateExpirationDate { get; set; }
[Display(ShortName = "Certificates", Name = "Provider Id", Description = "The provider identifier of the most recently assigned active certificate associated with the device")]
public bool CertificateProviderId { get; set; }
public static DeviceExportOptions DefaultOptions()
{
return new DeviceExportOptions()
{
ExportType = DeviceExportTypes.All,
DeviceSerialNumber = true,
ModelId = true,
ProfileId = true,
BatchId = true,
AssignedUserId = true,
DeviceLocation = true,
DeviceAssetNumber = true
};
}
}
}
@@ -0,0 +1,51 @@
using Disco.Models.Repository;
using System;
using System.Collections.Generic;
namespace Disco.Models.Services.Devices.Exporting
{
public class DeviceExportRecord
{
public Device Device { get; set; }
// Details
public IEnumerable<DeviceDetail> DeviceDetails { get; set; }
// Model
public int? ModelId { get; set; }
public string ModelDescription { get; set; }
public string ModelManufacturer { get; set; }
public string ModelModel { get; set; }
public string ModelType { get; set; }
// Batch
public int? BatchId { get; set; }
public string BatchName { get; set; }
public DateTime? BatchPurchaseDate { get; set; }
public string BatchSupplier { get; set; }
public decimal? BatchUnitCost { get; set; }
public DateTime? BatchWarrantyValidUntilDate { get; set; }
public DateTime? BatchInsuredDate { get; set; }
public string BatchInsuranceSupplier { get; set; }
public DateTime? BatchInsuredUntilDate { get; set; }
// Profile
public int ProfileId { get; set; }
public string ProfileName { get; set; }
public string ProfileShortName { get; set; }
// User
public DeviceUserAssignment DeviceUserAssignment { get; set; }
public User AssignedUser { get; set; }
// Jobs
public int JobsTotalCount { get; set; }
public int JobsOpenCount { get; set; }
// Attachments
public int AttachmentsCount { get; set; }
// Certificates
public DeviceCertificate DeviceCertificate { get; set; }
}
}
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.Services.Devices.Exporting
{
public enum DeviceExportTypes
{
All,
Batch,
Model,
Profile
}
}
@@ -0,0 +1,16 @@
using Disco.Models.Services.Devices.Exporting;
using System.Collections.Generic;
namespace Disco.Models.UI.Device
{
public interface DeviceExportModel : BaseUIModel
{
DeviceExportOptions Options { get; set; }
string DownloadExportSessionId { get; set; }
IEnumerable<KeyValuePair<int, string>> DeviceBatches { get; set; }
IEnumerable<KeyValuePair<int, string>> DeviceModels { get; set; }
IEnumerable<KeyValuePair<int, string>> DeviceProfiles { get; set; }
}
}
@@ -0,0 +1,229 @@
using Disco.Data.Repository;
using Disco.Models.Repository;
using Disco.Models.Services.Devices.Exporting;
using Disco.Services.Tasks;
using Disco.Services.Users;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Services.Devices.Export
{
public static class DeviceExport
{
public static MemoryStream GenerateExport(DiscoDataContext Database, IQueryable<Device> Devices, DeviceExportOptions Options, IScheduledTaskBasicStatus TaskStatus)
{
TaskStatus.UpdateStatus(15, "Building metadata and database query");
var metadata = Options.BuildMetadata();
if (metadata.Count == 0)
throw new ArgumentException("At least one export field must be specified", "Options");
// Update Users
if (Options.AssignedUserDisplayName ||
Options.AssignedUserSurname ||
Options.AssignedUserGivenName ||
Options.AssignedUserPhoneNumber ||
Options.AssignedUserEmailAddress)
{
TaskStatus.UpdateStatus(20, "Updating Assigned User details");
Devices.Where(d => d.AssignedUserId != null).Select(d => d.AssignedUserId).Distinct().ToList().ForEach(userId =>
{
try
{
UserService.GetUser(userId, Database);
}
catch (Exception) {} // Ignore Errors
});
}
TaskStatus.UpdateStatus(40, "Extracting records from the database");
var records = BuildRecords(Devices).ToList();
var stream = new MemoryStream();
TaskStatus.UpdateStatus(80, string.Format("Formatting {0} records for export", records.Count));
using (StreamWriter writer = new StreamWriter(stream, Encoding.Default, 0x400, true))
{
// Header
writer.Write('"');
writer.Write(string.Join("\",\"", metadata.Select(m => m.Item2)));
writer.Write('"');
// Records
foreach (var record in records)
{
writer.WriteLine();
writer.Write(string.Join(",", metadata.Select(m => {
var value = m.Item3(record);
return (m.Item4 && value != null) ? string.Concat("\"", value, "\"") : value;
})));
}
}
stream.Position = 0;
return stream;
}
public static MemoryStream GenerateExport(DiscoDataContext Database, IQueryable<Device> Devices, DeviceExportOptions Options)
{
return GenerateExport(Database, Devices, Options, ScheduledTaskMockStatus.Create());
}
public static MemoryStream GenerateExport(DiscoDataContext Database, DeviceExportOptions Options, IScheduledTaskBasicStatus TaskStatus)
{
switch (Options.ExportType)
{
case DeviceExportTypes.All:
return GenerateExport(Database, Database.Devices, Options, TaskStatus);
case DeviceExportTypes.Batch:
return GenerateExport(Database, Database.Devices.Where(d => d.DeviceBatchId == Options.ExportTypeTargetId), Options, TaskStatus);
case DeviceExportTypes.Model:
return GenerateExport(Database, Database.Devices.Where(d => d.DeviceModelId == Options.ExportTypeTargetId), Options, TaskStatus);
case DeviceExportTypes.Profile:
return GenerateExport(Database, Database.Devices.Where(d => d.DeviceProfileId == Options.ExportTypeTargetId), Options, TaskStatus);
default:
throw new ArgumentException(string.Format("Unknown Device Export Type", Options.ExportType.ToString()), "Options");
}
}
public static MemoryStream GenerateExport(DiscoDataContext Database, DeviceExportOptions Options)
{
return GenerateExport(Database, Options, ScheduledTaskMockStatus.Create());
}
private static IEnumerable<DeviceExportRecord> BuildRecords(IQueryable<Device> Devices)
{
var deviceDetailHardwareKeys = new List<string> { DeviceDetail.HardwareKeyLanMacAddress, DeviceDetail.HardwareKeyWLanMacAddress, DeviceDetail.HardwareKeyACAdapter };
return Devices.Select(d => new DeviceExportRecord()
{
Device = d,
DeviceDetails = d.DeviceDetails.Where(dd => dd.Scope == DeviceDetail.ScopeHardware && deviceDetailHardwareKeys.Contains(dd.Key)),
ModelId = d.DeviceModelId,
ModelDescription = d.DeviceModel.Description,
ModelManufacturer = d.DeviceModel.Manufacturer,
ModelModel = d.DeviceModel.Model,
ModelType = d.DeviceModel.ModelType,
BatchId = d.DeviceBatchId,
BatchName = d.DeviceBatch.Name,
BatchPurchaseDate = d.DeviceBatch.PurchaseDate,
BatchSupplier = d.DeviceBatch.Supplier,
BatchUnitCost = d.DeviceBatch.UnitCost,
BatchWarrantyValidUntilDate = d.DeviceBatch.WarrantyValidUntil,
BatchInsuredDate = d.DeviceBatch.InsuredDate,
BatchInsuranceSupplier = d.DeviceBatch.InsuranceSupplier,
BatchInsuredUntilDate = d.DeviceBatch.InsuredUntil,
ProfileId = d.DeviceProfileId,
ProfileName = d.DeviceProfile.Name,
ProfileShortName = d.DeviceProfile.ShortName,
DeviceUserAssignment = d.DeviceUserAssignments.Where(dua => dua.UnassignedDate == null).FirstOrDefault(),
AssignedUser = d.AssignedUser,
JobsTotalCount = d.Jobs.Count(),
JobsOpenCount = d.Jobs.Count(j => j.ClosedDate == null),
AttachmentsCount = d.DeviceAttachments.Count(),
DeviceCertificate = d.DeviceCertificates.Where(dc => dc.Enabled).FirstOrDefault()
});
}
/// <returns>Tuple Format: Property Name, Column Name, Property Access, Escape CSV Value?</returns>
private static List<Tuple<string, string, Func<DeviceExportRecord, string>, bool>> BuildMetadata(this DeviceExportOptions Options)
{
var allAssessors = BuildRecordAssessors().ToList();
return typeof(DeviceExportOptions).GetProperties()
.Where(p => p.PropertyType == typeof(bool))
.Select(p => Tuple.Create(p, (DisplayAttribute)p.GetCustomAttributes(typeof(DisplayAttribute), false).FirstOrDefault()))
.Where(p => p.Item2 != null && (bool)p.Item1.GetValue(Options))
.Select(p => {
var accessor = allAssessors.First(i => i.Item1 == p.Item1.Name);
var columnName = (p.Item2.ShortName == "Device" || p.Item2.ShortName == "Details") ? p.Item2.Name : string.Format("{0} {1}", p.Item2.ShortName, p.Item2.Name);
return Tuple.Create(p.Item1.Name, columnName, accessor.Item2, accessor.Item3);
}).ToList();
}
/// <returns>Tuple Format: Property Name, Property Access, Escape CSV Value?</returns>
private static IEnumerable<Tuple<string, Func<DeviceExportRecord, string>, bool>> BuildRecordAssessors()
{
const string DateFormat = "yyyy-MM-dd";
const string DateTimeFormat = DateFormat + " HH:mm:ss";
// Device
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("DeviceSerialNumber", r => r.Device.SerialNumber, true);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("DeviceAssetNumber", r => r.Device.AssetNumber, true);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("DeviceLocation", r => r.Device.Location, true);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("DeviceComputerName", r => r.Device.DeviceDomainId, true);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("DeviceLastNetworkLogon", r => r.Device.LastNetworkLogonDate.HasValue ? r.Device.LastNetworkLogonDate.Value.ToString(DateTimeFormat) : null, false);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("DeviceCreatedDate", r => r.Device.CreatedDate.ToString(DateTimeFormat), false);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("DeviceFirstEnrolledDate", r => r.Device.EnrolledDate.HasValue ? r.Device.EnrolledDate.Value.ToString(DateTimeFormat) : null, false);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("DeviceLastEnrolledDate", r => r.Device.LastEnrolDate.HasValue ? r.Device.LastEnrolDate.Value.ToString(DateTimeFormat) : null, false);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("DeviceDecommissionedDate", r => r.Device.DecommissionedDate.HasValue ? r.Device.DecommissionedDate.Value.ToString(DateTimeFormat) : null, false);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("DeviceDecommissionedReason", r => r.Device.DecommissionReason.HasValue ? r.Device.DecommissionReason.Value.ToString() : null, true);
// Details
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("DetailLanMacAddress", r => r.DeviceDetails.Where(dd => dd.Key == DeviceDetail.HardwareKeyLanMacAddress).Select(dd => dd.Value).FirstOrDefault(), true);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("DetailWLanMacAddress", r => r.DeviceDetails.Where(dd => dd.Key == DeviceDetail.HardwareKeyWLanMacAddress).Select(dd => dd.Value).FirstOrDefault(), true);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("DetailACAdapter", r => r.DeviceDetails.Where(dd => dd.Key == DeviceDetail.HardwareKeyACAdapter).Select(dd => dd.Value).FirstOrDefault(), true);
// Model
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("ModelId", r => r.ModelId.HasValue ? r.ModelId.Value.ToString() : null, false);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("ModelDescription", r => r.ModelDescription, true);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("ModelManufacturer", r => r.ModelManufacturer, true);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("ModelModel", r => r.ModelModel, true);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("ModelType", r => r.ModelType, true);
// Batch
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("BatchId", r => r.BatchId.HasValue ? r.BatchId.Value.ToString() : null, false);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("BatchName", r => r.BatchName, true);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("BatchPurchaseDate", r => r.BatchPurchaseDate.HasValue ? r.BatchPurchaseDate.Value.ToString(DateFormat) : null, false);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("BatchSupplier", r => r.BatchSupplier, true);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("BatchUnitCost", r => r.BatchUnitCost.HasValue ? r.BatchUnitCost.ToString() : null, false);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("BatchWarrantyValidUntilDate", r => r.BatchWarrantyValidUntilDate.HasValue ? r.BatchWarrantyValidUntilDate.Value.ToString(DateFormat) : null, false);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("BatchInsuredDate", r => r.BatchInsuredDate.HasValue ? r.BatchInsuredDate.Value.ToString(DateFormat) : null, false);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("BatchInsuranceSupplier", r => r.BatchInsuranceSupplier, true);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("BatchInsuredUntilDate", r => r.BatchInsuredUntilDate.HasValue ? r.BatchInsuredUntilDate.Value.ToString(DateFormat) : null, false);
// Profile
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("ProfileId", r => r.ProfileId.ToString(), false);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("ProfileName", r => r.ProfileName, true);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("ProfileShortName", r => r.ProfileShortName, true);
// User
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("AssignedUserId", r => r.AssignedUser != null ? r.AssignedUser.UserId : null, true);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("AssignedUserDate", r => r.DeviceUserAssignment != null ? r.DeviceUserAssignment.AssignedDate.ToString(DateTimeFormat) : null, false);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("AssignedUserDisplayName", r => r.AssignedUser != null ? r.AssignedUser.DisplayName : null, true);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("AssignedUserSurname", r => r.AssignedUser != null ? r.AssignedUser.Surname : null, true);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("AssignedUserGivenName", r => r.AssignedUser != null ? r.AssignedUser.GivenName : null, true);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("AssignedUserPhoneNumber", r => r.AssignedUser != null ? r.AssignedUser.PhoneNumber : null, true);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("AssignedUserEmailAddress", r => r.AssignedUser != null ? r.AssignedUser.EmailAddress : null, true);
// Jobs
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("JobsTotalCount", r => r.JobsTotalCount.ToString(), false);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("JobsOpenCount", r => r.JobsOpenCount.ToString(), false);
// Attachments
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("AttachmentsCount", r => r.AttachmentsCount.ToString(), false);
// Certificates
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("CertificateName", r => r.DeviceCertificate != null ? r.DeviceCertificate.Name : null, true);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("CertificateAllocatedDate", r => r.DeviceCertificate != null && r.DeviceCertificate.AllocatedDate.HasValue ? r.DeviceCertificate.AllocatedDate.Value.ToString(DateTimeFormat) : null, false);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("CertificateExpirationDate", r => r.DeviceCertificate != null && r.DeviceCertificate.ExpirationDate.HasValue ? r.DeviceCertificate.ExpirationDate.Value.ToString(DateTimeFormat) : null, false);
yield return new Tuple<string, Func<DeviceExportRecord, string>, bool>("CertificateProviderId", r => r.DeviceCertificate != null ? r.DeviceCertificate.ProviderId : null, true);
}
}
}
@@ -0,0 +1,47 @@
using Disco.Models.Repository;
using Disco.Models.Services.Devices.Exporting;
using Disco.Services.Tasks;
using Quartz;
using System;
using System.IO;
using System.Linq;
using Disco.Data.Repository;
namespace Disco.Services.Devices.Export
{
public class DeviceExportTask : ScheduledTask
{
private const string JobDataMapContext = "Context";
public override string TaskName { get { return "Export Devices"; } }
public override bool SingleInstanceTask { get { return false; } }
public override bool CancelInitiallySupported { get { return false; } }
public static DeviceExportTaskContext ScheduleNow(DeviceExportOptions Options)
{
// Build Context
var context = new DeviceExportTaskContext(Options);
// Build Data Map
var task = new DeviceExportTask();
JobDataMap taskData = new JobDataMap() { { JobDataMapContext, context} };
// Schedule Task
context.TaskStatus = task.ScheduleTask(taskData);
return context;
}
protected override void ExecuteTask()
{
var context = (DeviceExportTaskContext)this.ExecutionContext.JobDetail.JobDataMap[JobDataMapContext];
Status.UpdateStatus(10, "Exporting Device Records", "Starting...");
using (DiscoDataContext Database = new DiscoDataContext())
{
context.CsvResult = DeviceExport.GenerateExport(Database, context.Options, this.Status);
}
}
}
}
@@ -0,0 +1,20 @@
using Disco.Models.Services.Devices.Exporting;
using Disco.Services.Tasks;
using System.IO;
namespace Disco.Services.Devices.Export
{
public class DeviceExportTaskContext
{
public DeviceExportOptions Options { get; private set; }
public ScheduledTaskStatus TaskStatus { get; set; }
public MemoryStream CsvResult { get; set; }
public DeviceExportTaskContext(DeviceExportOptions Options)
{
this.Options = Options;
}
}
}
+5
View File
@@ -172,6 +172,9 @@
<Compile Include="Authorization\Roles\RoleCache.cs" /> <Compile Include="Authorization\Roles\RoleCache.cs" />
<Compile Include="Authorization\Roles\RoleClaims.cs" /> <Compile Include="Authorization\Roles\RoleClaims.cs" />
<Compile Include="Authorization\Roles\RoleToken.cs" /> <Compile Include="Authorization\Roles\RoleToken.cs" />
<Compile Include="Devices\Export\DeviceExport.cs" />
<Compile Include="Devices\Export\DeviceExportTask.cs" />
<Compile Include="Devices\Export\DeviceExportTaskContext.cs" />
<Compile Include="Extensions\DateTimeExtensions.cs" /> <Compile Include="Extensions\DateTimeExtensions.cs" />
<Compile Include="Extensions\StringExtensions.cs" /> <Compile Include="Extensions\StringExtensions.cs" />
<Compile Include="Interop\ActiveDirectory\ActiveDirectory.cs" /> <Compile Include="Interop\ActiveDirectory\ActiveDirectory.cs" />
@@ -249,7 +252,9 @@
<Compile Include="Plugins\WebPageHelper.cs" /> <Compile Include="Plugins\WebPageHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Searching\Search.cs" /> <Compile Include="Searching\Search.cs" />
<Compile Include="Tasks\IScheduledTaskBasicStatus.cs" />
<Compile Include="Tasks\ScheduledTask.cs" /> <Compile Include="Tasks\ScheduledTask.cs" />
<Compile Include="Tasks\ScheduledTaskMockStatus.cs" />
<Compile Include="Tasks\ScheduledTasks.cs" /> <Compile Include="Tasks\ScheduledTasks.cs" />
<Compile Include="Tasks\ScheduledTasksLog.cs" /> <Compile Include="Tasks\ScheduledTasksLog.cs" />
<Compile Include="Tasks\ScheduledTaskStatus.cs" /> <Compile Include="Tasks\ScheduledTaskStatus.cs" />
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Services.Tasks
{
public interface IScheduledTaskBasicStatus
{
byte Progress { get; }
string CurrentProcess { get; }
string CurrentDescription { get; }
void UpdateStatus(byte Progress);
void UpdateStatus(double Progress);
void UpdateStatus(string CurrentDescription);
void UpdateStatus(byte Progress, string CurrentDescription);
void UpdateStatus(double Progress, string CurrentDescription);
void UpdateStatus(byte Progress, string CurrentProcess, string CurrentDescription);
void UpdateStatus(double Progress, string CurrentProcess, string CurrentDescription);
}
}
@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Services.Tasks
{
public class ScheduledTaskMockStatus : IScheduledTaskBasicStatus
{
private byte progress;
private string currentProcess;
private string currentDescription;
public byte Progress { get { return this.progress; } }
public string CurrentProcess { get { return this.currentProcess; } }
public string CurrentDescription { get { return this.currentDescription; } }
public void UpdateStatus(byte Progress)
{
this.progress = Progress;
}
public void UpdateStatus(double Progress)
{
UpdateStatus((byte)Progress);
}
public void UpdateStatus(string CurrentDescription)
{
this.currentDescription = CurrentDescription;
}
public void UpdateStatus(byte Progress, string CurrentDescription)
{
this.progress = Progress;
this.currentDescription = CurrentDescription;
}
public void UpdateStatus(double Progress, string CurrentDescription)
{
UpdateStatus((byte)Progress, CurrentDescription);
}
public void UpdateStatus(byte Progress, string CurrentProcess, string CurrentDescription)
{
this.progress = Progress;
this.currentProcess = CurrentProcess;
this.currentDescription = CurrentDescription;
}
public void UpdateStatus(double Progress, string CurrentProcess, string CurrentDescription)
{
UpdateStatus((byte)Progress, CurrentProcess, CurrentDescription);
}
public static ScheduledTaskMockStatus Create()
{
return new ScheduledTaskMockStatus();
}
}
}
+1 -1
View File
@@ -9,7 +9,7 @@ using System.Threading.Tasks;
namespace Disco.Services.Tasks namespace Disco.Services.Tasks
{ {
public class ScheduledTaskStatus public class ScheduledTaskStatus : IScheduledTaskBasicStatus
{ {
#region Backing Fields #region Backing Fields
@@ -497,25 +497,5 @@ namespace Disco.Web.Areas.API.Controllers
} }
#endregion #endregion
#region Exporting
[DiscoAuthorizeAll(Claims.Config.DeviceBatch.Show, Claims.Device.Actions.Export)]
public virtual ActionResult ExportDevices(int id)
{
DeviceBatch db = Database.DeviceBatches.Find(id);
if (db == null)
throw new ArgumentNullException("id", "Invalid Device Batch Id");
var devices = Database.Devices.Where(d => !d.DecommissionedDate.HasValue && d.DeviceBatchId == db.Id);
var export = BI.DeviceBI.Importing.Export.GenerateExport(devices);
var filename = string.Format("DiscoDeviceExport-Batch_{0}-{1:yyyyMMdd-HHmmss}.csv", db.Id, DateTime.Now);
return File(export, "text/csv", filename);
}
#endregion
} }
} }
@@ -1,12 +1,15 @@
using Disco.BI.Extensions; using Disco.BI.Extensions;
using Disco.Services.Authorization; using Disco.Services.Authorization;
using Disco.Services.Devices.Export;
using Disco.Services.Interop.ActiveDirectory; using Disco.Services.Interop.ActiveDirectory;
using Disco.Services.Users; using Disco.Services.Users;
using Disco.Services.Web; using Disco.Services.Web;
using Disco.Web.Models.Device;
using System; using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Web; using System.Web;
using System.Web.Caching;
using System.Web.Mvc; using System.Web.Mvc;
namespace Disco.Web.Areas.API.Controllers namespace Disco.Web.Areas.API.Controllers
@@ -265,7 +268,7 @@ namespace Disco.Web.Areas.API.Controllers
{ {
if (d.CanDecommission()) if (d.CanDecommission())
{ {
d.OnDecommission((Disco.Models.Repository.Device.DecommissionReasons)Reason); d.OnDecommission((Disco.Models.Repository.DecommissionReasons)Reason);
Database.SaveChanges(); Database.SaveChanges();
if (redirect) if (redirect)
@@ -526,7 +529,7 @@ namespace Disco.Web.Areas.API.Controllers
#endregion #endregion
#region Importing / Exporting #region Importing
[DiscoAuthorize(Claims.Device.Actions.Import)] [DiscoAuthorize(Claims.Device.Actions.Import)]
public virtual ActionResult ImportParse(HttpPostedFileBase ImportFile) public virtual ActionResult ImportParse(HttpPostedFileBase ImportFile)
@@ -558,17 +561,56 @@ namespace Disco.Web.Areas.API.Controllers
return RedirectToAction(MVC.Config.Logging.TaskStatus(status.SessionId)); return RedirectToAction(MVC.Config.Logging.TaskStatus(status.SessionId));
} }
#endregion
#region Exporting
private const string ExportSessionCacheKey = "DeviceExportContext_{0}";
[DiscoAuthorize(Claims.Device.Actions.Export)] [DiscoAuthorize(Claims.Device.Actions.Export)]
public virtual ActionResult ExportAllDevices() public virtual ActionResult Export(ExportModel Model)
{ {
// Non-Decommissioned Devices if (Model == null || Model.Options == null)
var devices = Database.Devices.Where(d => !d.DecommissionedDate.HasValue); throw new ArgumentNullException("Model");
var export = BI.DeviceBI.Importing.Export.GenerateExport(devices); // Write Options to Configuration
Database.DiscoConfiguration.Devices.LastExportOptions = Model.Options;
Database.SaveChanges();
var filename = string.Format("DiscoDeviceExport-AllDevices-{0:yyyyMMdd-HHmmss}.csv", DateTime.Now); // Start Export
var exportContext = DeviceExportTask.ScheduleNow(Model.Options);
return File(export, "text/csv", filename); // Store Export Context in Web Cache
string key = string.Format(ExportSessionCacheKey, exportContext.TaskStatus.SessionId);
HttpRuntime.Cache.Insert(key, exportContext, null, DateTime.Now.AddMinutes(60), Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null);
// Set Task Finished Url
var finishedActionResult = MVC.Device.Export(exportContext.TaskStatus.SessionId, null, null);
exportContext.TaskStatus.SetFinishedUrl(Url.Action(finishedActionResult));
// Try waiting for completion
if (exportContext.TaskStatus.WaitUntilFinished(TimeSpan.FromSeconds(1.5)))
return RedirectToAction(finishedActionResult);
else
return RedirectToAction(MVC.Config.Logging.TaskStatus(exportContext.TaskStatus.SessionId));
}
[DiscoAuthorize(Claims.Device.Actions.Export)]
public virtual ActionResult ExportRetrieve(string Id)
{
if (string.IsNullOrWhiteSpace(Id))
throw new ArgumentNullException("Id");
string key = string.Format(ExportSessionCacheKey, Id);
var context = HttpRuntime.Cache.Get(key) as DeviceExportTaskContext;
if (context == null)
throw new ArgumentException("The Id specified is invalid, or the export data expired (60 minutes)", "Id");
if (context.CsvResult == null)
throw new ArgumentException("The export session is still running, or failed to complete successfully", "Id");
var filename = string.Format("DiscoDeviceExport-{0:yyyyMMdd-HHmmss}.csv", context.TaskStatus.StartedTimestamp.Value);
return File(context.CsvResult.ToArray(), "text/csv", filename);
} }
#endregion #endregion
@@ -356,23 +356,5 @@ namespace Disco.Web.Areas.API.Controllers
} }
#endregion #endregion
#region Exporting
[DiscoAuthorizeAll(Claims.Config.DeviceModel.Show, Claims.Device.Actions.Export)]
public virtual ActionResult ExportDevices(int id)
{
DeviceModel dm = Database.DeviceModels.Find(id);
if (dm == null)
throw new ArgumentNullException("id", "Invalid Device Model Id");
var devices = Database.Devices.Where(d => !d.DecommissionedDate.HasValue && d.DeviceModelId == dm.Id);
var export = BI.DeviceBI.Importing.Export.GenerateExport(devices);
var filename = string.Format("DiscoDeviceExport-Model_{0}-{1:yyyyMMdd-HHmmss}.csv", dm.Id, DateTime.Now);
return File(export, "text/csv", filename);
}
#endregion
} }
} }
@@ -461,23 +461,5 @@ namespace Disco.Web.Areas.API.Controllers
#endregion #endregion
#region Exporting
[DiscoAuthorizeAll(Claims.Config.DeviceProfile.Show, Claims.Device.Actions.Export)]
public virtual ActionResult ExportDevices(int id)
{
DeviceProfile dp = Database.DeviceProfiles.Find(id);
if (dp == null)
throw new ArgumentNullException("id", "Invalid Device Profile Id");
var devices = Database.Devices.Where(d => !d.DecommissionedDate.HasValue && d.DeviceProfileId == dp.Id);
var export = BI.DeviceBI.Importing.Export.GenerateExport(devices);
var filename = string.Format("DiscoDeviceExport-Profile_{0}-{1:yyyyMMdd-HHmmss}.csv", dp.Id, DateTime.Now);
return File(export, "text/csv", filename);
}
#endregion
} }
} }
@@ -663,7 +663,7 @@
{ {
if (Authorization.Has(Claims.Device.Actions.Export)) if (Authorization.Has(Claims.Device.Actions.Export))
{ {
@Html.ActionLinkButton("Export Devices", MVC.API.DeviceBatch.ExportDevices(Model.DeviceBatch.Id)) @Html.ActionLinkButton("Export Devices", MVC.Device.Export(null, Disco.Models.Services.Devices.Exporting.DeviceExportTypes.Batch, Model.DeviceBatch.Id))
} }
if (Authorization.Has(Claims.Device.Search)) if (Authorization.Has(Claims.Device.Search))
{ {
@@ -2,7 +2,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.34011 // Runtime Version:4.0.30319.34014
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
@@ -2016,7 +2016,7 @@ WriteLiteral(" ");
#line hidden #line hidden
#line 666 "..\..\Areas\Config\Views\DeviceBatch\Show.cshtml" #line 666 "..\..\Areas\Config\Views\DeviceBatch\Show.cshtml"
Write(Html.ActionLinkButton("Export Devices", MVC.API.DeviceBatch.ExportDevices(Model.DeviceBatch.Id))); Write(Html.ActionLinkButton("Export Devices", MVC.Device.Export(null, Disco.Models.Services.Devices.Exporting.DeviceExportTypes.Batch, Model.DeviceBatch.Id)));
#line default #line default
@@ -250,7 +250,7 @@
{ {
if (Authorization.Has(Claims.Device.Actions.Export)) if (Authorization.Has(Claims.Device.Actions.Export))
{ {
@Html.ActionLinkButton("Export Devices", MVC.API.DeviceModel.ExportDevices(Model.DeviceModel.Id)) @Html.ActionLinkButton("Export Devices", MVC.Device.Export(null, Disco.Models.Services.Devices.Exporting.DeviceExportTypes.Model, Model.DeviceModel.Id))
} }
if (Authorization.Has(Claims.Device.Search)) if (Authorization.Has(Claims.Device.Search))
{ {
@@ -2,7 +2,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.34011 // Runtime Version:4.0.30319.34014
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
@@ -723,7 +723,7 @@ WriteLiteral(" ");
#line hidden #line hidden
#line 253 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml" #line 253 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
Write(Html.ActionLinkButton("Export Devices", MVC.API.DeviceModel.ExportDevices(Model.DeviceModel.Id))); Write(Html.ActionLinkButton("Export Devices", MVC.Device.Export(null, Disco.Models.Services.Devices.Exporting.DeviceExportTypes.Model, Model.DeviceModel.Id)));
#line default #line default
@@ -735,7 +735,7 @@
} }
@if (Authorization.Has(Claims.Device.Actions.Export)) @if (Authorization.Has(Claims.Device.Actions.Export))
{ {
@Html.ActionLinkButton("Export Devices", MVC.API.DeviceProfile.ExportDevices(Model.DeviceProfile.Id)) @Html.ActionLinkButton("Export Devices", MVC.Device.Export(null, Disco.Models.Services.Devices.Exporting.DeviceExportTypes.Profile, Model.DeviceProfile.Id))
} }
@if (Authorization.Has(Claims.Device.Search)) @if (Authorization.Has(Claims.Device.Search))
{ {
@@ -2032,7 +2032,7 @@ WriteLiteral(" ");
#line hidden #line hidden
#line 738 "..\..\Areas\Config\Views\DeviceProfile\Show.cshtml" #line 738 "..\..\Areas\Config\Views\DeviceProfile\Show.cshtml"
Write(Html.ActionLinkButton("Export Devices", MVC.API.DeviceProfile.ExportDevices(Model.DeviceProfile.Id))); Write(Html.ActionLinkButton("Export Devices", MVC.Device.Export(null, Disco.Models.Services.Devices.Exporting.DeviceExportTypes.Profile, Model.DeviceProfile.Id)));
#line default #line default
+3 -2
View File
@@ -3651,6 +3651,9 @@ a.button:hover {
border: 1px solid #6b6b6b; border: 1px solid #6b6b6b;
background: #9e9e9e; background: #9e9e9e;
} }
a.button i {
margin-right: 10px;
}
div.actionBar { div.actionBar {
margin: 0 -30px 0 -30px; margin: 0 -30px 0 -30px;
padding: 10px; padding: 10px;
@@ -4123,11 +4126,9 @@ select {
border: 1px solid #ccc; border: 1px solid #ccc;
padding: 2px; padding: 2px;
color: #444; color: #444;
min-width: 200px;
} }
select.small { select.small {
padding: 0; padding: 0;
min-width: 150px;
} }
input[type="submit"], input[type="submit"],
button { button {
File diff suppressed because one or more lines are too long
+24
View File
@@ -341,6 +341,30 @@
background-color: #ededed; background-color: #ededed;
border: 1px solid #cccccc; border: 1px solid #cccccc;
} }
#Devices_Export .Devices_Export_Type_Target {
margin-top: 10px;
display: none;
}
#Devices_Export #Devices_Export_Fields #Devices_Export_Fields_Defaults {
font-size: .75em;
}
#Devices_Export #Devices_Export_Fields th {
font-size: 1.05em;
}
#Devices_Export #Devices_Export_Fields th span {
margin-top: 4px;
font-size: .8em;
}
#Devices_Export_Download_Dialog {
padding-top: 20px;
text-align: center;
}
#Devices_Export_Download_Dialog h4 {
margin-bottom: 30px;
}
#Devices_Export_Download_Dialog a {
margin-bottom: 20px;
}
#deviceImport #ImportFile { #deviceImport #ImportFile {
width: 100%; width: 100%;
} }
+35
View File
@@ -312,6 +312,41 @@
} }
} }
#Devices_Export {
.Devices_Export_Type_Target {
margin-top: 10px;
display: none;
}
#Devices_Export_Fields {
#Devices_Export_Fields_Defaults {
font-size: .75em;
}
th {
font-size: 1.05em;
span {
margin-top: 4px;
font-size: .8em;
}
}
}
}
#Devices_Export_Download_Dialog {
padding-top: 20px;
text-align: center;
h4 {
margin-bottom: 30px;
}
a {
margin-bottom: 20px;
}
}
#deviceImport { #deviceImport {
#ImportFile { #ImportFile {
width: 100%; width: 100%;
File diff suppressed because one or more lines are too long
+3 -2
View File
@@ -474,6 +474,9 @@ a.button:hover {
border: 1px solid #6b6b6b; border: 1px solid #6b6b6b;
background: #9e9e9e; background: #9e9e9e;
} }
a.button i {
margin-right: 10px;
}
div.actionBar { div.actionBar {
margin: 0 -30px 0 -30px; margin: 0 -30px 0 -30px;
padding: 10px; padding: 10px;
@@ -946,11 +949,9 @@ select {
border: 1px solid #ccc; border: 1px solid #ccc;
padding: 2px; padding: 2px;
color: #444; color: #444;
min-width: 200px;
} }
select.small { select.small {
padding: 0; padding: 0;
min-width: 150px;
} }
input[type="submit"], input[type="submit"],
button { button {
+4 -2
View File
@@ -422,6 +422,10 @@ a {
border: 1px solid @ButtonBorderHoverColour; border: 1px solid @ButtonBorderHoverColour;
background: @ButtonHoverColour; background: @ButtonHoverColour;
} }
i {
margin-right: 10px;
}
} }
div.actionBar { div.actionBar {
@@ -901,12 +905,10 @@ select {
border: 1px solid #ccc; border: 1px solid #ccc;
padding: 2px; padding: 2px;
color: #444; color: #444;
min-width: 200px;
} }
select.small { select.small {
padding: 0; padding: 0;
min-width: 150px;
} }
input[type="submit"], button { input[type="submit"], button {
File diff suppressed because one or more lines are too long
+33
View File
@@ -1,5 +1,6 @@
using Disco.BI.Extensions; using Disco.BI.Extensions;
using Disco.Models.Repository; using Disco.Models.Repository;
using Disco.Models.Services.Devices.Exporting;
using Disco.Models.Services.Jobs.JobLists; using Disco.Models.Services.Jobs.JobLists;
using Disco.Models.UI.Device; using Disco.Models.UI.Device;
using Disco.Services; using Disco.Services;
@@ -9,6 +10,8 @@ using Disco.Services.Plugins.Features.UIExtension;
using Disco.Services.Users; using Disco.Services.Users;
using Disco.Services.Web; using Disco.Services.Web;
using System; using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Web.Mvc; using System.Web.Mvc;
@@ -81,6 +84,36 @@ namespace Disco.Web.Controllers
} }
#endregion #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 #region Import/Export
[DiscoAuthorizeAny(Claims.Device.Actions.Import, Claims.Device.Actions.Export), HttpGet] [DiscoAuthorizeAny(Claims.Device.Actions.Import, Claims.Device.Actions.Export), HttpGet]
public virtual ActionResult ImportExport() public virtual ActionResult ImportExport()
+11 -1
View File
@@ -544,7 +544,13 @@
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
</Compile> </Compile>
<Compile Include="Extensions\T4MVCExtensions.cs" /> <Compile Include="Extensions\T4MVCExtensions.cs" />
<Compile Include="Models\Device\ExportModel.cs" />
<Compile Include="Models\InitialConfig\AdministratorsModel.cs" /> <Compile Include="Models\InitialConfig\AdministratorsModel.cs" />
<Compile Include="Views\Device\Export.generated.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Export.cshtml</DependentUpon>
</Compile>
<Compile Include="Views\InitialConfig\Administrators.generated.cs"> <Compile Include="Views\InitialConfig\Administrators.generated.cs">
<DependentUpon>Administrators.cshtml</DependentUpon> <DependentUpon>Administrators.cshtml</DependentUpon>
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
@@ -1544,6 +1550,10 @@
<Generator>RazorGenerator</Generator> <Generator>RazorGenerator</Generator>
<LastGenOutput>_Subject.generated.cs</LastGenOutput> <LastGenOutput>_Subject.generated.cs</LastGenOutput>
</None> </None>
<None Include="Views\Device\Export.cshtml">
<Generator>RazorGenerator</Generator>
<LastGenOutput>Export.generated.cs</LastGenOutput>
</None>
<None Include="Views\Device\ImportExport.cshtml"> <None Include="Views\Device\ImportExport.cshtml">
<Generator>RazorGenerator</Generator> <Generator>RazorGenerator</Generator>
<LastGenOutput>ImportExport.generated.cs</LastGenOutput> <LastGenOutput>ImportExport.generated.cs</LastGenOutput>
@@ -2053,7 +2063,7 @@
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile> <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties> </WebProjectProperties>
</FlavorProperties> </FlavorProperties>
<UserProperties BuildVersion_UpdateFileVersion="True" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.DeltaBaseYear.MonthAndDayStamp.TimeStamp" BuildVersion_DetectChanges="False" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildAction="Both" BuildVersion_StartDate="2011/7/1" /> <UserProperties BuildVersion_StartDate="2011/7/1" BuildVersion_BuildAction="Both" BuildVersion_UseGlobalSettings="False" BuildVersion_DetectChanges="False" BuildVersion_BuildVersioningStyle="None.DeltaBaseYear.MonthAndDayStamp.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_UpdateFileVersion="True" />
</VisualStudio> </VisualStudio>
</ProjectExtensions> </ProjectExtensions>
<Import Project="$(SolutionDir)\.nuget\nuget.targets" /> <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
+17
View File
@@ -0,0 +1,17 @@
using Disco.Models.Services.Devices.Exporting;
using Disco.Models.UI.Device;
using System.Collections.Generic;
namespace Disco.Web.Models.Device
{
public class ExportModel : DeviceExportModel
{
public DeviceExportOptions Options { get; set; }
public string DownloadExportSessionId { get; set; }
public IEnumerable<KeyValuePair<int, string>> DeviceBatches { get; set; }
public IEnumerable<KeyValuePair<int, string>> DeviceModels { get; set; }
public IEnumerable<KeyValuePair<int, string>> DeviceProfiles { get; set; }
}
}
+2
View File
@@ -2,12 +2,14 @@
using Disco.Models.Services.Jobs.JobLists; using Disco.Models.Services.Jobs.JobLists;
using Disco.Models.UI.Search; using Disco.Models.UI.Search;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Disco.Web.Models.Search namespace Disco.Web.Models.Search
{ {
public class QueryModel : SearchQueryModel public class QueryModel : SearchQueryModel
{ {
public string FriendlyTerm { get; set; } public string FriendlyTerm { get; set; }
[Required, MinLength(2)]
public string Term { get; set; } public string Term { get; set; }
public bool Success { get; set; } public bool Success { get; set; }
public string ErrorMessage { get; set; } public string ErrorMessage { get; set; }
+79 -84
View File
@@ -881,6 +881,12 @@ namespace Disco.Web.Controllers
return RedirectToRoutePermanent(callInfo.RouteValueDictionary); return RedirectToRoutePermanent(callInfo.RouteValueDictionary);
} }
[NonAction]
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public virtual System.Web.Mvc.ActionResult Export()
{
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Export);
}
[NonAction] [NonAction]
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public virtual System.Web.Mvc.ActionResult ImportReview() public virtual System.Web.Mvc.ActionResult ImportReview()
@@ -911,6 +917,7 @@ namespace Disco.Web.Controllers
{ {
public readonly string Index = "Index"; public readonly string Index = "Index";
public readonly string AddOffline = "AddOffline"; public readonly string AddOffline = "AddOffline";
public readonly string Export = "Export";
public readonly string ImportExport = "ImportExport"; public readonly string ImportExport = "ImportExport";
public readonly string ImportReview = "ImportReview"; public readonly string ImportReview = "ImportReview";
public readonly string Show = "Show"; public readonly string Show = "Show";
@@ -921,6 +928,7 @@ namespace Disco.Web.Controllers
{ {
public const string Index = "Index"; public const string Index = "Index";
public const string AddOffline = "AddOffline"; public const string AddOffline = "AddOffline";
public const string Export = "Export";
public const string ImportExport = "ImportExport"; public const string ImportExport = "ImportExport";
public const string ImportReview = "ImportReview"; public const string ImportReview = "ImportReview";
public const string Show = "Show"; public const string Show = "Show";
@@ -935,6 +943,16 @@ namespace Disco.Web.Controllers
{ {
public readonly string m = "m"; public readonly string m = "m";
} }
static readonly ActionParamsClass_Export s_params_Export = new ActionParamsClass_Export();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ActionParamsClass_Export ExportParams { get { return s_params_Export; } }
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionParamsClass_Export
{
public readonly string DownloadId = "DownloadId";
public readonly string ExportType = "ExportType";
public readonly string ExportTypeTargetId = "ExportTypeTargetId";
}
static readonly ActionParamsClass_ImportReview s_params_ImportReview = new ActionParamsClass_ImportReview(); static readonly ActionParamsClass_ImportReview s_params_ImportReview = new ActionParamsClass_ImportReview();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ActionParamsClass_ImportReview ImportReviewParams { get { return s_params_ImportReview; } } public ActionParamsClass_ImportReview ImportReviewParams { get { return s_params_ImportReview; } }
@@ -964,6 +982,7 @@ namespace Disco.Web.Controllers
public readonly string _DeviceTable = "_DeviceTable"; public readonly string _DeviceTable = "_DeviceTable";
public readonly string _ViewStart = "_ViewStart"; public readonly string _ViewStart = "_ViewStart";
public readonly string AddOffline = "AddOffline"; public readonly string AddOffline = "AddOffline";
public readonly string Export = "Export";
public readonly string ImportExport = "ImportExport"; public readonly string ImportExport = "ImportExport";
public readonly string ImportReview = "ImportReview"; public readonly string ImportReview = "ImportReview";
public readonly string Index = "Index"; public readonly string Index = "Index";
@@ -972,6 +991,7 @@ namespace Disco.Web.Controllers
public readonly string _DeviceTable = "~/Views/Device/_DeviceTable.cshtml"; public readonly string _DeviceTable = "~/Views/Device/_DeviceTable.cshtml";
public readonly string _ViewStart = "~/Views/Device/_ViewStart.cshtml"; public readonly string _ViewStart = "~/Views/Device/_ViewStart.cshtml";
public readonly string AddOffline = "~/Views/Device/AddOffline.cshtml"; public readonly string AddOffline = "~/Views/Device/AddOffline.cshtml";
public readonly string Export = "~/Views/Device/Export.cshtml";
public readonly string ImportExport = "~/Views/Device/ImportExport.cshtml"; public readonly string ImportExport = "~/Views/Device/ImportExport.cshtml";
public readonly string ImportReview = "~/Views/Device/ImportReview.cshtml"; public readonly string ImportReview = "~/Views/Device/ImportReview.cshtml";
public readonly string Index = "~/Views/Device/Index.cshtml"; public readonly string Index = "~/Views/Device/Index.cshtml";
@@ -1035,6 +1055,18 @@ namespace Disco.Web.Controllers
return callInfo; return callInfo;
} }
partial void ExportOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string DownloadId, Disco.Models.Services.Devices.Exporting.DeviceExportTypes? ExportType, int? ExportTypeTargetId);
public override System.Web.Mvc.ActionResult Export(string DownloadId, Disco.Models.Services.Devices.Exporting.DeviceExportTypes? ExportType, int? ExportTypeTargetId)
{
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Export);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "DownloadId", DownloadId);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "ExportType", ExportType);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "ExportTypeTargetId", ExportTypeTargetId);
ExportOverride(callInfo, DownloadId, ExportType, ExportTypeTargetId);
return callInfo;
}
partial void ImportExportOverride(T4MVC_System_Web_Mvc_ActionResult callInfo); partial void ImportExportOverride(T4MVC_System_Web_Mvc_ActionResult callInfo);
public override System.Web.Mvc.ActionResult ImportExport() public override System.Web.Mvc.ActionResult ImportExport()
@@ -2822,12 +2854,6 @@ namespace Disco.Web.Areas.API.Controllers
{ {
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Index); return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Index);
} }
[NonAction]
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public virtual System.Web.Mvc.ActionResult ExportDevices()
{
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ExportDevices);
}
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public DeviceBatchController Actions { get { return MVC.API.DeviceBatch; } } public DeviceBatchController Actions { get { return MVC.API.DeviceBatch; } }
@@ -2862,7 +2888,6 @@ namespace Disco.Web.Areas.API.Controllers
public readonly string Delete = "Delete"; public readonly string Delete = "Delete";
public readonly string Index = "Index"; public readonly string Index = "Index";
public readonly string Timeline = "Timeline"; public readonly string Timeline = "Timeline";
public readonly string ExportDevices = "ExportDevices";
} }
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
@@ -2886,7 +2911,6 @@ namespace Disco.Web.Areas.API.Controllers
public const string Delete = "Delete"; public const string Delete = "Delete";
public const string Index = "Index"; public const string Index = "Index";
public const string Timeline = "Timeline"; public const string Timeline = "Timeline";
public const string ExportDevices = "ExportDevices";
} }
@@ -3058,14 +3082,6 @@ namespace Disco.Web.Areas.API.Controllers
{ {
public readonly string id = "id"; public readonly string id = "id";
} }
static readonly ActionParamsClass_ExportDevices s_params_ExportDevices = new ActionParamsClass_ExportDevices();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ActionParamsClass_ExportDevices ExportDevicesParams { get { return s_params_ExportDevices; } }
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionParamsClass_ExportDevices
{
public readonly string id = "id";
}
static readonly ViewsClass s_views = new ViewsClass(); static readonly ViewsClass s_views = new ViewsClass();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ViewsClass Views { get { return s_views; } } public ViewsClass Views { get { return s_views; } }
@@ -3296,16 +3312,6 @@ namespace Disco.Web.Areas.API.Controllers
return callInfo; return callInfo;
} }
partial void ExportDevicesOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, int id);
public override System.Web.Mvc.ActionResult ExportDevices(int id)
{
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ExportDevices);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "id", id);
ExportDevicesOverride(callInfo, id);
return callInfo;
}
} }
} }
@@ -3555,6 +3561,18 @@ namespace Disco.Web.Areas.API.Controllers
{ {
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ImportProcess); return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ImportProcess);
} }
[NonAction]
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public virtual System.Web.Mvc.ActionResult Export()
{
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Export);
}
[NonAction]
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public virtual System.Web.Mvc.ActionResult ExportRetrieve()
{
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ExportRetrieve);
}
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public DeviceController Actions { get { return MVC.API.Device; } } public DeviceController Actions { get { return MVC.API.Device; } }
@@ -3592,7 +3610,8 @@ namespace Disco.Web.Areas.API.Controllers
public readonly string AttachmentRemove = "AttachmentRemove"; public readonly string AttachmentRemove = "AttachmentRemove";
public readonly string ImportParse = "ImportParse"; public readonly string ImportParse = "ImportParse";
public readonly string ImportProcess = "ImportProcess"; public readonly string ImportProcess = "ImportProcess";
public readonly string ExportAllDevices = "ExportAllDevices"; public readonly string Export = "Export";
public readonly string ExportRetrieve = "ExportRetrieve";
public readonly string MigrateDeviceMacAddressesFromLog = "MigrateDeviceMacAddressesFromLog"; public readonly string MigrateDeviceMacAddressesFromLog = "MigrateDeviceMacAddressesFromLog";
} }
@@ -3620,7 +3639,8 @@ namespace Disco.Web.Areas.API.Controllers
public const string AttachmentRemove = "AttachmentRemove"; public const string AttachmentRemove = "AttachmentRemove";
public const string ImportParse = "ImportParse"; public const string ImportParse = "ImportParse";
public const string ImportProcess = "ImportProcess"; public const string ImportProcess = "ImportProcess";
public const string ExportAllDevices = "ExportAllDevices"; public const string Export = "Export";
public const string ExportRetrieve = "ExportRetrieve";
public const string MigrateDeviceMacAddressesFromLog = "MigrateDeviceMacAddressesFromLog"; public const string MigrateDeviceMacAddressesFromLog = "MigrateDeviceMacAddressesFromLog";
} }
@@ -3817,6 +3837,22 @@ namespace Disco.Web.Areas.API.Controllers
{ {
public readonly string ParseTaskSessionKey = "ParseTaskSessionKey"; public readonly string ParseTaskSessionKey = "ParseTaskSessionKey";
} }
static readonly ActionParamsClass_Export s_params_Export = new ActionParamsClass_Export();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ActionParamsClass_Export ExportParams { get { return s_params_Export; } }
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionParamsClass_Export
{
public readonly string Model = "Model";
}
static readonly ActionParamsClass_ExportRetrieve s_params_ExportRetrieve = new ActionParamsClass_ExportRetrieve();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ActionParamsClass_ExportRetrieve ExportRetrieveParams { get { return s_params_ExportRetrieve; } }
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionParamsClass_ExportRetrieve
{
public readonly string Id = "Id";
}
static readonly ViewsClass s_views = new ViewsClass(); static readonly ViewsClass s_views = new ViewsClass();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ViewsClass Views { get { return s_views; } } public ViewsClass Views { get { return s_views; } }
@@ -4070,12 +4106,23 @@ namespace Disco.Web.Areas.API.Controllers
return callInfo; return callInfo;
} }
partial void ExportAllDevicesOverride(T4MVC_System_Web_Mvc_ActionResult callInfo); partial void ExportOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, Disco.Web.Models.Device.ExportModel Model);
public override System.Web.Mvc.ActionResult ExportAllDevices() public override System.Web.Mvc.ActionResult Export(Disco.Web.Models.Device.ExportModel Model)
{ {
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ExportAllDevices); var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Export);
ExportAllDevicesOverride(callInfo); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "Model", Model);
ExportOverride(callInfo, Model);
return callInfo;
}
partial void ExportRetrieveOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string Id);
public override System.Web.Mvc.ActionResult ExportRetrieve(string Id)
{
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ExportRetrieve);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "Id", Id);
ExportRetrieveOverride(callInfo, Id);
return callInfo; return callInfo;
} }
@@ -4181,12 +4228,6 @@ namespace Disco.Web.Areas.API.Controllers
{ {
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ComponentRemove); return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ComponentRemove);
} }
[NonAction]
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public virtual System.Web.Mvc.ActionResult ExportDevices()
{
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ExportDevices);
}
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public DeviceModelController Actions { get { return MVC.API.DeviceModel; } } public DeviceModelController Actions { get { return MVC.API.DeviceModel; } }
@@ -4215,7 +4256,6 @@ namespace Disco.Web.Areas.API.Controllers
public readonly string ComponentUpdate = "ComponentUpdate"; public readonly string ComponentUpdate = "ComponentUpdate";
public readonly string ComponentRemove = "ComponentRemove"; public readonly string ComponentRemove = "ComponentRemove";
public readonly string Index = "Index"; public readonly string Index = "Index";
public readonly string ExportDevices = "ExportDevices";
} }
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
@@ -4233,7 +4273,6 @@ namespace Disco.Web.Areas.API.Controllers
public const string ComponentUpdate = "ComponentUpdate"; public const string ComponentUpdate = "ComponentUpdate";
public const string ComponentRemove = "ComponentRemove"; public const string ComponentRemove = "ComponentRemove";
public const string Index = "Index"; public const string Index = "Index";
public const string ExportDevices = "ExportDevices";
} }
@@ -4343,14 +4382,6 @@ namespace Disco.Web.Areas.API.Controllers
{ {
public readonly string id = "id"; public readonly string id = "id";
} }
static readonly ActionParamsClass_ExportDevices s_params_ExportDevices = new ActionParamsClass_ExportDevices();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ActionParamsClass_ExportDevices ExportDevicesParams { get { return s_params_ExportDevices; } }
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionParamsClass_ExportDevices
{
public readonly string id = "id";
}
static readonly ViewsClass s_views = new ViewsClass(); static readonly ViewsClass s_views = new ViewsClass();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ViewsClass Views { get { return s_views; } } public ViewsClass Views { get { return s_views; } }
@@ -4517,16 +4548,6 @@ namespace Disco.Web.Areas.API.Controllers
return callInfo; return callInfo;
} }
partial void ExportDevicesOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, int id);
public override System.Web.Mvc.ActionResult ExportDevices(int id)
{
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ExportDevices);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "id", id);
ExportDevicesOverride(callInfo, id);
return callInfo;
}
} }
} }
@@ -4656,12 +4677,6 @@ namespace Disco.Web.Areas.API.Controllers
{ {
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.DefaultAddDeviceOffline); return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.DefaultAddDeviceOffline);
} }
[NonAction]
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public virtual System.Web.Mvc.ActionResult ExportDevices()
{
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ExportDevices);
}
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public DeviceProfileController Actions { get { return MVC.API.DeviceProfile; } } public DeviceProfileController Actions { get { return MVC.API.DeviceProfile; } }
@@ -4695,7 +4710,6 @@ namespace Disco.Web.Areas.API.Controllers
public readonly string Delete = "Delete"; public readonly string Delete = "Delete";
public readonly string Default = "Default"; public readonly string Default = "Default";
public readonly string DefaultAddDeviceOffline = "DefaultAddDeviceOffline"; public readonly string DefaultAddDeviceOffline = "DefaultAddDeviceOffline";
public readonly string ExportDevices = "ExportDevices";
} }
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
@@ -4718,7 +4732,6 @@ namespace Disco.Web.Areas.API.Controllers
public const string Delete = "Delete"; public const string Delete = "Delete";
public const string Default = "Default"; public const string Default = "Default";
public const string DefaultAddDeviceOffline = "DefaultAddDeviceOffline"; public const string DefaultAddDeviceOffline = "DefaultAddDeviceOffline";
public const string ExportDevices = "ExportDevices";
} }
@@ -4890,14 +4903,6 @@ namespace Disco.Web.Areas.API.Controllers
public readonly string id = "id"; public readonly string id = "id";
public readonly string redirect = "redirect"; public readonly string redirect = "redirect";
} }
static readonly ActionParamsClass_ExportDevices s_params_ExportDevices = new ActionParamsClass_ExportDevices();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ActionParamsClass_ExportDevices ExportDevicesParams { get { return s_params_ExportDevices; } }
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionParamsClass_ExportDevices
{
public readonly string id = "id";
}
static readonly ViewsClass s_views = new ViewsClass(); static readonly ViewsClass s_views = new ViewsClass();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ViewsClass Views { get { return s_views; } } public ViewsClass Views { get { return s_views; } }
@@ -5119,16 +5124,6 @@ namespace Disco.Web.Areas.API.Controllers
return callInfo; return callInfo;
} }
partial void ExportDevicesOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, int id);
public override System.Web.Mvc.ActionResult ExportDevices(int id)
{
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ExportDevices);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "id", id);
ExportDevicesOverride(callInfo, id);
return callInfo;
}
} }
} }
@@ -673,11 +673,11 @@
</div> </div>
<div> <div>
<ul class="none"> <ul class="none">
@foreach (Device.DecommissionReasons decommissionReason in Enum.GetValues(typeof(Device.DecommissionReasons))) @foreach (DecommissionReasons decommissionReason in Enum.GetValues(typeof(DecommissionReasons)))
{ {
<li> <li>
<input type="radio" id="Device_Show_Device_Actions_Decommission_Reason_@((int)decommissionReason)" <input type="radio" id="Device_Show_Device_Actions_Decommission_Reason_@((int)decommissionReason)"
name="Device_Show_Device_Actions_Decommission_Reason" value="@((int)decommissionReason)" @((decommissionReason == Device.DecommissionReasons.EndOfLife) ? "checked=\"checked\"" : string.Empty)/> name="Device_Show_Device_Actions_Decommission_Reason" value="@((int)decommissionReason)" @((decommissionReason == DecommissionReasons.EndOfLife) ? "checked=\"checked\"" : string.Empty)/>
<label for="Device_Show_Device_Actions_Decommission_Reason_@((int)decommissionReason)">@(decommissionReason.ReasonMessage())</label> <label for="Device_Show_Device_Actions_Decommission_Reason_@((int)decommissionReason)">@(decommissionReason.ReasonMessage())</label>
</li> </li>
} }
@@ -2304,7 +2304,7 @@ WriteLiteral(">\r\n");
#line hidden #line hidden
#line 676 "..\..\Views\Device\DeviceParts\_Subject.cshtml" #line 676 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
foreach (Device.DecommissionReasons decommissionReason in Enum.GetValues(typeof(Device.DecommissionReasons))) foreach (DecommissionReasons decommissionReason in Enum.GetValues(typeof(DecommissionReasons)))
{ {
@@ -2314,50 +2314,50 @@ WriteLiteral(" <li>\r\n
WriteLiteral(" type=\"radio\""); WriteLiteral(" type=\"radio\"");
WriteAttribute("id", Tuple.Create(" id=\"", 41943), Tuple.Create("\"", 42021) WriteAttribute("id", Tuple.Create(" id=\"", 41929), Tuple.Create("\"", 42007)
, Tuple.Create(Tuple.Create("", 41948), Tuple.Create("Device_Show_Device_Actions_Decommission_Reason_", 41948), true) , Tuple.Create(Tuple.Create("", 41934), Tuple.Create("Device_Show_Device_Actions_Decommission_Reason_", 41934), true)
#line 679 "..\..\Views\Device\DeviceParts\_Subject.cshtml" #line 679 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
, Tuple.Create(Tuple.Create("", 41995), Tuple.Create<System.Object, System.Int32>((int)decommissionReason , Tuple.Create(Tuple.Create("", 41981), Tuple.Create<System.Object, System.Int32>((int)decommissionReason
#line default #line default
#line hidden #line hidden
, 41995), false) , 41981), false)
); );
WriteLiteral("\r\n name=\"Device_Show_Device_Actions_Decomm" + WriteLiteral("\r\n name=\"Device_Show_Device_Actions_Decomm" +
"ission_Reason\""); "ission_Reason\"");
WriteAttribute("value", Tuple.Create(" value=\"", 42117), Tuple.Create("\"", 42151) WriteAttribute("value", Tuple.Create(" value=\"", 42103), Tuple.Create("\"", 42137)
#line 680 "..\..\Views\Device\DeviceParts\_Subject.cshtml" #line 680 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
, Tuple.Create(Tuple.Create("", 42125), Tuple.Create<System.Object, System.Int32>((int)decommissionReason , Tuple.Create(Tuple.Create("", 42111), Tuple.Create<System.Object, System.Int32>((int)decommissionReason
#line default #line default
#line hidden #line hidden
, 42125), false) , 42111), false)
); );
WriteLiteral(" "); WriteLiteral(" ");
#line 680 "..\..\Views\Device\DeviceParts\_Subject.cshtml" #line 680 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
Write((decommissionReason == Device.DecommissionReasons.EndOfLife) ? "checked=\"checked\"" : string.Empty); Write((decommissionReason == DecommissionReasons.EndOfLife) ? "checked=\"checked\"" : string.Empty);
#line default #line default
#line hidden #line hidden
WriteLiteral("/>\r\n <label"); WriteLiteral("/>\r\n <label");
WriteAttribute("for", Tuple.Create(" for=\"", 42301), Tuple.Create("\"", 42380) WriteAttribute("for", Tuple.Create(" for=\"", 42280), Tuple.Create("\"", 42359)
, Tuple.Create(Tuple.Create("", 42307), Tuple.Create("Device_Show_Device_Actions_Decommission_Reason_", 42307), true) , Tuple.Create(Tuple.Create("", 42286), Tuple.Create("Device_Show_Device_Actions_Decommission_Reason_", 42286), true)
#line 681 "..\..\Views\Device\DeviceParts\_Subject.cshtml" #line 681 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
, Tuple.Create(Tuple.Create("", 42354), Tuple.Create<System.Object, System.Int32>((int)decommissionReason , Tuple.Create(Tuple.Create("", 42333), Tuple.Create<System.Object, System.Int32>((int)decommissionReason
#line default #line default
#line hidden #line hidden
, 42354), false) , 42333), false)
); );
WriteLiteral(">"); WriteLiteral(">");
+150
View File
@@ -0,0 +1,150 @@
@using Disco.Web.Models.Device;
@using Disco.Models.Services.Devices;
@model ExportModel
@{
Authorization.RequireAny(Claims.Device.Actions.Export);
ViewBag.Title = Html.ToBreadcrumb("Devices", MVC.Device.Index(), "Export Devices");
var optionsMetadata = ModelMetadata.FromLambdaExpression(m => m.Options, ViewData);
var optionGroups = optionsMetadata.Properties.Where(p => p.ShortDisplayName != null && p.ModelType == typeof(bool))
.GroupBy(m => m.ShortDisplayName);
}
<div id="Devices_Export">
@if (!string.IsNullOrEmpty(Model.DownloadExportSessionId))
{
<div id="Devices_Export_Download_Dialog" class="dialog" title="Export Devices">
<h4>The Device Export was completed successfully.</h4>
<a href="@Url.Action(MVC.API.Device.ExportRetrieve(Model.DownloadExportSessionId))" class="button"><i class="fa fa-download fa-lg"></i>Download Device Export</a>
</div>
<script>
$(function () {
$('#Devices_Export_Download_Dialog')
.dialog({
width: 400,
resizable: false,
modal: true,
autoOpen: true
});
});
</script>
}
@using (Html.BeginForm(MVC.API.Device.Export()))
{
<div id="Devices_Export_Type" class="form" style="width: 530px">
<h2>Export Type</h2>
<table>
<tr>
<th style="width: 150px">Type:
</th>
<td>
@Html.DropDownListFor(m => m.Options.ExportType, Enum.GetNames(typeof(Disco.Models.Services.Devices.Exporting.DeviceExportTypes)).Select(t => new SelectListItem() { Text = t, Value = t }))
<div id="Devices_Export_Type_Target_Batch" class="Devices_Export_Type_Target">
@Html.DropDownListFor(m => m.Options.ExportTypeTargetId, Model.DeviceBatches.Select(i => new SelectListItem() { Value = i.Key.ToString(), Text = i.Value }))
</div>
<div id="Devices_Export_Type_Target_Model" class="Devices_Export_Type_Target">
@Html.DropDownListFor(m => m.Options.ExportTypeTargetId, Model.DeviceModels.Select(i => new SelectListItem() { Value = i.Key.ToString(), Text = i.Value }))
</div>
<div id="Devices_Export_Type_Target_Profile" class="Devices_Export_Type_Target">
@Html.DropDownListFor(m => m.Options.ExportTypeTargetId, Model.DeviceProfiles.Select(i => new SelectListItem() { Value = i.Key.ToString(), Text = i.Value }))
</div>
</td>
</tr>
</table>
</div>
<div id="Devices_Export_Fields" class="form" style="width: 530px; margin-top: 15px;">
<h2>Export Fields <a id="Devices_Export_Fields_Defaults" href="#">(Defaults)</a></h2>
<table>
@foreach (var optionGroup in optionGroups)
{
var optionFields = optionGroup.ToList();
var itemsPerColumn = (int)Math.Ceiling((double)optionFields.Count / 2);
<tr>
<th style="width: 120px;">
@optionGroup.Key
@if (optionFields.Count > 2)
{
<span style="display: block;" class="select"><a class="selectAll" href="#">ALL</a> | <a class="selectNone" href="#">NONE</a></span>
}
</th>
<td>
<div class="Devices_Export_Fields_Group">
<table class="none">
<tr>
<td style="width: 50%">
<ul class="none">
@foreach (var optionItem in optionFields.Take(itemsPerColumn))
{
<li title="@optionItem.Description">
<input type="checkbox" id="Options_@optionItem.PropertyName" name="Options.@optionItem.PropertyName" value="true" @(((bool)optionItem.Model) ? "checked " : null)/><label for="Options_@optionItem.PropertyName">@optionItem.DisplayName</label></li>
}
</ul>
</td>
<td style="width: 50%">
<ul class="none">
@foreach (var optionItem in optionFields.Skip(itemsPerColumn))
{
<li title="@optionItem.Description">
<input type="checkbox" id="Options_@optionItem.PropertyName" name="Options.@optionItem.PropertyName" value="true" @(((bool)optionItem.Model) ? "checked " : null)/><label for="Options_@optionItem.PropertyName">@optionItem.DisplayName</label></li>
}
</ul>
</td>
</tr>
</table>
</div>
</td>
</tr>
}
</table>
</div>
<script>
$(function () {
exportDefaultFields = ['DeviceSerialNumber', 'ModelId', 'ProfileId', 'BatchId', 'AssignedUserId', 'DeviceLocation', 'DeviceAssetNumber'];
$exportFields = $('#Devices_Export_Fields');
$exportType = $('#Options_ExportType');
$exportTypeTargetContainers = $('#Devices_Export_Type').find('.Devices_Export_Type_Target');
function exportTypeChange() {
$exportTypeTargetContainers.hide();
$exportTypeTargetContainers.find('select').prop('disabled', true);
switch ($exportType.val()) {
case 'Batch':
$('#Devices_Export_Type_Target_Batch').show().find('select').prop('disabled', false);
break;
case 'Profile':
$('#Devices_Export_Type_Target_Profile').show().find('select').prop('disabled', false);
break;
case 'Model':
$('#Devices_Export_Type_Target_Model').show().find('select').prop('disabled', false);
break;
}
}
$exportType.change(exportTypeChange);
exportTypeChange();
$exportFields.on('click', 'a.selectAll,a.selectNone', function () {
$this = $(this);
$this.closest('tr').find('input').prop('checked', $this.is('.selectAll'));
return false;
});
$('#Devices_Export_Fields_Defaults').click(function () {
$exportFields.find('input').prop('checked', false);
$.each(exportDefaultFields, function (index, value) {
$('#Options_' + value).prop('checked', true);
});
return false;
});
});
</script>
<div class="actionBar">
<input type="submit" class="button" value="Export Devices" />
</div>
}
</div>
+611
View File
@@ -0,0 +1,611 @@
#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34014
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Disco.Web.Views.Device
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
using System.Web.Helpers;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using System.Web.Mvc.Html;
using System.Web.Routing;
using System.Web.Security;
using System.Web.UI;
using System.Web.WebPages;
using Disco;
using Disco.BI.Extensions;
using Disco.Models.Repository;
#line 2 "..\..\Views\Device\Export.cshtml"
using Disco.Models.Services.Devices;
#line default
#line hidden
using Disco.Services;
using Disco.Services.Authorization;
using Disco.Services.Web;
using Disco.Web;
using Disco.Web.Extensions;
#line 1 "..\..\Views\Device\Export.cshtml"
using Disco.Web.Models.Device;
#line default
#line hidden
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
[System.Web.WebPages.PageVirtualPathAttribute("~/Views/Device/Export.cshtml")]
public partial class Export : Disco.Services.Web.WebViewPage<ExportModel>
{
public Export()
{
}
public override void Execute()
{
#line 4 "..\..\Views\Device\Export.cshtml"
Authorization.RequireAny(Claims.Device.Actions.Export);
ViewBag.Title = Html.ToBreadcrumb("Devices", MVC.Device.Index(), "Export Devices");
var optionsMetadata = ModelMetadata.FromLambdaExpression(m => m.Options, ViewData);
var optionGroups = optionsMetadata.Properties.Where(p => p.ShortDisplayName != null && p.ModelType == typeof(bool))
.GroupBy(m => m.ShortDisplayName);
#line default
#line hidden
WriteLiteral("\r\n<div");
WriteLiteral(" id=\"Devices_Export\"");
WriteLiteral(">\r\n");
#line 14 "..\..\Views\Device\Export.cshtml"
#line default
#line hidden
#line 14 "..\..\Views\Device\Export.cshtml"
if (!string.IsNullOrEmpty(Model.DownloadExportSessionId))
{
#line default
#line hidden
WriteLiteral(" <div");
WriteLiteral(" id=\"Devices_Export_Download_Dialog\"");
WriteLiteral(" class=\"dialog\"");
WriteLiteral(" title=\"Export Devices\"");
WriteLiteral(">\r\n <h4>The Device Export was completed successfully.</h4>\r\n " +
" <a");
WriteAttribute("href", Tuple.Create(" href=\"", 776), Tuple.Create("\"", 856)
#line 18 "..\..\Views\Device\Export.cshtml"
, Tuple.Create(Tuple.Create("", 783), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.Device.ExportRetrieve(Model.DownloadExportSessionId))
#line default
#line hidden
, 783), false)
);
WriteLiteral(" class=\"button\"");
WriteLiteral("><i");
WriteLiteral(" class=\"fa fa-download fa-lg\"");
WriteLiteral("></i>Download Device Export</a>\r\n </div>\r\n");
WriteLiteral(@" <script>
$(function () {
$('#Devices_Export_Download_Dialog')
.dialog({
width: 400,
resizable: false,
modal: true,
autoOpen: true
});
});
</script>
");
#line 31 "..\..\Views\Device\Export.cshtml"
}
#line default
#line hidden
WriteLiteral(" ");
#line 32 "..\..\Views\Device\Export.cshtml"
using (Html.BeginForm(MVC.API.Device.Export()))
{
#line default
#line hidden
WriteLiteral(" <div");
WriteLiteral(" id=\"Devices_Export_Type\"");
WriteLiteral(" class=\"form\"");
WriteLiteral(" style=\"width: 530px\"");
WriteLiteral(">\r\n <h2>Export Type</h2>\r\n <table>\r\n <tr>\r\n " +
" <th");
WriteLiteral(" style=\"width: 150px\"");
WriteLiteral(">Type:\r\n </th>\r\n <td>\r\n");
WriteLiteral(" ");
#line 41 "..\..\Views\Device\Export.cshtml"
Write(Html.DropDownListFor(m => m.Options.ExportType, Enum.GetNames(typeof(Disco.Models.Services.Devices.Exporting.DeviceExportTypes)).Select(t => new SelectListItem() { Text = t, Value = t })));
#line default
#line hidden
WriteLiteral("\r\n <div");
WriteLiteral(" id=\"Devices_Export_Type_Target_Batch\"");
WriteLiteral(" class=\"Devices_Export_Type_Target\"");
WriteLiteral(">\r\n");
WriteLiteral(" ");
#line 43 "..\..\Views\Device\Export.cshtml"
Write(Html.DropDownListFor(m => m.Options.ExportTypeTargetId, Model.DeviceBatches.Select(i => new SelectListItem() { Value = i.Key.ToString(), Text = i.Value })));
#line default
#line hidden
WriteLiteral("\r\n </div>\r\n <div");
WriteLiteral(" id=\"Devices_Export_Type_Target_Model\"");
WriteLiteral(" class=\"Devices_Export_Type_Target\"");
WriteLiteral(">\r\n");
WriteLiteral(" ");
#line 46 "..\..\Views\Device\Export.cshtml"
Write(Html.DropDownListFor(m => m.Options.ExportTypeTargetId, Model.DeviceModels.Select(i => new SelectListItem() { Value = i.Key.ToString(), Text = i.Value })));
#line default
#line hidden
WriteLiteral("\r\n </div>\r\n <div");
WriteLiteral(" id=\"Devices_Export_Type_Target_Profile\"");
WriteLiteral(" class=\"Devices_Export_Type_Target\"");
WriteLiteral(">\r\n");
WriteLiteral(" ");
#line 49 "..\..\Views\Device\Export.cshtml"
Write(Html.DropDownListFor(m => m.Options.ExportTypeTargetId, Model.DeviceProfiles.Select(i => new SelectListItem() { Value = i.Key.ToString(), Text = i.Value })));
#line default
#line hidden
WriteLiteral("\r\n </div>\r\n </td>\r\n </tr" +
">\r\n </table>\r\n </div>\r\n");
WriteLiteral(" <div");
WriteLiteral(" id=\"Devices_Export_Fields\"");
WriteLiteral(" class=\"form\"");
WriteLiteral(" style=\"width: 530px; margin-top: 15px;\"");
WriteLiteral(">\r\n <h2>Export Fields <a");
WriteLiteral(" id=\"Devices_Export_Fields_Defaults\"");
WriteLiteral(" href=\"#\"");
WriteLiteral(">(Defaults)</a></h2>\r\n <table>\r\n");
#line 58 "..\..\Views\Device\Export.cshtml"
#line default
#line hidden
#line 58 "..\..\Views\Device\Export.cshtml"
foreach (var optionGroup in optionGroups)
{
var optionFields = optionGroup.ToList();
var itemsPerColumn = (int)Math.Ceiling((double)optionFields.Count / 2);
#line default
#line hidden
WriteLiteral(" <tr>\r\n <th");
WriteLiteral(" style=\"width: 120px;\"");
WriteLiteral(">\r\n");
WriteLiteral(" ");
#line 64 "..\..\Views\Device\Export.cshtml"
Write(optionGroup.Key);
#line default
#line hidden
WriteLiteral("\r\n");
#line 65 "..\..\Views\Device\Export.cshtml"
#line default
#line hidden
#line 65 "..\..\Views\Device\Export.cshtml"
if (optionFields.Count > 2)
{
#line default
#line hidden
WriteLiteral(" <span");
WriteLiteral(" style=\"display: block;\"");
WriteLiteral(" class=\"select\"");
WriteLiteral("><a");
WriteLiteral(" class=\"selectAll\"");
WriteLiteral(" href=\"#\"");
WriteLiteral(">ALL</a> | <a");
WriteLiteral(" class=\"selectNone\"");
WriteLiteral(" href=\"#\"");
WriteLiteral(">NONE</a></span>\r\n");
#line 68 "..\..\Views\Device\Export.cshtml"
}
#line default
#line hidden
WriteLiteral(" </th>\r\n <td>\r\n " +
" <div");
WriteLiteral(" class=\"Devices_Export_Fields_Group\"");
WriteLiteral(">\r\n <table");
WriteLiteral(" class=\"none\"");
WriteLiteral(">\r\n <tr>\r\n " +
" <td");
WriteLiteral(" style=\"width: 50%\"");
WriteLiteral(">\r\n <ul");
WriteLiteral(" class=\"none\"");
WriteLiteral(">\r\n");
#line 76 "..\..\Views\Device\Export.cshtml"
#line default
#line hidden
#line 76 "..\..\Views\Device\Export.cshtml"
foreach (var optionItem in optionFields.Take(itemsPerColumn))
{
#line default
#line hidden
WriteLiteral(" <li");
WriteAttribute("title", Tuple.Create(" title=\"", 4330), Tuple.Create("\"", 4361)
#line 78 "..\..\Views\Device\Export.cshtml"
, Tuple.Create(Tuple.Create("", 4338), Tuple.Create<System.Object, System.Int32>(optionItem.Description
#line default
#line hidden
, 4338), false)
);
WriteLiteral(">\r\n <input");
WriteLiteral(" type=\"checkbox\"");
WriteAttribute("id", Tuple.Create(" id=\"", 4443), Tuple.Create("\"", 4480)
, Tuple.Create(Tuple.Create("", 4448), Tuple.Create("Options_", 4448), true)
#line 79 "..\..\Views\Device\Export.cshtml"
, Tuple.Create(Tuple.Create("", 4456), Tuple.Create<System.Object, System.Int32>(optionItem.PropertyName
#line default
#line hidden
, 4456), false)
);
WriteAttribute("name", Tuple.Create(" name=\"", 4481), Tuple.Create("\"", 4520)
, Tuple.Create(Tuple.Create("", 4488), Tuple.Create("Options.", 4488), true)
#line 79 "..\..\Views\Device\Export.cshtml"
, Tuple.Create(Tuple.Create("", 4496), Tuple.Create<System.Object, System.Int32>(optionItem.PropertyName
#line default
#line hidden
, 4496), false)
);
WriteLiteral(" value=\"true\"");
WriteLiteral(" ");
#line 79 "..\..\Views\Device\Export.cshtml"
Write(((bool)optionItem.Model) ? "checked " : null);
#line default
#line hidden
WriteLiteral("/><label");
WriteAttribute("for", Tuple.Create(" for=\"", 4590), Tuple.Create("\"", 4628)
, Tuple.Create(Tuple.Create("", 4596), Tuple.Create("Options_", 4596), true)
#line 79 "..\..\Views\Device\Export.cshtml"
, Tuple.Create(Tuple.Create("", 4604), Tuple.Create<System.Object, System.Int32>(optionItem.PropertyName
#line default
#line hidden
, 4604), false)
);
WriteLiteral(">");
#line 79 "..\..\Views\Device\Export.cshtml"
Write(optionItem.DisplayName);
#line default
#line hidden
WriteLiteral("</label></li>\r\n");
#line 80 "..\..\Views\Device\Export.cshtml"
}
#line default
#line hidden
WriteLiteral(" </ul>\r\n " +
" </td>\r\n <td");
WriteLiteral(" style=\"width: 50%\"");
WriteLiteral(">\r\n <ul");
WriteLiteral(" class=\"none\"");
WriteLiteral(">\r\n");
#line 85 "..\..\Views\Device\Export.cshtml"
#line default
#line hidden
#line 85 "..\..\Views\Device\Export.cshtml"
foreach (var optionItem in optionFields.Skip(itemsPerColumn))
{
#line default
#line hidden
WriteLiteral(" <li");
WriteAttribute("title", Tuple.Create(" title=\"", 5163), Tuple.Create("\"", 5194)
#line 87 "..\..\Views\Device\Export.cshtml"
, Tuple.Create(Tuple.Create("", 5171), Tuple.Create<System.Object, System.Int32>(optionItem.Description
#line default
#line hidden
, 5171), false)
);
WriteLiteral(">\r\n <input");
WriteLiteral(" type=\"checkbox\"");
WriteAttribute("id", Tuple.Create(" id=\"", 5276), Tuple.Create("\"", 5313)
, Tuple.Create(Tuple.Create("", 5281), Tuple.Create("Options_", 5281), true)
#line 88 "..\..\Views\Device\Export.cshtml"
, Tuple.Create(Tuple.Create("", 5289), Tuple.Create<System.Object, System.Int32>(optionItem.PropertyName
#line default
#line hidden
, 5289), false)
);
WriteAttribute("name", Tuple.Create(" name=\"", 5314), Tuple.Create("\"", 5353)
, Tuple.Create(Tuple.Create("", 5321), Tuple.Create("Options.", 5321), true)
#line 88 "..\..\Views\Device\Export.cshtml"
, Tuple.Create(Tuple.Create("", 5329), Tuple.Create<System.Object, System.Int32>(optionItem.PropertyName
#line default
#line hidden
, 5329), false)
);
WriteLiteral(" value=\"true\"");
WriteLiteral(" ");
#line 88 "..\..\Views\Device\Export.cshtml"
Write(((bool)optionItem.Model) ? "checked " : null);
#line default
#line hidden
WriteLiteral("/><label");
WriteAttribute("for", Tuple.Create(" for=\"", 5423), Tuple.Create("\"", 5461)
, Tuple.Create(Tuple.Create("", 5429), Tuple.Create("Options_", 5429), true)
#line 88 "..\..\Views\Device\Export.cshtml"
, Tuple.Create(Tuple.Create("", 5437), Tuple.Create<System.Object, System.Int32>(optionItem.PropertyName
#line default
#line hidden
, 5437), false)
);
WriteLiteral(">");
#line 88 "..\..\Views\Device\Export.cshtml"
Write(optionItem.DisplayName);
#line default
#line hidden
WriteLiteral("</label></li>\r\n");
#line 89 "..\..\Views\Device\Export.cshtml"
}
#line default
#line hidden
WriteLiteral(@" </ul>
</td>
</tr>
</table>
</div>
</td>
</tr>
");
#line 97 "..\..\Views\Device\Export.cshtml"
}
#line default
#line hidden
WriteLiteral(" </table>\r\n </div>\r\n");
WriteLiteral(" <script>\r\n $(function () {\r\n exportDefaultField" +
"s = [\'DeviceSerialNumber\', \'ModelId\', \'ProfileId\', \'BatchId\', \'AssignedUserId\', " +
"\'DeviceLocation\', \'DeviceAssetNumber\'];\r\n $exportFields = $(\'#Dev" +
"ices_Export_Fields\');\r\n $exportType = $(\'#Options_ExportType\');\r\n" +
" $exportTypeTargetContainers = $(\'#Devices_Export_Type\').find(\'.D" +
"evices_Export_Type_Target\');\r\n\r\n function exportTypeChange() {\r\n " +
" $exportTypeTargetContainers.hide();\r\n $exp" +
"ortTypeTargetContainers.find(\'select\').prop(\'disabled\', true);\r\n\r\n " +
" switch ($exportType.val()) {\r\n case \'Batch\':\r\n " +
" $(\'#Devices_Export_Type_Target_Batch\').show().find(\'selec" +
"t\').prop(\'disabled\', false);\r\n break;\r\n " +
" case \'Profile\':\r\n $(\'#Devices_Export_Type_T" +
"arget_Profile\').show().find(\'select\').prop(\'disabled\', false);\r\n " +
" break;\r\n case \'Model\':\r\n " +
" $(\'#Devices_Export_Type_Target_Model\').show().find(\'select\').prop(\'disabl" +
"ed\', false);\r\n break;\r\n }\r\n " +
" }\r\n $exportType.change(exportTypeChange);\r\n " +
" exportTypeChange();\r\n\r\n $exportFields.on(\'click\', \'a.selectAll" +
",a.selectNone\', function () {\r\n $this = $(this);\r\n\r\n " +
" $this.closest(\'tr\').find(\'input\').prop(\'checked\', $this.is(\'.selectAl" +
"l\'));\r\n\r\n return false;\r\n });\r\n\r\n " +
" $(\'#Devices_Export_Fields_Defaults\').click(function () {\r\n\r\n " +
" $exportFields.find(\'input\').prop(\'checked\', false);\r\n\r\n $." +
"each(exportDefaultFields, function (index, value) {\r\n $(\'" +
"#Options_\' + value).prop(\'checked\', true);\r\n });\r\n\r\n " +
" return false;\r\n });\r\n });\r\n </script" +
">\r\n");
WriteLiteral(" <div");
WriteLiteral(" class=\"actionBar\"");
WriteLiteral(">\r\n <input");
WriteLiteral(" type=\"submit\"");
WriteLiteral(" class=\"button\"");
WriteLiteral(" value=\"Export Devices\"");
WriteLiteral(" />\r\n </div>\r\n");
#line 149 "..\..\Views\Device\Export.cshtml"
}
#line default
#line hidden
WriteLiteral("</div>\r\n");
}
}
}
#pragma warning restore 1591
@@ -190,8 +190,3 @@
</div> </div>
</div> </div>
} }
@if (Authorization.Has(Claims.Device.Actions.Export)){
<div class="actionBar">
@Html.ActionLinkButton("Export All Devices", MVC.API.Device.ExportAllDevices())
</div>
}
@@ -2,7 +2,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.34011 // Runtime Version:4.0.30319.34014
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
@@ -545,37 +545,6 @@ WriteLiteral(" </tbody>\r\n </table>\r\n </div>
#line 192 "..\..\Views\Device\ImportExport.cshtml" #line 192 "..\..\Views\Device\ImportExport.cshtml"
} }
#line default
#line hidden
#line 193 "..\..\Views\Device\ImportExport.cshtml"
if (Authorization.Has(Claims.Device.Actions.Export)){
#line default
#line hidden
WriteLiteral("<div");
WriteLiteral(" class=\"actionBar\"");
WriteLiteral(">\r\n");
WriteLiteral(" ");
#line 195 "..\..\Views\Device\ImportExport.cshtml"
Write(Html.ActionLinkButton("Export All Devices", MVC.API.Device.ExportAllDevices()));
#line default
#line hidden
WriteLiteral("\r\n</div>\r\n");
#line 197 "..\..\Views\Device\ImportExport.cshtml"
}
#line default #line default
#line hidden #line hidden
} }
+5 -5
View File
@@ -9,13 +9,13 @@
@if (Authorization.HasAny(Claims.Device.Actions.Import, Claims.Device.Actions.Export, Claims.Device.Actions.EnrolDevices)) @if (Authorization.HasAny(Claims.Device.Actions.Import, Claims.Device.Actions.Export, Claims.Device.Actions.EnrolDevices))
{ {
<div class="actionBar"> <div class="actionBar">
@if (Authorization.HasAll(Claims.Device.Actions.Import, Claims.Device.Actions.Export)) @if (Authorization.Has(Claims.Device.Actions.Import))
{ {
@Html.ActionLinkButton("Import/Export Devices", MVC.Device.ImportExport())
}else if (Authorization.Has(Claims.Device.Actions.Import)){
@Html.ActionLinkButton("Import Devices", MVC.Device.ImportExport()) @Html.ActionLinkButton("Import Devices", MVC.Device.ImportExport())
}else if (Authorization.Has(Claims.Device.Actions.Export)){ }
@Html.ActionLinkButton("Export All Devices", MVC.API.Device.ExportAllDevices()) @if (Authorization.Has(Claims.Device.Actions.Export))
{
@Html.ActionLinkButton("Export Devices", MVC.Device.Export())
} }
@if (Authorization.Has(Claims.Device.Actions.EnrolDevices)) @if (Authorization.Has(Claims.Device.Actions.EnrolDevices))
{ {
+9 -14
View File
@@ -2,7 +2,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.34011 // Runtime Version:4.0.30319.34014
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
@@ -107,7 +107,7 @@ WriteLiteral(">\r\n");
#line hidden #line hidden
#line 12 "..\..\Views\Device\Index.cshtml" #line 12 "..\..\Views\Device\Index.cshtml"
if (Authorization.HasAll(Claims.Device.Actions.Import, Claims.Device.Actions.Export)) if (Authorization.Has(Claims.Device.Actions.Import))
{ {
@@ -115,7 +115,7 @@ WriteLiteral(">\r\n");
#line hidden #line hidden
#line 14 "..\..\Views\Device\Index.cshtml" #line 14 "..\..\Views\Device\Index.cshtml"
Write(Html.ActionLinkButton("Import/Export Devices", MVC.Device.ImportExport())); Write(Html.ActionLinkButton("Import Devices", MVC.Device.ImportExport()));
#line default #line default
@@ -123,29 +123,24 @@ WriteLiteral(">\r\n");
#line 14 "..\..\Views\Device\Index.cshtml" #line 14 "..\..\Views\Device\Index.cshtml"
}else if (Authorization.Has(Claims.Device.Actions.Import)){ }
#line default #line default
#line hidden #line hidden
WriteLiteral(" ");
#line 16 "..\..\Views\Device\Index.cshtml" #line 16 "..\..\Views\Device\Index.cshtml"
Write(Html.ActionLinkButton("Import Devices", MVC.Device.ImportExport())); if (Authorization.Has(Claims.Device.Actions.Export))
{
#line default
#line hidden
#line 16 "..\..\Views\Device\Index.cshtml"
}else if (Authorization.Has(Claims.Device.Actions.Export)){
#line default #line default
#line hidden #line hidden
#line 18 "..\..\Views\Device\Index.cshtml" #line 18 "..\..\Views\Device\Index.cshtml"
Write(Html.ActionLinkButton("Export All Devices", MVC.API.Device.ExportAllDevices())); Write(Html.ActionLinkButton("Export Devices", MVC.Device.Export()));
#line default #line default