This commit is contained in:
2018-12-11 17:49:14 +00:00
parent 2ce1db72b1
commit dd31c18520

View File

@@ -31,6 +31,7 @@ namespace AyaNova.Util
{ {
bool LogJob = JobId != Guid.Empty; bool LogJob = JobId != Guid.Empty;
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("Seeder"); ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("Seeder");
ApiServerState apiServerState = (ApiServerState)ServiceProviderProvider.Provider.GetService(typeof(ApiServerState)); ApiServerState apiServerState = (ApiServerState)ServiceProviderProvider.Provider.GetService(typeof(ApiServerState));
@@ -54,12 +55,27 @@ namespace AyaNova.Util
throw new System.NotSupportedException(msg); throw new System.NotSupportedException(msg);
} }
//validate timezone offset
if (timeZoneOffset > 14 || timeZoneOffset < (-12))
{
var msg = $"Time zone offset \"{timeZoneOffset.ToString()}\" is not valid";
LogStatus(JobId, LogJob, log, msg);
throw new System.NotSupportedException(msg);
}
apiServerState.SetOpsOnly("Seeding database"); apiServerState.SetOpsOnly("Seeding database");
//Erase all the data except for the license, schema and the manager user //Erase all the data except for the license, schema and the manager user
DbUtil.PrepareDatabaseForSeeding(log); DbUtil.PrepareDatabaseForSeeding(log);
Set the time zone of the manager account here //Set the time zone of the manager account
{
var ct = ServiceProviderProvider.DBContext;
var mgr = ct.UserOptions.FirstAsync(m => m.Id == 1).Result;
mgr.TimeZoneOffset = timeZoneOffset;
ct.SaveChanges();
}
//Seed special test data for integration testing //Seed special test data for integration testing
//log.LogInformation("Seeding known users"); //log.LogInformation("Seeding known users");
@@ -421,7 +437,7 @@ namespace AyaNova.Util
//Children and relations //Children and relations
u.UserOptions = new UserOptions(1); u.UserOptions = new UserOptions(1);
u.UserOptions.EmailAddress = p.Email.Replace("gmail.com", "helloayanova.com").Replace("hotmail.com", "helloayanova.com").Replace("yahoo.com", "helloayanova.com"); u.UserOptions.EmailAddress = p.Email.Replace("gmail.com", "helloayanova.com").Replace("hotmail.com", "helloayanova.com").Replace("yahoo.com", "helloayanova.com");
u.UserOptions.TimeZoneOffset=timeZoneOffset; u.UserOptions.TimeZoneOffset = timeZoneOffset;
var NewObject = Biz.Create(ServiceProviderProvider.DBContext, u); var NewObject = Biz.Create(ServiceProviderProvider.DBContext, u);
if (NewObject == null) if (NewObject == null)