refactor: make exporting consistent
This commit is contained in:
@@ -7,7 +7,7 @@ namespace Disco.Data.Configuration.Modules
|
|||||||
{
|
{
|
||||||
public DeviceProfilesConfiguration(DiscoDataContext Database) : base(Database) { }
|
public DeviceProfilesConfiguration(DiscoDataContext Database) : base(Database) { }
|
||||||
|
|
||||||
public override string Scope { get { return "DeviceProfiles"; } }
|
public override string Scope { get; } = "DeviceProfiles";
|
||||||
|
|
||||||
public int DefaultDeviceProfileId
|
public int DefaultDeviceProfileId
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using Disco.Data.Repository;
|
using Disco.Data.Repository;
|
||||||
using Disco.Models.Services.Devices.Exporting;
|
using Disco.Models.Services.Devices;
|
||||||
|
|
||||||
namespace Disco.Data.Configuration.Modules
|
namespace Disco.Data.Configuration.Modules
|
||||||
{
|
{
|
||||||
@@ -7,12 +7,12 @@ namespace Disco.Data.Configuration.Modules
|
|||||||
{
|
{
|
||||||
public DevicesConfiguration(DiscoDataContext Database) : base(Database) { }
|
public DevicesConfiguration(DiscoDataContext Database) : base(Database) { }
|
||||||
|
|
||||||
public override string Scope { get { return "Devices"; } }
|
public override string Scope { get; } = "Devices";
|
||||||
|
|
||||||
public DeviceExportOptions LastExportOptions
|
public DeviceExportOptions LastExportOptions
|
||||||
{
|
{
|
||||||
get { return this.Get<DeviceExportOptions>(DeviceExportOptions.DefaultOptions()); }
|
get => Get(DeviceExportOptions.DefaultOptions());
|
||||||
set { this.Set(value); }
|
set => Set(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace Disco.Data.Configuration.Modules
|
|||||||
{
|
{
|
||||||
public DocumentsConfiguration(DiscoDataContext Database) : base(Database) { }
|
public DocumentsConfiguration(DiscoDataContext Database) : base(Database) { }
|
||||||
|
|
||||||
public override string Scope { get { return "Documents"; } }
|
public override string Scope { get; } = "Documents";
|
||||||
|
|
||||||
public List<DocumentTemplatePackage> Packages
|
public List<DocumentTemplatePackage> Packages
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using Disco.Data.Repository;
|
using Disco.Data.Repository;
|
||||||
using Disco.Models.Services.Jobs;
|
using Disco.Models.Services.Jobs;
|
||||||
using Disco.Models.Services.Jobs.Exporting;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
@@ -10,15 +9,15 @@ namespace Disco.Data.Configuration.Modules
|
|||||||
{
|
{
|
||||||
public JobPreferencesConfiguration(DiscoDataContext Database) : base(Database) { }
|
public JobPreferencesConfiguration(DiscoDataContext Database) : base(Database) { }
|
||||||
|
|
||||||
public override string Scope { get { return "JobPreferences"; } }
|
public override string Scope { get; } = "JobPreferences";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initial comments template for new jobs
|
/// Initial comments template for new jobs
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string InitialCommentsTemplate
|
public string InitialCommentsTemplate
|
||||||
{
|
{
|
||||||
get { return Get<string>(null); }
|
get => Get<string>(null);
|
||||||
set { Set(value); }
|
set => Set(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -26,11 +25,11 @@ namespace Disco.Data.Configuration.Modules
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int LongRunningJobDaysThreshold
|
public int LongRunningJobDaysThreshold
|
||||||
{
|
{
|
||||||
get { return Get<int>(7); }
|
get => Get(7);
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value < 0)
|
if (value < 0)
|
||||||
throw new ArgumentOutOfRangeException("value", "The Long Running Job Days Threshold cannot be less than zero");
|
throw new ArgumentOutOfRangeException(nameof(value), "The Long Running Job Days Threshold cannot be less than zero");
|
||||||
|
|
||||||
Set(value);
|
Set(value);
|
||||||
}
|
}
|
||||||
@@ -41,11 +40,11 @@ namespace Disco.Data.Configuration.Modules
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int StaleJobMinutesThreshold
|
public int StaleJobMinutesThreshold
|
||||||
{
|
{
|
||||||
get { return Get<int>(60 * 24 * 2); } // Default to 48 Hours (2 days)
|
get => Get(60 * 24 * 2); // Default to 48 Hours (2 days)
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value < 0)
|
if (value < 0)
|
||||||
throw new ArgumentOutOfRangeException("value", "The Stale Job Minutes Threshold cannot be less than zero");
|
throw new ArgumentOutOfRangeException(nameof(value), "The Stale Job Minutes Threshold cannot be less than zero");
|
||||||
|
|
||||||
Set(value);
|
Set(value);
|
||||||
}
|
}
|
||||||
@@ -53,8 +52,8 @@ namespace Disco.Data.Configuration.Modules
|
|||||||
|
|
||||||
public bool LodgmentIncludeAllAttachmentsByDefault
|
public bool LodgmentIncludeAllAttachmentsByDefault
|
||||||
{
|
{
|
||||||
get { return Get(false); }
|
get => Get(false);
|
||||||
set { Set(value); }
|
set => Set(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -63,11 +62,11 @@ namespace Disco.Data.Configuration.Modules
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string DefaultNoticeboardTheme
|
public string DefaultNoticeboardTheme
|
||||||
{
|
{
|
||||||
get { return Get("default"); }
|
get => Get("default");
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(value))
|
if (string.IsNullOrWhiteSpace(value))
|
||||||
throw new ArgumentNullException("DefaultNoticeboardTheme");
|
throw new ArgumentNullException(nameof(DefaultNoticeboardTheme));
|
||||||
|
|
||||||
Set(value);
|
Set(value);
|
||||||
}
|
}
|
||||||
@@ -75,47 +74,48 @@ namespace Disco.Data.Configuration.Modules
|
|||||||
|
|
||||||
public LocationModes LocationMode
|
public LocationModes LocationMode
|
||||||
{
|
{
|
||||||
get { return Get(LocationModes.Unrestricted); }
|
get => Get(LocationModes.Unrestricted);
|
||||||
set { Set(value); }
|
set => Set(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<string> LocationList
|
public List<string> LocationList
|
||||||
{
|
{
|
||||||
get { return Get(new List<string>()); }
|
get => Get(new List<string>());
|
||||||
set { Set(value); }
|
set => Set(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string OnCreateExpression
|
public string OnCreateExpression
|
||||||
{
|
{
|
||||||
get { return Get<string>(null); }
|
get => Get<string>(null);
|
||||||
set { Set(value); }
|
set => Set(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string OnDeviceReadyForReturnExpression
|
public string OnDeviceReadyForReturnExpression
|
||||||
{
|
{
|
||||||
get { return Get<string>(null); }
|
get => Get<string>(null);
|
||||||
set { Set(value); }
|
set => Set(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string OnCloseExpression
|
public string OnCloseExpression
|
||||||
{
|
{
|
||||||
get { return Get<string>(null); }
|
get => Get<string>(null);
|
||||||
set { Set(value); }
|
set => Set(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JobExportOptions LastExportOptions
|
public JobExportOptions LastExportOptions
|
||||||
{
|
{
|
||||||
get { return this.Get(JobExportOptions.DefaultOptions()); }
|
get => Get(JobExportOptions.DefaultOptions());
|
||||||
set {
|
set
|
||||||
this.Set(value);
|
{
|
||||||
this.LastExportDate = DateTime.Now;
|
Set(value);
|
||||||
|
LastExportDate = DateTime.Now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateTime? LastExportDate
|
public DateTime? LastExportDate
|
||||||
{
|
{
|
||||||
get { return this.Get<DateTime?>(null); }
|
get => Get<DateTime?>(null);
|
||||||
set { this.Set(value); }
|
set => Set(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using Disco.Data.Repository;
|
using Disco.Data.Repository;
|
||||||
using Disco.Models.BI.Config;
|
using Disco.Models.BI.Config;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
@@ -8,11 +7,9 @@ namespace Disco.Data.Configuration.Modules
|
|||||||
{
|
{
|
||||||
public class OrganisationAddressesConfiguration : ConfigurationBase
|
public class OrganisationAddressesConfiguration : ConfigurationBase
|
||||||
{
|
{
|
||||||
private const string scope = "OrganisationAddresses";
|
|
||||||
|
|
||||||
public OrganisationAddressesConfiguration(DiscoDataContext Database) : base(Database) { }
|
public OrganisationAddressesConfiguration(DiscoDataContext Database) : base(Database) { }
|
||||||
|
|
||||||
public override string Scope { get { return scope; } }
|
public override string Scope { get; } = "OrganisationAddresses";
|
||||||
|
|
||||||
public OrganisationAddress GetAddress(int Id)
|
public OrganisationAddress GetAddress(int Id)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ namespace Disco.Data.Configuration
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public override string Scope { get { return "System"; } }
|
public override string Scope { get; } = "System";
|
||||||
|
|
||||||
public string DataStoreLocation
|
public string DataStoreLocation
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -83,8 +83,8 @@
|
|||||||
<Compile Include="Services\Interop\DiscoServices\Activation\CallbackModel.cs" />
|
<Compile Include="Services\Interop\DiscoServices\Activation\CallbackModel.cs" />
|
||||||
<Compile Include="Services\Interop\DiscoServices\Activation\ChallengeModel.cs" />
|
<Compile Include="Services\Interop\DiscoServices\Activation\ChallengeModel.cs" />
|
||||||
<Compile Include="Services\Interop\DiscoServices\IConnectNotification.cs" />
|
<Compile Include="Services\Interop\DiscoServices\IConnectNotification.cs" />
|
||||||
<Compile Include="Services\Jobs\Exporting\JobExportOptions.cs" />
|
<Compile Include="Services\Jobs\JobExportOptions.cs" />
|
||||||
<Compile Include="Services\Jobs\Exporting\JobExportRecord.cs" />
|
<Compile Include="Services\Jobs\JobExportRecord.cs" />
|
||||||
<Compile Include="Services\Jobs\LocationModes.cs" />
|
<Compile Include="Services\Jobs\LocationModes.cs" />
|
||||||
<Compile Include="ClientServices\EnrolmentInformation\Certificate.cs" />
|
<Compile Include="ClientServices\EnrolmentInformation\Certificate.cs" />
|
||||||
<Compile Include="ClientServices\Register.cs" />
|
<Compile Include="ClientServices\Register.cs" />
|
||||||
@@ -137,10 +137,10 @@
|
|||||||
<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\DeviceExportRecord.cs" />
|
||||||
<Compile Include="Exporting\ExportResult.cs" />
|
<Compile Include="Exporting\ExportResult.cs" />
|
||||||
<Compile Include="Services\Devices\Exporting\DeviceExportTypes.cs" />
|
<Compile Include="Services\Devices\DeviceExportTypes.cs" />
|
||||||
<Compile Include="Services\Devices\Exporting\DeviceExportOptions.cs" />
|
<Compile Include="Services\Devices\DeviceExportOptions.cs" />
|
||||||
<Compile Include="Services\Devices\Importing\DeviceImportFieldTypes.cs" />
|
<Compile Include="Services\Devices\Importing\DeviceImportFieldTypes.cs" />
|
||||||
<Compile Include="Services\Devices\Importing\IDeviceImportRecord.cs" />
|
<Compile Include="Services\Devices\Importing\IDeviceImportRecord.cs" />
|
||||||
<Compile Include="Services\Devices\Importing\IDeviceImportContext.cs" />
|
<Compile Include="Services\Devices\Importing\IDeviceImportContext.cs" />
|
||||||
@@ -159,6 +159,7 @@
|
|||||||
<Compile Include="Services\Jobs\JobLists\JobTableStatusQueueItemModel.cs" />
|
<Compile Include="Services\Jobs\JobLists\JobTableStatusQueueItemModel.cs" />
|
||||||
<Compile Include="Services\Jobs\JobQueues\IJobQueueToken.cs" />
|
<Compile Include="Services\Jobs\JobQueues\IJobQueueToken.cs" />
|
||||||
<Compile Include="Services\Jobs\Noticeboards\IHeldDeviceItem.cs" />
|
<Compile Include="Services\Jobs\Noticeboards\IHeldDeviceItem.cs" />
|
||||||
|
<Compile Include="Services\Logging\LogExportOptions.cs" />
|
||||||
<Compile Include="Services\Messaging\Email.cs" />
|
<Compile Include="Services\Messaging\Email.cs" />
|
||||||
<Compile Include="Services\Messaging\EmailAttachment.cs" />
|
<Compile Include="Services\Messaging\EmailAttachment.cs" />
|
||||||
<Compile Include="Services\Users\Contact\UserContact.cs" />
|
<Compile Include="Services\Users\Contact\UserContact.cs" />
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ namespace Disco.Models.Services.Exporting
|
|||||||
{
|
{
|
||||||
public interface IExportOptions
|
public interface IExportOptions
|
||||||
{
|
{
|
||||||
ExportFormat Format { get; }
|
int Version { get; set; }
|
||||||
string FilenamePrefix { get; }
|
ExportFormat Format { get; set; }
|
||||||
string ExcelWorksheetName { get; }
|
|
||||||
string ExcelTableName { get; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-6
@@ -2,17 +2,15 @@
|
|||||||
using Disco.Models.Services.Exporting;
|
using Disco.Models.Services.Exporting;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace Disco.Models.Services.Devices.Exporting
|
namespace Disco.Models.Services.Devices
|
||||||
{
|
{
|
||||||
public class DeviceExportOptions : IExportOptions
|
public class DeviceExportOptions : IExportOptions
|
||||||
{
|
{
|
||||||
|
public int Version { get; set; } = 1;
|
||||||
|
public ExportFormat Format { get; set; }
|
||||||
|
|
||||||
public DeviceExportTypes ExportType { get; set; }
|
public DeviceExportTypes ExportType { get; set; }
|
||||||
public int? ExportTypeTargetId { get; set; }
|
public int? ExportTypeTargetId { get; set; }
|
||||||
|
|
||||||
public ExportFormat Format { get; set; }
|
|
||||||
public string FilenamePrefix { get; } = "DiscoDeviceExport";
|
|
||||||
public string ExcelWorksheetName { get; } = "DeviceExport";
|
|
||||||
public string ExcelTableName { get; } = "Devices";
|
|
||||||
|
|
||||||
// Device
|
// Device
|
||||||
[Display(ShortName = "Device", Name = "Serial Number", Description = "The device serial number")]
|
[Display(ShortName = "Device", Name = "Serial Number", Description = "The device serial number")]
|
||||||
+1
-1
@@ -4,7 +4,7 @@ using Disco.Models.Repository;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Disco.Models.Services.Devices.Exporting
|
namespace Disco.Models.Services.Devices
|
||||||
{
|
{
|
||||||
public class DeviceExportRecord : IExportRecord
|
public class DeviceExportRecord : IExportRecord
|
||||||
{
|
{
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace Disco.Models.Services.Devices.Exporting
|
namespace Disco.Models.Services.Devices
|
||||||
{
|
{
|
||||||
public enum DeviceExportTypes
|
public enum DeviceExportTypes
|
||||||
{
|
{
|
||||||
@@ -7,10 +7,8 @@ namespace Disco.Models.Services.Devices.DeviceFlag
|
|||||||
{
|
{
|
||||||
public class DeviceFlagExportOptions : IExportOptions
|
public class DeviceFlagExportOptions : IExportOptions
|
||||||
{
|
{
|
||||||
|
public int Version { get; set; } = 1;
|
||||||
public ExportFormat Format { get; set; }
|
public ExportFormat Format { get; set; }
|
||||||
public string FilenamePrefix { get; } = "DiscoDeviceFlagExport";
|
|
||||||
public string ExcelWorksheetName { get; } = "DeviceFlagExport";
|
|
||||||
public string ExcelTableName { get; } = "DeviceFlags";
|
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public List<int> DeviceFlagIds { get; set; } = new List<int>();
|
public List<int> DeviceFlagIds { get; set; } = new List<int>();
|
||||||
|
|||||||
+4
-6
@@ -4,10 +4,13 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace Disco.Models.Services.Jobs.Exporting
|
namespace Disco.Models.Services.Jobs
|
||||||
{
|
{
|
||||||
public class JobExportOptions : IExportOptions
|
public class JobExportOptions : IExportOptions
|
||||||
{
|
{
|
||||||
|
public int Version { get; set; } = 1;
|
||||||
|
public ExportFormat Format { get; set; }
|
||||||
|
|
||||||
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true, ConvertEmptyStringToNull = true, HtmlEncode = false)]
|
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true, ConvertEmptyStringToNull = true, HtmlEncode = false)]
|
||||||
public DateTime FilterStartDate { get; set; }
|
public DateTime FilterStartDate { get; set; }
|
||||||
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true, ConvertEmptyStringToNull = true, HtmlEncode = false)]
|
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true, ConvertEmptyStringToNull = true, HtmlEncode = false)]
|
||||||
@@ -17,11 +20,6 @@ namespace Disco.Models.Services.Jobs.Exporting
|
|||||||
public List<string> FilterJobSubTypeIds { get; set; }
|
public List<string> FilterJobSubTypeIds { get; set; }
|
||||||
public int? FilterJobQueueId { get; set; }
|
public int? FilterJobQueueId { get; set; }
|
||||||
|
|
||||||
public ExportFormat Format { get; set; }
|
|
||||||
public string FilenamePrefix { get; } = "DiscoJobExport";
|
|
||||||
public string ExcelWorksheetName { get; } = "JobExport";
|
|
||||||
public string ExcelTableName { get; } = "Jobs";
|
|
||||||
|
|
||||||
// Job
|
// Job
|
||||||
[Display(ShortName = "Job", Name = "Identifier", Description = "The identifier of the job")]
|
[Display(ShortName = "Job", Name = "Identifier", Description = "The identifier of the job")]
|
||||||
public bool JobId { get; set; }
|
public bool JobId { get; set; }
|
||||||
+1
-1
@@ -3,7 +3,7 @@ using Disco.Models.Repository;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Disco.Models.Services.Jobs.Exporting
|
namespace Disco.Models.Services.Jobs
|
||||||
{
|
{
|
||||||
public class JobExportRecord : IExportRecord
|
public class JobExportRecord : IExportRecord
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using Disco.Models.Exporting;
|
||||||
|
using Disco.Models.Services.Exporting;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Disco.Models.Services.Logging
|
||||||
|
{
|
||||||
|
public class LogExportOptions : IExportOptions
|
||||||
|
{
|
||||||
|
public int Version { get; set; } = 1;
|
||||||
|
public ExportFormat Format { get; set; }
|
||||||
|
|
||||||
|
public DateTime? StartDate { get; set; }
|
||||||
|
public DateTime? EndDate { get; set; }
|
||||||
|
public int? ModuleId { get; set; }
|
||||||
|
public List<int> EventTypeIds { get; set; }
|
||||||
|
public int? Take { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,10 +7,8 @@ namespace Disco.Models.Services.Users.UserFlags
|
|||||||
{
|
{
|
||||||
public class UserFlagExportOptions : IExportOptions
|
public class UserFlagExportOptions : IExportOptions
|
||||||
{
|
{
|
||||||
|
public int Version { get; set; } = 1;
|
||||||
public ExportFormat Format { get; set; }
|
public ExportFormat Format { get; set; }
|
||||||
public string FilenamePrefix { get; } = "DiscoUserFlagExport";
|
|
||||||
public string ExcelWorksheetName { get; } = "UserFlagExport";
|
|
||||||
public string ExcelTableName { get; } = "UserFlags";
|
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public List<int> UserFlagIds { get; set; } = new List<int>();
|
public List<int> UserFlagIds { get; set; } = new List<int>();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Disco.Models.Services.Devices.DeviceFlag;
|
using Disco.Models.Services.Devices.DeviceFlag;
|
||||||
using Disco.Models.Services.Exporting;
|
using Disco.Models.Services.Exporting;
|
||||||
using Disco.Models.UI;
|
using Disco.Models.UI;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Disco.Models.Areas.Config.UI.DeviceFlag
|
namespace Disco.Models.Areas.Config.UI.DeviceFlag
|
||||||
@@ -9,8 +10,8 @@ namespace Disco.Models.Areas.Config.UI.DeviceFlag
|
|||||||
{
|
{
|
||||||
DeviceFlagExportOptions Options { get; set; }
|
DeviceFlagExportOptions Options { get; set; }
|
||||||
|
|
||||||
string ExportSessionId { get; set; }
|
Guid? ExportId { get; set; }
|
||||||
ExportResult ExportSessionResult { get; set; }
|
ExportResult ExportResult { get; set; }
|
||||||
|
|
||||||
List<Repository.DeviceFlag> DeviceFlags { get; set; }
|
List<Repository.DeviceFlag> DeviceFlags { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Disco.Models.Services.Exporting;
|
using Disco.Models.Services.Exporting;
|
||||||
using Disco.Models.Services.Users.UserFlags;
|
using Disco.Models.Services.Users.UserFlags;
|
||||||
using Disco.Models.UI;
|
using Disco.Models.UI;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Disco.Models.Areas.Config.UI.UserFlag
|
namespace Disco.Models.Areas.Config.UI.UserFlag
|
||||||
@@ -9,8 +10,8 @@ namespace Disco.Models.Areas.Config.UI.UserFlag
|
|||||||
{
|
{
|
||||||
UserFlagExportOptions Options { get; set; }
|
UserFlagExportOptions Options { get; set; }
|
||||||
|
|
||||||
string ExportSessionId { get; set; }
|
Guid? ExportId { get; set; }
|
||||||
ExportResult ExportSessionResult { get; set; }
|
ExportResult ExportResult { get; set; }
|
||||||
|
|
||||||
List<Repository.UserFlag> UserFlags { get; set; }
|
List<Repository.UserFlag> UserFlags { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Disco.Models.Services.Devices.Exporting;
|
using Disco.Models.Services.Devices;
|
||||||
using Disco.Models.Services.Exporting;
|
using Disco.Models.Services.Exporting;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Disco.Models.UI.Device
|
namespace Disco.Models.UI.Device
|
||||||
@@ -8,8 +9,8 @@ namespace Disco.Models.UI.Device
|
|||||||
{
|
{
|
||||||
DeviceExportOptions Options { get; set; }
|
DeviceExportOptions Options { get; set; }
|
||||||
|
|
||||||
string ExportSessionId { get; set; }
|
Guid? ExportId { get; set; }
|
||||||
ExportResult ExportSessionResult { get; set; }
|
ExportResult ExportResult { get; set; }
|
||||||
|
|
||||||
IEnumerable<KeyValuePair<int, string>> DeviceBatches { get; set; }
|
IEnumerable<KeyValuePair<int, string>> DeviceBatches { get; set; }
|
||||||
IEnumerable<KeyValuePair<int, string>> DeviceModels { get; set; }
|
IEnumerable<KeyValuePair<int, string>> DeviceModels { get; set; }
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Disco.Models.Repository;
|
using Disco.Models.Repository;
|
||||||
using Disco.Models.Services.Exporting;
|
using Disco.Models.Services.Exporting;
|
||||||
using Disco.Models.Services.Jobs.Exporting;
|
using Disco.Models.Services.Jobs;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Disco.Models.UI.Job
|
namespace Disco.Models.UI.Job
|
||||||
@@ -9,8 +10,8 @@ namespace Disco.Models.UI.Job
|
|||||||
{
|
{
|
||||||
JobExportOptions Options { get; set; }
|
JobExportOptions Options { get; set; }
|
||||||
|
|
||||||
string ExportSessionId { get; set; }
|
Guid? ExportId { get; set; }
|
||||||
ExportResult ExportSessionResult { get; set; }
|
ExportResult ExportResult { get; set; }
|
||||||
|
|
||||||
List<JobQueue> JobQueues { get; set; }
|
List<JobQueue> JobQueues { get; set; }
|
||||||
List<KeyValuePair<string, string>> JobStatuses { get; set; }
|
List<KeyValuePair<string, string>> JobStatuses { get; set; }
|
||||||
|
|||||||
+112
-93
@@ -1,32 +1,89 @@
|
|||||||
using Disco.Data.Repository;
|
using Disco.Data.Repository;
|
||||||
using Disco.Models.Exporting;
|
using Disco.Models.Exporting;
|
||||||
using Disco.Models.Repository;
|
using Disco.Models.Repository;
|
||||||
using Disco.Models.Services.Devices.Exporting;
|
using Disco.Models.Services.Devices;
|
||||||
using Disco.Models.Services.Exporting;
|
using Disco.Models.Services.Exporting;
|
||||||
|
using Disco.Services.Exporting;
|
||||||
using Disco.Services.Plugins.Features.DetailsProvider;
|
using Disco.Services.Plugins.Features.DetailsProvider;
|
||||||
using Disco.Services.Tasks;
|
using Disco.Services.Tasks;
|
||||||
using Disco.Services.Users;
|
using Disco.Services.Users;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Data;
|
|
||||||
using System.Data.Entity;
|
using System.Data.Entity;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Disco.Services.Devices.Exporting
|
namespace Disco.Services.Devices
|
||||||
{
|
{
|
||||||
using Metadata = ExportFieldMetadata<DeviceExportRecord>;
|
using Metadata = ExportFieldMetadata<DeviceExportRecord>;
|
||||||
|
|
||||||
public static class DeviceExport
|
public class DeviceExportContext : IExportContext<DeviceExportOptions, DeviceExportRecord>
|
||||||
{
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
public bool TimestampSuffix { get; set; }
|
||||||
|
public DeviceExportOptions Options { get; set; }
|
||||||
|
|
||||||
public static ExportResult GenerateExport(DiscoDataContext Database, Func<IQueryable<Device>, IQueryable<Device>> Filter, DeviceExportOptions Options, IScheduledTaskStatus TaskStatus)
|
public string SuggestedFilenamePrefix { get; } = "DeviceExport";
|
||||||
|
public string ExcelWorksheetName { get; } = "DeviceExport";
|
||||||
|
public string ExcelTableName { get; } = "Devices";
|
||||||
|
|
||||||
|
[JsonConstructor]
|
||||||
|
private DeviceExportContext()
|
||||||
{
|
{
|
||||||
var deviceQuery = Database.Devices
|
}
|
||||||
|
|
||||||
|
public DeviceExportContext(string name, string description, bool timestampSuffix, DeviceExportOptions options)
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid();
|
||||||
|
Name = name;
|
||||||
|
Description = description;
|
||||||
|
TimestampSuffix = timestampSuffix;
|
||||||
|
Options = options;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceExportContext(DeviceExportOptions options)
|
||||||
|
: this("Device Export", null, true, options)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExportResult Export(DiscoDataContext database, IScheduledTaskStatus taskStatus)
|
||||||
|
=> Exporter.Export(database, this, taskStatus);
|
||||||
|
|
||||||
|
private IQueryable<Device> BuildFilteredRecords(DiscoDataContext database)
|
||||||
|
{
|
||||||
|
var query = database.Devices
|
||||||
.Include(d => d.AssignedUser.UserDetails)
|
.Include(d => d.AssignedUser.UserDetails)
|
||||||
.Include(d => d.DeviceDetails);
|
.Include(d => d.DeviceDetails);
|
||||||
if (Filter != null)
|
|
||||||
deviceQuery = Filter(deviceQuery);
|
switch (Options.ExportType)
|
||||||
|
{
|
||||||
|
case DeviceExportTypes.All:
|
||||||
|
break;
|
||||||
|
case DeviceExportTypes.Batch:
|
||||||
|
if (Options.ExportTypeTargetId.HasValue && Options.ExportTypeTargetId.Value > 0)
|
||||||
|
query = query.Where(d => d.DeviceBatchId != Options.ExportTypeTargetId);
|
||||||
|
else
|
||||||
|
query = query.Where(d => d.DeviceBatchId != null);
|
||||||
|
break;
|
||||||
|
case DeviceExportTypes.Model:
|
||||||
|
query = query.Where(d => d.DeviceModelId == Options.ExportTypeTargetId);
|
||||||
|
break;
|
||||||
|
case DeviceExportTypes.Profile:
|
||||||
|
query = query.Where(d => d.DeviceProfileId == Options.ExportTypeTargetId);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new ArgumentException($"Unknown Device Export Type '{Options.ExportType}'", nameof(Options.ExportType));
|
||||||
|
}
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<DeviceExportRecord> BuildRecords(DiscoDataContext database, IScheduledTaskStatus taskStatus)
|
||||||
|
{
|
||||||
|
var query = BuildFilteredRecords(database);
|
||||||
|
|
||||||
// Update Users
|
// Update Users
|
||||||
if (Options.AssignedUserDisplayName ||
|
if (Options.AssignedUserDisplayName ||
|
||||||
@@ -35,13 +92,13 @@ namespace Disco.Services.Devices.Exporting
|
|||||||
Options.AssignedUserPhoneNumber ||
|
Options.AssignedUserPhoneNumber ||
|
||||||
Options.AssignedUserEmailAddress)
|
Options.AssignedUserEmailAddress)
|
||||||
{
|
{
|
||||||
TaskStatus.UpdateStatus(5, "Refreshing user details from Active Directory");
|
taskStatus.UpdateStatus(5, "Refreshing user details from Active Directory");
|
||||||
var userIds = deviceQuery.Where(d => d.AssignedUserId != null).Select(d => d.AssignedUserId).Distinct().ToList();
|
var userIds = query.Where(d => d.AssignedUserId != null).Select(d => d.AssignedUserId).Distinct().ToList();
|
||||||
foreach (var userId in userIds)
|
foreach (var userId in userIds)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
UserService.GetUser(userId, Database);
|
UserService.GetUser(userId, database);
|
||||||
}
|
}
|
||||||
catch (Exception) { } // Ignore Errors
|
catch (Exception) { } // Ignore Errors
|
||||||
}
|
}
|
||||||
@@ -50,91 +107,18 @@ namespace Disco.Services.Devices.Exporting
|
|||||||
// Update Last Network Logon Date
|
// Update Last Network Logon Date
|
||||||
if (Options.DeviceLastNetworkLogon)
|
if (Options.DeviceLastNetworkLogon)
|
||||||
{
|
{
|
||||||
TaskStatus.UpdateStatus(15, "Refreshing device last network logon dates from Active Directory");
|
taskStatus.UpdateStatus(15, "Refreshing device last network logon dates from Active Directory");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Interop.ActiveDirectory.ADNetworkLogonDatesUpdateTask.UpdateLastNetworkLogonDates(Database, ScheduledTaskMockStatus.Create("UpdateLastNetworkLogonDates"));
|
Interop.ActiveDirectory.ADNetworkLogonDatesUpdateTask.UpdateLastNetworkLogonDates(database, ScheduledTaskMockStatus.Create("UpdateLastNetworkLogonDates"));
|
||||||
Database.SaveChanges();
|
database.SaveChanges();
|
||||||
}
|
}
|
||||||
catch (Exception) { } // Ignore Errors
|
catch (Exception) { } // Ignore Errors
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskStatus.UpdateStatus(25, "Extracting records from the database");
|
taskStatus.UpdateStatus(25, "Gathering database records");
|
||||||
|
|
||||||
var records = BuildRecords(deviceQuery).ToList();
|
var records = query.Select(d => new DeviceExportRecord()
|
||||||
|
|
||||||
// materialize device details
|
|
||||||
records.ForEach(r =>
|
|
||||||
{
|
|
||||||
if (Options.DetailBios)
|
|
||||||
r.DeviceDetailBios = r.DeviceDetails.Bios();
|
|
||||||
if (Options.DetailBaseBoard)
|
|
||||||
r.DeviceDetailBaseBoard = r.DeviceDetails.BaseBoard();
|
|
||||||
if (Options.DetailComputerSystem)
|
|
||||||
r.DeviceDetailComputerSystem = r.DeviceDetails.ComputerSystem();
|
|
||||||
if (Options.DetailProcessors)
|
|
||||||
r.DeviceDetailProcessors = r.DeviceDetails.Processors();
|
|
||||||
if (Options.DetailMemory)
|
|
||||||
r.DeviceDetailPhysicalMemory = r.DeviceDetails.PhysicalMemory();
|
|
||||||
if (Options.DetailDiskDrives)
|
|
||||||
r.DeviceDetailDiskDrives = r.DeviceDetails.DiskDrives();
|
|
||||||
if (Options.DetailLanAdapters || Options.DetailWLanAdapters)
|
|
||||||
{
|
|
||||||
r.DeviceDetailNetworkAdapters = r.DeviceDetails.NetworkAdapters();
|
|
||||||
if (r.DeviceDetailNetworkAdapters == null)
|
|
||||||
{
|
|
||||||
r.DeviceDetailLanMacAddresses = r.DeviceDetails.LanMacAddress()?.Split(';').Select(a => a.Trim()).ToList();
|
|
||||||
r.DeviceDetailWlanMacAddresses = r.DeviceDetails.WLanMacAddress()?.Split(';').Select(a => a.Trim()).ToList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Options.DetailBatteries)
|
|
||||||
r.DeviceDetailBatteries = r.DeviceDetails.Batteries();
|
|
||||||
|
|
||||||
if (Options.AssignedUserDetailCustom && r.AssignedUser != null)
|
|
||||||
{
|
|
||||||
var detailsService = new DetailsProviderService(Database);
|
|
||||||
r.AssignedUserCustomDetails = detailsService.GetDetails(r.AssignedUser);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
TaskStatus.UpdateStatus(70, "Building metadata");
|
|
||||||
var metadata = Options.BuildMetadata(records);
|
|
||||||
|
|
||||||
if (metadata.Count == 0)
|
|
||||||
throw new ArgumentException("At least one export field must be specified", "Options");
|
|
||||||
|
|
||||||
TaskStatus.UpdateStatus(80, $"Formatting {records.Count} records for export");
|
|
||||||
|
|
||||||
return ExportHelpers.WriteExport(Options, TaskStatus, metadata, records);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ExportResult GenerateExport(DiscoDataContext Database, DeviceExportOptions Options, IScheduledTaskStatus TaskStatus)
|
|
||||||
{
|
|
||||||
switch (Options.ExportType)
|
|
||||||
{
|
|
||||||
case DeviceExportTypes.All:
|
|
||||||
return GenerateExport(Database, null, Options, TaskStatus);
|
|
||||||
case DeviceExportTypes.Batch:
|
|
||||||
if (Options.ExportTypeTargetId.HasValue && Options.ExportTypeTargetId.Value > 0)
|
|
||||||
return GenerateExport(Database, devices => devices.Where(d => d.DeviceBatchId == Options.ExportTypeTargetId), Options, TaskStatus);
|
|
||||||
else
|
|
||||||
return GenerateExport(Database, devices => devices.Where(d => d.DeviceBatchId == null), Options, TaskStatus);
|
|
||||||
case DeviceExportTypes.Model:
|
|
||||||
return GenerateExport(Database, devices => devices.Where(d => d.DeviceModelId == Options.ExportTypeTargetId), Options, TaskStatus);
|
|
||||||
case DeviceExportTypes.Profile:
|
|
||||||
return GenerateExport(Database, devices => 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 ExportResult GenerateExport(DiscoDataContext Database, DeviceExportOptions Options)
|
|
||||||
{
|
|
||||||
return GenerateExport(Database, Options, ScheduledTaskMockStatus.Create("Device Export"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static IEnumerable<DeviceExportRecord> BuildRecords(IQueryable<Device> Devices)
|
|
||||||
{
|
|
||||||
return Devices.Select(d => new DeviceExportRecord()
|
|
||||||
{
|
{
|
||||||
Device = d,
|
Device = d,
|
||||||
|
|
||||||
@@ -170,10 +154,46 @@ namespace Disco.Services.Devices.Exporting
|
|||||||
AttachmentsCount = d.DeviceAttachments.Count(),
|
AttachmentsCount = d.DeviceAttachments.Count(),
|
||||||
|
|
||||||
DeviceCertificates = d.DeviceCertificates.Where(dc => dc.Enabled).OrderByDescending(dc => dc.AllocatedDate)
|
DeviceCertificates = d.DeviceCertificates.Where(dc => dc.Enabled).OrderByDescending(dc => dc.AllocatedDate)
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
// materialize device details
|
||||||
|
records.ForEach(r =>
|
||||||
|
{
|
||||||
|
if (Options.DetailBios)
|
||||||
|
r.DeviceDetailBios = r.DeviceDetails.Bios();
|
||||||
|
if (Options.DetailBaseBoard)
|
||||||
|
r.DeviceDetailBaseBoard = r.DeviceDetails.BaseBoard();
|
||||||
|
if (Options.DetailComputerSystem)
|
||||||
|
r.DeviceDetailComputerSystem = r.DeviceDetails.ComputerSystem();
|
||||||
|
if (Options.DetailProcessors)
|
||||||
|
r.DeviceDetailProcessors = r.DeviceDetails.Processors();
|
||||||
|
if (Options.DetailMemory)
|
||||||
|
r.DeviceDetailPhysicalMemory = r.DeviceDetails.PhysicalMemory();
|
||||||
|
if (Options.DetailDiskDrives)
|
||||||
|
r.DeviceDetailDiskDrives = r.DeviceDetails.DiskDrives();
|
||||||
|
if (Options.DetailLanAdapters || Options.DetailWLanAdapters)
|
||||||
|
{
|
||||||
|
r.DeviceDetailNetworkAdapters = r.DeviceDetails.NetworkAdapters();
|
||||||
|
if (r.DeviceDetailNetworkAdapters == null)
|
||||||
|
{
|
||||||
|
r.DeviceDetailLanMacAddresses = r.DeviceDetails.LanMacAddress()?.Split(';').Select(a => a.Trim()).ToList();
|
||||||
|
r.DeviceDetailWlanMacAddresses = r.DeviceDetails.WLanMacAddress()?.Split(';').Select(a => a.Trim()).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Options.DetailBatteries)
|
||||||
|
r.DeviceDetailBatteries = r.DeviceDetails.Batteries();
|
||||||
|
|
||||||
|
if (Options.AssignedUserDetailCustom && r.AssignedUser != null)
|
||||||
|
{
|
||||||
|
var detailsService = new DetailsProviderService(database);
|
||||||
|
r.AssignedUserCustomDetails = detailsService.GetDetails(r.AssignedUser);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return records;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Metadata> BuildMetadata(this DeviceExportOptions options, List<DeviceExportRecord> records)
|
public List<Metadata> BuildMetadata(DiscoDataContext database, List<DeviceExportRecord> records, IScheduledTaskStatus taskStatus)
|
||||||
{
|
{
|
||||||
var processorMaxCount = Math.Max(1, records.Max(r => r.DeviceDetailProcessors?.Count ?? 0));
|
var processorMaxCount = Math.Max(1, records.Max(r => r.DeviceDetailProcessors?.Count ?? 0));
|
||||||
var memoryMaxCount = Math.Max(1, records.Max(r => r.DeviceDetailPhysicalMemory?.Count ?? 0));
|
var memoryMaxCount = Math.Max(1, records.Max(r => r.DeviceDetailPhysicalMemory?.Count ?? 0));
|
||||||
@@ -184,7 +204,7 @@ namespace Disco.Services.Devices.Exporting
|
|||||||
var batteriesMaxCount = Math.Max(1, records.Max(r => r.DeviceDetailBatteries?.Count ?? 0));
|
var batteriesMaxCount = Math.Max(1, records.Max(r => r.DeviceDetailBatteries?.Count ?? 0));
|
||||||
|
|
||||||
IEnumerable<string> assignedUserDetailCustomKeys = null;
|
IEnumerable<string> assignedUserDetailCustomKeys = null;
|
||||||
if (options.AssignedUserDetailCustom)
|
if (Options.AssignedUserDetailCustom)
|
||||||
assignedUserDetailCustomKeys = records.Where(r => r.AssignedUserCustomDetails != null).SelectMany(r => r.AssignedUserCustomDetails.Keys).Distinct(StringComparer.OrdinalIgnoreCase).ToList();
|
assignedUserDetailCustomKeys = records.Where(r => r.AssignedUserCustomDetails != null).SelectMany(r => r.AssignedUserCustomDetails.Keys).Distinct(StringComparer.OrdinalIgnoreCase).ToList();
|
||||||
|
|
||||||
var allAccessors = BuildRecordAccessors(processorMaxCount, memoryMaxCount, diskDriveMaxCount, lanAdapterMaxCount, wlanAdapterMaxCount, certificateMaxCount, batteriesMaxCount, assignedUserDetailCustomKeys);
|
var allAccessors = BuildRecordAccessors(processorMaxCount, memoryMaxCount, diskDriveMaxCount, lanAdapterMaxCount, wlanAdapterMaxCount, certificateMaxCount, batteriesMaxCount, assignedUserDetailCustomKeys);
|
||||||
@@ -196,7 +216,7 @@ namespace Disco.Services.Devices.Exporting
|
|||||||
property = p,
|
property = p,
|
||||||
details = (DisplayAttribute)p.GetCustomAttributes(typeof(DisplayAttribute), false).FirstOrDefault()
|
details = (DisplayAttribute)p.GetCustomAttributes(typeof(DisplayAttribute), false).FirstOrDefault()
|
||||||
})
|
})
|
||||||
.Where(p => p.details != null && (bool)p.property.GetValue(options))
|
.Where(p => p.details != null && (bool)p.property.GetValue(Options))
|
||||||
.SelectMany(p =>
|
.SelectMany(p =>
|
||||||
{
|
{
|
||||||
var fieldMetadata = allAccessors[p.property.Name];
|
var fieldMetadata = allAccessors[p.property.Name];
|
||||||
@@ -460,6 +480,5 @@ namespace Disco.Services.Devices.Exporting
|
|||||||
|
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+42
-33
@@ -2,9 +2,11 @@
|
|||||||
using Disco.Models.Exporting;
|
using Disco.Models.Exporting;
|
||||||
using Disco.Models.Services.Devices.DeviceFlag;
|
using Disco.Models.Services.Devices.DeviceFlag;
|
||||||
using Disco.Models.Services.Exporting;
|
using Disco.Models.Services.Exporting;
|
||||||
|
using Disco.Services.Exporting;
|
||||||
using Disco.Services.Plugins.Features.DetailsProvider;
|
using Disco.Services.Plugins.Features.DetailsProvider;
|
||||||
using Disco.Services.Tasks;
|
using Disco.Services.Tasks;
|
||||||
using Disco.Services.Users;
|
using Disco.Services.Users;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
@@ -15,57 +17,67 @@ namespace Disco.Services.Devices.DeviceFlags
|
|||||||
{
|
{
|
||||||
using Metadata = ExportFieldMetadata<DeviceFlagExportRecord>;
|
using Metadata = ExportFieldMetadata<DeviceFlagExportRecord>;
|
||||||
|
|
||||||
public class DeviceFlagExport
|
public class DeviceFlagExportContext : IExportContext<DeviceFlagExportOptions, DeviceFlagExportRecord>
|
||||||
{
|
{
|
||||||
private readonly DiscoDataContext database;
|
public Guid Id { get; set; }
|
||||||
private readonly DeviceFlagExportOptions options;
|
public string Name { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
public bool TimestampSuffix { get; set; }
|
||||||
|
public DeviceFlagExportOptions Options { get; set; }
|
||||||
|
|
||||||
public DeviceFlagExport(DiscoDataContext database, DeviceFlagExportOptions options)
|
public string SuggestedFilenamePrefix { get; } = "DeviceFlagExport";
|
||||||
|
public string ExcelWorksheetName { get; } = "DeviceFlagExport";
|
||||||
|
public string ExcelTableName { get; } = "DeviceFlags";
|
||||||
|
|
||||||
|
[JsonConstructor]
|
||||||
|
private DeviceFlagExportContext()
|
||||||
{
|
{
|
||||||
this.database = database;
|
|
||||||
this.options = options;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExportResult Generate(IScheduledTaskStatus status)
|
public DeviceFlagExportContext(string name, string description, bool timestampSuffix, DeviceFlagExportOptions options)
|
||||||
{
|
{
|
||||||
var records = BuildRecords(status);
|
Id = Guid.NewGuid();
|
||||||
|
Name = name;
|
||||||
var metadata = BuildMetadata(records, status);
|
Description = description;
|
||||||
|
TimestampSuffix = timestampSuffix;
|
||||||
if (metadata.Count == 0)
|
Options = options;
|
||||||
throw new ArgumentException("At least one export field must be specified", nameof(options));
|
|
||||||
|
|
||||||
status.UpdateStatus(90, $"Formatting {records.Count} records for export");
|
|
||||||
return ExportHelpers.WriteExport(options, status, metadata, records);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<DeviceFlagExportRecord> BuildRecords(IScheduledTaskStatus status)
|
public DeviceFlagExportContext(DeviceFlagExportOptions options)
|
||||||
|
: this("Device Flag Export", null, true, options)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExportResult Export(DiscoDataContext database, IScheduledTaskStatus status)
|
||||||
|
=> Exporter.Export(database, this, status);
|
||||||
|
|
||||||
|
public List<DeviceFlagExportRecord> BuildRecords(DiscoDataContext database, IScheduledTaskStatus status)
|
||||||
{
|
{
|
||||||
var query = database.DeviceFlagAssignments
|
var query = database.DeviceFlagAssignments
|
||||||
.Include(a => a.DeviceFlag);
|
.Include(a => a.DeviceFlag);
|
||||||
|
|
||||||
if (options.HasDeviceOptions())
|
if (Options.HasDeviceOptions())
|
||||||
query = query.Include(a => a.Device);
|
query = query.Include(a => a.Device);
|
||||||
if (options.HasDeviceModelOptions())
|
if (Options.HasDeviceModelOptions())
|
||||||
query = query.Include(a => a.Device.DeviceModel);
|
query = query.Include(a => a.Device.DeviceModel);
|
||||||
if (options.HasDeviceBatchOptions())
|
if (Options.HasDeviceBatchOptions())
|
||||||
query = query.Include(a => a.Device.DeviceBatch);
|
query = query.Include(a => a.Device.DeviceBatch);
|
||||||
if (options.HasDeviceProfileOptions())
|
if (Options.HasDeviceProfileOptions())
|
||||||
query = query.Include(a => a.Device.DeviceProfile);
|
query = query.Include(a => a.Device.DeviceProfile);
|
||||||
if (options.HasAssignedUserOptions())
|
if (Options.HasAssignedUserOptions())
|
||||||
query = query.Include(a => a.Device.AssignedUser);
|
query = query.Include(a => a.Device.AssignedUser);
|
||||||
if (options.AssignedUserDetailCustom)
|
if (Options.AssignedUserDetailCustom)
|
||||||
query = query.Include(a => a.Device.AssignedUser.UserDetails);
|
query = query.Include(a => a.Device.AssignedUser.UserDetails);
|
||||||
|
|
||||||
query = query.Where(a => options.DeviceFlagIds.Contains(a.DeviceFlagId));
|
query = query.Where(a => Options.DeviceFlagIds.Contains(a.DeviceFlagId));
|
||||||
|
|
||||||
if (options.CurrentOnly)
|
if (Options.CurrentOnly)
|
||||||
{
|
{
|
||||||
query = query.Where(a => !a.RemovedDate.HasValue);
|
query = query.Where(a => !a.RemovedDate.HasValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update Users
|
// Update Users
|
||||||
if (options.HasAssignedUserOptions())
|
if (Options.HasAssignedUserOptions())
|
||||||
{
|
{
|
||||||
status.UpdateStatus(5, "Refreshing user details from Active Directory");
|
status.UpdateStatus(5, "Refreshing user details from Active Directory");
|
||||||
var userIds = query.Where(d => d.Device.AssignedUserId != null).Select(d => d.Device.AssignedUserId).Distinct().ToList();
|
var userIds = query.Where(d => d.Device.AssignedUserId != null).Select(d => d.Device.AssignedUserId).Distinct().ToList();
|
||||||
@@ -86,7 +98,7 @@ namespace Disco.Services.Devices.DeviceFlags
|
|||||||
Assignment = a
|
Assignment = a
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
if (options.AssignedUserDetailCustom)
|
if (Options.AssignedUserDetailCustom)
|
||||||
{
|
{
|
||||||
status.UpdateStatus(50, "Extracting custom user detail records");
|
status.UpdateStatus(50, "Extracting custom user detail records");
|
||||||
|
|
||||||
@@ -108,12 +120,10 @@ namespace Disco.Services.Devices.DeviceFlags
|
|||||||
return records;
|
return records;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Metadata> BuildMetadata(List<DeviceFlagExportRecord> records, IScheduledTaskStatus status)
|
public List<Metadata> BuildMetadata(DiscoDataContext database, List<DeviceFlagExportRecord> records, IScheduledTaskStatus status)
|
||||||
{
|
{
|
||||||
status.UpdateStatus(80, "Building metadata");
|
|
||||||
|
|
||||||
IEnumerable<string> userDetailCustomKeys = null;
|
IEnumerable<string> userDetailCustomKeys = null;
|
||||||
if (options.AssignedUserDetailCustom)
|
if (Options.AssignedUserDetailCustom)
|
||||||
userDetailCustomKeys = records.Where(r => r.AssignedUserCustomDetails != null).SelectMany(r => r.AssignedUserCustomDetails.Keys).Distinct(StringComparer.OrdinalIgnoreCase).ToList();
|
userDetailCustomKeys = records.Where(r => r.AssignedUserCustomDetails != null).SelectMany(r => r.AssignedUserCustomDetails.Keys).Distinct(StringComparer.OrdinalIgnoreCase).ToList();
|
||||||
|
|
||||||
var accessors = BuildAccessors(userDetailCustomKeys);
|
var accessors = BuildAccessors(userDetailCustomKeys);
|
||||||
@@ -125,7 +135,7 @@ namespace Disco.Services.Devices.DeviceFlags
|
|||||||
property = p,
|
property = p,
|
||||||
details = (DisplayAttribute)p.GetCustomAttributes(typeof(DisplayAttribute), false).FirstOrDefault()
|
details = (DisplayAttribute)p.GetCustomAttributes(typeof(DisplayAttribute), false).FirstOrDefault()
|
||||||
})
|
})
|
||||||
.Where(p => p.details != null && p.property.Name != nameof(options.CurrentOnly) && (bool)p.property.GetValue(options))
|
.Where(p => p.details != null && p.property.Name != nameof(Options.CurrentOnly) && (bool)p.property.GetValue(Options))
|
||||||
.SelectMany(p =>
|
.SelectMany(p =>
|
||||||
{
|
{
|
||||||
var fieldMetadata = accessors[p.property.Name];
|
var fieldMetadata = accessors[p.property.Name];
|
||||||
@@ -224,6 +234,5 @@ namespace Disco.Services.Devices.DeviceFlags
|
|||||||
|
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
using Disco.Data.Repository;
|
|
||||||
using Disco.Models.Services.Devices.DeviceFlag;
|
|
||||||
using Disco.Services.Exporting;
|
|
||||||
using Disco.Services.Tasks;
|
|
||||||
using Quartz;
|
|
||||||
|
|
||||||
namespace Disco.Services.Devices.DeviceFlags
|
|
||||||
{
|
|
||||||
public class DeviceFlagExportTask : ScheduledTask
|
|
||||||
{
|
|
||||||
private const string JobDataMapContext = "Context";
|
|
||||||
|
|
||||||
public override string TaskName { get; } = "Export Device Flags";
|
|
||||||
public override bool SingleInstanceTask { get { return false; } }
|
|
||||||
public override bool CancelInitiallySupported { get { return false; } }
|
|
||||||
|
|
||||||
public static ExportTaskContext<DeviceFlagExportOptions> ScheduleNow(DeviceFlagExportOptions options)
|
|
||||||
{
|
|
||||||
// Build Context
|
|
||||||
var context = new ExportTaskContext<DeviceFlagExportOptions>(options);
|
|
||||||
|
|
||||||
// Build Data Map
|
|
||||||
var task = new DeviceFlagExportTask();
|
|
||||||
JobDataMap taskData = new JobDataMap() { { JobDataMapContext, context } };
|
|
||||||
|
|
||||||
// Schedule Task
|
|
||||||
context.TaskStatus = task.ScheduleTask(taskData);
|
|
||||||
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void ExecuteTask()
|
|
||||||
{
|
|
||||||
var context = (ExportTaskContext<DeviceFlagExportOptions>)ExecutionContext.JobDetail.JobDataMap[JobDataMapContext];
|
|
||||||
|
|
||||||
Status.UpdateStatus(10, "Exporting Device Flag Records", "Starting...");
|
|
||||||
|
|
||||||
using (DiscoDataContext Database = new DiscoDataContext())
|
|
||||||
{
|
|
||||||
var export = new DeviceFlagExport(Database, context.Options);
|
|
||||||
|
|
||||||
context.Result = export.Generate(Status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
using Disco.Models.Services.Devices.Exporting;
|
|
||||||
using Disco.Services.Tasks;
|
|
||||||
using Quartz;
|
|
||||||
using Disco.Data.Repository;
|
|
||||||
using Disco.Services.Exporting;
|
|
||||||
|
|
||||||
namespace Disco.Services.Devices.Exporting
|
|
||||||
{
|
|
||||||
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 ExportTaskContext<DeviceExportOptions> ScheduleNow(DeviceExportOptions Options)
|
|
||||||
{
|
|
||||||
// Build Context
|
|
||||||
var context = new ExportTaskContext<DeviceExportOptions>(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 = (ExportTaskContext<DeviceExportOptions>)ExecutionContext.JobDetail.JobDataMap[JobDataMapContext];
|
|
||||||
|
|
||||||
Status.UpdateStatus(10, "Exporting Device Records", "Starting...");
|
|
||||||
|
|
||||||
using (DiscoDataContext Database = new DiscoDataContext())
|
|
||||||
{
|
|
||||||
context.Result = DeviceExport.GenerateExport(Database, context.Options, Status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -347,6 +347,7 @@
|
|||||||
<Compile Include="Devices\DeviceDataStoreExtensions.cs" />
|
<Compile Include="Devices\DeviceDataStoreExtensions.cs" />
|
||||||
<Compile Include="Devices\DeviceDetailExtensions.cs" />
|
<Compile Include="Devices\DeviceDetailExtensions.cs" />
|
||||||
<Compile Include="Devices\DeviceExtensions.cs" />
|
<Compile Include="Devices\DeviceExtensions.cs" />
|
||||||
|
<Compile Include="Devices\DeviceFlags\DeviceFlagExportContext.cs" />
|
||||||
<Compile Include="Devices\DeviceModelExtensions.cs" />
|
<Compile Include="Devices\DeviceModelExtensions.cs" />
|
||||||
<Compile Include="Devices\DeviceProfileExtensions.cs" />
|
<Compile Include="Devices\DeviceProfileExtensions.cs" />
|
||||||
<Compile Include="Devices\DeviceBatchUpdatesHub.cs" />
|
<Compile Include="Devices\DeviceBatchUpdatesHub.cs" />
|
||||||
@@ -357,18 +358,16 @@
|
|||||||
<Compile Include="Devices\Enrolment\EnrolmentTypes.cs" />
|
<Compile Include="Devices\Enrolment\EnrolmentTypes.cs" />
|
||||||
<Compile Include="Devices\Enrolment\LogMacAddressImportingTask.cs" />
|
<Compile Include="Devices\Enrolment\LogMacAddressImportingTask.cs" />
|
||||||
<Compile Include="Devices\Enrolment\MacDeviceEnrolment.cs" />
|
<Compile Include="Devices\Enrolment\MacDeviceEnrolment.cs" />
|
||||||
<Compile Include="Devices\Exporting\DeviceExport.cs" />
|
<Compile Include="Devices\DeviceExportContext.cs" />
|
||||||
<Compile Include="Devices\Exporting\DeviceExportTask.cs" />
|
|
||||||
<Compile Include="Devices\DeviceFlags\Cache.cs" />
|
<Compile Include="Devices\DeviceFlags\Cache.cs" />
|
||||||
<Compile Include="Devices\DeviceFlags\DeviceFlagExport.cs" />
|
|
||||||
<Compile Include="Devices\DeviceFlags\DeviceFlagExportTask.cs" />
|
|
||||||
<Compile Include="Devices\DeviceFlags\DeviceFlagExtensions.cs" />
|
<Compile Include="Devices\DeviceFlags\DeviceFlagExtensions.cs" />
|
||||||
<Compile Include="Devices\DeviceFlags\DeviceFlagsBulkAssignTask.cs" />
|
<Compile Include="Devices\DeviceFlags\DeviceFlagsBulkAssignTask.cs" />
|
||||||
<Compile Include="Devices\DeviceFlags\DeviceFlagsDeleteTask.cs" />
|
<Compile Include="Devices\DeviceFlags\DeviceFlagsDeleteTask.cs" />
|
||||||
<Compile Include="Devices\DeviceFlags\DeviceFlagService.cs" />
|
<Compile Include="Devices\DeviceFlags\DeviceFlagService.cs" />
|
||||||
<Compile Include="Devices\DeviceFlags\DeviceFlagDeviceAssignedUsersManagedGroup.cs" />
|
<Compile Include="Devices\DeviceFlags\DeviceFlagDeviceAssignedUsersManagedGroup.cs" />
|
||||||
<Compile Include="Devices\DeviceFlags\DeviceFlagDevicesManagedGroup.cs" />
|
<Compile Include="Devices\DeviceFlags\DeviceFlagDevicesManagedGroup.cs" />
|
||||||
<Compile Include="Exporting\ExportHelpers.cs" />
|
<Compile Include="Exporting\Exporter.cs" />
|
||||||
|
<Compile Include="Exporting\ExportTask.cs" />
|
||||||
<Compile Include="Exporting\ExportTaskContext.cs" />
|
<Compile Include="Exporting\ExportTaskContext.cs" />
|
||||||
<Compile Include="Devices\Importing\BaseDeviceImportContext.cs" />
|
<Compile Include="Devices\Importing\BaseDeviceImportContext.cs" />
|
||||||
<Compile Include="Devices\Importing\CsvDeviceImportDataReader.cs" />
|
<Compile Include="Devices\Importing\CsvDeviceImportDataReader.cs" />
|
||||||
@@ -425,6 +424,7 @@
|
|||||||
<Compile Include="Documents\ManagedGroups\DocumentTemplateManagedGroups.cs" />
|
<Compile Include="Documents\ManagedGroups\DocumentTemplateManagedGroups.cs" />
|
||||||
<Compile Include="Documents\ManagedGroups\DocumentTemplateUsersManagedGroup.cs" />
|
<Compile Include="Documents\ManagedGroups\DocumentTemplateUsersManagedGroup.cs" />
|
||||||
<Compile Include="Documents\QRCodeBinaryEncoder.cs" />
|
<Compile Include="Documents\QRCodeBinaryEncoder.cs" />
|
||||||
|
<Compile Include="Exporting\IExportContext.cs" />
|
||||||
<Compile Include="Expressions\EvaluateExpressionParseException.cs" />
|
<Compile Include="Expressions\EvaluateExpressionParseException.cs" />
|
||||||
<Compile Include="Expressions\EvaluateExpressionPart.cs" />
|
<Compile Include="Expressions\EvaluateExpressionPart.cs" />
|
||||||
<Compile Include="Expressions\Expression.cs" />
|
<Compile Include="Expressions\Expression.cs" />
|
||||||
@@ -491,8 +491,7 @@
|
|||||||
<Compile Include="Interop\VicEduDept\VicSmart.cs" />
|
<Compile Include="Interop\VicEduDept\VicSmart.cs" />
|
||||||
<Compile Include="Interop\DiscoServices\UpdateQuery.cs" />
|
<Compile Include="Interop\DiscoServices\UpdateQuery.cs" />
|
||||||
<Compile Include="Interop\DiscoServices\UpdateQueryTask.cs" />
|
<Compile Include="Interop\DiscoServices\UpdateQueryTask.cs" />
|
||||||
<Compile Include="Jobs\Exporting\JobExport.cs" />
|
<Compile Include="Jobs\JobExportContext.cs" />
|
||||||
<Compile Include="Jobs\Exporting\JobExportTask.cs" />
|
|
||||||
<Compile Include="Jobs\JobActionExtensions.cs" />
|
<Compile Include="Jobs\JobActionExtensions.cs" />
|
||||||
<Compile Include="Jobs\JobExtensions.cs" />
|
<Compile Include="Jobs\JobExtensions.cs" />
|
||||||
<Compile Include="Jobs\JobFlagExtensions.cs" />
|
<Compile Include="Jobs\JobFlagExtensions.cs" />
|
||||||
@@ -512,7 +511,7 @@
|
|||||||
<Compile Include="Jobs\Statistics\DailyOpenedClosed.cs" />
|
<Compile Include="Jobs\Statistics\DailyOpenedClosed.cs" />
|
||||||
<Compile Include="Logging\LogBase.cs" />
|
<Compile Include="Logging\LogBase.cs" />
|
||||||
<Compile Include="Logging\LogContext.cs" />
|
<Compile Include="Logging\LogContext.cs" />
|
||||||
<Compile Include="Logging\LogExport.cs" />
|
<Compile Include="Logging\LogExportContext.cs" />
|
||||||
<Compile Include="Logging\LogReInitalizeJob.cs" />
|
<Compile Include="Logging\LogReInitalizeJob.cs" />
|
||||||
<Compile Include="Logging\Models\LogEvent.cs" />
|
<Compile Include="Logging\Models\LogEvent.cs" />
|
||||||
<Compile Include="Logging\Models\LogEventType.cs" />
|
<Compile Include="Logging\Models\LogEventType.cs" />
|
||||||
@@ -600,8 +599,7 @@
|
|||||||
<Compile Include="Users\Contact\UserContactService.cs" />
|
<Compile Include="Users\Contact\UserContactService.cs" />
|
||||||
<Compile Include="Users\UserExtensions.cs" />
|
<Compile Include="Users\UserExtensions.cs" />
|
||||||
<Compile Include="Users\UserFlags\Cache.cs" />
|
<Compile Include="Users\UserFlags\Cache.cs" />
|
||||||
<Compile Include="Users\UserFlags\UserFlagExport.cs" />
|
<Compile Include="Users\UserFlags\UserFlagExportContext.cs" />
|
||||||
<Compile Include="Users\UserFlags\UserFlagExportTask.cs" />
|
|
||||||
<Compile Include="Users\UserFlags\UserFlagExtensions.cs" />
|
<Compile Include="Users\UserFlags\UserFlagExtensions.cs" />
|
||||||
<Compile Include="Users\UserFlags\UserFlagUserDevicesManagedGroup.cs" />
|
<Compile Include="Users\UserFlags\UserFlagUserDevicesManagedGroup.cs" />
|
||||||
<Compile Include="Users\UserFlags\UserFlagUsersManagedGroup.cs" />
|
<Compile Include="Users\UserFlags\UserFlagUsersManagedGroup.cs" />
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
using Disco.Data.Repository;
|
||||||
|
using Disco.Services.Tasks;
|
||||||
|
using Quartz;
|
||||||
|
using System;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Caching;
|
||||||
|
|
||||||
|
namespace Disco.Services.Exporting
|
||||||
|
{
|
||||||
|
public class ExportTask : ScheduledTask
|
||||||
|
{
|
||||||
|
private IExportContext context;
|
||||||
|
public override string TaskName { get => context?.Name ?? "Exporting"; }
|
||||||
|
public override bool SingleInstanceTask { get { return false; } }
|
||||||
|
public override bool CancelInitiallySupported { get { return false; } }
|
||||||
|
|
||||||
|
public static ExportTaskContext ScheduleNow(IExportContext exportContext)
|
||||||
|
{
|
||||||
|
// Build Context
|
||||||
|
var taskContext = new ExportTaskContext(exportContext);
|
||||||
|
|
||||||
|
// Build Data Map
|
||||||
|
var task = new ExportTask();
|
||||||
|
JobDataMap taskData = new JobDataMap() { { nameof(ExportTask), taskContext } };
|
||||||
|
|
||||||
|
// Schedule Task
|
||||||
|
taskContext.TaskStatus = task.ScheduleTask(taskData);
|
||||||
|
|
||||||
|
return taskContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetCacheKey(Guid exportId) => $"ExportTask_{exportId}";
|
||||||
|
|
||||||
|
public static ExportTaskContext ScheduleNowCacheResult(IExportContext exportContext, Func<Guid, string> returnUrlBuilder)
|
||||||
|
{
|
||||||
|
var taskContext = ScheduleNow(exportContext);
|
||||||
|
|
||||||
|
var key = GetCacheKey(taskContext.Id);
|
||||||
|
HttpRuntime.Cache.Insert(key, taskContext, null, DateTime.Now.AddMinutes(60), Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null);
|
||||||
|
|
||||||
|
taskContext.TaskStatus.SetFinishedUrl(returnUrlBuilder(taskContext.Id));
|
||||||
|
|
||||||
|
return taskContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool TryFromCache(Guid? exportId, out ExportTaskContext exportContext)
|
||||||
|
{
|
||||||
|
if (exportId != null)
|
||||||
|
{
|
||||||
|
var key = GetCacheKey(exportId.Value);
|
||||||
|
|
||||||
|
if (HttpRuntime.Cache.Get(key) is ExportTaskContext context)
|
||||||
|
{
|
||||||
|
exportContext = context;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exportContext = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void ExecuteTask()
|
||||||
|
{
|
||||||
|
var context = (ExportTaskContext)ExecutionContext.JobDetail.JobDataMap[nameof(ExportTask)];
|
||||||
|
this.context = context.ExportContext;
|
||||||
|
|
||||||
|
Status.UpdateStatus(0, "Exporting", "Starting...");
|
||||||
|
|
||||||
|
using (var database = new DiscoDataContext())
|
||||||
|
{
|
||||||
|
context.Result = context.ExportContext.Export(database, Status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,19 +1,20 @@
|
|||||||
using Disco.Models.Services.Exporting;
|
using Disco.Models.Services.Exporting;
|
||||||
using Disco.Services.Tasks;
|
using Disco.Services.Tasks;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Disco.Services.Exporting
|
namespace Disco.Services.Exporting
|
||||||
{
|
{
|
||||||
public class ExportTaskContext<T> where T : IExportOptions
|
public class ExportTaskContext
|
||||||
{
|
{
|
||||||
public T Options { get; private set; }
|
public IExportContext ExportContext { get; }
|
||||||
|
public ScheduledTaskStatus TaskStatus { get; internal set; }
|
||||||
|
public ExportResult Result { get; internal set; }
|
||||||
|
|
||||||
public ScheduledTaskStatus TaskStatus { get; set; }
|
public Guid Id => ExportContext.Id;
|
||||||
|
|
||||||
public ExportResult Result { get; set; }
|
public ExportTaskContext(IExportContext context)
|
||||||
|
|
||||||
public ExportTaskContext(T Options)
|
|
||||||
{
|
{
|
||||||
this.Options = Options;
|
ExportContext = context;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using ClosedXML.Excel;
|
using ClosedXML.Excel;
|
||||||
|
using Disco.Data.Repository;
|
||||||
using Disco.Models.Exporting;
|
using Disco.Models.Exporting;
|
||||||
using Disco.Models.Services.Exporting;
|
using Disco.Models.Services.Exporting;
|
||||||
using Disco.Services.Tasks;
|
using Disco.Services.Tasks;
|
||||||
@@ -9,43 +10,66 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Disco.Services
|
namespace Disco.Services.Exporting
|
||||||
{
|
{
|
||||||
internal class ExportHelpers
|
public static class Exporter
|
||||||
{
|
{
|
||||||
public static ExportResult WriteExport<T>(IExportOptions options, IScheduledTaskStatus status, List<ExportFieldMetadata<T>> metadata, List<T> records) where T : IExportRecord
|
public static ExportResult Export<T, R>(DiscoDataContext database, IExportContext<T, R> context, IScheduledTaskStatus status)
|
||||||
|
where T : IExportOptions, new()
|
||||||
|
where R : IExportRecord
|
||||||
{
|
{
|
||||||
var filenameWithoutExtension = $"{options.FilenamePrefix}-{status.StartedTimestamp.Value:yyyyMMdd-HHmmss}";
|
|
||||||
MemoryStream stream;
|
MemoryStream stream;
|
||||||
string filename;
|
|
||||||
string mimeType;
|
string mimeType;
|
||||||
|
|
||||||
switch (options.Format)
|
status.UpdateStatus(1, $"Exporting {context.Name}", "Gathering data");
|
||||||
|
|
||||||
|
var records = context.BuildRecords(database, status);
|
||||||
|
|
||||||
|
status.UpdateStatus(70, "Building metadata");
|
||||||
|
|
||||||
|
var metadata = context.BuildMetadata(database, records, status);
|
||||||
|
|
||||||
|
if (metadata.Count == 0)
|
||||||
|
throw new ArgumentException("At least one export field must be specified", nameof(context.Options));
|
||||||
|
|
||||||
|
var filenameBuilder = new StringBuilder();
|
||||||
|
filenameBuilder.Append(context.SuggestedFilenamePrefix);
|
||||||
|
if (context.TimestampSuffix)
|
||||||
|
{
|
||||||
|
filenameBuilder.Append('-');
|
||||||
|
filenameBuilder.Append(status.StartedTimestamp.Value.ToString("yyyyMMdd-HHmmss"));
|
||||||
|
}
|
||||||
|
|
||||||
|
status.UpdateStatus(80, $"Rendering {records.Count} records for export");
|
||||||
|
|
||||||
|
switch (context.Options.Format)
|
||||||
{
|
{
|
||||||
case ExportFormat.Csv:
|
case ExportFormat.Csv:
|
||||||
stream = WriteCSV(filenameWithoutExtension, metadata, records, out filename, out mimeType);
|
filenameBuilder.Append(".csv");
|
||||||
|
mimeType = "text/csv";
|
||||||
|
stream = WriteCSV(metadata, records);
|
||||||
break;
|
break;
|
||||||
case ExportFormat.Xlsx:
|
case ExportFormat.Xlsx:
|
||||||
stream = WriteXlsx(filenameWithoutExtension, options.ExcelWorksheetName, options.ExcelTableName, metadata, records, out filename, out mimeType);
|
filenameBuilder.Append(".xlsx");
|
||||||
|
mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
||||||
|
stream = WriteXlsx(context.ExcelWorksheetName, context.ExcelTableName, metadata, records);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new NotSupportedException($"Unsupported export format: {options.Format}");
|
throw new NotSupportedException($"Unsupported export format: {context.Options.Format}");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ExportResult()
|
return new ExportResult()
|
||||||
{
|
{
|
||||||
Result = stream,
|
Result = stream,
|
||||||
RecordCount = records.Count,
|
RecordCount = records.Count,
|
||||||
Filename = filename,
|
Filename = filenameBuilder.ToString(),
|
||||||
MimeType = mimeType,
|
MimeType = mimeType,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MemoryStream WriteCSV<T>(string filenameWithoutExtension, List<ExportFieldMetadata<T>> metadata, List<T> records, out string filename, out string mimeType) where T : IExportRecord
|
private static MemoryStream WriteCSV<T>(List<ExportFieldMetadata<T>> metadata, List<T> records) where T : IExportRecord
|
||||||
{
|
{
|
||||||
var stream = new MemoryStream();
|
var stream = new MemoryStream();
|
||||||
mimeType = "text/csv";
|
|
||||||
filename = $"{filenameWithoutExtension}.csv";
|
|
||||||
|
|
||||||
using (StreamWriter writer = new StreamWriter(stream, Encoding.Default, 0x400, true))
|
using (StreamWriter writer = new StreamWriter(stream, Encoding.Default, 0x400, true))
|
||||||
{
|
{
|
||||||
@@ -74,11 +98,9 @@ namespace Disco.Services
|
|||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MemoryStream WriteXlsx<T>(string filenameWithoutExtension, string worksheetName, string tableName, List<ExportFieldMetadata<T>> metadata, List<T> records, out string filename, out string mimeType) where T : IExportRecord
|
private static MemoryStream WriteXlsx<T>(string worksheetName, string tableName, List<ExportFieldMetadata<T>> metadata, List<T> records) where T : IExportRecord
|
||||||
{
|
{
|
||||||
var stream = new MemoryStream();
|
var stream = new MemoryStream();
|
||||||
mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
||||||
filename = $"{filenameWithoutExtension}.xlsx";
|
|
||||||
|
|
||||||
// Create DataTable
|
// Create DataTable
|
||||||
var dataTable = new DataTable();
|
var dataTable = new DataTable();
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
using Disco.Data.Repository;
|
||||||
|
using Disco.Models.Exporting;
|
||||||
|
using Disco.Models.Services.Exporting;
|
||||||
|
using Disco.Services.Tasks;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace Disco.Services.Exporting
|
||||||
|
{
|
||||||
|
public interface IExportContext
|
||||||
|
{
|
||||||
|
Guid Id { get; set; }
|
||||||
|
string Name { get; set; }
|
||||||
|
string Description { get; set; }
|
||||||
|
|
||||||
|
ExportResult Export(DiscoDataContext database, IScheduledTaskStatus status);
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IExportContext<T, R>
|
||||||
|
: IExportContext
|
||||||
|
where T : IExportOptions, new()
|
||||||
|
where R : IExportRecord
|
||||||
|
{
|
||||||
|
bool TimestampSuffix { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
string SuggestedFilenamePrefix { get; }
|
||||||
|
[JsonIgnore]
|
||||||
|
string ExcelWorksheetName { get; }
|
||||||
|
[JsonIgnore]
|
||||||
|
string ExcelTableName { get; }
|
||||||
|
|
||||||
|
T Options { get; set; }
|
||||||
|
|
||||||
|
List<R> BuildRecords(DiscoDataContext database, IScheduledTaskStatus status);
|
||||||
|
List<ExportFieldMetadata<R>> BuildMetadata(DiscoDataContext database, List<R> records, IScheduledTaskStatus status);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
using Disco.Data.Repository;
|
|
||||||
using Disco.Models.Services.Jobs.Exporting;
|
|
||||||
using Disco.Services.Exporting;
|
|
||||||
using Disco.Services.Tasks;
|
|
||||||
using Quartz;
|
|
||||||
|
|
||||||
namespace Disco.Services.Jobs.Exporting
|
|
||||||
{
|
|
||||||
public class JobExportTask : ScheduledTask
|
|
||||||
{
|
|
||||||
private const string JobDataMapContext = "Context";
|
|
||||||
|
|
||||||
public override string TaskName { get { return "Export Jobs"; } }
|
|
||||||
public override bool SingleInstanceTask { get { return false; } }
|
|
||||||
public override bool CancelInitiallySupported { get { return false; } }
|
|
||||||
|
|
||||||
public static ExportTaskContext<JobExportOptions> ScheduleNow(JobExportOptions Options)
|
|
||||||
{
|
|
||||||
// Build Context
|
|
||||||
var context = new ExportTaskContext<JobExportOptions>(Options);
|
|
||||||
|
|
||||||
// Build Data Map
|
|
||||||
var task = new JobExportTask();
|
|
||||||
JobDataMap taskData = new JobDataMap() { { JobDataMapContext, context} };
|
|
||||||
|
|
||||||
// Schedule Task
|
|
||||||
context.TaskStatus = task.ScheduleTask(taskData);
|
|
||||||
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void ExecuteTask()
|
|
||||||
{
|
|
||||||
var context = (ExportTaskContext<JobExportOptions>)ExecutionContext.JobDetail.JobDataMap[JobDataMapContext];
|
|
||||||
|
|
||||||
Status.UpdateStatus(10, "Exporting Job Records", "Starting...");
|
|
||||||
|
|
||||||
using (DiscoDataContext Database = new DiscoDataContext())
|
|
||||||
{
|
|
||||||
context.Result = JobExport.GenerateExport(Database, context.Options, Status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+142
-133
@@ -2,41 +2,131 @@
|
|||||||
using Disco.Models.Exporting;
|
using Disco.Models.Exporting;
|
||||||
using Disco.Models.Repository;
|
using Disco.Models.Repository;
|
||||||
using Disco.Models.Services.Exporting;
|
using Disco.Models.Services.Exporting;
|
||||||
using Disco.Models.Services.Jobs.Exporting;
|
using Disco.Models.Services.Jobs;
|
||||||
|
using Disco.Services.Exporting;
|
||||||
using Disco.Services.Jobs.JobQueues;
|
using Disco.Services.Jobs.JobQueues;
|
||||||
using Disco.Services.Plugins.Features.DetailsProvider;
|
using Disco.Services.Plugins.Features.DetailsProvider;
|
||||||
using Disco.Services.Tasks;
|
using Disco.Services.Tasks;
|
||||||
using Disco.Services.Users;
|
using Disco.Services.Users;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Data;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Disco.Services.Jobs.Exporting
|
namespace Disco.Services.Jobs
|
||||||
{
|
{
|
||||||
using Metadata = ExportFieldMetadata<JobExportRecord>;
|
using Metadata = ExportFieldMetadata<JobExportRecord>;
|
||||||
|
|
||||||
public static class JobExport
|
public class JobExportContext : IExportContext<JobExportOptions, JobExportRecord>
|
||||||
{
|
{
|
||||||
public static ExportResult GenerateExport(DiscoDataContext database, Func<IQueryable<Job>, IQueryable<Job>> filter, JobExportOptions options, IScheduledTaskStatus taskStatus)
|
public Guid Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
public bool TimestampSuffix { get; set; }
|
||||||
|
public JobExportOptions Options { get; set; }
|
||||||
|
|
||||||
|
public string SuggestedFilenamePrefix { get; } = "JobExport";
|
||||||
|
public string ExcelWorksheetName { get; } = "JobExport";
|
||||||
|
public string ExcelTableName { get; } = "Jobs";
|
||||||
|
|
||||||
|
[JsonConstructor]
|
||||||
|
private JobExportContext()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public JobExportContext(string name, string description, bool timestampSuffix, JobExportOptions options)
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid();
|
||||||
|
Name = name;
|
||||||
|
Description = description;
|
||||||
|
TimestampSuffix = timestampSuffix;
|
||||||
|
Options = options;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JobExportContext(JobExportOptions options)
|
||||||
|
: this("Job Export", null, true, options)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExportResult Export(DiscoDataContext database, IScheduledTaskStatus status)
|
||||||
|
=> Exporter.Export(database, this, status);
|
||||||
|
|
||||||
|
private IQueryable<Job> BuildFilteredRecords(DiscoDataContext database)
|
||||||
|
{
|
||||||
|
var o = Options;
|
||||||
|
|
||||||
|
var q = database.Jobs.Where(j => j.OpenedDate >= o.FilterStartDate);
|
||||||
|
if (o.FilterEndDate.HasValue)
|
||||||
|
q = q.Where(j => j.OpenedDate <= o.FilterEndDate);
|
||||||
|
|
||||||
|
if (o.FilterJobTypeId != null)
|
||||||
|
q = q.Where(j => j.JobTypeId == o.FilterJobTypeId);
|
||||||
|
|
||||||
|
if (o.FilterJobSubTypeIds?.Any() ?? false)
|
||||||
|
q = q.Where(j => j.JobSubTypes.Any(st => o.FilterJobSubTypeIds.Contains(st.Id)));
|
||||||
|
|
||||||
|
if (o.FilterJobQueueId.HasValue)
|
||||||
|
q = q.Where(j => j.JobQueues.Any(jq => !jq.RemovedDate.HasValue && jq.JobQueueId == o.FilterJobQueueId));
|
||||||
|
|
||||||
|
if (o.FilterJobStatusId != null)
|
||||||
|
{
|
||||||
|
if (o.FilterJobStatusId != Job.JobStatusIds.Closed)
|
||||||
|
q = q.Where(j => j.ClosedDate == null);
|
||||||
|
|
||||||
|
switch (o.FilterJobStatusId)
|
||||||
|
{
|
||||||
|
case Job.JobStatusIds.Open:
|
||||||
|
// already filtered
|
||||||
|
break;
|
||||||
|
case Job.JobStatusIds.AwaitingAccountingPayment:
|
||||||
|
q = q.Where(j => j.JobTypeId == JobType.JobTypeIds.HNWar && j.JobMetaNonWarranty.AccountingChargeAddedDate != null && j.JobMetaNonWarranty.AccountingChargePaidDate == null);
|
||||||
|
break;
|
||||||
|
case Job.JobStatusIds.AwaitingAccountingCharge:
|
||||||
|
q = q.Where(j => j.JobTypeId == JobType.JobTypeIds.HNWar && j.JobMetaNonWarranty.AccountingChargeRequiredDate == null && (j.JobMetaNonWarranty.AccountingChargePaidDate != null || j.JobMetaNonWarranty.AccountingChargeAddedDate != null));
|
||||||
|
break;
|
||||||
|
case Job.JobStatusIds.AwaitingDeviceReturn:
|
||||||
|
q = q.Where(j => j.DeviceReadyForReturn != null && j.DeviceReturnedDate == null);
|
||||||
|
break;
|
||||||
|
case Job.JobStatusIds.AwaitingInsuranceProcessing:
|
||||||
|
q = q.Where(j => j.JobTypeId == JobType.JobTypeIds.HNWar && j.JobMetaNonWarranty.IsInsuranceClaim && j.JobMetaInsurance.ClaimFormSentDate == null);
|
||||||
|
break;
|
||||||
|
case Job.JobStatusIds.AwaitingRepairs:
|
||||||
|
q = q.Where(j => j.JobTypeId == JobType.JobTypeIds.HNWar && j.JobMetaNonWarranty.RepairerLoggedDate != null && j.JobMetaNonWarranty.RepairerCompletedDate == null);
|
||||||
|
break;
|
||||||
|
case Job.JobStatusIds.AwaitingUserAction:
|
||||||
|
q = q.Where(j => j.WaitingForUserAction != null);
|
||||||
|
break;
|
||||||
|
case Job.JobStatusIds.AwaitingWarrantyRepair:
|
||||||
|
q = q.Where(j => j.JobTypeId == JobType.JobTypeIds.HWar && j.JobMetaWarranty.ExternalLoggedDate != null && j.JobMetaWarranty.ExternalCompletedDate == null);
|
||||||
|
break;
|
||||||
|
case Job.JobStatusIds.Closed:
|
||||||
|
q = q.Where(j => j.ClosedDate != null);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new ArgumentException($"Unknown Job Status Id: {o.FilterJobStatusId}", nameof(o.FilterJobStatusId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return q;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<JobExportRecord> BuildRecords(DiscoDataContext database, IScheduledTaskStatus status)
|
||||||
{
|
{
|
||||||
database.Configuration.LazyLoadingEnabled = false;
|
database.Configuration.LazyLoadingEnabled = false;
|
||||||
database.Configuration.ProxyCreationEnabled = false;
|
database.Configuration.ProxyCreationEnabled = false;
|
||||||
|
|
||||||
var jobQuery = (IQueryable<Job>)database.Jobs;
|
var query = BuildFilteredRecords(database);
|
||||||
if (filter != null)
|
|
||||||
jobQuery = filter(jobQuery);
|
|
||||||
|
|
||||||
// Update Users
|
// Update Users
|
||||||
if (options.UserDisplayName ||
|
if (Options.UserDisplayName ||
|
||||||
options.UserSurname ||
|
Options.UserSurname ||
|
||||||
options.UserGivenName ||
|
Options.UserGivenName ||
|
||||||
options.UserPhoneNumber ||
|
Options.UserPhoneNumber ||
|
||||||
options.UserEmailAddress)
|
Options.UserEmailAddress)
|
||||||
{
|
{
|
||||||
taskStatus.UpdateStatus(5, "Refreshing user details from Active Directory");
|
status.UpdateStatus(5, "Refreshing user details from Active Directory");
|
||||||
var userIds = jobQuery.Where(d => d.UserId != null).Select(d => d.UserId).Distinct().ToList();
|
var userIds = query.Where(d => d.UserId != null).Select(d => d.UserId).Distinct().ToList();
|
||||||
foreach (var userId in userIds)
|
foreach (var userId in userIds)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -48,9 +138,9 @@ namespace Disco.Services.Jobs.Exporting
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update Last Network Logon Date
|
// Update Last Network Logon Date
|
||||||
if (options.DeviceLastNetworkLogon)
|
if (Options.DeviceLastNetworkLogon)
|
||||||
{
|
{
|
||||||
taskStatus.UpdateStatus(15, "Refreshing device last network logon dates from Active Directory");
|
status.UpdateStatus(15, "Refreshing device last network logon dates from Active Directory");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Interop.ActiveDirectory.ADNetworkLogonDatesUpdateTask.UpdateLastNetworkLogonDates(database, ScheduledTaskMockStatus.Create("UpdateLastNetworkLogonDates"));
|
Interop.ActiveDirectory.ADNetworkLogonDatesUpdateTask.UpdateLastNetworkLogonDates(database, ScheduledTaskMockStatus.Create("UpdateLastNetworkLogonDates"));
|
||||||
@@ -59,119 +149,9 @@ namespace Disco.Services.Jobs.Exporting
|
|||||||
catch (Exception) { } // Ignore Errors
|
catch (Exception) { } // Ignore Errors
|
||||||
}
|
}
|
||||||
|
|
||||||
taskStatus.UpdateStatus(25, "Extracting records from the database");
|
status.UpdateStatus(25, "Extracting records from the database");
|
||||||
|
|
||||||
var records = BuildRecords(jobQuery).ToList();
|
var records = query.Select(j => new JobExportRecord()
|
||||||
|
|
||||||
records.ForEach(r =>
|
|
||||||
{
|
|
||||||
if (options.JobStatus)
|
|
||||||
{
|
|
||||||
r.JobStatus = JobExtensions.CalculateStatusId(
|
|
||||||
r.Job.ClosedDate,
|
|
||||||
r.Job.JobTypeId,
|
|
||||||
r.JobMetaWarranty?.ExternalLoggedDate,
|
|
||||||
r.JobMetaWarranty?.ExternalCompletedDate,
|
|
||||||
r.JobMetaNonWarranty?.RepairerLoggedDate,
|
|
||||||
r.JobMetaNonWarranty?.RepairerCompletedDate,
|
|
||||||
r.JobMetaNonWarranty?.AccountingChargeRequiredDate,
|
|
||||||
r.JobMetaNonWarranty?.AccountingChargeAddedDate,
|
|
||||||
r.JobMetaNonWarranty?.AccountingChargePaidDate,
|
|
||||||
r.JobMetaNonWarranty?.IsInsuranceClaim,
|
|
||||||
r.JobMetaInsurance?.ClaimFormSentDate,
|
|
||||||
r.Job.WaitingForUserAction,
|
|
||||||
r.Job.DeviceReadyForReturn,
|
|
||||||
r.Job.DeviceReturnedDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.UserDetailCustom && r.User != null)
|
|
||||||
{
|
|
||||||
var detailsService = new DetailsProviderService(database);
|
|
||||||
r.UserCustomDetails = detailsService.GetDetails(r.User);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
taskStatus.UpdateStatus(70, "Building metadata");
|
|
||||||
var metadata = options.BuildMetadata(records);
|
|
||||||
|
|
||||||
if (metadata.Count == 0)
|
|
||||||
throw new ArgumentException("At least one export field must be specified", "Options");
|
|
||||||
|
|
||||||
taskStatus.UpdateStatus(80, $"Formatting {records.Count} records for export");
|
|
||||||
|
|
||||||
return ExportHelpers.WriteExport(options, taskStatus, metadata, records);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ExportResult GenerateExport(DiscoDataContext database, JobExportOptions options, IScheduledTaskStatus taskStatus)
|
|
||||||
{
|
|
||||||
Func<IQueryable<Job>, IQueryable<Job>> filter = q =>
|
|
||||||
{
|
|
||||||
var r = q.Where(j => j.OpenedDate >= options.FilterStartDate);
|
|
||||||
if (options.FilterEndDate.HasValue)
|
|
||||||
r = r.Where(j => j.OpenedDate <= options.FilterEndDate);
|
|
||||||
|
|
||||||
if (options.FilterJobTypeId != null)
|
|
||||||
r = r.Where(j => j.JobTypeId == options.FilterJobTypeId);
|
|
||||||
|
|
||||||
if (options.FilterJobSubTypeIds?.Any() ?? false)
|
|
||||||
r = r.Where(j => j.JobSubTypes.Any(st => options.FilterJobSubTypeIds.Contains(st.Id)));
|
|
||||||
|
|
||||||
if (options.FilterJobQueueId.HasValue)
|
|
||||||
r = r.Where(j => j.JobQueues.Any(jq => !jq.RemovedDate.HasValue && jq.JobQueueId == options.FilterJobQueueId));
|
|
||||||
|
|
||||||
if (options.FilterJobStatusId != null)
|
|
||||||
{
|
|
||||||
if (options.FilterJobStatusId != Job.JobStatusIds.Closed)
|
|
||||||
r = r.Where(j => j.ClosedDate == null);
|
|
||||||
|
|
||||||
switch (options.FilterJobStatusId)
|
|
||||||
{
|
|
||||||
case Job.JobStatusIds.Open:
|
|
||||||
// already filtered
|
|
||||||
break;
|
|
||||||
case Job.JobStatusIds.AwaitingAccountingPayment:
|
|
||||||
r = r.Where(j => j.JobTypeId == JobType.JobTypeIds.HNWar && j.JobMetaNonWarranty.AccountingChargeAddedDate != null && j.JobMetaNonWarranty.AccountingChargePaidDate == null);
|
|
||||||
break;
|
|
||||||
case Job.JobStatusIds.AwaitingAccountingCharge:
|
|
||||||
r = r.Where(j => j.JobTypeId == JobType.JobTypeIds.HNWar && j.JobMetaNonWarranty.AccountingChargeRequiredDate == null && (j.JobMetaNonWarranty.AccountingChargePaidDate != null || j.JobMetaNonWarranty.AccountingChargeAddedDate != null));
|
|
||||||
break;
|
|
||||||
case Job.JobStatusIds.AwaitingDeviceReturn:
|
|
||||||
r = r.Where(j => j.DeviceReadyForReturn != null && j.DeviceReturnedDate == null);
|
|
||||||
break;
|
|
||||||
case Job.JobStatusIds.AwaitingInsuranceProcessing:
|
|
||||||
r = r.Where(j => j.JobTypeId == JobType.JobTypeIds.HNWar && j.JobMetaNonWarranty.IsInsuranceClaim && j.JobMetaInsurance.ClaimFormSentDate == null);
|
|
||||||
break;
|
|
||||||
case Job.JobStatusIds.AwaitingRepairs:
|
|
||||||
r = r.Where(j => j.JobTypeId == JobType.JobTypeIds.HNWar && j.JobMetaNonWarranty.RepairerLoggedDate != null && j.JobMetaNonWarranty.RepairerCompletedDate == null);
|
|
||||||
break;
|
|
||||||
case Job.JobStatusIds.AwaitingUserAction:
|
|
||||||
r = r.Where(j => j.WaitingForUserAction != null);
|
|
||||||
break;
|
|
||||||
case Job.JobStatusIds.AwaitingWarrantyRepair:
|
|
||||||
r = r.Where(j => j.JobTypeId == JobType.JobTypeIds.HWar && j.JobMetaWarranty.ExternalLoggedDate != null && j.JobMetaWarranty.ExternalCompletedDate == null);
|
|
||||||
break;
|
|
||||||
case Job.JobStatusIds.Closed:
|
|
||||||
r = r.Where(j => j.ClosedDate != null);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new ArgumentException($"Unknown Job Status Id: {options.FilterJobStatusId}", nameof(options.FilterJobStatusId));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return r;
|
|
||||||
};
|
|
||||||
|
|
||||||
return GenerateExport(database, filter, options, taskStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ExportResult GenerateExport(DiscoDataContext database, JobExportOptions options)
|
|
||||||
{
|
|
||||||
return GenerateExport(database, options, ScheduledTaskMockStatus.Create("Job Export"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static IEnumerable<JobExportRecord> BuildRecords(IQueryable<Job> jobs)
|
|
||||||
{
|
|
||||||
return jobs.Select(j => new JobExportRecord()
|
|
||||||
{
|
{
|
||||||
Job = j,
|
Job = j,
|
||||||
JobTypeDescription = j.JobType.Description,
|
JobTypeDescription = j.JobType.Description,
|
||||||
@@ -214,13 +194,43 @@ namespace Disco.Services.Jobs.Exporting
|
|||||||
DeviceProfileId = j.Device.DeviceProfileId,
|
DeviceProfileId = j.Device.DeviceProfileId,
|
||||||
DeviceProfileName = j.Device.DeviceProfile.Name,
|
DeviceProfileName = j.Device.DeviceProfile.Name,
|
||||||
DeviceProfileShortName = j.Device.DeviceProfile.ShortName,
|
DeviceProfileShortName = j.Device.DeviceProfile.ShortName,
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
records.ForEach(r =>
|
||||||
|
{
|
||||||
|
if (Options.JobStatus)
|
||||||
|
{
|
||||||
|
r.JobStatus = JobExtensions.CalculateStatusId(
|
||||||
|
r.Job.ClosedDate,
|
||||||
|
r.Job.JobTypeId,
|
||||||
|
r.JobMetaWarranty?.ExternalLoggedDate,
|
||||||
|
r.JobMetaWarranty?.ExternalCompletedDate,
|
||||||
|
r.JobMetaNonWarranty?.RepairerLoggedDate,
|
||||||
|
r.JobMetaNonWarranty?.RepairerCompletedDate,
|
||||||
|
r.JobMetaNonWarranty?.AccountingChargeRequiredDate,
|
||||||
|
r.JobMetaNonWarranty?.AccountingChargeAddedDate,
|
||||||
|
r.JobMetaNonWarranty?.AccountingChargePaidDate,
|
||||||
|
r.JobMetaNonWarranty?.IsInsuranceClaim,
|
||||||
|
r.JobMetaInsurance?.ClaimFormSentDate,
|
||||||
|
r.Job.WaitingForUserAction,
|
||||||
|
r.Job.DeviceReadyForReturn,
|
||||||
|
r.Job.DeviceReturnedDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Options.UserDetailCustom && r.User != null)
|
||||||
|
{
|
||||||
|
var detailsService = new DetailsProviderService(database);
|
||||||
|
r.UserCustomDetails = detailsService.GetDetails(r.User);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return records;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Metadata> BuildMetadata(this JobExportOptions options, List<JobExportRecord> records)
|
public List<Metadata> BuildMetadata(DiscoDataContext database, List<JobExportRecord> records, IScheduledTaskStatus status)
|
||||||
{
|
{
|
||||||
IEnumerable<string> userDetailCustomKeys = null;
|
IEnumerable<string> userDetailCustomKeys = null;
|
||||||
if (options.UserDetailCustom)
|
if (Options.UserDetailCustom)
|
||||||
userDetailCustomKeys = records.Where(r => r.UserCustomDetails != null).SelectMany(r => r.UserCustomDetails.Keys).Distinct(StringComparer.OrdinalIgnoreCase).ToList();
|
userDetailCustomKeys = records.Where(r => r.UserCustomDetails != null).SelectMany(r => r.UserCustomDetails.Keys).Distinct(StringComparer.OrdinalIgnoreCase).ToList();
|
||||||
|
|
||||||
var allAccessors = BuildRecordAccessors(userDetailCustomKeys);
|
var allAccessors = BuildRecordAccessors(userDetailCustomKeys);
|
||||||
@@ -232,7 +242,7 @@ namespace Disco.Services.Jobs.Exporting
|
|||||||
property = p,
|
property = p,
|
||||||
details = (DisplayAttribute)p.GetCustomAttributes(typeof(DisplayAttribute), false).FirstOrDefault()
|
details = (DisplayAttribute)p.GetCustomAttributes(typeof(DisplayAttribute), false).FirstOrDefault()
|
||||||
})
|
})
|
||||||
.Where(p => p.details != null && (bool)p.property.GetValue(options))
|
.Where(p => p.details != null && (bool)p.property.GetValue(Options))
|
||||||
.SelectMany(p =>
|
.SelectMany(p =>
|
||||||
{
|
{
|
||||||
var fieldMetadata = allAccessors[p.property.Name];
|
var fieldMetadata = allAccessors[p.property.Name];
|
||||||
@@ -397,6 +407,5 @@ namespace Disco.Services.Jobs.Exporting
|
|||||||
|
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,11 @@
|
|||||||
using Disco.Models.Exporting;
|
using Disco.Data.Repository;
|
||||||
|
using Disco.Models.Exporting;
|
||||||
using Disco.Models.Services.Exporting;
|
using Disco.Models.Services.Exporting;
|
||||||
|
using Disco.Models.Services.Logging;
|
||||||
|
using Disco.Services.Exporting;
|
||||||
using Disco.Services.Logging.Models;
|
using Disco.Services.Logging.Models;
|
||||||
using Disco.Services.Tasks;
|
using Disco.Services.Tasks;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -10,12 +14,56 @@ namespace Disco.Services.Logging
|
|||||||
{
|
{
|
||||||
using Metadata = ExportFieldMetadata<LogLiveEvent>;
|
using Metadata = ExportFieldMetadata<LogLiveEvent>;
|
||||||
|
|
||||||
public static class LogExport
|
public class LogExportContext : IExportContext<LogExportOptions, LogLiveEvent>
|
||||||
{
|
{
|
||||||
public static ExportResult GenerateExport(ExportFormat format, List<LogLiveEvent> records)
|
public Guid Id { get; set; }
|
||||||
{
|
public string Name { get; set; }
|
||||||
var options = new LogExportOptions(format);
|
public string Description { get; set; }
|
||||||
|
public bool TimestampSuffix { get; set; }
|
||||||
|
public LogExportOptions Options { get; set; }
|
||||||
|
|
||||||
|
public string SuggestedFilenamePrefix { get; } = "DiscoIctLogs";
|
||||||
|
public string ExcelWorksheetName { get; } = "Disco ICT Logs";
|
||||||
|
public string ExcelTableName { get; } = "DiscoIctLogs";
|
||||||
|
|
||||||
|
[JsonConstructor]
|
||||||
|
private LogExportContext()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public LogExportContext(string name, string description, bool timestampSuffix, LogExportOptions options)
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid();
|
||||||
|
Name = name;
|
||||||
|
Description = description;
|
||||||
|
TimestampSuffix = timestampSuffix;
|
||||||
|
Options = options;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LogExportContext(LogExportOptions options)
|
||||||
|
: this("Log Export", null, true, options)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExportResult Export(DiscoDataContext database, IScheduledTaskStatus status)
|
||||||
|
=> Exporter.Export(database, this, status);
|
||||||
|
|
||||||
|
public List<LogLiveEvent> BuildRecords(DiscoDataContext database, IScheduledTaskStatus status)
|
||||||
|
{
|
||||||
|
var logRetriever = new ReadLogContext()
|
||||||
|
{
|
||||||
|
Start = Options.StartDate,
|
||||||
|
End = Options.EndDate,
|
||||||
|
Module = Options.ModuleId,
|
||||||
|
EventTypes = Options.EventTypeIds,
|
||||||
|
Take = Options.Take,
|
||||||
|
};
|
||||||
|
|
||||||
|
return logRetriever.Query(database);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Metadata> BuildMetadata(DiscoDataContext database, List<LogLiveEvent> records, IScheduledTaskStatus status)
|
||||||
|
{
|
||||||
const string DateFormat = "yyyy-MM-dd";
|
const string DateFormat = "yyyy-MM-dd";
|
||||||
const string DateTimeFormat = DateFormat + " HH:mm:ss";
|
const string DateTimeFormat = DateFormat + " HH:mm:ss";
|
||||||
Func<object, string> csvStringEncoded = (o) => o == null ? null : $"\"{((string)o).Replace("\"", "\"\"")}\"";
|
Func<object, string> csvStringEncoded = (o) => o == null ? null : $"\"{((string)o).Replace("\"", "\"\"")}\"";
|
||||||
@@ -48,20 +96,7 @@ namespace Disco.Services.Logging
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ExportHelpers.WriteExport(options, ScheduledTaskMockStatus.Create("Export Disco ICT Logs"), metadata, records);
|
return metadata;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class LogExportOptions : IExportOptions
|
|
||||||
{
|
|
||||||
public ExportFormat Format { get; set; }
|
|
||||||
public string FilenamePrefix { get; } = "DiscoIctLogs";
|
|
||||||
public string ExcelWorksheetName { get; set; } = "Disco ICT Logs";
|
|
||||||
public string ExcelTableName { get; set; } = "DiscoIctLogs";
|
|
||||||
|
|
||||||
public LogExportOptions(ExportFormat format)
|
|
||||||
{
|
|
||||||
Format = format;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+46
-36
@@ -2,8 +2,11 @@
|
|||||||
using Disco.Models.Exporting;
|
using Disco.Models.Exporting;
|
||||||
using Disco.Models.Services.Exporting;
|
using Disco.Models.Services.Exporting;
|
||||||
using Disco.Models.Services.Users.UserFlags;
|
using Disco.Models.Services.Users.UserFlags;
|
||||||
|
using Disco.Services.Exporting;
|
||||||
using Disco.Services.Plugins.Features.DetailsProvider;
|
using Disco.Services.Plugins.Features.DetailsProvider;
|
||||||
using Disco.Services.Tasks;
|
using Disco.Services.Tasks;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
@@ -14,48 +17,56 @@ namespace Disco.Services.Users.UserFlags
|
|||||||
{
|
{
|
||||||
using Metadata = ExportFieldMetadata<UserFlagExportRecord>;
|
using Metadata = ExportFieldMetadata<UserFlagExportRecord>;
|
||||||
|
|
||||||
public class UserFlagExport
|
public class UserFlagExportContext : IExportContext<UserFlagExportOptions, UserFlagExportRecord>
|
||||||
{
|
{
|
||||||
private readonly DiscoDataContext database;
|
public Guid Id { get; set; }
|
||||||
private readonly UserFlagExportOptions options;
|
public string Name { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
public bool TimestampSuffix { get; set; }
|
||||||
|
public UserFlagExportOptions Options { get; set; }
|
||||||
|
|
||||||
public UserFlagExport(DiscoDataContext database, UserFlagExportOptions options)
|
public string SuggestedFilenamePrefix { get; } = "UserFlagExport";
|
||||||
|
public string ExcelWorksheetName { get; } = "UserFlagExport";
|
||||||
|
public string ExcelTableName { get; } = "UserFlags";
|
||||||
|
|
||||||
|
[JsonConstructor]
|
||||||
|
private UserFlagExportContext()
|
||||||
{
|
{
|
||||||
this.database = database;
|
|
||||||
this.options = options;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExportResult Generate(IScheduledTaskStatus status)
|
public UserFlagExportContext(string name, string description, bool timestampSuffix, UserFlagExportOptions options)
|
||||||
{
|
{
|
||||||
var records = BuildRecords(status);
|
Id = Guid.NewGuid();
|
||||||
|
Name = name;
|
||||||
var metadata = BuildMetadata(records, status);
|
Description = description;
|
||||||
|
TimestampSuffix = timestampSuffix;
|
||||||
if (metadata.Count == 0)
|
Options = options;
|
||||||
throw new ArgumentException("At least one export field must be specified", nameof(options));
|
|
||||||
|
|
||||||
status.UpdateStatus(90, $"Formatting {records.Count} records for export");
|
|
||||||
return ExportHelpers.WriteExport(options, status, metadata, records);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<UserFlagExportRecord> BuildRecords(IScheduledTaskStatus status)
|
public UserFlagExportContext(UserFlagExportOptions options)
|
||||||
|
: this("User Flag Export", null, true, options)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExportResult Export(DiscoDataContext database, IScheduledTaskStatus status)
|
||||||
|
=> Exporter.Export(database, this, status);
|
||||||
|
|
||||||
|
public List<UserFlagExportRecord> BuildRecords(DiscoDataContext database, IScheduledTaskStatus status)
|
||||||
{
|
{
|
||||||
var query = database.UserFlagAssignments
|
var query = database.UserFlagAssignments
|
||||||
.Include(a => a.User.UserDetails)
|
.Include(a => a.User.UserDetails)
|
||||||
.Include(a => a.UserFlag)
|
.Include(a => a.UserFlag)
|
||||||
.Where(a => options.UserFlagIds.Contains(a.UserFlagId));
|
.Where(a => Options.UserFlagIds.Contains(a.UserFlagId));
|
||||||
|
|
||||||
if (options.CurrentOnly)
|
if (Options.CurrentOnly)
|
||||||
{
|
|
||||||
query = query.Where(a => !a.RemovedDate.HasValue);
|
query = query.Where(a => !a.RemovedDate.HasValue);
|
||||||
}
|
|
||||||
|
|
||||||
// Update Users
|
// Update Users
|
||||||
if (options.UserDisplayName ||
|
if (Options.UserDisplayName ||
|
||||||
options.UserSurname ||
|
Options.UserSurname ||
|
||||||
options.UserGivenName ||
|
Options.UserGivenName ||
|
||||||
options.UserPhoneNumber ||
|
Options.UserPhoneNumber ||
|
||||||
options.UserEmailAddress)
|
Options.UserEmailAddress)
|
||||||
{
|
{
|
||||||
status.UpdateStatus(5, "Refreshing user details from Active Directory");
|
status.UpdateStatus(5, "Refreshing user details from Active Directory");
|
||||||
var userIds = query.Select(d => d.UserId).Distinct().ToList();
|
var userIds = query.Select(d => d.UserId).Distinct().ToList();
|
||||||
@@ -72,11 +83,11 @@ namespace Disco.Services.Users.UserFlags
|
|||||||
status.UpdateStatus(15, "Extracting records from the database");
|
status.UpdateStatus(15, "Extracting records from the database");
|
||||||
|
|
||||||
var records = query.Select(a => new UserFlagExportRecord()
|
var records = query.Select(a => new UserFlagExportRecord()
|
||||||
{
|
{
|
||||||
Assignment = a
|
Assignment = a
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
if (options.UserDetailCustom)
|
if (Options.UserDetailCustom)
|
||||||
{
|
{
|
||||||
status.UpdateStatus(50, "Extracting custom user detail records");
|
status.UpdateStatus(50, "Extracting custom user detail records");
|
||||||
|
|
||||||
@@ -93,12 +104,12 @@ namespace Disco.Services.Users.UserFlags
|
|||||||
return records;
|
return records;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Metadata> BuildMetadata(List<UserFlagExportRecord> records, IScheduledTaskStatus status)
|
public List<Metadata> BuildMetadata(DiscoDataContext database, List<UserFlagExportRecord> records, IScheduledTaskStatus status)
|
||||||
{
|
{
|
||||||
status.UpdateStatus(80, "Building metadata");
|
status.UpdateStatus(80, "Building metadata");
|
||||||
|
|
||||||
IEnumerable<string> userDetailCustomKeys = null;
|
IEnumerable<string> userDetailCustomKeys = null;
|
||||||
if (options.UserDetailCustom)
|
if (Options.UserDetailCustom)
|
||||||
userDetailCustomKeys = records.Where(r => r.UserCustomDetails != null).SelectMany(r => r.UserCustomDetails.Keys).Distinct(StringComparer.OrdinalIgnoreCase).ToList();
|
userDetailCustomKeys = records.Where(r => r.UserCustomDetails != null).SelectMany(r => r.UserCustomDetails.Keys).Distinct(StringComparer.OrdinalIgnoreCase).ToList();
|
||||||
|
|
||||||
var accessors = BuildAccessors(userDetailCustomKeys);
|
var accessors = BuildAccessors(userDetailCustomKeys);
|
||||||
@@ -110,9 +121,9 @@ namespace Disco.Services.Users.UserFlags
|
|||||||
property = p,
|
property = p,
|
||||||
details = (DisplayAttribute)p.GetCustomAttributes(typeof(DisplayAttribute), false).FirstOrDefault()
|
details = (DisplayAttribute)p.GetCustomAttributes(typeof(DisplayAttribute), false).FirstOrDefault()
|
||||||
})
|
})
|
||||||
.Where(p => p.details != null && p.property.Name != nameof(options.CurrentOnly) && (bool)p.property.GetValue(options))
|
.Where(p => p.details != null && p.property.Name != nameof(Options.CurrentOnly) && (bool)p.property.GetValue(Options))
|
||||||
.SelectMany(p =>
|
.SelectMany(p =>
|
||||||
{
|
{
|
||||||
var fieldMetadata = accessors[p.property.Name];
|
var fieldMetadata = accessors[p.property.Name];
|
||||||
fieldMetadata.ForEach(f =>
|
fieldMetadata.ForEach(f =>
|
||||||
{
|
{
|
||||||
@@ -171,6 +182,5 @@ namespace Disco.Services.Users.UserFlags
|
|||||||
|
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
using Disco.Data.Repository;
|
|
||||||
using Disco.Models.Services.Users.UserFlags;
|
|
||||||
using Disco.Services.Exporting;
|
|
||||||
using Disco.Services.Tasks;
|
|
||||||
using Quartz;
|
|
||||||
|
|
||||||
namespace Disco.Services.Users.UserFlags
|
|
||||||
{
|
|
||||||
public class UserFlagExportTask : ScheduledTask
|
|
||||||
{
|
|
||||||
private const string JobDataMapContext = "Context";
|
|
||||||
|
|
||||||
public override string TaskName { get; } = "Export User Flags";
|
|
||||||
public override bool SingleInstanceTask { get { return false; } }
|
|
||||||
public override bool CancelInitiallySupported { get { return false; } }
|
|
||||||
|
|
||||||
public static ExportTaskContext<UserFlagExportOptions> ScheduleNow(UserFlagExportOptions options)
|
|
||||||
{
|
|
||||||
// Build Context
|
|
||||||
var context = new ExportTaskContext<UserFlagExportOptions>(options);
|
|
||||||
|
|
||||||
// Build Data Map
|
|
||||||
var task = new UserFlagExportTask();
|
|
||||||
JobDataMap taskData = new JobDataMap() { { JobDataMapContext, context } };
|
|
||||||
|
|
||||||
// Schedule Task
|
|
||||||
context.TaskStatus = task.ScheduleTask(taskData);
|
|
||||||
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void ExecuteTask()
|
|
||||||
{
|
|
||||||
var context = (ExportTaskContext<UserFlagExportOptions>)ExecutionContext.JobDetail.JobDataMap[JobDataMapContext];
|
|
||||||
|
|
||||||
Status.UpdateStatus(10, "Exporting User Flag Records", "Starting...");
|
|
||||||
|
|
||||||
using (DiscoDataContext Database = new DiscoDataContext())
|
|
||||||
{
|
|
||||||
var export = new UserFlagExport(Database, context.Options);
|
|
||||||
|
|
||||||
context.Result = export.Generate(Status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
using Disco.Models.Repository;
|
using Disco.Models.Repository;
|
||||||
using Disco.Models.Services.Devices.Exporting;
|
|
||||||
using Disco.Models.Services.Devices.Importing;
|
using Disco.Models.Services.Devices.Importing;
|
||||||
using Disco.Services;
|
using Disco.Services;
|
||||||
using Disco.Services.Authorization;
|
using Disco.Services.Authorization;
|
||||||
using Disco.Services.Devices.Exporting;
|
using Disco.Services.Devices;
|
||||||
using Disco.Services.Devices.Importing;
|
using Disco.Services.Devices.Importing;
|
||||||
using Disco.Services.Exporting;
|
using Disco.Services.Exporting;
|
||||||
using Disco.Services.Interop;
|
using Disco.Services.Interop;
|
||||||
@@ -685,7 +684,6 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Exporting
|
#region Exporting
|
||||||
internal const string ExportSessionCacheKey = "DeviceExportContext_{0}";
|
|
||||||
|
|
||||||
[DiscoAuthorize(Claims.Device.Actions.Export)]
|
[DiscoAuthorize(Claims.Device.Actions.Export)]
|
||||||
[HttpPost, ValidateAntiForgeryToken]
|
[HttpPost, ValidateAntiForgeryToken]
|
||||||
@@ -699,39 +697,29 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
Database.SaveChanges();
|
Database.SaveChanges();
|
||||||
|
|
||||||
// Start Export
|
// Start Export
|
||||||
var exportContext = DeviceExportTask.ScheduleNow(Model.Options);
|
var exportContext = new DeviceExportContext(Model.Options);
|
||||||
|
var taskContext = ExportTask.ScheduleNowCacheResult(exportContext, id => Url.Action(MVC.Device.Export(id, null, null)));
|
||||||
// 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
|
// Try waiting for completion
|
||||||
if (exportContext.TaskStatus.WaitUntilFinished(TimeSpan.FromSeconds(2)))
|
if (taskContext.TaskStatus.WaitUntilFinished(TimeSpan.FromSeconds(1)))
|
||||||
return RedirectToAction(finishedActionResult);
|
return RedirectToAction(MVC.Device.Export(taskContext.Id, null, null));
|
||||||
else
|
else
|
||||||
return RedirectToAction(MVC.Config.Logging.TaskStatus(exportContext.TaskStatus.SessionId));
|
return RedirectToAction(MVC.Config.Logging.TaskStatus(taskContext.TaskStatus.SessionId));
|
||||||
}
|
}
|
||||||
[DiscoAuthorize(Claims.Device.Actions.Export)]
|
[DiscoAuthorize(Claims.Device.Actions.Export)]
|
||||||
public virtual ActionResult ExportRetrieve(string Id)
|
public virtual ActionResult ExportRetrieve(Guid id)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(Id))
|
if (id == Guid.Empty)
|
||||||
throw new ArgumentNullException("Id");
|
throw new ArgumentNullException(nameof(id));
|
||||||
|
|
||||||
string key = string.Format(ExportSessionCacheKey, Id);
|
if (!ExportTask.TryFromCache(id, out var context))
|
||||||
var context = HttpRuntime.Cache.Get(key) as ExportTaskContext<DeviceExportOptions>;
|
throw new ArgumentException("The export id specified is invalid, or the export data expired (60 minutes)", nameof(id));
|
||||||
|
|
||||||
if (context == null)
|
|
||||||
throw new ArgumentException("The Id specified is invalid, or the export data expired (60 minutes)", "Id");
|
|
||||||
|
|
||||||
if (context.Result == null || context.Result.Result == null)
|
if (context.Result == null || context.Result.Result == null)
|
||||||
throw new ArgumentException("The export session is still running, or failed to complete successfully", "Id");
|
throw new ArgumentException("The export session is still running, or failed to complete successfully", nameof(id));
|
||||||
|
|
||||||
if (context.Result.RecordCount == 0)
|
if (context.Result.RecordCount == 0)
|
||||||
throw new ArgumentException("No records were found to export", nameof(Id));
|
throw new ArgumentException("No records were found to export", nameof(id));
|
||||||
|
|
||||||
var fileStream = context.Result.Result;
|
var fileStream = context.Result.Result;
|
||||||
|
|
||||||
|
|||||||
@@ -404,7 +404,6 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Exporting
|
#region Exporting
|
||||||
internal const string ExportSessionCacheKey = "DeviceFlagExportContext_{0}";
|
|
||||||
|
|
||||||
[DiscoAuthorize(Claims.Config.DeviceFlag.Export)]
|
[DiscoAuthorize(Claims.Config.DeviceFlag.Export)]
|
||||||
public virtual ActionResult Export(ExportModel Model)
|
public virtual ActionResult Export(ExportModel Model)
|
||||||
@@ -413,39 +412,29 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
throw new ArgumentNullException(nameof(Model));
|
throw new ArgumentNullException(nameof(Model));
|
||||||
|
|
||||||
// Start Export
|
// Start Export
|
||||||
var exportContext = DeviceFlagExportTask.ScheduleNow(Model.Options);
|
var exportContext = new DeviceFlagExportContext(Model.Options);
|
||||||
|
var taskContext = ExportTask.ScheduleNowCacheResult(exportContext, id => Url.Action(MVC.Config.DeviceFlag.Export(id, null, null)));
|
||||||
// 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.Config.DeviceFlag.Export(exportContext.TaskStatus.SessionId, null, null);
|
|
||||||
exportContext.TaskStatus.SetFinishedUrl(Url.Action(finishedActionResult));
|
|
||||||
|
|
||||||
// Try waiting for completion
|
// Try waiting for completion
|
||||||
if (exportContext.TaskStatus.WaitUntilFinished(TimeSpan.FromSeconds(2)))
|
if (taskContext.TaskStatus.WaitUntilFinished(TimeSpan.FromSeconds(1)))
|
||||||
return RedirectToAction(finishedActionResult);
|
return RedirectToAction(MVC.Config.DeviceFlag.Export(taskContext.Id, null, null));
|
||||||
else
|
else
|
||||||
return RedirectToAction(MVC.Config.Logging.TaskStatus(exportContext.TaskStatus.SessionId));
|
return RedirectToAction(MVC.Config.Logging.TaskStatus(taskContext.TaskStatus.SessionId));
|
||||||
}
|
}
|
||||||
[DiscoAuthorize(Claims.Config.DeviceFlag.Export)]
|
[DiscoAuthorize(Claims.Config.DeviceFlag.Export)]
|
||||||
public virtual ActionResult ExportRetrieve(string Id)
|
public virtual ActionResult ExportRetrieve(Guid id)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(Id))
|
if (id == Guid.Empty)
|
||||||
throw new ArgumentNullException("Id");
|
throw new ArgumentNullException(nameof(id));
|
||||||
|
|
||||||
string key = string.Format(ExportSessionCacheKey, Id);
|
if (!ExportTask.TryFromCache(id, out var context))
|
||||||
var context = HttpRuntime.Cache.Get(key) as ExportTaskContext<DeviceFlagExportOptions>;
|
throw new ArgumentException("The export id specified is invalid, or the export data expired (60 minutes)", nameof(id));
|
||||||
|
|
||||||
if (context == null)
|
|
||||||
throw new ArgumentException("The Id specified is invalid, or the export data expired (60 minutes)", nameof(Id));
|
|
||||||
|
|
||||||
if (context.Result == null || context.Result.Result == null)
|
if (context.Result == null || context.Result.Result == null)
|
||||||
throw new ArgumentException("The export session is still running, or failed to complete successfully", nameof(Id));
|
throw new ArgumentException("The export session is still running, or failed to complete successfully", nameof(id));
|
||||||
|
|
||||||
if (context.Result.RecordCount == 0)
|
if (context.Result.RecordCount == 0)
|
||||||
throw new ArgumentException("No records were found to export", nameof(Id));
|
throw new ArgumentException("No records were found to export", nameof(id));
|
||||||
|
|
||||||
var fileStream = context.Result.Result;
|
var fileStream = context.Result.Result;
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
using Disco.Models.Repository;
|
using Disco.Models.Repository;
|
||||||
using Disco.Models.Services.Jobs;
|
using Disco.Models.Services.Jobs;
|
||||||
using Disco.Models.Services.Jobs.Exporting;
|
|
||||||
using Disco.Models.Services.Jobs.JobLists;
|
using Disco.Models.Services.Jobs.JobLists;
|
||||||
using Disco.Services;
|
using Disco.Services;
|
||||||
using Disco.Services.Authorization;
|
using Disco.Services.Authorization;
|
||||||
using Disco.Services.Exporting;
|
using Disco.Services.Exporting;
|
||||||
using Disco.Services.Interop;
|
using Disco.Services.Interop;
|
||||||
using Disco.Services.Jobs;
|
using Disco.Services.Jobs;
|
||||||
using Disco.Services.Jobs.Exporting;
|
|
||||||
using Disco.Services.Jobs.JobLists;
|
using Disco.Services.Jobs.JobLists;
|
||||||
using Disco.Services.Jobs.Statistics;
|
using Disco.Services.Jobs.Statistics;
|
||||||
using Disco.Services.Users;
|
using Disco.Services.Users;
|
||||||
@@ -2168,7 +2166,6 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
#region Exporting
|
#region Exporting
|
||||||
internal const string ExportSessionCacheKey = "JobExportContext_{0}";
|
|
||||||
|
|
||||||
[DiscoAuthorize(Claims.Job.Actions.Export)]
|
[DiscoAuthorize(Claims.Job.Actions.Export)]
|
||||||
[HttpPost, ValidateAntiForgeryToken]
|
[HttpPost, ValidateAntiForgeryToken]
|
||||||
@@ -2182,34 +2179,24 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
Database.SaveChanges();
|
Database.SaveChanges();
|
||||||
|
|
||||||
// Start Export
|
// Start Export
|
||||||
var exportContext = JobExportTask.ScheduleNow(model.Options);
|
var exportContext = new JobExportContext(model.Options);
|
||||||
|
var taskContext = ExportTask.ScheduleNowCacheResult(exportContext, id => Url.Action(MVC.Job.Export(id)));
|
||||||
// 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.Job.Export(exportContext.TaskStatus.SessionId);
|
|
||||||
exportContext.TaskStatus.SetFinishedUrl(Url.Action(finishedActionResult));
|
|
||||||
|
|
||||||
// Try waiting for completion
|
// Try waiting for completion
|
||||||
if (exportContext.TaskStatus.WaitUntilFinished(TimeSpan.FromSeconds(2)))
|
if (taskContext.TaskStatus.WaitUntilFinished(TimeSpan.FromSeconds(1)))
|
||||||
return RedirectToAction(finishedActionResult);
|
return RedirectToAction(MVC.Job.Export(taskContext.Id));
|
||||||
else
|
else
|
||||||
return RedirectToAction(MVC.Config.Logging.TaskStatus(exportContext.TaskStatus.SessionId));
|
return RedirectToAction(MVC.Config.Logging.TaskStatus(taskContext.TaskStatus.SessionId));
|
||||||
}
|
}
|
||||||
|
|
||||||
[DiscoAuthorize(Claims.Job.Actions.Export)]
|
[DiscoAuthorize(Claims.Job.Actions.Export)]
|
||||||
public virtual ActionResult ExportRetrieve(string id)
|
public virtual ActionResult ExportRetrieve(Guid id)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(id))
|
if (id == Guid.Empty)
|
||||||
throw new ArgumentNullException("Id");
|
throw new ArgumentNullException(nameof(id));
|
||||||
|
|
||||||
string key = string.Format(ExportSessionCacheKey, id);
|
if (!ExportTask.TryFromCache(id, out var context))
|
||||||
var context = HttpRuntime.Cache.Get(key) as ExportTaskContext<JobExportOptions>;
|
throw new ArgumentException("The export id specified is invalid, or the export data expired (60 minutes)", nameof(id));
|
||||||
|
|
||||||
if (context == null)
|
|
||||||
throw new ArgumentException("The Id specified is invalid, or the export data expired (60 minutes)", nameof(id));
|
|
||||||
|
|
||||||
if (context.Result == null || context.Result.Result == null)
|
if (context.Result == null || context.Result.Result == null)
|
||||||
throw new ArgumentException("The export session is still running, or failed to complete successfully", nameof(id));
|
throw new ArgumentException("The export session is still running, or failed to complete successfully", nameof(id));
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Disco.Models.Exporting;
|
using Disco.Models.Exporting;
|
||||||
|
using Disco.Models.Services.Logging;
|
||||||
using Disco.Services.Authorization;
|
using Disco.Services.Authorization;
|
||||||
using Disco.Services.Logging;
|
using Disco.Services.Logging;
|
||||||
using Disco.Services.Tasks;
|
using Disco.Services.Tasks;
|
||||||
@@ -23,30 +24,40 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
[HttpPost, ValidateAntiForgeryToken, DiscoAuthorize(Claims.Config.Logging.Show)]
|
[HttpPost, ValidateAntiForgeryToken, DiscoAuthorize(Claims.Config.Logging.Show)]
|
||||||
public virtual ActionResult RetrieveEvents(string Format, DateTime? Start = null, DateTime? End = null, int? ModuleId = null, List<int> EventTypeIds = null, int? Take = null)
|
public virtual ActionResult RetrieveEvents(string Format, DateTime? Start = null, DateTime? End = null, int? ModuleId = null, List<int> EventTypeIds = null, int? Take = null)
|
||||||
{
|
{
|
||||||
var logRetriever = new ReadLogContext()
|
if (string.Equals(Format, "json", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
Start = Start,
|
var logRetriever = new ReadLogContext()
|
||||||
End = End,
|
{
|
||||||
Module = ModuleId,
|
Start = Start,
|
||||||
EventTypes = EventTypeIds,
|
End = End,
|
||||||
Take = Take
|
Module = ModuleId,
|
||||||
};
|
EventTypes = EventTypeIds,
|
||||||
var results = logRetriever.Query(Database);
|
Take = Take,
|
||||||
|
};
|
||||||
var exportFormat = ExportFormat.Xlsx;
|
var results = logRetriever.Query(Database);
|
||||||
|
return Json(results, JsonRequestBehavior.AllowGet);
|
||||||
switch (Format.ToLower())
|
|
||||||
{
|
|
||||||
case "json":
|
|
||||||
return Json(results, JsonRequestBehavior.AllowGet);
|
|
||||||
case "csv":
|
|
||||||
exportFormat = ExportFormat.Csv;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var exportFormat = ExportFormat.Xlsx;
|
||||||
|
if (string.Equals(Format, "csv", StringComparison.OrdinalIgnoreCase))
|
||||||
|
exportFormat = ExportFormat.Csv;
|
||||||
|
|
||||||
var export = LogExport.GenerateExport(exportFormat, results);
|
var options = new LogExportOptions()
|
||||||
|
{
|
||||||
|
Format = exportFormat,
|
||||||
|
StartDate = Start,
|
||||||
|
EndDate = End,
|
||||||
|
ModuleId = ModuleId,
|
||||||
|
EventTypeIds = EventTypeIds,
|
||||||
|
Take = Take,
|
||||||
|
};
|
||||||
|
var exportContext = new LogExportContext(options);
|
||||||
|
|
||||||
return File(export.Result, export.MimeType, export.Filename);
|
var export = exportContext.Export(Database, ScheduledTaskMockStatus.Create("Log Export"));
|
||||||
|
|
||||||
|
return File(export.Result, export.MimeType, export.Filename);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual ActionResult ScheduledTaskStatus(string id)
|
public virtual ActionResult ScheduledTaskStatus(string id)
|
||||||
|
|||||||
@@ -409,7 +409,6 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Exporting
|
#region Exporting
|
||||||
internal const string ExportSessionCacheKey = "UserFlagExportContext_{0}";
|
|
||||||
|
|
||||||
[DiscoAuthorize(Claims.Config.UserFlag.Export)]
|
[DiscoAuthorize(Claims.Config.UserFlag.Export)]
|
||||||
public virtual ActionResult Export(ExportModel Model)
|
public virtual ActionResult Export(ExportModel Model)
|
||||||
@@ -418,39 +417,26 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
throw new ArgumentNullException(nameof(Model));
|
throw new ArgumentNullException(nameof(Model));
|
||||||
|
|
||||||
// Start Export
|
// Start Export
|
||||||
var exportContext = UserFlagExportTask.ScheduleNow(Model.Options);
|
var exportContext = new UserFlagExportContext(Model.Options);
|
||||||
|
var taskContext = ExportTask.ScheduleNowCacheResult(exportContext, id => Url.Action(MVC.Config.UserFlag.Export(id, null, null)));
|
||||||
// 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.Config.UserFlag.Export(exportContext.TaskStatus.SessionId, null, null);
|
|
||||||
exportContext.TaskStatus.SetFinishedUrl(Url.Action(finishedActionResult));
|
|
||||||
|
|
||||||
// Try waiting for completion
|
// Try waiting for completion
|
||||||
if (exportContext.TaskStatus.WaitUntilFinished(TimeSpan.FromSeconds(2)))
|
if (taskContext.TaskStatus.WaitUntilFinished(TimeSpan.FromSeconds(1)))
|
||||||
return RedirectToAction(finishedActionResult);
|
return RedirectToAction(MVC.Config.UserFlag.Export(taskContext.Id, null, null));
|
||||||
else
|
else
|
||||||
return RedirectToAction(MVC.Config.Logging.TaskStatus(exportContext.TaskStatus.SessionId));
|
return RedirectToAction(MVC.Config.Logging.TaskStatus(taskContext.TaskStatus.SessionId));
|
||||||
}
|
}
|
||||||
[DiscoAuthorize(Claims.Config.UserFlag.Export)]
|
[DiscoAuthorize(Claims.Config.UserFlag.Export)]
|
||||||
public virtual ActionResult ExportRetrieve(string Id)
|
public virtual ActionResult ExportRetrieve(Guid id)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(Id))
|
if (!ExportTask.TryFromCache(id, out var context))
|
||||||
throw new ArgumentNullException("Id");
|
throw new ArgumentException("The export id specified is invalid, or the export data expired (60 minutes)", nameof(id));
|
||||||
|
|
||||||
string key = string.Format(ExportSessionCacheKey, Id);
|
|
||||||
var context = HttpRuntime.Cache.Get(key) as ExportTaskContext<UserFlagExportOptions>;
|
|
||||||
|
|
||||||
if (context == null)
|
|
||||||
throw new ArgumentException("The Id specified is invalid, or the export data expired (60 minutes)", nameof(Id));
|
|
||||||
|
|
||||||
if (context.Result == null || context.Result.Result == null)
|
if (context.Result == null || context.Result.Result == null)
|
||||||
throw new ArgumentException("The export session is still running, or failed to complete successfully", nameof(Id));
|
throw new ArgumentException("The export session is still running, or failed to complete successfully", nameof(id));
|
||||||
|
|
||||||
if (context.Result.RecordCount == 0)
|
if (context.Result.RecordCount == 0)
|
||||||
throw new ArgumentException("No records were found to export", nameof(Id));
|
throw new ArgumentException("No records were found to export", nameof(id));
|
||||||
|
|
||||||
var fileStream = context.Result.Result;
|
var fileStream = context.Result.Result;
|
||||||
|
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ namespace Disco.Web.Areas.Config.Controllers
|
|||||||
#region Export
|
#region Export
|
||||||
|
|
||||||
[DiscoAuthorizeAny(Claims.Config.DeviceFlag.Export), HttpGet]
|
[DiscoAuthorizeAny(Claims.Config.DeviceFlag.Export), HttpGet]
|
||||||
public virtual ActionResult Export(string DownloadId, int? DeviceFlagId, bool? CurrentOnly)
|
public virtual ActionResult Export(Guid? exportId, int? deviceFlagId, bool? currentOnly)
|
||||||
{
|
{
|
||||||
var m = new ExportModel()
|
var m = new ExportModel()
|
||||||
{
|
{
|
||||||
@@ -130,26 +130,20 @@ namespace Disco.Web.Areas.Config.Controllers
|
|||||||
DeviceFlags = DeviceFlagService.GetDeviceFlags(),
|
DeviceFlags = DeviceFlagService.GetDeviceFlags(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(DownloadId))
|
if (ExportTask.TryFromCache(exportId, out var context))
|
||||||
{
|
{
|
||||||
string key = string.Format(API.Controllers.DeviceFlagController.ExportSessionCacheKey, DownloadId);
|
m.ExportId = context.Id;
|
||||||
var context = HttpRuntime.Cache.Get(key) as ExportTaskContext<DeviceFlagExportOptions>;
|
m.ExportResult = context.Result;
|
||||||
|
|
||||||
if (context != null)
|
|
||||||
{
|
|
||||||
m.ExportSessionResult = context.Result;
|
|
||||||
m.ExportSessionId = DownloadId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DeviceFlagId.HasValue && CurrentOnly.HasValue)
|
if (deviceFlagId.HasValue && currentOnly.HasValue)
|
||||||
{
|
{
|
||||||
m.Options.DeviceFlagIds = new List<int>() { DeviceFlagId.Value };
|
m.Options.DeviceFlagIds = new List<int>() { deviceFlagId.Value };
|
||||||
m.Options.CurrentOnly = CurrentOnly.Value;
|
m.Options.CurrentOnly = currentOnly.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// UI Extensions
|
// UI Extensions
|
||||||
UIExtensions.ExecuteExtensions<ConfigDeviceFlagExportModel>(this.ControllerContext, m);
|
UIExtensions.ExecuteExtensions<ConfigDeviceFlagExportModel>(ControllerContext, m);
|
||||||
|
|
||||||
return View(m);
|
return View(m);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ namespace Disco.Web.Areas.Config.Controllers
|
|||||||
#region Export
|
#region Export
|
||||||
|
|
||||||
[DiscoAuthorizeAny(Claims.Config.UserFlag.Export), HttpGet]
|
[DiscoAuthorizeAny(Claims.Config.UserFlag.Export), HttpGet]
|
||||||
public virtual ActionResult Export(string DownloadId, int? UserFlagId, bool? CurrentOnly)
|
public virtual ActionResult Export(Guid? exportId, int? userFlagId, bool? currentOnly)
|
||||||
{
|
{
|
||||||
var m = new ExportModel()
|
var m = new ExportModel()
|
||||||
{
|
{
|
||||||
@@ -132,26 +132,20 @@ namespace Disco.Web.Areas.Config.Controllers
|
|||||||
UserFlags = UserFlagService.GetUserFlags(),
|
UserFlags = UserFlagService.GetUserFlags(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(DownloadId))
|
if (ExportTask.TryFromCache(exportId, out var context))
|
||||||
{
|
{
|
||||||
string key = string.Format(API.Controllers.UserFlagController.ExportSessionCacheKey, DownloadId);
|
m.ExportId = exportId;
|
||||||
var context = HttpRuntime.Cache.Get(key) as ExportTaskContext<UserFlagExportOptions>;
|
m.ExportResult = context.Result;
|
||||||
|
|
||||||
if (context != null)
|
|
||||||
{
|
|
||||||
m.ExportSessionResult = context.Result;
|
|
||||||
m.ExportSessionId = DownloadId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UserFlagId.HasValue && CurrentOnly.HasValue)
|
if (userFlagId.HasValue && currentOnly.HasValue)
|
||||||
{
|
{
|
||||||
m.Options.UserFlagIds = new List<int>() { UserFlagId.Value };
|
m.Options.UserFlagIds = new List<int>() { userFlagId.Value };
|
||||||
m.Options.CurrentOnly = CurrentOnly.Value;
|
m.Options.CurrentOnly = currentOnly.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// UI Extensions
|
// UI Extensions
|
||||||
UIExtensions.ExecuteExtensions<ConfigUserFlagExportModel>(this.ControllerContext, m);
|
UIExtensions.ExecuteExtensions<ConfigUserFlagExportModel>(ControllerContext, m);
|
||||||
|
|
||||||
return View(m);
|
return View(m);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Disco.Models.Areas.Config.UI.DeviceFlag;
|
using Disco.Models.Areas.Config.UI.DeviceFlag;
|
||||||
using Disco.Models.Services.Devices.DeviceFlag;
|
using Disco.Models.Services.Devices.DeviceFlag;
|
||||||
using Disco.Models.Services.Exporting;
|
using Disco.Models.Services.Exporting;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Disco.Web.Areas.Config.Models.DeviceFlag
|
namespace Disco.Web.Areas.Config.Models.DeviceFlag
|
||||||
@@ -9,8 +10,8 @@ namespace Disco.Web.Areas.Config.Models.DeviceFlag
|
|||||||
{
|
{
|
||||||
public DeviceFlagExportOptions Options { get; set; }
|
public DeviceFlagExportOptions Options { get; set; }
|
||||||
|
|
||||||
public string ExportSessionId { get; set; }
|
public Guid? ExportId { get; set; }
|
||||||
public ExportResult ExportSessionResult { get; set; }
|
public ExportResult ExportResult { get; set; }
|
||||||
|
|
||||||
public List<Disco.Models.Repository.DeviceFlag> DeviceFlags { get; set; }
|
public List<Disco.Models.Repository.DeviceFlag> DeviceFlags { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Disco.Models.Areas.Config.UI.UserFlag;
|
using Disco.Models.Areas.Config.UI.UserFlag;
|
||||||
using Disco.Models.Services.Exporting;
|
using Disco.Models.Services.Exporting;
|
||||||
using Disco.Models.Services.Users.UserFlags;
|
using Disco.Models.Services.Users.UserFlags;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Disco.Web.Areas.Config.Models.UserFlag
|
namespace Disco.Web.Areas.Config.Models.UserFlag
|
||||||
@@ -9,8 +10,8 @@ namespace Disco.Web.Areas.Config.Models.UserFlag
|
|||||||
{
|
{
|
||||||
public UserFlagExportOptions Options { get; set; }
|
public UserFlagExportOptions Options { get; set; }
|
||||||
|
|
||||||
public string ExportSessionId { get; set; }
|
public Guid? ExportId { get; set; }
|
||||||
public ExportResult ExportSessionResult { get; set; }
|
public ExportResult ExportResult { get; set; }
|
||||||
|
|
||||||
public List<Disco.Models.Repository.UserFlag> UserFlags { get; set; }
|
public List<Disco.Models.Repository.UserFlag> UserFlags { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1017,7 +1017,7 @@
|
|||||||
{
|
{
|
||||||
if (Authorization.Has(Claims.Device.Actions.Export))
|
if (Authorization.Has(Claims.Device.Actions.Export))
|
||||||
{
|
{
|
||||||
@Html.ActionLinkButton("Export Devices", MVC.Device.Export(null, Disco.Models.Services.Devices.Exporting.DeviceExportTypes.Batch, Model.DeviceBatch.Id))
|
@Html.ActionLinkButton("Export Devices", MVC.Device.Export(null, Disco.Models.Services.Devices.DeviceExportTypes.Batch, Model.DeviceBatch.Id))
|
||||||
}
|
}
|
||||||
if (Authorization.Has(Claims.Device.Search) && Model.DeviceCount > 0)
|
if (Authorization.Has(Claims.Device.Search) && Model.DeviceCount > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2778,14 +2778,14 @@ WriteLiteral(" ");
|
|||||||
#line hidden
|
#line hidden
|
||||||
|
|
||||||
#line 1020 "..\..\Areas\Config\Views\DeviceBatch\Show.cshtml"
|
#line 1020 "..\..\Areas\Config\Views\DeviceBatch\Show.cshtml"
|
||||||
Write(Html.ActionLinkButton("Export Devices", MVC.Device.Export(null, Disco.Models.Services.Devices.Exporting.DeviceExportTypes.Batch, Model.DeviceBatch.Id)));
|
Write(Html.ActionLinkButton("Export Devices", MVC.Device.Export(null, Disco.Models.Services.Devices.DeviceExportTypes.Batch, Model.DeviceBatch.Id)));
|
||||||
|
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
#line hidden
|
#line hidden
|
||||||
|
|
||||||
#line 1020 "..\..\Areas\Config\Views\DeviceBatch\Show.cshtml"
|
#line 1020 "..\..\Areas\Config\Views\DeviceBatch\Show.cshtml"
|
||||||
|
|
||||||
}
|
}
|
||||||
if (Authorization.Has(Claims.Device.Search) && Model.DeviceCount > 0)
|
if (Authorization.Has(Claims.Device.Search) && Model.DeviceCount > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -161,17 +161,17 @@
|
|||||||
</script>
|
</script>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@if (Model.ExportSessionId != null)
|
@if (Model.ExportId.HasValue)
|
||||||
{
|
{
|
||||||
<div id="DeviceFlag_Export_Download_Dialog" class="dialog" title="Export Device Flags">
|
<div id="DeviceFlag_Export_Download_Dialog" class="dialog" title="Export Device Flags">
|
||||||
@if (Model.ExportSessionResult.RecordCount == 0)
|
@if (Model.ExportResult.RecordCount == 0)
|
||||||
{
|
{
|
||||||
<h4>No records matched the filter criteria</h4>
|
<h4>No records matched the filter criteria</h4>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<h4>@Model.ExportSessionResult.RecordCount record@(Model.ExportSessionResult.RecordCount != 1 ? "s" : null) were successfully exported.</h4>
|
<h4>@Model.ExportResult.RecordCount record@(Model.ExportResult.RecordCount != 1 ? "s" : null) were successfully exported.</h4>
|
||||||
<a href="@Url.Action(MVC.API.DeviceFlag.ExportRetrieve(Model.ExportSessionId))" class="button"><i class="fa fa-download fa-lg"></i>Download Device Flag Export</a>
|
<a href="@Url.Action(MVC.API.DeviceFlag.ExportRetrieve(Model.ExportId.Value))" class="button"><i class="fa fa-download fa-lg"></i>Download Device Flag Export</a>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
@@ -601,7 +601,7 @@ WriteLiteral("</div>\r\n");
|
|||||||
|
|
||||||
|
|
||||||
#line 164 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
|
#line 164 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
|
||||||
if (Model.ExportSessionId != null)
|
if (Model.ExportId.HasValue)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@@ -625,7 +625,7 @@ WriteLiteral(">\r\n");
|
|||||||
#line hidden
|
#line hidden
|
||||||
|
|
||||||
#line 167 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
|
#line 167 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
|
||||||
if (Model.ExportSessionResult.RecordCount == 0)
|
if (Model.ExportResult.RecordCount == 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@@ -646,7 +646,7 @@ WriteLiteral(" <h4>");
|
|||||||
|
|
||||||
|
|
||||||
#line 173 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
|
#line 173 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
|
||||||
Write(Model.ExportSessionResult.RecordCount);
|
Write(Model.ExportResult.RecordCount);
|
||||||
|
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
@@ -655,7 +655,7 @@ WriteLiteral(" record");
|
|||||||
|
|
||||||
|
|
||||||
#line 173 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
|
#line 173 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
|
||||||
Write(Model.ExportSessionResult.RecordCount != 1 ? "s" : null);
|
Write(Model.ExportResult.RecordCount != 1 ? "s" : null);
|
||||||
|
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
@@ -664,14 +664,14 @@ WriteLiteral(" were successfully exported.</h4>\r\n");
|
|||||||
|
|
||||||
WriteLiteral(" <a");
|
WriteLiteral(" <a");
|
||||||
|
|
||||||
WriteAttribute("href", Tuple.Create(" href=\"", 8524), Tuple.Create("\"", 8600)
|
WriteAttribute("href", Tuple.Create(" href=\"", 8497), Tuple.Create("\"", 8572)
|
||||||
|
|
||||||
#line 174 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
|
#line 174 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
|
||||||
, Tuple.Create(Tuple.Create("", 8531), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.DeviceFlag.ExportRetrieve(Model.ExportSessionId))
|
, Tuple.Create(Tuple.Create("", 8504), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.DeviceFlag.ExportRetrieve(Model.ExportId.Value))
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
#line hidden
|
#line hidden
|
||||||
, 8531), false)
|
, 8504), false)
|
||||||
);
|
);
|
||||||
|
|
||||||
WriteLiteral(" class=\"button\"");
|
WriteLiteral(" class=\"button\"");
|
||||||
|
|||||||
@@ -255,7 +255,7 @@
|
|||||||
{
|
{
|
||||||
if (Authorization.Has(Claims.Device.Actions.Export))
|
if (Authorization.Has(Claims.Device.Actions.Export))
|
||||||
{
|
{
|
||||||
@Html.ActionLinkButton("Export Devices", MVC.Device.Export(null, Disco.Models.Services.Devices.Exporting.DeviceExportTypes.Model, Model.DeviceModel.Id))
|
@Html.ActionLinkButton("Export Devices", MVC.Device.Export(null, Disco.Models.Services.Devices.DeviceExportTypes.Model, Model.DeviceModel.Id))
|
||||||
}
|
}
|
||||||
if (Authorization.Has(Claims.Device.Search) && Model.DeviceCount > 0)
|
if (Authorization.Has(Claims.Device.Search) && Model.DeviceCount > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -859,14 +859,14 @@ WriteLiteral(" ");
|
|||||||
#line hidden
|
#line hidden
|
||||||
|
|
||||||
#line 258 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
#line 258 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
||||||
Write(Html.ActionLinkButton("Export Devices", MVC.Device.Export(null, Disco.Models.Services.Devices.Exporting.DeviceExportTypes.Model, Model.DeviceModel.Id)));
|
Write(Html.ActionLinkButton("Export Devices", MVC.Device.Export(null, Disco.Models.Services.Devices.DeviceExportTypes.Model, Model.DeviceModel.Id)));
|
||||||
|
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
#line hidden
|
#line hidden
|
||||||
|
|
||||||
#line 258 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
#line 258 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
||||||
|
|
||||||
}
|
}
|
||||||
if (Authorization.Has(Claims.Device.Search) && Model.DeviceCount > 0)
|
if (Authorization.Has(Claims.Device.Search) && Model.DeviceCount > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1012,7 +1012,7 @@
|
|||||||
}
|
}
|
||||||
@if (Authorization.Has(Claims.Device.Actions.Export))
|
@if (Authorization.Has(Claims.Device.Actions.Export))
|
||||||
{
|
{
|
||||||
@Html.ActionLinkButton("Export Devices", MVC.Device.Export(null, Disco.Models.Services.Devices.Exporting.DeviceExportTypes.Profile, Model.DeviceProfile.Id))
|
@Html.ActionLinkButton("Export Devices", MVC.Device.Export(null, Disco.Models.Services.Devices.DeviceExportTypes.Profile, Model.DeviceProfile.Id))
|
||||||
}
|
}
|
||||||
@if (Authorization.Has(Claims.Device.Search) && Model.DeviceCount > 0)
|
@if (Authorization.Has(Claims.Device.Search) && Model.DeviceCount > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3022,14 +3022,14 @@ WriteLiteral(" ");
|
|||||||
#line hidden
|
#line hidden
|
||||||
|
|
||||||
#line 1015 "..\..\Areas\Config\Views\DeviceProfile\Show.cshtml"
|
#line 1015 "..\..\Areas\Config\Views\DeviceProfile\Show.cshtml"
|
||||||
Write(Html.ActionLinkButton("Export Devices", MVC.Device.Export(null, Disco.Models.Services.Devices.Exporting.DeviceExportTypes.Profile, Model.DeviceProfile.Id)));
|
Write(Html.ActionLinkButton("Export Devices", MVC.Device.Export(null, Disco.Models.Services.Devices.DeviceExportTypes.Profile, Model.DeviceProfile.Id)));
|
||||||
|
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
#line hidden
|
#line hidden
|
||||||
|
|
||||||
#line 1015 "..\..\Areas\Config\Views\DeviceProfile\Show.cshtml"
|
#line 1015 "..\..\Areas\Config\Views\DeviceProfile\Show.cshtml"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -161,17 +161,17 @@
|
|||||||
</script>
|
</script>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@if (Model.ExportSessionId != null)
|
@if (Model.ExportId.HasValue)
|
||||||
{
|
{
|
||||||
<div id="UserFlag_Export_Download_Dialog" class="dialog" title="Export User Flags">
|
<div id="UserFlag_Export_Download_Dialog" class="dialog" title="Export User Flags">
|
||||||
@if (Model.ExportSessionResult.RecordCount == 0)
|
@if (Model.ExportResult.RecordCount == 0)
|
||||||
{
|
{
|
||||||
<h4>No records matched the filter criteria</h4>
|
<h4>No records matched the filter criteria</h4>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<h4>@Model.ExportSessionResult.RecordCount record@(Model.ExportSessionResult.RecordCount != 1 ? "s" : null) were successfully exported.</h4>
|
<h4>@Model.ExportResult.RecordCount record@(Model.ExportResult.RecordCount != 1 ? "s" : null) were successfully exported.</h4>
|
||||||
<a href="@Url.Action(MVC.API.UserFlag.ExportRetrieve(Model.ExportSessionId))" class="button"><i class="fa fa-download fa-lg"></i>Download User Flag Export</a>
|
<a href="@Url.Action(MVC.API.UserFlag.ExportRetrieve(Model.ExportId.Value))" class="button"><i class="fa fa-download fa-lg"></i>Download User Flag Export</a>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
@@ -601,7 +601,7 @@ WriteLiteral("</div>\r\n");
|
|||||||
|
|
||||||
|
|
||||||
#line 164 "..\..\Areas\Config\Views\UserFlag\Export.cshtml"
|
#line 164 "..\..\Areas\Config\Views\UserFlag\Export.cshtml"
|
||||||
if (Model.ExportSessionId != null)
|
if (Model.ExportId.HasValue)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@@ -625,7 +625,7 @@ WriteLiteral(">\r\n");
|
|||||||
#line hidden
|
#line hidden
|
||||||
|
|
||||||
#line 167 "..\..\Areas\Config\Views\UserFlag\Export.cshtml"
|
#line 167 "..\..\Areas\Config\Views\UserFlag\Export.cshtml"
|
||||||
if (Model.ExportSessionResult.RecordCount == 0)
|
if (Model.ExportResult.RecordCount == 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@@ -646,7 +646,7 @@ WriteLiteral(" <h4>");
|
|||||||
|
|
||||||
|
|
||||||
#line 173 "..\..\Areas\Config\Views\UserFlag\Export.cshtml"
|
#line 173 "..\..\Areas\Config\Views\UserFlag\Export.cshtml"
|
||||||
Write(Model.ExportSessionResult.RecordCount);
|
Write(Model.ExportResult.RecordCount);
|
||||||
|
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
@@ -655,7 +655,7 @@ WriteLiteral(" record");
|
|||||||
|
|
||||||
|
|
||||||
#line 173 "..\..\Areas\Config\Views\UserFlag\Export.cshtml"
|
#line 173 "..\..\Areas\Config\Views\UserFlag\Export.cshtml"
|
||||||
Write(Model.ExportSessionResult.RecordCount != 1 ? "s" : null);
|
Write(Model.ExportResult.RecordCount != 1 ? "s" : null);
|
||||||
|
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
@@ -664,14 +664,14 @@ WriteLiteral(" were successfully exported.</h4>\r\n");
|
|||||||
|
|
||||||
WriteLiteral(" <a");
|
WriteLiteral(" <a");
|
||||||
|
|
||||||
WriteAttribute("href", Tuple.Create(" href=\"", 8500), Tuple.Create("\"", 8574)
|
WriteAttribute("href", Tuple.Create(" href=\"", 8473), Tuple.Create("\"", 8546)
|
||||||
|
|
||||||
#line 174 "..\..\Areas\Config\Views\UserFlag\Export.cshtml"
|
#line 174 "..\..\Areas\Config\Views\UserFlag\Export.cshtml"
|
||||||
, Tuple.Create(Tuple.Create("", 8507), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.UserFlag.ExportRetrieve(Model.ExportSessionId))
|
, Tuple.Create(Tuple.Create("", 8480), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.UserFlag.ExportRetrieve(Model.ExportId.Value))
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
#line hidden
|
#line hidden
|
||||||
, 8507), false)
|
, 8480), false)
|
||||||
);
|
);
|
||||||
|
|
||||||
WriteLiteral(" class=\"button\"");
|
WriteLiteral(" class=\"button\"");
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using Disco.Models.Repository;
|
using Disco.Models.Repository;
|
||||||
using Disco.Models.Services.Devices.Exporting;
|
using Disco.Models.Services.Devices;
|
||||||
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;
|
||||||
@@ -15,7 +15,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data.Entity;
|
using System.Data.Entity;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web;
|
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
|
|
||||||
|
|
||||||
@@ -114,7 +113,7 @@ namespace Disco.Web.Controllers
|
|||||||
#region Export
|
#region Export
|
||||||
|
|
||||||
[DiscoAuthorizeAny(Claims.Device.Actions.Export), HttpGet]
|
[DiscoAuthorizeAny(Claims.Device.Actions.Export), HttpGet]
|
||||||
public virtual ActionResult Export(string DownloadId, DeviceExportTypes? ExportType, int? ExportTypeTargetId)
|
public virtual ActionResult Export(Guid? exportId, DeviceExportTypes? exportType, int? exportTypeTargetId)
|
||||||
{
|
{
|
||||||
var m = new Models.Device.ExportModel()
|
var m = new Models.Device.ExportModel()
|
||||||
{
|
{
|
||||||
@@ -124,22 +123,16 @@ namespace Disco.Web.Controllers
|
|||||||
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))
|
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))
|
if (ExportTask.TryFromCache(exportId.Value, out var context))
|
||||||
{
|
{
|
||||||
string key = string.Format(Areas.API.Controllers.DeviceController.ExportSessionCacheKey, DownloadId);
|
m.ExportId = context.Id;
|
||||||
var context = HttpRuntime.Cache.Get(key) as ExportTaskContext<DeviceExportOptions>;
|
m.ExportResult = context.Result;
|
||||||
|
|
||||||
if (context != null)
|
|
||||||
{
|
|
||||||
m.ExportSessionResult = context.Result;
|
|
||||||
m.ExportSessionId = DownloadId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ExportType.HasValue && ExportTypeTargetId.HasValue)
|
if (exportType.HasValue && exportTypeTargetId.HasValue)
|
||||||
{
|
{
|
||||||
m.Options.ExportType = ExportType.Value;
|
m.Options.ExportType = exportType.Value;
|
||||||
m.Options.ExportTypeTargetId = ExportTypeTargetId.Value;
|
m.Options.ExportTypeTargetId = exportTypeTargetId.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// UI Extensions
|
// UI Extensions
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using Disco.Models.Repository;
|
using Disco.Models.Repository;
|
||||||
using Disco.Models.Services.Jobs;
|
using Disco.Models.Services.Jobs;
|
||||||
using Disco.Models.Services.Jobs.Exporting;
|
|
||||||
using Disco.Models.Services.Jobs.JobLists;
|
using Disco.Models.Services.Jobs.JobLists;
|
||||||
using Disco.Models.UI.Job;
|
using Disco.Models.UI.Job;
|
||||||
using Disco.Services;
|
using Disco.Services;
|
||||||
@@ -24,7 +23,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data.Entity;
|
using System.Data.Entity;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web;
|
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
|
|
||||||
namespace Disco.Web.Controllers
|
namespace Disco.Web.Controllers
|
||||||
@@ -1084,7 +1082,7 @@ namespace Disco.Web.Controllers
|
|||||||
#region Export
|
#region Export
|
||||||
|
|
||||||
[DiscoAuthorizeAny(Claims.Job.Actions.Export), HttpGet]
|
[DiscoAuthorizeAny(Claims.Job.Actions.Export), HttpGet]
|
||||||
public virtual ActionResult Export(string downloadId)
|
public virtual ActionResult Export(Guid? exportId)
|
||||||
{
|
{
|
||||||
var m = new Models.Job.ExportModel()
|
var m = new Models.Job.ExportModel()
|
||||||
{
|
{
|
||||||
@@ -1100,20 +1098,14 @@ namespace Disco.Web.Controllers
|
|||||||
m.Options.FilterEndDate = null;
|
m.Options.FilterEndDate = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(downloadId))
|
if (ExportTask.TryFromCache(exportId, out var context))
|
||||||
{
|
{
|
||||||
string key = string.Format(Areas.API.Controllers.JobController.ExportSessionCacheKey, downloadId);
|
m.ExportId = context.Id;
|
||||||
var context = HttpRuntime.Cache.Get(key) as ExportTaskContext<JobExportOptions>;
|
m.ExportResult = context.Result;
|
||||||
|
|
||||||
if (context != null)
|
|
||||||
{
|
|
||||||
m.ExportSessionResult = context.Result;
|
|
||||||
m.ExportSessionId = downloadId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// UI Extensions
|
// UI Extensions
|
||||||
UIExtensions.ExecuteExtensions<JobExportModel>(this.ControllerContext, m);
|
UIExtensions.ExecuteExtensions<JobExportModel>(ControllerContext, m);
|
||||||
|
|
||||||
return View(m);
|
return View(m);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -546,7 +546,7 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||||
public class ActionParamsClass_ExportRetrieve
|
public class ActionParamsClass_ExportRetrieve
|
||||||
{
|
{
|
||||||
public readonly string Id = "Id";
|
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]
|
||||||
@@ -911,14 +911,14 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
partial void ExportRetrieveOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string Id);
|
partial void ExportRetrieveOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, System.Guid id);
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public override System.Web.Mvc.ActionResult ExportRetrieve(string Id)
|
public override System.Web.Mvc.ActionResult ExportRetrieve(System.Guid id)
|
||||||
{
|
{
|
||||||
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ExportRetrieve);
|
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ExportRetrieve);
|
||||||
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "Id", Id);
|
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "id", id);
|
||||||
ExportRetrieveOverride(callInfo, Id);
|
ExportRetrieveOverride(callInfo, id);
|
||||||
return callInfo;
|
return callInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -349,7 +349,7 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||||
public class ActionParamsClass_ExportRetrieve
|
public class ActionParamsClass_ExportRetrieve
|
||||||
{
|
{
|
||||||
public readonly string Id = "Id";
|
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]
|
||||||
@@ -567,14 +567,14 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
partial void ExportRetrieveOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string Id);
|
partial void ExportRetrieveOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, System.Guid id);
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public override System.Web.Mvc.ActionResult ExportRetrieve(string Id)
|
public override System.Web.Mvc.ActionResult ExportRetrieve(System.Guid id)
|
||||||
{
|
{
|
||||||
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ExportRetrieve);
|
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ExportRetrieve);
|
||||||
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "Id", Id);
|
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "id", id);
|
||||||
ExportRetrieveOverride(callInfo, Id);
|
ExportRetrieveOverride(callInfo, id);
|
||||||
return callInfo;
|
return callInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2229,10 +2229,10 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
partial void ExportRetrieveOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string id);
|
partial void ExportRetrieveOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, System.Guid id);
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public override System.Web.Mvc.ActionResult ExportRetrieve(string id)
|
public override System.Web.Mvc.ActionResult ExportRetrieve(System.Guid id)
|
||||||
{
|
{
|
||||||
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ExportRetrieve);
|
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ExportRetrieve);
|
||||||
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "id", id);
|
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "id", id);
|
||||||
|
|||||||
@@ -349,7 +349,7 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||||
public class ActionParamsClass_ExportRetrieve
|
public class ActionParamsClass_ExportRetrieve
|
||||||
{
|
{
|
||||||
public readonly string Id = "Id";
|
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]
|
||||||
@@ -567,14 +567,14 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
partial void ExportRetrieveOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string Id);
|
partial void ExportRetrieveOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, System.Guid id);
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public override System.Web.Mvc.ActionResult ExportRetrieve(string Id)
|
public override System.Web.Mvc.ActionResult ExportRetrieve(System.Guid id)
|
||||||
{
|
{
|
||||||
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ExportRetrieve);
|
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ExportRetrieve);
|
||||||
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "Id", Id);
|
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "id", id);
|
||||||
ExportRetrieveOverride(callInfo, Id);
|
ExportRetrieveOverride(callInfo, id);
|
||||||
return callInfo;
|
return callInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -123,9 +123,9 @@ namespace Disco.Web.Areas.Config.Controllers
|
|||||||
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||||
public class ActionParamsClass_Export
|
public class ActionParamsClass_Export
|
||||||
{
|
{
|
||||||
public readonly string DownloadId = "DownloadId";
|
public readonly string exportId = "exportId";
|
||||||
public readonly string DeviceFlagId = "DeviceFlagId";
|
public readonly string deviceFlagId = "deviceFlagId";
|
||||||
public readonly string CurrentOnly = "CurrentOnly";
|
public readonly string currentOnly = "currentOnly";
|
||||||
}
|
}
|
||||||
static readonly ViewsClass s_views = new ViewsClass();
|
static readonly ViewsClass s_views = new ViewsClass();
|
||||||
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||||
@@ -190,16 +190,16 @@ namespace Disco.Web.Areas.Config.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
partial void ExportOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string DownloadId, int? DeviceFlagId, bool? CurrentOnly);
|
partial void ExportOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, System.Guid? exportId, int? deviceFlagId, bool? currentOnly);
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public override System.Web.Mvc.ActionResult Export(string DownloadId, int? DeviceFlagId, bool? CurrentOnly)
|
public override System.Web.Mvc.ActionResult Export(System.Guid? exportId, int? deviceFlagId, bool? currentOnly)
|
||||||
{
|
{
|
||||||
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Export);
|
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Export);
|
||||||
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "DownloadId", DownloadId);
|
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "exportId", exportId);
|
||||||
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "DeviceFlagId", DeviceFlagId);
|
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "deviceFlagId", deviceFlagId);
|
||||||
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "CurrentOnly", CurrentOnly);
|
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "currentOnly", currentOnly);
|
||||||
ExportOverride(callInfo, DownloadId, DeviceFlagId, CurrentOnly);
|
ExportOverride(callInfo, exportId, deviceFlagId, currentOnly);
|
||||||
return callInfo;
|
return callInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -123,9 +123,9 @@ namespace Disco.Web.Areas.Config.Controllers
|
|||||||
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||||
public class ActionParamsClass_Export
|
public class ActionParamsClass_Export
|
||||||
{
|
{
|
||||||
public readonly string DownloadId = "DownloadId";
|
public readonly string exportId = "exportId";
|
||||||
public readonly string UserFlagId = "UserFlagId";
|
public readonly string userFlagId = "userFlagId";
|
||||||
public readonly string CurrentOnly = "CurrentOnly";
|
public readonly string currentOnly = "currentOnly";
|
||||||
}
|
}
|
||||||
static readonly ViewsClass s_views = new ViewsClass();
|
static readonly ViewsClass s_views = new ViewsClass();
|
||||||
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||||
@@ -190,16 +190,16 @@ namespace Disco.Web.Areas.Config.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
partial void ExportOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string DownloadId, int? UserFlagId, bool? CurrentOnly);
|
partial void ExportOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, System.Guid? exportId, int? userFlagId, bool? currentOnly);
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public override System.Web.Mvc.ActionResult Export(string DownloadId, int? UserFlagId, bool? CurrentOnly)
|
public override System.Web.Mvc.ActionResult Export(System.Guid? exportId, int? userFlagId, bool? currentOnly)
|
||||||
{
|
{
|
||||||
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Export);
|
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Export);
|
||||||
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "DownloadId", DownloadId);
|
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "exportId", exportId);
|
||||||
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "UserFlagId", UserFlagId);
|
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "userFlagId", userFlagId);
|
||||||
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "CurrentOnly", CurrentOnly);
|
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "currentOnly", currentOnly);
|
||||||
ExportOverride(callInfo, DownloadId, UserFlagId, CurrentOnly);
|
ExportOverride(callInfo, exportId, userFlagId, currentOnly);
|
||||||
return callInfo;
|
return callInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -141,9 +141,9 @@ namespace Disco.Web.Controllers
|
|||||||
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||||
public class ActionParamsClass_Export
|
public class ActionParamsClass_Export
|
||||||
{
|
{
|
||||||
public readonly string DownloadId = "DownloadId";
|
public readonly string exportId = "exportId";
|
||||||
public readonly string ExportType = "ExportType";
|
public readonly string exportType = "exportType";
|
||||||
public readonly string ExportTypeTargetId = "ExportTypeTargetId";
|
public readonly string exportTypeTargetId = "exportTypeTargetId";
|
||||||
}
|
}
|
||||||
static readonly ActionParamsClass_Import s_params_Import = new ActionParamsClass_Import();
|
static readonly ActionParamsClass_Import s_params_Import = new ActionParamsClass_Import();
|
||||||
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||||
@@ -274,16 +274,16 @@ namespace Disco.Web.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
partial void ExportOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string DownloadId, Disco.Models.Services.Devices.Exporting.DeviceExportTypes? ExportType, int? ExportTypeTargetId);
|
partial void ExportOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, System.Guid? exportId, Disco.Models.Services.Devices.DeviceExportTypes? exportType, int? exportTypeTargetId);
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public override System.Web.Mvc.ActionResult Export(string DownloadId, Disco.Models.Services.Devices.Exporting.DeviceExportTypes? ExportType, int? ExportTypeTargetId)
|
public override System.Web.Mvc.ActionResult Export(System.Guid? exportId, Disco.Models.Services.Devices.DeviceExportTypes? exportType, int? exportTypeTargetId)
|
||||||
{
|
{
|
||||||
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Export);
|
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Export);
|
||||||
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "DownloadId", DownloadId);
|
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "exportId", exportId);
|
||||||
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "ExportType", ExportType);
|
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "exportType", exportType);
|
||||||
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "ExportTypeTargetId", ExportTypeTargetId);
|
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "exportTypeTargetId", exportTypeTargetId);
|
||||||
ExportOverride(callInfo, DownloadId, ExportType, ExportTypeTargetId);
|
ExportOverride(callInfo, exportId, exportType, exportTypeTargetId);
|
||||||
return callInfo;
|
return callInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ namespace Disco.Web.Controllers
|
|||||||
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||||
public class ActionParamsClass_Export
|
public class ActionParamsClass_Export
|
||||||
{
|
{
|
||||||
public readonly string downloadId = "downloadId";
|
public readonly string exportId = "exportId";
|
||||||
}
|
}
|
||||||
static readonly ViewsClass s_views = new ViewsClass();
|
static readonly ViewsClass s_views = new ViewsClass();
|
||||||
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||||
@@ -711,14 +711,14 @@ namespace Disco.Web.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
partial void ExportOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string downloadId);
|
partial void ExportOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, System.Guid? exportId);
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public override System.Web.Mvc.ActionResult Export(string downloadId)
|
public override System.Web.Mvc.ActionResult Export(System.Guid? exportId)
|
||||||
{
|
{
|
||||||
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Export);
|
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Export);
|
||||||
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "downloadId", downloadId);
|
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "exportId", exportId);
|
||||||
ExportOverride(callInfo, downloadId);
|
ExportOverride(callInfo, exportId);
|
||||||
return callInfo;
|
return callInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Disco.Models.Services.Devices.Exporting;
|
using Disco.Models.Services.Devices;
|
||||||
using Disco.Models.Services.Exporting;
|
using Disco.Models.Services.Exporting;
|
||||||
using Disco.Models.UI.Device;
|
using Disco.Models.UI.Device;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Disco.Web.Models.Device
|
namespace Disco.Web.Models.Device
|
||||||
@@ -9,8 +10,8 @@ namespace Disco.Web.Models.Device
|
|||||||
{
|
{
|
||||||
public DeviceExportOptions Options { get; set; }
|
public DeviceExportOptions Options { get; set; }
|
||||||
|
|
||||||
public string ExportSessionId { get; set; }
|
public Guid? ExportId { get; set; }
|
||||||
public ExportResult ExportSessionResult { get; set; }
|
public ExportResult ExportResult { get; set; }
|
||||||
|
|
||||||
public IEnumerable<KeyValuePair<int, string>> DeviceBatches { get; set; }
|
public IEnumerable<KeyValuePair<int, string>> DeviceBatches { get; set; }
|
||||||
public IEnumerable<KeyValuePair<int, string>> DeviceModels { get; set; }
|
public IEnumerable<KeyValuePair<int, string>> DeviceModels { get; set; }
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
using Disco.Models.Repository;
|
using Disco.Models.Repository;
|
||||||
using Disco.Models.Services.Exporting;
|
using Disco.Models.Services.Exporting;
|
||||||
using Disco.Models.Services.Jobs.Exporting;
|
using Disco.Models.Services.Jobs;
|
||||||
using Disco.Models.UI.Job;
|
using Disco.Models.UI.Job;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Disco.Web.Models.Job
|
namespace Disco.Web.Models.Job
|
||||||
@@ -10,8 +11,8 @@ namespace Disco.Web.Models.Job
|
|||||||
{
|
{
|
||||||
public JobExportOptions Options { get; set; }
|
public JobExportOptions Options { get; set; }
|
||||||
|
|
||||||
public string ExportSessionId { get; set; }
|
public Guid? ExportId { get; set; }
|
||||||
public ExportResult ExportSessionResult { get; set; }
|
public ExportResult ExportResult { get; set; }
|
||||||
|
|
||||||
public List<JobQueue> JobQueues { get; set; }
|
public List<JobQueue> JobQueues { get; set; }
|
||||||
public List<KeyValuePair<string, string>> JobStatuses { get; set; }
|
public List<KeyValuePair<string, string>> JobStatuses { get; set; }
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
Type:
|
Type:
|
||||||
</th>
|
</th>
|
||||||
<td>
|
<td>
|
||||||
@Html.DropDownListFor(m => m.Options.ExportType, Enum.GetNames(typeof(Disco.Models.Services.Devices.Exporting.DeviceExportTypes)).Select(t => new SelectListItem() { Text = t, Value = t }))
|
@Html.DropDownListFor(m => m.Options.ExportType, Enum.GetNames(typeof(Disco.Models.Services.Devices.DeviceExportTypes)).Select(t => new SelectListItem() { Text = t, Value = t }))
|
||||||
<div id="Devices_Export_Type_Target_Batch" class="Devices_Export_Type_Target">
|
<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 }))
|
@Html.DropDownListFor(m => m.Options.ExportTypeTargetId, Model.DeviceBatches.Select(i => new SelectListItem() { Value = i.Key.ToString(), Text = i.Value }))
|
||||||
</div>
|
</div>
|
||||||
@@ -175,17 +175,17 @@
|
|||||||
</script>
|
</script>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@if (Model.ExportSessionId != null)
|
@if (Model.ExportId.HasValue)
|
||||||
{
|
{
|
||||||
<div id="Devices_Export_Download_Dialog" class="dialog" title="Export Devices">
|
<div id="Devices_Export_Download_Dialog" class="dialog" title="Export Devices">
|
||||||
@if (Model.ExportSessionResult.RecordCount == 0)
|
@if (Model.ExportResult.RecordCount == 0)
|
||||||
{
|
{
|
||||||
<h4>No records matched the filter criteria</h4>
|
<h4>No records matched the filter criteria</h4>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<h4>@Model.ExportSessionResult.RecordCount record@(Model.ExportSessionResult.RecordCount != 1 ? "s" : null) were successfully exported.</h4>
|
<h4>@Model.ExportResult.RecordCount record@(Model.ExportResult.RecordCount != 1 ? "s" : null) were successfully exported.</h4>
|
||||||
<a href="@Url.Action(MVC.API.Device.ExportRetrieve(Model.ExportSessionId))" class="button"><i class="fa fa-download fa-lg"></i>Download Device Export</a>
|
<a href="@Url.Action(MVC.API.Device.ExportRetrieve(Model.ExportId.Value))" class="button"><i class="fa fa-download fa-lg"></i>Download Device Export</a>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ WriteLiteral(" ");
|
|||||||
|
|
||||||
|
|
||||||
#line 24 "..\..\Views\Device\Export.cshtml"
|
#line 24 "..\..\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 })));
|
Write(Html.DropDownListFor(m => m.Options.ExportType, Enum.GetNames(typeof(Disco.Models.Services.Devices.DeviceExportTypes)).Select(t => new SelectListItem() { Text = t, Value = t })));
|
||||||
|
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
@@ -323,40 +323,40 @@ WriteLiteral(">\r\n");
|
|||||||
#line hidden
|
#line hidden
|
||||||
WriteLiteral(" <li");
|
WriteLiteral(" <li");
|
||||||
|
|
||||||
WriteAttribute("title", Tuple.Create(" title=\"", 3928), Tuple.Create("\"", 3959)
|
WriteAttribute("title", Tuple.Create(" title=\"", 3918), Tuple.Create("\"", 3949)
|
||||||
|
|
||||||
#line 67 "..\..\Views\Device\Export.cshtml"
|
#line 67 "..\..\Views\Device\Export.cshtml"
|
||||||
, Tuple.Create(Tuple.Create("", 3936), Tuple.Create<System.Object, System.Int32>(optionItem.Description
|
, Tuple.Create(Tuple.Create("", 3926), Tuple.Create<System.Object, System.Int32>(optionItem.Description
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
#line hidden
|
#line hidden
|
||||||
, 3936), false)
|
, 3926), false)
|
||||||
);
|
);
|
||||||
|
|
||||||
WriteLiteral(">\r\n <input");
|
WriteLiteral(">\r\n <input");
|
||||||
|
|
||||||
WriteLiteral(" type=\"checkbox\"");
|
WriteLiteral(" type=\"checkbox\"");
|
||||||
|
|
||||||
WriteAttribute("id", Tuple.Create(" id=\"", 4041), Tuple.Create("\"", 4078)
|
WriteAttribute("id", Tuple.Create(" id=\"", 4031), Tuple.Create("\"", 4068)
|
||||||
, Tuple.Create(Tuple.Create("", 4046), Tuple.Create("Options_", 4046), true)
|
, Tuple.Create(Tuple.Create("", 4036), Tuple.Create("Options_", 4036), true)
|
||||||
|
|
||||||
#line 68 "..\..\Views\Device\Export.cshtml"
|
#line 68 "..\..\Views\Device\Export.cshtml"
|
||||||
, Tuple.Create(Tuple.Create("", 4054), Tuple.Create<System.Object, System.Int32>(optionItem.PropertyName
|
, Tuple.Create(Tuple.Create("", 4044), Tuple.Create<System.Object, System.Int32>(optionItem.PropertyName
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
#line hidden
|
#line hidden
|
||||||
, 4054), false)
|
, 4044), false)
|
||||||
);
|
);
|
||||||
|
|
||||||
WriteAttribute("name", Tuple.Create(" name=\"", 4079), Tuple.Create("\"", 4118)
|
WriteAttribute("name", Tuple.Create(" name=\"", 4069), Tuple.Create("\"", 4108)
|
||||||
, Tuple.Create(Tuple.Create("", 4086), Tuple.Create("Options.", 4086), true)
|
, Tuple.Create(Tuple.Create("", 4076), Tuple.Create("Options.", 4076), true)
|
||||||
|
|
||||||
#line 68 "..\..\Views\Device\Export.cshtml"
|
#line 68 "..\..\Views\Device\Export.cshtml"
|
||||||
, Tuple.Create(Tuple.Create("", 4094), Tuple.Create<System.Object, System.Int32>(optionItem.PropertyName
|
, Tuple.Create(Tuple.Create("", 4084), Tuple.Create<System.Object, System.Int32>(optionItem.PropertyName
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
#line hidden
|
#line hidden
|
||||||
, 4094), false)
|
, 4084), false)
|
||||||
);
|
);
|
||||||
|
|
||||||
WriteLiteral(" value=\"true\"");
|
WriteLiteral(" value=\"true\"");
|
||||||
@@ -372,15 +372,15 @@ WriteLiteral(" ");
|
|||||||
#line hidden
|
#line hidden
|
||||||
WriteLiteral(" /><label");
|
WriteLiteral(" /><label");
|
||||||
|
|
||||||
WriteAttribute("for", Tuple.Create(" for=\"", 4189), Tuple.Create("\"", 4227)
|
WriteAttribute("for", Tuple.Create(" for=\"", 4179), Tuple.Create("\"", 4217)
|
||||||
, Tuple.Create(Tuple.Create("", 4195), Tuple.Create("Options_", 4195), true)
|
, Tuple.Create(Tuple.Create("", 4185), Tuple.Create("Options_", 4185), true)
|
||||||
|
|
||||||
#line 68 "..\..\Views\Device\Export.cshtml"
|
#line 68 "..\..\Views\Device\Export.cshtml"
|
||||||
, Tuple.Create(Tuple.Create("", 4203), Tuple.Create<System.Object, System.Int32>(optionItem.PropertyName
|
, Tuple.Create(Tuple.Create("", 4193), Tuple.Create<System.Object, System.Int32>(optionItem.PropertyName
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
#line hidden
|
#line hidden
|
||||||
, 4203), false)
|
, 4193), false)
|
||||||
);
|
);
|
||||||
|
|
||||||
WriteLiteral(">");
|
WriteLiteral(">");
|
||||||
@@ -428,40 +428,40 @@ WriteLiteral(">\r\n");
|
|||||||
#line hidden
|
#line hidden
|
||||||
WriteLiteral(" <li");
|
WriteLiteral(" <li");
|
||||||
|
|
||||||
WriteAttribute("title", Tuple.Create(" title=\"", 4816), Tuple.Create("\"", 4847)
|
WriteAttribute("title", Tuple.Create(" title=\"", 4806), Tuple.Create("\"", 4837)
|
||||||
|
|
||||||
#line 77 "..\..\Views\Device\Export.cshtml"
|
#line 77 "..\..\Views\Device\Export.cshtml"
|
||||||
, Tuple.Create(Tuple.Create("", 4824), Tuple.Create<System.Object, System.Int32>(optionItem.Description
|
, Tuple.Create(Tuple.Create("", 4814), Tuple.Create<System.Object, System.Int32>(optionItem.Description
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
#line hidden
|
#line hidden
|
||||||
, 4824), false)
|
, 4814), false)
|
||||||
);
|
);
|
||||||
|
|
||||||
WriteLiteral(">\r\n <input");
|
WriteLiteral(">\r\n <input");
|
||||||
|
|
||||||
WriteLiteral(" type=\"checkbox\"");
|
WriteLiteral(" type=\"checkbox\"");
|
||||||
|
|
||||||
WriteAttribute("id", Tuple.Create(" id=\"", 4929), Tuple.Create("\"", 4966)
|
WriteAttribute("id", Tuple.Create(" id=\"", 4919), Tuple.Create("\"", 4956)
|
||||||
, Tuple.Create(Tuple.Create("", 4934), Tuple.Create("Options_", 4934), true)
|
, Tuple.Create(Tuple.Create("", 4924), Tuple.Create("Options_", 4924), true)
|
||||||
|
|
||||||
#line 78 "..\..\Views\Device\Export.cshtml"
|
#line 78 "..\..\Views\Device\Export.cshtml"
|
||||||
, Tuple.Create(Tuple.Create("", 4942), Tuple.Create<System.Object, System.Int32>(optionItem.PropertyName
|
, Tuple.Create(Tuple.Create("", 4932), Tuple.Create<System.Object, System.Int32>(optionItem.PropertyName
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
#line hidden
|
#line hidden
|
||||||
, 4942), false)
|
, 4932), false)
|
||||||
);
|
);
|
||||||
|
|
||||||
WriteAttribute("name", Tuple.Create(" name=\"", 4967), Tuple.Create("\"", 5006)
|
WriteAttribute("name", Tuple.Create(" name=\"", 4957), Tuple.Create("\"", 4996)
|
||||||
, Tuple.Create(Tuple.Create("", 4974), Tuple.Create("Options.", 4974), true)
|
, Tuple.Create(Tuple.Create("", 4964), Tuple.Create("Options.", 4964), true)
|
||||||
|
|
||||||
#line 78 "..\..\Views\Device\Export.cshtml"
|
#line 78 "..\..\Views\Device\Export.cshtml"
|
||||||
, Tuple.Create(Tuple.Create("", 4982), Tuple.Create<System.Object, System.Int32>(optionItem.PropertyName
|
, Tuple.Create(Tuple.Create("", 4972), Tuple.Create<System.Object, System.Int32>(optionItem.PropertyName
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
#line hidden
|
#line hidden
|
||||||
, 4982), false)
|
, 4972), false)
|
||||||
);
|
);
|
||||||
|
|
||||||
WriteLiteral(" value=\"true\"");
|
WriteLiteral(" value=\"true\"");
|
||||||
@@ -477,15 +477,15 @@ WriteLiteral(" ");
|
|||||||
#line hidden
|
#line hidden
|
||||||
WriteLiteral(" /><label");
|
WriteLiteral(" /><label");
|
||||||
|
|
||||||
WriteAttribute("for", Tuple.Create(" for=\"", 5077), Tuple.Create("\"", 5115)
|
WriteAttribute("for", Tuple.Create(" for=\"", 5067), Tuple.Create("\"", 5105)
|
||||||
, Tuple.Create(Tuple.Create("", 5083), Tuple.Create("Options_", 5083), true)
|
, Tuple.Create(Tuple.Create("", 5073), Tuple.Create("Options_", 5073), true)
|
||||||
|
|
||||||
#line 78 "..\..\Views\Device\Export.cshtml"
|
#line 78 "..\..\Views\Device\Export.cshtml"
|
||||||
, Tuple.Create(Tuple.Create("", 5091), Tuple.Create<System.Object, System.Int32>(optionItem.PropertyName
|
, Tuple.Create(Tuple.Create("", 5081), Tuple.Create<System.Object, System.Int32>(optionItem.PropertyName
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
#line hidden
|
#line hidden
|
||||||
, 5091), false)
|
, 5081), false)
|
||||||
);
|
);
|
||||||
|
|
||||||
WriteLiteral(">");
|
WriteLiteral(">");
|
||||||
@@ -583,7 +583,7 @@ WriteLiteral("</div>\r\n");
|
|||||||
|
|
||||||
|
|
||||||
#line 178 "..\..\Views\Device\Export.cshtml"
|
#line 178 "..\..\Views\Device\Export.cshtml"
|
||||||
if (Model.ExportSessionId != null)
|
if (Model.ExportId.HasValue)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@@ -607,7 +607,7 @@ WriteLiteral(">\r\n");
|
|||||||
#line hidden
|
#line hidden
|
||||||
|
|
||||||
#line 181 "..\..\Views\Device\Export.cshtml"
|
#line 181 "..\..\Views\Device\Export.cshtml"
|
||||||
if (Model.ExportSessionResult.RecordCount == 0)
|
if (Model.ExportResult.RecordCount == 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@@ -628,7 +628,7 @@ WriteLiteral(" <h4>");
|
|||||||
|
|
||||||
|
|
||||||
#line 187 "..\..\Views\Device\Export.cshtml"
|
#line 187 "..\..\Views\Device\Export.cshtml"
|
||||||
Write(Model.ExportSessionResult.RecordCount);
|
Write(Model.ExportResult.RecordCount);
|
||||||
|
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
@@ -637,7 +637,7 @@ WriteLiteral(" record");
|
|||||||
|
|
||||||
|
|
||||||
#line 187 "..\..\Views\Device\Export.cshtml"
|
#line 187 "..\..\Views\Device\Export.cshtml"
|
||||||
Write(Model.ExportSessionResult.RecordCount != 1 ? "s" : null);
|
Write(Model.ExportResult.RecordCount != 1 ? "s" : null);
|
||||||
|
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
@@ -646,14 +646,14 @@ WriteLiteral(" were successfully exported.</h4>\r\n");
|
|||||||
|
|
||||||
WriteLiteral(" <a");
|
WriteLiteral(" <a");
|
||||||
|
|
||||||
WriteAttribute("href", Tuple.Create(" href=\"", 9710), Tuple.Create("\"", 9782)
|
WriteAttribute("href", Tuple.Create(" href=\"", 9673), Tuple.Create("\"", 9744)
|
||||||
|
|
||||||
#line 188 "..\..\Views\Device\Export.cshtml"
|
#line 188 "..\..\Views\Device\Export.cshtml"
|
||||||
, Tuple.Create(Tuple.Create("", 9717), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.Device.ExportRetrieve(Model.ExportSessionId))
|
, Tuple.Create(Tuple.Create("", 9680), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.Device.ExportRetrieve(Model.ExportId.Value))
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
#line hidden
|
#line hidden
|
||||||
, 9717), false)
|
, 9680), false)
|
||||||
);
|
);
|
||||||
|
|
||||||
WriteLiteral(" class=\"button\"");
|
WriteLiteral(" class=\"button\"");
|
||||||
|
|||||||
@@ -253,17 +253,17 @@
|
|||||||
</script>
|
</script>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@if (Model.ExportSessionId != null)
|
@if (Model.ExportId.HasValue)
|
||||||
{
|
{
|
||||||
<div id="Jobs_Export_Download_Dialog" class="dialog" title="Export Jobs">
|
<div id="Jobs_Export_Download_Dialog" class="dialog" title="Export Jobs">
|
||||||
@if (Model.ExportSessionResult.RecordCount == 0)
|
@if (Model.ExportResult.RecordCount == 0)
|
||||||
{
|
{
|
||||||
<h4>No records matched the filter criteria</h4>
|
<h4>No records matched the filter criteria</h4>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<h4>@Model.ExportSessionResult.RecordCount record@(Model.ExportSessionResult.RecordCount != 1 ? "s" : null) were successfully exported.</h4>
|
<h4>@Model.ExportResult.RecordCount record@(Model.ExportResult.RecordCount != 1 ? "s" : null) were successfully exported.</h4>
|
||||||
<a href="@Url.Action(MVC.API.Job.ExportRetrieve(Model.ExportSessionId))" class="button"><i class="fa fa-download fa-lg"></i>Download Job Export</a>
|
<a href="@Url.Action(MVC.API.Job.ExportRetrieve(Model.ExportId.Value))" class="button"><i class="fa fa-download fa-lg"></i>Download Job Export</a>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
@@ -960,7 +960,7 @@ WriteLiteral("</div>\r\n");
|
|||||||
|
|
||||||
|
|
||||||
#line 256 "..\..\Views\Job\Export.cshtml"
|
#line 256 "..\..\Views\Job\Export.cshtml"
|
||||||
if (Model.ExportSessionId != null)
|
if (Model.ExportId.HasValue)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@@ -984,7 +984,7 @@ WriteLiteral(">\r\n");
|
|||||||
#line hidden
|
#line hidden
|
||||||
|
|
||||||
#line 259 "..\..\Views\Job\Export.cshtml"
|
#line 259 "..\..\Views\Job\Export.cshtml"
|
||||||
if (Model.ExportSessionResult.RecordCount == 0)
|
if (Model.ExportResult.RecordCount == 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@@ -1005,7 +1005,7 @@ WriteLiteral(" <h4>");
|
|||||||
|
|
||||||
|
|
||||||
#line 265 "..\..\Views\Job\Export.cshtml"
|
#line 265 "..\..\Views\Job\Export.cshtml"
|
||||||
Write(Model.ExportSessionResult.RecordCount);
|
Write(Model.ExportResult.RecordCount);
|
||||||
|
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
@@ -1014,7 +1014,7 @@ WriteLiteral(" record");
|
|||||||
|
|
||||||
|
|
||||||
#line 265 "..\..\Views\Job\Export.cshtml"
|
#line 265 "..\..\Views\Job\Export.cshtml"
|
||||||
Write(Model.ExportSessionResult.RecordCount != 1 ? "s" : null);
|
Write(Model.ExportResult.RecordCount != 1 ? "s" : null);
|
||||||
|
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
@@ -1023,14 +1023,14 @@ WriteLiteral(" were successfully exported.</h4>\r\n");
|
|||||||
|
|
||||||
WriteLiteral(" <a");
|
WriteLiteral(" <a");
|
||||||
|
|
||||||
WriteAttribute("href", Tuple.Create(" href=\"", 14444), Tuple.Create("\"", 14513)
|
WriteAttribute("href", Tuple.Create(" href=\"", 14417), Tuple.Create("\"", 14485)
|
||||||
|
|
||||||
#line 266 "..\..\Views\Job\Export.cshtml"
|
#line 266 "..\..\Views\Job\Export.cshtml"
|
||||||
, Tuple.Create(Tuple.Create("", 14451), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.Job.ExportRetrieve(Model.ExportSessionId))
|
, Tuple.Create(Tuple.Create("", 14424), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.Job.ExportRetrieve(Model.ExportId.Value))
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
#line hidden
|
#line hidden
|
||||||
, 14451), false)
|
, 14424), false)
|
||||||
);
|
);
|
||||||
|
|
||||||
WriteLiteral(" class=\"button\"");
|
WriteLiteral(" class=\"button\"");
|
||||||
|
|||||||
Reference in New Issue
Block a user