This commit is contained in:
@@ -60,7 +60,7 @@ namespace AyaNova.Biz
|
|||||||
//NOTE: If this code throws an exception the caller will automatically set the job to failed and log the exeption so
|
//NOTE: If this code throws an exception the caller will automatically set the job to failed and log the exeption so
|
||||||
//basically any error condition during job processing should throw up an exception if it can't be handled
|
//basically any error condition during job processing should throw up an exception if it can't be handled
|
||||||
List<ImportAyaNova7MapItem> importMap = new List<ImportAyaNova7MapItem>();
|
List<ImportAyaNova7MapItem> importMap = new List<ImportAyaNova7MapItem>();
|
||||||
|
|
||||||
JobsBiz.UpdateJobStatus(job.GId, JobStatus.Running, ct);
|
JobsBiz.UpdateJobStatus(job.GId, JobStatus.Running, ct);
|
||||||
JobsBiz.LogJob(job.GId, $"ImportAyaNova7 starting", ct);
|
JobsBiz.LogJob(job.GId, $"ImportAyaNova7 starting", ct);
|
||||||
|
|
||||||
@@ -86,24 +86,27 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
//Pass off the JSON data from the import file into the import job item by item
|
//Pass off the JSON data from the import file into the import job item by item
|
||||||
|
|
||||||
// TAGS
|
// TAGS
|
||||||
// - Unit model category
|
// - Unit model category
|
||||||
// - Unit service type
|
// - Unit service type
|
||||||
// - Workorder Item Type
|
// - Workorder Item Type
|
||||||
// - Client group
|
// - Client group
|
||||||
// - Workorder category
|
// - Workorder category
|
||||||
// - REGIONS
|
// - REGIONS
|
||||||
// - PartCategory
|
// - PartCategory
|
||||||
// - Dispatch zones
|
// - Dispatch zones
|
||||||
// - ScheduleableUserGroups
|
// - ScheduleableUserGroups
|
||||||
|
|
||||||
//USERS - Import first so all other objects can be properly attributed in event log
|
//USERS - Import first so all other objects can be properly attributed in event log
|
||||||
|
|
||||||
|
|
||||||
|
//IMPORT UNIT MODEL CATEGORIES AS TAGS
|
||||||
|
await DoImport("GZTW.AyaNova.BLL.UnitModelCategory", AyaType.Tag, job.GId, importMap, importFileName, zipEntries);
|
||||||
|
|
||||||
//IMPORT REGIONS AS TAGS
|
//IMPORT REGIONS AS TAGS
|
||||||
await DoImport("GZTW.AyaNova.BLL.Region", AyaType.Tag, job.GId, importMap, importFileName, zipEntries);
|
await DoImport("GZTW.AyaNova.BLL.Region", AyaType.Tag, job.GId, importMap, importFileName, zipEntries);
|
||||||
|
|
||||||
//IMPORT LOCALES
|
//IMPORT LOCALES
|
||||||
await DoImport("GZTW.AyaNova.BLL.Locale", AyaType.Locale, job.GId, importMap, importFileName, zipEntries);
|
await DoImport("GZTW.AyaNova.BLL.Locale", AyaType.Locale, job.GId, importMap, importFileName, zipEntries);
|
||||||
|
|
||||||
JobsBiz.LogJob(job.GId, "ImportAyaNova7 finished", ct);
|
JobsBiz.LogJob(job.GId, "ImportAyaNova7 finished", ct);
|
||||||
|
|||||||
@@ -233,9 +233,11 @@ namespace AyaNova.Biz
|
|||||||
/// IMPORT v7 implementation
|
/// IMPORT v7 implementation
|
||||||
public async Task<bool> ImportV7Async(JObject j, List<ImportAyaNova7MapItem> importMap, Guid jobId)
|
public async Task<bool> ImportV7Async(JObject j, List<ImportAyaNova7MapItem> importMap, Guid jobId)
|
||||||
{
|
{
|
||||||
switch (j["V7_TYPE"].Value<string>())
|
string SourceType=j["V7_TYPE"].Value<string>();
|
||||||
|
switch (SourceType)
|
||||||
{
|
{
|
||||||
case "GZTW.AyaNova.BLL.Region":
|
case "GZTW.AyaNova.BLL.Region":
|
||||||
|
case "GZTW.AyaNova.BLL.UnitModelCategory":
|
||||||
{
|
{
|
||||||
var name = j["Name"].Value<string>();
|
var name = j["Name"].Value<string>();
|
||||||
var oldId = new Guid(j["ID"].Value<string>());
|
var oldId = new Guid(j["ID"].Value<string>());
|
||||||
@@ -243,11 +245,19 @@ namespace AyaNova.Biz
|
|||||||
//In RAVEN tags can only be 35 characters
|
//In RAVEN tags can only be 35 characters
|
||||||
name = StringUtil.MaxLength(name, 35);
|
name = StringUtil.MaxLength(name, 35);
|
||||||
|
|
||||||
|
//There might already be a tag of the same name since so many different types of V7 objects are becoming tags
|
||||||
|
//Weighed the pros and cons of uniquifying by object type versus just using the same name for different object types:
|
||||||
|
//it seems to me at this point that people might desire the same exact name because if they used it that way they probably
|
||||||
|
//intended it that way, so this bit of code will check if it already exists and then use that ID in the importMap instead
|
||||||
|
//for matching other objects imported to tags
|
||||||
|
if (ct.Tag.Where(m => m.Name == inObj).FirstOrDefault() != null)
|
||||||
|
|
||||||
|
|
||||||
Tag o = await CreateAsync(name);
|
Tag o = await CreateAsync(name);
|
||||||
if (HasErrors)
|
if (HasErrors)
|
||||||
{
|
{
|
||||||
//If there are any validation errors, log in joblog and move on
|
//If there are any validation errors, log in joblog and move on
|
||||||
JobsBiz.LogJob(jobId, $"TagBiz::ImportV7Async -> import object \"{name}\" source id {oldId.ToString()} failed validation and was not imported: {GetErrorsAsString()} ", ct);
|
JobsBiz.LogJob(jobId, $"TagBiz::ImportV7Async -> import object \"{name}\" of type \"{SourceType}\" source id {oldId.ToString()} failed validation and was not imported: {GetErrorsAsString()} ", ct);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -261,6 +271,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//this is the equivalent of returning void for a Task signature with nothing to return
|
//this is the equivalent of returning void for a Task signature with nothing to return
|
||||||
|
|||||||
Reference in New Issue
Block a user