This commit is contained in:
2022-03-15 21:27:20 +00:00
parent f99bba70f6
commit d129192c9f
7 changed files with 38 additions and 15 deletions

View File

@@ -136,7 +136,7 @@ namespace AyaNova.Biz
foreach (FileInfo file in di.EnumerateFiles())
{
if (file.Extension.ToLowerInvariant() == ".ayrt")
await r.ImportAsync(JObject.Parse(await File.ReadAllTextAsync(file.FullName)));
await r.ImportAsync(JObject.Parse(await File.ReadAllTextAsync(file.FullName)), true);
}
}
}

View File

@@ -63,7 +63,7 @@ namespace AyaNova.Biz
////////////////////////////////////////////////////////////////////////////////////////////////
//IMPORT
//
internal async Task<bool> ImportAsync(JObject o)
internal async Task<bool> ImportAsync(JObject o, bool skipIfAlreadyPresent = false)
{
//Report newObject = new Report();
@@ -78,7 +78,16 @@ namespace AyaNova.Biz
{
NotUnique = await ct.Report.AnyAsync(z => z.Name == newUniqueName);
if (NotUnique)
newUniqueName = Util.StringUtil.UniqueNameBuilder(proposedName, l++, 255);
{
if (!skipIfAlreadyPresent)
newUniqueName = Util.StringUtil.UniqueNameBuilder(proposedName, l++, 255);
else
{
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<ReportBiz>();
log.LogInformation($"Import report '{proposedName}' skipped due to already present in database.");
return true;
}
}
} while (NotUnique);
@@ -186,7 +195,7 @@ namespace AyaNova.Biz
//GET LIST
//
internal async Task<List<NameIdItem>> GetReportListAsync(AyaType aType)
{
{
var rpts = await ct.Report.AsNoTracking().Where(z => z.AType == aType && z.Active == true).Select(z => new { id = z.Id, name = z.Name, roles = z.Roles }).OrderBy(z => z.name).ToListAsync();
var ret = new List<NameIdItem>();
foreach (var item in rpts)

View File

@@ -568,6 +568,9 @@ namespace AyaNova.Util
//If we got here then it's safe to erase the attachment files
FileUtil.EraseEntireContentsOfAttachmentFilesFolder();
_log.LogInformation("Importing any missing stock Report templates");
await AyaNova.Biz.PrimeData.PrimeReportTemplates();
apiServerState.ResumePriorState();
_log.LogInformation("Database erase completed");