Ensured that auto-export settings are available
This commit is contained in:
parent
574d1ef8bf
commit
9f0d664105
@ -67,16 +67,23 @@ public static class Setup
|
|||||||
//
|
//
|
||||||
|
|
||||||
// Enable the auto-export feature:
|
// Enable the auto-export feature:
|
||||||
var autoExportEnabled = await dbContext.Settings.FirstAsync(n => n.Code == SettingNames.AUTO_EXPORT_ENABLED);
|
var autoExportEnabled = await dbContext.Settings.FirstOrDefaultAsync(n => n.Code == SettingNames.AUTO_EXPORT_ENABLED) ?? new Setting { Code = SettingNames.AUTO_EXPORT_ENABLED };
|
||||||
autoExportEnabled.BoolValue = true;
|
autoExportEnabled.BoolValue = true;
|
||||||
|
|
||||||
// Set the auto-export path and file:
|
// Set the auto-export path and file:
|
||||||
var autoExportPath = await dbContext.Settings.FirstAsync(n => n.Code == SettingNames.AUTO_EXPORT_DESTINATION_PATH);
|
var autoExportPath = await dbContext.Settings.FirstOrDefaultAsync(n => n.Code == SettingNames.AUTO_EXPORT_DESTINATION_PATH) ?? new Setting { Code = SettingNames.AUTO_EXPORT_DESTINATION_PATH };
|
||||||
autoExportPath.TextValue = Path.GetDirectoryName(path2JSONFile) ?? string.Empty;
|
autoExportPath.TextValue = Path.GetDirectoryName(path2JSONFile) ?? string.Empty;
|
||||||
|
|
||||||
var autoExportFile = await dbContext.Settings.FirstAsync(n => n.Code == SettingNames.AUTO_EXPORT_FILENAME);
|
var autoExportFile = await dbContext.Settings.FirstOrDefaultAsync(n => n.Code == SettingNames.AUTO_EXPORT_FILENAME) ?? new Setting { Code = SettingNames.AUTO_EXPORT_FILENAME };
|
||||||
autoExportFile.TextValue = Path.GetFileName(path2JSONFile);
|
autoExportFile.TextValue = Path.GetFileName(path2JSONFile);
|
||||||
|
|
||||||
|
// Ensure that the sensitive data setting is present and disabled by default:
|
||||||
|
var autoExportSensitiveData = await dbContext.Settings.FirstOrDefaultAsync(n => n.Code == SettingNames.AUTO_EXPORT_SENSITIVE_DATA) ?? new Setting
|
||||||
|
{
|
||||||
|
Code = SettingNames.AUTO_EXPORT_SENSITIVE_DATA,
|
||||||
|
BoolValue = false,
|
||||||
|
};
|
||||||
|
|
||||||
// Save the changes:
|
// Save the changes:
|
||||||
await dbContext.SaveChangesAsync();
|
await dbContext.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user