This commit is contained in:
2020-01-27 23:03:01 +00:00
parent 5ee6c90586
commit 021b7e4b7b
6 changed files with 67 additions and 77 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using AyaNova.Models;
using AyaNova.Biz;
@@ -165,7 +166,7 @@ namespace AyaNova.Util
watch = new Stopwatch();
watch.Start();
//await GenSeedWidgetAsync(log, 100);
GenSeedWidget(log, 100);
GenSeedWidgetAsync(log, 100);
//PERF
watch.Stop();
LogStatus(JobId, LogJob, log, $"100 Widgets seeded in {watch.ElapsedMilliseconds} ms");
@@ -227,7 +228,7 @@ namespace AyaNova.Util
watch.Start();
//await GenSeedWidgetAsync(log, 500);
GenSeedWidget(log, 500);
GenSeedWidgetAsync(log, 500);
//PERF
watch.Stop();
LogStatus(JobId, LogJob, log, $"500 Widgets seeded in {watch.ElapsedMilliseconds} ms");
@@ -303,7 +304,7 @@ namespace AyaNova.Util
watch = new Stopwatch();
watch.Start();
//await GenSeedWidgetAsync(log, 5000);
GenSeedWidget(log, 5000);
GenSeedWidgetAsync(log, 5000);
//PERF
watch.Stop();
@@ -380,7 +381,7 @@ namespace AyaNova.Util
watch = new Stopwatch();
watch.Start();
//await GenSeedWidgetAsync(log, 20000);
GenSeedWidget(log, 20000);
GenSeedWidgetAsync(log, 20000);
watch.Stop();
LogStatus(JobId, LogJob, log, $"20k Widgets seeded in {watch.ElapsedMilliseconds} ms");
#endregion genhuge
@@ -509,15 +510,15 @@ namespace AyaNova.Util
public static void GenSeedUser(ILogger log, int count, AuthorizationRoles roles, UserType userType, decimal timeZoneOffset,
public static async Task GenSeedUser(ILogger log, int count, AuthorizationRoles roles, UserType userType, decimal timeZoneOffset,
bool active = true, string login = null, string password = null, long localeId = 0)
{
if (localeId == 0)
localeId = ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID;
using (var cct = ServiceProviderProvider.DBContext)
using (var ct = ServiceProviderProvider.DBContext)
{
UserBiz Biz = UserBiz.GetBizInternal(cct);
UserBiz Biz = UserBiz.GetBizInternal(ct);
//allow creation of not entirely ready users (missing client id or subcontractor vendor id etc)
Biz.SeedOrImportRelaxedRulesMode = true;
@@ -555,7 +556,7 @@ namespace AyaNova.Util
u.UserOptions.EmailAddress = p.Email.Replace("gmail.com", "helloayanova.com").Replace("hotmail.com", "helloayanova.com").Replace("yahoo.com", "helloayanova.com");
u.UserOptions.TimeZoneOffset = timeZoneOffset;
var NewObject = Biz.Create(cct, u);
var NewObject = await Biz.CreateAsync(u);
if (NewObject == null)
{
log.LogError($"Seeder::GenSeedUser error creating user {u.Name}\r\n" + Biz.GetErrorsAsString());
@@ -570,7 +571,7 @@ namespace AyaNova.Util
//////////////////////////////////////////////////////
//Seed widget for testing
//
public static void GenSeedWidget(ILogger log, int count)
public static async Task GenSeedWidgetAsync(ILogger log, int count)
{
var f = new Bogus.Faker();
@@ -610,7 +611,7 @@ namespace AyaNova.Util
//var NewObject = Cached_WidgetBiz.CreateAsync(o).Result;
//test without cached widgetbiz
WidgetBiz biz = WidgetBiz.GetBizInternal(ServiceProviderProvider.DBContext);
var NewObject = biz.Create(o);
var NewObject = await biz.CreateAsync(o);
if (NewObject == null)
{
log.LogError($"Seeder::GenSeedWidget error creating widget {o.Name}\r\n" + biz.GetErrorsAsString());