This commit is contained in:
2020-01-27 22:01:21 +00:00
parent fe9adc7329
commit 8fbead3c8b
11 changed files with 67 additions and 66 deletions

View File

@@ -62,8 +62,8 @@ namespace AyaNova.Biz
//basically any error condition during job processing should throw up an exception if it can't be handled
List<ImportAyaNova7MapItem> importMap = new List<ImportAyaNova7MapItem>();
JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Running, ct);
JobsBiz.LogJobAsync(job.GId, $"ImportAyaNova7 starting", ct);
await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Running, ct);
await JobsBiz.LogJobAsync(job.GId, $"ImportAyaNova7 starting", ct);
//Get the import filename from the jsondata
JObject jobData = JObject.Parse(job.JobInfo);
@@ -81,8 +81,8 @@ namespace AyaNova.Biz
//Erase all the data except for the license, schema and the manager user
Microsoft.Extensions.Logging.ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("ImportAyaNova7");
JobsBiz.LogJobAsync(job.GId, "ImportAyaNova7 - Erasing data from database", ct);
DbUtil.EmptyBizDataFromDatabaseForSeedingOrImporting(log);
await JobsBiz.LogJobAsync(job.GId, "ImportAyaNova7 - Erasing data from database", ct);
DbUtil.EmptyBizDataFromDatabaseForSeedingOrImportingAsync(log);
//get the contents of the archive
@@ -105,42 +105,42 @@ namespace AyaNova.Biz
//IMPORT UNIT MODEL CATEGORIES AS TAGS
TagLists.Add("UnitModelCategory", new Dictionary<Guid, string>());
ImportTagList("GZTW.AyaNova.BLL.UnitModelCategory", job.GId, TagLists["UnitModelCategory"], importFileName, zipEntries);
await ImportTagListAsync("GZTW.AyaNova.BLL.UnitModelCategory", job.GId, TagLists["UnitModelCategory"], importFileName, zipEntries);
//IMPORT Unit service type AS TAGS
TagLists.Add("UnitServiceType", new Dictionary<Guid, string>());
ImportTagList("GZTW.AyaNova.BLL.UnitServiceType", job.GId, TagLists["UnitServiceType"], importFileName, zipEntries);
await ImportTagListAsync("GZTW.AyaNova.BLL.UnitServiceType", job.GId, TagLists["UnitServiceType"], importFileName, zipEntries);
//IMPORT Workorder Item Type AS TAGS
TagLists.Add("WorkorderItemType", new Dictionary<Guid, string>());
ImportTagList("GZTW.AyaNova.BLL.WorkorderItemType", job.GId, TagLists["WorkorderItemType"], importFileName, zipEntries);
await ImportTagListAsync("GZTW.AyaNova.BLL.WorkorderItemType", job.GId, TagLists["WorkorderItemType"], importFileName, zipEntries);
//IMPORT Client group AS TAGS
TagLists.Add("ClientGroup", new Dictionary<Guid, string>());
ImportTagList("GZTW.AyaNova.BLL.ClientGroup", job.GId, TagLists["ClientGroup"], importFileName, zipEntries);
await ImportTagListAsync("GZTW.AyaNova.BLL.ClientGroup", job.GId, TagLists["ClientGroup"], importFileName, zipEntries);
//IMPORT Workorder category AS TAGS
TagLists.Add("WorkorderCategory", new Dictionary<Guid, string>());
ImportTagList("GZTW.AyaNova.BLL.WorkorderCategory", job.GId, TagLists["WorkorderCategory"], importFileName, zipEntries);
await ImportTagListAsync("GZTW.AyaNova.BLL.WorkorderCategory", job.GId, TagLists["WorkorderCategory"], importFileName, zipEntries);
//IMPORT Part Category AS TAGS
TagLists.Add("PartCategory", new Dictionary<Guid, string>());
ImportTagList("GZTW.AyaNova.BLL.PartCategory", job.GId, TagLists["PartCategory"], importFileName, zipEntries);
await ImportTagListAsync("GZTW.AyaNova.BLL.PartCategory", job.GId, TagLists["PartCategory"], importFileName, zipEntries);
//IMPORT Dispatch zones AS TAGS
TagLists.Add("DispatchZone", new Dictionary<Guid, string>());
ImportTagList("GZTW.AyaNova.BLL.DispatchZone", job.GId, TagLists["DispatchZone"], importFileName, zipEntries);
await ImportTagListAsync("GZTW.AyaNova.BLL.DispatchZone", job.GId, TagLists["DispatchZone"], importFileName, zipEntries);
//IMPORT Scheduleable User Groups AS TAGS
TagLists.Add("ScheduleableUserGroup", new Dictionary<Guid, string>());
ImportTagList("GZTW.AyaNova.BLL.ScheduleableUserGroup", job.GId, TagLists["ScheduleableUserGroup"], importFileName, zipEntries);
await ImportTagListAsync("GZTW.AyaNova.BLL.ScheduleableUserGroup", job.GId, TagLists["ScheduleableUserGroup"], importFileName, zipEntries);
//Now can set users to correct tag for scheduleable user group
// await ImportTagList("GZTW.AyaNova.BLL.ScheduleableUserGroup", "scheduleableusergrouptags", AyaType.Tag, job.GId, importMap, importFileName, zipEntries);
//IMPORT REGIONS AS TAGS
TagLists.Add("Region", new Dictionary<Guid, string>());
ImportTagList("GZTW.AyaNova.BLL.Region", job.GId, TagLists["Region"], importFileName, zipEntries);
await ImportTagListAsync("GZTW.AyaNova.BLL.Region", job.GId, TagLists["Region"], importFileName, zipEntries);
@@ -173,8 +173,8 @@ namespace AyaNova.Biz
//----------------
JobsBiz.LogJobAsync(job.GId, "ImportAyaNova7 finished", ct);
JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Completed, ct);
await JobsBiz.LogJobAsync(job.GId, "ImportAyaNova7 finished", ct);
await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Completed, ct);
}
@@ -204,11 +204,11 @@ namespace AyaNova.Biz
{
if (importTask != "main")
{
JobsBiz.LogJobAsync(jobId, $"Starting import sub-task {importTask} of {entryStartsWith} objects", ct);
await JobsBiz.LogJobAsync(jobId, $"Starting import sub-task {importTask} of {entryStartsWith} objects", ct);
}
else
{
JobsBiz.LogJobAsync(jobId, $"Starting import of {entryStartsWith} objects", ct);
await JobsBiz.LogJobAsync(jobId, $"Starting import of {entryStartsWith} objects", ct);
}
var jList = FileUtil.ZipGetUtilityArchiveEntriesAsJsonObjects(zipObjectList, importFileName);
@@ -235,11 +235,11 @@ namespace AyaNova.Biz
{
if (importTask != "main")
{
JobsBiz.LogJobAsync(jobId, $"Successfully ran import subtask {importTask} on {importCount.ToString()} of {zipObjectList.Count.ToString()} {entryStartsWith} objects", ct);
await JobsBiz.LogJobAsync(jobId, $"Successfully ran import subtask {importTask} on {importCount.ToString()} of {zipObjectList.Count.ToString()} {entryStartsWith} objects", ct);
}
else
{
JobsBiz.LogJobAsync(jobId, $"Successfully imported {importCount.ToString()} of {zipObjectList.Count.ToString()} {entryStartsWith} objects", ct);
await JobsBiz.LogJobAsync(jobId, $"Successfully imported {importCount.ToString()} of {zipObjectList.Count.ToString()} {entryStartsWith} objects", ct);
}
}
@@ -247,11 +247,11 @@ namespace AyaNova.Biz
{
if (importTask != "main")
{
JobsBiz.LogJobAsync(jobId, $"Failed to run import subtask {importTask} on {notImportCount.ToString()} of {zipObjectList.Count.ToString()} {entryStartsWith} objects", ct);
await JobsBiz.LogJobAsync(jobId, $"Failed to run import subtask {importTask} on {notImportCount.ToString()} of {zipObjectList.Count.ToString()} {entryStartsWith} objects", ct);
}
else
{
JobsBiz.LogJobAsync(jobId, $"Did not import {notImportCount.ToString()} of {zipObjectList.Count.ToString()} {entryStartsWith} objects", ct);
await JobsBiz.LogJobAsync(jobId, $"Did not import {notImportCount.ToString()} of {zipObjectList.Count.ToString()} {entryStartsWith} objects", ct);
}
}
}
@@ -260,14 +260,14 @@ namespace AyaNova.Biz
//Other job handlers here...
private void ImportTagList(string entryStartsWith, Guid jobId, Dictionary<Guid, string> tagDictionary, string importFileName, List<string> zipEntries)
private async Task ImportTagListAsync(string entryStartsWith, Guid jobId, Dictionary<Guid, string> tagDictionary, string importFileName, List<string> zipEntries)
{
var zipObjectList = zipEntries.Where(m => m.StartsWith(entryStartsWith)).ToList();
long importCount = 0;
if (zipObjectList.Count > 0)
{
JobsBiz.LogJobAsync(jobId, $"Starting import to TAGS of {entryStartsWith} objects", ct);
await JobsBiz.LogJobAsync(jobId, $"Starting import to TAGS of {entryStartsWith} objects", ct);
var jList = FileUtil.ZipGetUtilityArchiveEntriesAsJsonObjects(zipObjectList, importFileName);
foreach (JObject j in jList)
@@ -327,7 +327,7 @@ namespace AyaNova.Biz
if (importCount > 0)
{
JobsBiz.LogJobAsync(jobId, $"Successfully imported as TAGS {importCount.ToString()} of {zipObjectList.Count.ToString()} {entryStartsWith} objects", ct);
await JobsBiz.LogJobAsync(jobId, $"Successfully imported as TAGS {importCount.ToString()} of {zipObjectList.Count.ToString()} {entryStartsWith} objects", ct);
}
}
}

View File

@@ -140,11 +140,11 @@ namespace AyaNova.Biz
/// <param name="newJob"></param>
/// <param name="ct"></param>
/// <returns></returns>
internal static OpsJob AddJob(OpsJob newJob, AyContext ct)
internal static async Task<OpsJob> AddJobAsync(OpsJob newJob, AyContext ct)
{
//TODO: Does this need to create an event so we know which user created the job?
ct.OpsJob.Add(newJob);
ct.SaveChanges();
await ct.OpsJob.AddAsync(newJob);
await ct.SaveChangesAsync();
return newJob;
}