case 4221
This commit is contained in:
@@ -62,10 +62,10 @@ namespace AyaNova.Util
|
||||
//Seed database for trial and testing purposes
|
||||
//
|
||||
|
||||
public async Task SeedDatabaseAsync(Level.SeedLevel slevel, Decimal timeZoneOffset, string forceEmail, string appendPassword, bool e2e = false)
|
||||
{
|
||||
await SeedDatabaseAsync(slevel, Guid.Empty, timeZoneOffset, forceEmail, appendPassword, e2e);
|
||||
}
|
||||
// public async Task SeedDatabaseAsync(Level.SeedLevel slevel, Decimal timeZoneOffset, string forceEmail, string appendPassword, bool e2e = false)
|
||||
// {
|
||||
// await SeedDatabaseAsync(slevel, Guid.Empty, timeZoneOffset, forceEmail, appendPassword, e2e);
|
||||
// }
|
||||
|
||||
public async Task SeedDatabaseAsync(Level.SeedLevel slevel, Guid JobId, Decimal timeZoneOffset, string forceEmail, string appendPassword, bool e2e = false)
|
||||
{
|
||||
@@ -93,6 +93,17 @@ namespace AyaNova.Util
|
||||
throw new System.NotSupportedException(msg);
|
||||
}
|
||||
|
||||
//Only empty db can be seeded
|
||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
{
|
||||
if (!await DbUtil.DBIsEmptyAsync(ct, log))
|
||||
{
|
||||
var msg = $"Current database is not empty. Only an empty database can be seeded.";
|
||||
await LogStatusAsync(JobId, LogJob, log, msg);
|
||||
throw new System.NotSupportedException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
//validate timezone offset
|
||||
if (timeZoneOffset > 14 || timeZoneOffset < (-12))
|
||||
{
|
||||
@@ -106,12 +117,14 @@ namespace AyaNova.Util
|
||||
apiServerState.SetOpsOnly("Seeding database");
|
||||
ServerBootConfig.SEEDING = true;
|
||||
|
||||
//case 4221, client only seeder now and it will call erase separately to avoid issue with job etc
|
||||
//Erase all the data except for the license, schema and the SuperUser
|
||||
await DbUtil.EmptyBizDataFromDatabaseForSeedingOrImportingAsync(log, JobId);
|
||||
// await DbUtil.EmptyBizDataFromDatabaseForSeedingOrImportingAsync(log, JobId);
|
||||
//Event log erase and seeding
|
||||
using (var ct = ServiceProviderProvider.DBContext)
|
||||
{
|
||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(1, 0, AyaType.Global, AyaEvent.EraseAllData, "(seeding preparation)"), ct);
|
||||
//case 4221
|
||||
// await EventLogProcessor.LogEventToDatabaseAsync(new Event(1, 0, AyaType.Global, AyaEvent.EraseAllData, "(seeding preparation)"), ct);
|
||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(1, 0, AyaType.Global, AyaEvent.SeedDatabase, StatusMsg), ct);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user