feat: import/export system config

This commit is contained in:
spiral
2021-11-30 17:04:42 -05:00
parent 9097142718
commit cc4e659cec
6 changed files with 30 additions and 9 deletions

View File

@@ -61,7 +61,7 @@ public partial class BulkImporter: IAsyncDisposable
importer._system = system;
}
importer._cfg = await repo.GetSystemConfig(system.Id);
importer._cfg = await repo.GetSystemConfig(system.Id, conn);
// Fetch all members in the system and log their names and hids
var members = await conn.QueryAsync<PKMember>("select id, hid, name from members where system = @System",

View File

@@ -30,6 +30,20 @@ public partial class BulkImporter
await _repo.UpdateSystem(_system.Id, patch, _conn);
var configPatch = new SystemConfigPatch();
if (importFile.ContainsKey("config"))
configPatch = SystemConfigPatch.FromJson(importFile.Value<JObject>("config"));
if (importFile.ContainsKey("timezone"))
configPatch.UiTz = importFile.Value<string>("timezone");
configPatch.AssertIsValid();
if (configPatch.Errors.Count > 0)
throw new ImportException($"Field config.{patch.Errors[0].Key} in export file is invalid.");
await _repo.UpdateSystemConfig(_system.Id, configPatch, _conn);
var members = importFile.Value<JArray>("members");
var groups = importFile.Value<JArray>("groups");
var switches = importFile.Value<JArray>("switches");