exporting: remember last options for documents/user flags/device flags
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
using Disco.Data.Repository;
|
||||||
|
using Disco.Models.Services.Devices.DeviceFlag;
|
||||||
|
|
||||||
|
namespace Disco.Data.Configuration.Modules
|
||||||
|
{
|
||||||
|
public class DeviceFlagsConfiguration : ConfigurationBase
|
||||||
|
{
|
||||||
|
public DeviceFlagsConfiguration(DiscoDataContext database) : base(database) { }
|
||||||
|
|
||||||
|
public override string Scope { get; } = "DeviceFlags";
|
||||||
|
|
||||||
|
public DeviceFlagExportOptions LastExportOptions
|
||||||
|
{
|
||||||
|
get => Get(DeviceFlagExportOptions.DefaultOptions());
|
||||||
|
set => Set(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,5 +15,11 @@ namespace Disco.Data.Configuration.Modules
|
|||||||
get { return Get<List<DocumentTemplatePackage>>(null); }
|
get { return Get<List<DocumentTemplatePackage>>(null); }
|
||||||
set { Set(value); }
|
set { Set(value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DocumentExportOptions LastExportOptions
|
||||||
|
{
|
||||||
|
get => Get(DocumentExportOptions.DefaultOptions());
|
||||||
|
set => Set(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using Disco.Data.Repository;
|
||||||
|
using Disco.Models.Services.Users.UserFlags;
|
||||||
|
|
||||||
|
namespace Disco.Data.Configuration.Modules
|
||||||
|
{
|
||||||
|
public class UserFlagsConfiguration : ConfigurationBase
|
||||||
|
{
|
||||||
|
public UserFlagsConfiguration(DiscoDataContext database) : base(database) { }
|
||||||
|
|
||||||
|
public override string Scope { get; } = "UserFlags";
|
||||||
|
|
||||||
|
public UserFlagExportOptions LastExportOptions
|
||||||
|
{
|
||||||
|
get => Get(UserFlagExportOptions.DefaultOptions());
|
||||||
|
set => Set(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,8 @@ namespace Disco.Data.Configuration
|
|||||||
moduleActiveDirectoryConfiguration = new Lazy<Modules.ActiveDirectoryConfiguration>(() => new Modules.ActiveDirectoryConfiguration(Database));
|
moduleActiveDirectoryConfiguration = new Lazy<Modules.ActiveDirectoryConfiguration>(() => new Modules.ActiveDirectoryConfiguration(Database));
|
||||||
moduleDevicesConfiguration = new Lazy<Modules.DevicesConfiguration>(() => new Modules.DevicesConfiguration(Database));
|
moduleDevicesConfiguration = new Lazy<Modules.DevicesConfiguration>(() => new Modules.DevicesConfiguration(Database));
|
||||||
moduleDocumentsConfiguration = new Lazy<Modules.DocumentsConfiguration>(() => new Modules.DocumentsConfiguration(Database));
|
moduleDocumentsConfiguration = new Lazy<Modules.DocumentsConfiguration>(() => new Modules.DocumentsConfiguration(Database));
|
||||||
|
moduleUserFlagsConfiguration = new Lazy<Modules.UserFlagsConfiguration>(() => new Modules.UserFlagsConfiguration(Database));
|
||||||
|
moduleDeviceFlagsConfiguration = new Lazy<Modules.DeviceFlagsConfiguration>(() => new Modules.DeviceFlagsConfiguration(Database));
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Configuration Modules
|
#region Configuration Modules
|
||||||
@@ -31,57 +33,18 @@ namespace Disco.Data.Configuration
|
|||||||
private Lazy<Modules.ActiveDirectoryConfiguration> moduleActiveDirectoryConfiguration;
|
private Lazy<Modules.ActiveDirectoryConfiguration> moduleActiveDirectoryConfiguration;
|
||||||
private Lazy<Modules.DevicesConfiguration> moduleDevicesConfiguration;
|
private Lazy<Modules.DevicesConfiguration> moduleDevicesConfiguration;
|
||||||
private Lazy<Modules.DocumentsConfiguration> moduleDocumentsConfiguration;
|
private Lazy<Modules.DocumentsConfiguration> moduleDocumentsConfiguration;
|
||||||
|
private Lazy<Modules.UserFlagsConfiguration> moduleUserFlagsConfiguration;
|
||||||
|
private Lazy<Modules.DeviceFlagsConfiguration> moduleDeviceFlagsConfiguration;
|
||||||
|
|
||||||
public Modules.BootstrapperConfiguration Bootstrapper
|
public Modules.BootstrapperConfiguration Bootstrapper => moduleBootstrapperConfiguration.Value;
|
||||||
{
|
public Modules.DeviceProfilesConfiguration DeviceProfiles => moduleDeviceProfilesConfiguration.Value;
|
||||||
get
|
public Modules.OrganisationAddressesConfiguration OrganisationAddresses => moduleOrganisationAddressesConfiguration.Value;
|
||||||
{
|
public Modules.JobPreferencesConfiguration JobPreferences => moduleJobPreferencesConfiguration.Value;
|
||||||
return moduleBootstrapperConfiguration.Value;
|
public Modules.ActiveDirectoryConfiguration ActiveDirectory => moduleActiveDirectoryConfiguration.Value;
|
||||||
}
|
public Modules.DevicesConfiguration Devices => moduleDevicesConfiguration.Value;
|
||||||
}
|
public Modules.DocumentsConfiguration Documents => moduleDocumentsConfiguration.Value;
|
||||||
public Modules.DeviceProfilesConfiguration DeviceProfiles
|
public Modules.UserFlagsConfiguration UserFlags => moduleUserFlagsConfiguration.Value;
|
||||||
{
|
public Modules.DeviceFlagsConfiguration DeviceFlags => moduleDeviceFlagsConfiguration.Value;
|
||||||
get
|
|
||||||
{
|
|
||||||
return moduleDeviceProfilesConfiguration.Value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public Modules.OrganisationAddressesConfiguration OrganisationAddresses
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return moduleOrganisationAddressesConfiguration.Value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public Modules.JobPreferencesConfiguration JobPreferences
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return moduleJobPreferencesConfiguration.Value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public Modules.ActiveDirectoryConfiguration ActiveDirectory
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return moduleActiveDirectoryConfiguration.Value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public Modules.DevicesConfiguration Devices
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return moduleDevicesConfiguration.Value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Modules.DocumentsConfiguration Documents
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return moduleDocumentsConfiguration.Value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -95,26 +58,27 @@ namespace Disco.Data.Configuration
|
|||||||
if (result == null)
|
if (result == null)
|
||||||
{
|
{
|
||||||
var appDataPath = System.Web.HttpContext.Current.Server.MapPath("~/App_Data");
|
var appDataPath = System.Web.HttpContext.Current.Server.MapPath("~/App_Data");
|
||||||
if (appDataPath.EndsWith("\\"))
|
|
||||||
return appDataPath;
|
if (!appDataPath.EndsWith(@"\"))
|
||||||
else
|
appDataPath += @"\";
|
||||||
return string.Concat(appDataPath, '\\');
|
|
||||||
|
return appDataPath;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value == null)
|
if (string.IsNullOrWhiteSpace(value))
|
||||||
throw new ArgumentNullException("value");
|
throw new ArgumentNullException(nameof(value));
|
||||||
if (!System.IO.Directory.Exists(value))
|
|
||||||
throw new System.IO.DirectoryNotFoundException(string.Format("DataStoreLocation: '{0}' could not be found", value));
|
if (!Directory.Exists(value))
|
||||||
string storePath;
|
throw new DirectoryNotFoundException($"DataStoreLocation: '{value}' could not be found");
|
||||||
if (value.EndsWith("\\"))
|
|
||||||
storePath = value;
|
if (!value.EndsWith(@"\"))
|
||||||
else
|
value += @"\";
|
||||||
storePath = string.Concat(value, '\\');
|
|
||||||
Set(storePath);
|
Set(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,30 +95,10 @@ namespace Disco.Data.Configuration
|
|||||||
}
|
}
|
||||||
|
|
||||||
#region Plugin Locations
|
#region Plugin Locations
|
||||||
public string PluginsLocation
|
public string PluginsLocation => Path.Combine(DataStoreLocation, @"Plugins\");
|
||||||
{
|
public string PluginStorageLocation => Path.Combine(DataStoreLocation, @"PluginStorage\");
|
||||||
get
|
public string PluginPackagesLocation => Path.Combine(DataStoreLocation, @"PluginPackages\");
|
||||||
{
|
public string PluginUserPhotosLocation => Path.Combine(DataStoreLocation, @"PluginUserPhotos\");
|
||||||
return System.IO.Path.Combine(DataStoreLocation, @"Plugins\");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public string PluginStorageLocation
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return System.IO.Path.Combine(DataStoreLocation, @"PluginStorage\");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public string PluginPackagesLocation
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return System.IO.Path.Combine(DataStoreLocation, @"PluginPackages\");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string PluginUserPhotosLocation
|
|
||||||
=> Path.Combine(DataStoreLocation, @"PluginUserPhotos\");
|
|
||||||
|
|
||||||
public DateTime PluginDetailsCacheExpiration
|
public DateTime PluginDetailsCacheExpiration
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -77,6 +77,8 @@
|
|||||||
<Compile Include="Configuration\ConfigurationCache.cs" />
|
<Compile Include="Configuration\ConfigurationCache.cs" />
|
||||||
<Compile Include="Configuration\Modules\ActiveDirectoryConfiguration.cs" />
|
<Compile Include="Configuration\Modules\ActiveDirectoryConfiguration.cs" />
|
||||||
<Compile Include="Configuration\Modules\DevicesConfiguration.cs" />
|
<Compile Include="Configuration\Modules\DevicesConfiguration.cs" />
|
||||||
|
<Compile Include="Configuration\Modules\DeviceFlagsConfiguration.cs" />
|
||||||
|
<Compile Include="Configuration\Modules\UserFlagsConfiguration.cs" />
|
||||||
<Compile Include="Configuration\Modules\DocumentsConfiguration.cs" />
|
<Compile Include="Configuration\Modules\DocumentsConfiguration.cs" />
|
||||||
<Compile Include="Configuration\Modules\JobPreferencesConfiguration.cs" />
|
<Compile Include="Configuration\Modules\JobPreferencesConfiguration.cs" />
|
||||||
<Compile Include="Configuration\SystemConfiguration.cs" />
|
<Compile Include="Configuration\SystemConfiguration.cs" />
|
||||||
|
|||||||
@@ -409,6 +409,9 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
if (Model == null || Model.Options == null)
|
if (Model == null || Model.Options == null)
|
||||||
throw new ArgumentNullException(nameof(Model));
|
throw new ArgumentNullException(nameof(Model));
|
||||||
|
|
||||||
|
Database.DiscoConfiguration.DeviceFlags.LastExportOptions = Model.Options;
|
||||||
|
Database.SaveChanges();
|
||||||
|
|
||||||
// Start Export
|
// Start Export
|
||||||
var exportContext = new DeviceFlagExport(Model.Options);
|
var exportContext = new DeviceFlagExport(Model.Options);
|
||||||
var taskContext = ExportTask.ScheduleNowCacheResult(exportContext, id => Url.Action(MVC.Config.DeviceFlag.Export(id, null, null)));
|
var taskContext = ExportTask.ScheduleNowCacheResult(exportContext, id => Url.Action(MVC.Config.DeviceFlag.Export(id, null, null)));
|
||||||
@@ -444,6 +447,8 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
[HttpPost, ValidateAntiForgeryToken]
|
[HttpPost, ValidateAntiForgeryToken]
|
||||||
public virtual ActionResult SaveExport(ExportModel Model)
|
public virtual ActionResult SaveExport(ExportModel Model)
|
||||||
{
|
{
|
||||||
|
Database.DiscoConfiguration.DeviceFlags.LastExportOptions = Model.Options;
|
||||||
|
|
||||||
var export = new DeviceFlagExport(Model.Options);
|
var export = new DeviceFlagExport(Model.Options);
|
||||||
var savedExport = SavedExports.SaveExport(export, Database, CurrentUser);
|
var savedExport = SavedExports.SaveExport(export, Database, CurrentUser);
|
||||||
|
|
||||||
|
|||||||
@@ -1462,6 +1462,9 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
if (Model.Options.DocumentTemplateIds.Count == 1)
|
if (Model.Options.DocumentTemplateIds.Count == 1)
|
||||||
templateId = Model.Options.DocumentTemplateIds.First();
|
templateId = Model.Options.DocumentTemplateIds.First();
|
||||||
|
|
||||||
|
Database.DiscoConfiguration.Documents.LastExportOptions = Model.Options;
|
||||||
|
Database.SaveChanges();
|
||||||
|
|
||||||
// Start Export
|
// Start Export
|
||||||
var exportContext = new DocumentExport(Model.Options);
|
var exportContext = new DocumentExport(Model.Options);
|
||||||
var taskContext = ExportTask.ScheduleNowCacheResult(exportContext, id => Url.Action(MVC.Config.DocumentTemplate.Export(templateId, id)));
|
var taskContext = ExportTask.ScheduleNowCacheResult(exportContext, id => Url.Action(MVC.Config.DocumentTemplate.Export(templateId, id)));
|
||||||
@@ -1494,6 +1497,8 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
[HttpPost, ValidateAntiForgeryToken]
|
[HttpPost, ValidateAntiForgeryToken]
|
||||||
public virtual ActionResult SaveExport(ExportModel Model)
|
public virtual ActionResult SaveExport(ExportModel Model)
|
||||||
{
|
{
|
||||||
|
Database.DiscoConfiguration.Documents.LastExportOptions = Model.Options;
|
||||||
|
|
||||||
var export = new DocumentExport(Model.Options);
|
var export = new DocumentExport(Model.Options);
|
||||||
var savedExport = SavedExports.SaveExport(export, Database, CurrentUser);
|
var savedExport = SavedExports.SaveExport(export, Database, CurrentUser);
|
||||||
|
|
||||||
|
|||||||
@@ -414,6 +414,9 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
if (Model == null || Model.Options == null)
|
if (Model == null || Model.Options == null)
|
||||||
throw new ArgumentNullException(nameof(Model));
|
throw new ArgumentNullException(nameof(Model));
|
||||||
|
|
||||||
|
Database.DiscoConfiguration.UserFlags.LastExportOptions = Model.Options;
|
||||||
|
Database.SaveChanges();
|
||||||
|
|
||||||
// Start Export
|
// Start Export
|
||||||
var exportContext = new UserFlagExport(Model.Options);
|
var exportContext = new UserFlagExport(Model.Options);
|
||||||
var taskContext = ExportTask.ScheduleNowCacheResult(exportContext, id => Url.Action(MVC.Config.UserFlag.Export(id, null, null)));
|
var taskContext = ExportTask.ScheduleNowCacheResult(exportContext, id => Url.Action(MVC.Config.UserFlag.Export(id, null, null)));
|
||||||
@@ -446,6 +449,8 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
[HttpPost, ValidateAntiForgeryToken]
|
[HttpPost, ValidateAntiForgeryToken]
|
||||||
public virtual ActionResult SaveExport(ExportModel Model)
|
public virtual ActionResult SaveExport(ExportModel Model)
|
||||||
{
|
{
|
||||||
|
Database.DiscoConfiguration.UserFlags.LastExportOptions = Model.Options;
|
||||||
|
|
||||||
var export = new UserFlagExport(Model.Options);
|
var export = new UserFlagExport(Model.Options);
|
||||||
var savedExport = SavedExports.SaveExport(export, Database, CurrentUser);
|
var savedExport = SavedExports.SaveExport(export, Database, CurrentUser);
|
||||||
|
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ namespace Disco.Web.Areas.Config.Controllers
|
|||||||
{
|
{
|
||||||
var m = new ExportModel()
|
var m = new ExportModel()
|
||||||
{
|
{
|
||||||
Options = DeviceFlagExportOptions.DefaultOptions(),
|
Options = Database.DiscoConfiguration.DeviceFlags.LastExportOptions,
|
||||||
DeviceFlags = DeviceFlagService.GetDeviceFlags(),
|
DeviceFlags = DeviceFlagService.GetDeviceFlags(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -302,7 +302,7 @@ namespace Disco.Web.Areas.Config.Controllers
|
|||||||
{
|
{
|
||||||
var m = new ExportModel()
|
var m = new ExportModel()
|
||||||
{
|
{
|
||||||
Options = DocumentExportOptions.DefaultOptions(),
|
Options = Database.DiscoConfiguration.Documents.LastExportOptions,
|
||||||
DocumentTemplates = Database.DocumentTemplates.OrderBy(d => d.Id).ToList(),
|
DocumentTemplates = Database.DocumentTemplates.OrderBy(d => d.Id).ToList(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ namespace Disco.Web.Areas.Config.Controllers
|
|||||||
{
|
{
|
||||||
var m = new ExportModel()
|
var m = new ExportModel()
|
||||||
{
|
{
|
||||||
Options = UserFlagExportOptions.DefaultOptions(),
|
Options = Database.DiscoConfiguration.UserFlags.LastExportOptions,
|
||||||
UserFlags = UserFlagService.GetUserFlags(),
|
UserFlags = UserFlagService.GetUserFlags(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user