From bb1a51af4ab145a5d8aa9d24bc435fc6adffae69 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 27 Jan 2020 22:42:22 +0000 Subject: [PATCH] --- server/AyaNova/biz/LocaleBiz.cs | 2 +- server/AyaNova/biz/PrimeData.cs | 25 ++++++++++++------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/server/AyaNova/biz/LocaleBiz.cs b/server/AyaNova/biz/LocaleBiz.cs index 638f93b9..774000ff 100644 --- a/server/AyaNova/biz/LocaleBiz.cs +++ b/server/AyaNova/biz/LocaleBiz.cs @@ -546,7 +546,7 @@ namespace AyaNova.Biz if (await LocaleExistsAsync(SourceLocaleName)) { //If there are any validation errors, log in joblog and move on - JobsBiz.LogJobAsync(jobId, $"LocaleBiz::ImportV7Async -> - Locale \"{SourceLocaleName}\" already exists in database, can not import over an existing locale", ct); + await JobsBiz.LogJobAsync(jobId, $"LocaleBiz::ImportV7Async -> - Locale \"{SourceLocaleName}\" already exists in database, can not import over an existing locale", ct); return false; } diff --git a/server/AyaNova/biz/PrimeData.cs b/server/AyaNova/biz/PrimeData.cs index d39de63b..7af3e8c0 100644 --- a/server/AyaNova/biz/PrimeData.cs +++ b/server/AyaNova/biz/PrimeData.cs @@ -1,4 +1,4 @@ -using System; +using System.Threading.Tasks; using System.IO; using Newtonsoft.Json.Linq; using Microsoft.Extensions.Logging; @@ -41,7 +41,7 @@ namespace AyaNova.Biz /// Prime the locales /// This may be called before there are any users on a fresh db boot /// - public static void PrimeLocales() + public static async Task PrimeLocales() {// @@ -53,19 +53,18 @@ namespace AyaNova.Biz } - ImportLocale(ResourceFolderPath, "en"); - ImportLocale(ResourceFolderPath, "es"); - ImportLocale(ResourceFolderPath, "fr"); - ImportLocale(ResourceFolderPath, "de"); - - //Ensure locales are present, not missing any keys and that there is a server default locale that exists + await ImportLocale(ResourceFolderPath, "en"); + await ImportLocale(ResourceFolderPath, "es"); + await ImportLocale(ResourceFolderPath, "fr"); + await ImportLocale(ResourceFolderPath, "de"); + //Ensure locales are present, not missing any keys and that there is a server default locale that exists LocaleBiz lb = LocaleBiz.GetBizInternal(ServiceProviderProvider.DBContext, 1, AuthorizationRoles.OpsAdminFull); - lb.ValidateLocalesAsync(); + await lb.ValidateLocalesAsync(); } - private static void ImportLocale(string resourceFolderPath, string localeCode) + private static async Task ImportLocale(string resourceFolderPath, string localeCode) { AyContext ct = ServiceProviderProvider.DBContext; var LocalePath = Path.Combine(resourceFolderPath, $"{localeCode}.json"); @@ -74,7 +73,7 @@ namespace AyaNova.Biz throw new System.Exception($"E1013: stock locale file \"{localeCode}\" not found where expected: \"{LocalePath}\", installation damaged?"); } - JObject o = JObject.Parse(File.ReadAllText(LocalePath)); + JObject o = JObject.Parse(await File.ReadAllTextAsync(LocalePath)); Locale l = new Locale(); l.Name = localeCode; @@ -89,8 +88,8 @@ namespace AyaNova.Biz l.LocaleItems.Add(new LocaleItem() { Key = key, Display = display });//, Locale = l } - ct.Locale.Add(l); - ct.SaveChanges(); + await ct.Locale.AddAsync(l); + await ct.SaveChangesAsync(); }