This commit is contained in:
2018-12-06 23:09:21 +00:00
parent fe58775866
commit d5691501ae
4 changed files with 32 additions and 29 deletions

View File

@@ -19,8 +19,9 @@ namespace AyaNova.Biz
/// <param name="v7ImportData">Json object containing source record</param> /// <param name="v7ImportData">Json object containing source record</param>
/// <param name="importMap">A collection that can be used to match import records to new records, NOT persistent between imports</param> /// <param name="importMap">A collection that can be used to match import records to new records, NOT persistent between imports</param>
/// <param name="JobId">JobId for logging or controlling jobs from within processor</param> /// <param name="JobId">JobId for logging or controlling jobs from within processor</param>
/// <param name="tagLists">All the items imported to lists of tags with matching id for attribution / tagging imported object</param>
/// <returns>True if imported, False if not imported due to invalid or other error (logged in job log)</returns> /// <returns>True if imported, False if not imported due to invalid or other error (logged in job log)</returns>
Task<bool> ImportV7Async(JObject v7ImportData, List<ImportAyaNova7MapItem> importMap, Guid JobId); Task<bool> ImportV7Async(JObject v7ImportData, List<ImportAyaNova7MapItem> importMap, Guid JobId, Dictionary<string, Dictionary<Guid, string>> tagLists);
/// <summary> /// <summary>
/// If true, relaxes validation rules so that incomplete data can be imported /// If true, relaxes validation rules so that incomplete data can be imported

View File

@@ -94,46 +94,46 @@ namespace AyaNova.Biz
// //
//FIRST: import items that will become tags first into temporary cache lists //FIRST: import items that will become tags first into temporary cache lists
Dictionary<string,Dictionary<Guid,string>> tagLists=new Dictionary<string, Dictionary<Guid, string>>(); Dictionary<string,Dictionary<Guid,string>> TagLists=new Dictionary<string, Dictionary<Guid, string>>();
//IMPORT UNIT MODEL CATEGORIES AS TAGS //IMPORT UNIT MODEL CATEGORIES AS TAGS
tagLists.Add("UnitModelCategory",new Dictionary<Guid, string>()); TagLists.Add("UnitModelCategory",new Dictionary<Guid, string>());
ImportTagList("GZTW.AyaNova.BLL.UnitModelCategory", job.GId, tagLists["UnitModelCategory"], importFileName, zipEntries); ImportTagList("GZTW.AyaNova.BLL.UnitModelCategory", job.GId, TagLists["UnitModelCategory"], importFileName, zipEntries);
//IMPORT Unit service type AS TAGS //IMPORT Unit service type AS TAGS
tagLists.Add("UnitServiceType",new Dictionary<Guid, string>()); TagLists.Add("UnitServiceType",new Dictionary<Guid, string>());
ImportTagList("GZTW.AyaNova.BLL.UnitServiceType", job.GId, tagLists["UnitServiceType"], importFileName, zipEntries); ImportTagList("GZTW.AyaNova.BLL.UnitServiceType", job.GId, TagLists["UnitServiceType"], importFileName, zipEntries);
//IMPORT Workorder Item Type AS TAGS //IMPORT Workorder Item Type AS TAGS
tagLists.Add("WorkorderItemType",new Dictionary<Guid, string>()); TagLists.Add("WorkorderItemType",new Dictionary<Guid, string>());
ImportTagList("GZTW.AyaNova.BLL.WorkorderItemType", job.GId, tagLists["WorkorderItemType"], importFileName, zipEntries); ImportTagList("GZTW.AyaNova.BLL.WorkorderItemType", job.GId, TagLists["WorkorderItemType"], importFileName, zipEntries);
//IMPORT Client group AS TAGS //IMPORT Client group AS TAGS
tagLists.Add("ClientGroup",new Dictionary<Guid, string>()); TagLists.Add("ClientGroup",new Dictionary<Guid, string>());
ImportTagList("GZTW.AyaNova.BLL.ClientGroup", job.GId, tagLists["ClientGroup"], importFileName, zipEntries); ImportTagList("GZTW.AyaNova.BLL.ClientGroup", job.GId, TagLists["ClientGroup"], importFileName, zipEntries);
//IMPORT Workorder category AS TAGS //IMPORT Workorder category AS TAGS
tagLists.Add("WorkorderCategory",new Dictionary<Guid, string>()); TagLists.Add("WorkorderCategory",new Dictionary<Guid, string>());
ImportTagList("GZTW.AyaNova.BLL.WorkorderCategory", job.GId, tagLists["WorkorderCategory"], importFileName, zipEntries); ImportTagList("GZTW.AyaNova.BLL.WorkorderCategory", job.GId, TagLists["WorkorderCategory"], importFileName, zipEntries);
//IMPORT Part Category AS TAGS //IMPORT Part Category AS TAGS
tagLists.Add("PartCategory",new Dictionary<Guid, string>()); TagLists.Add("PartCategory",new Dictionary<Guid, string>());
ImportTagList("GZTW.AyaNova.BLL.PartCategory", job.GId, tagLists["PartCategory"], importFileName, zipEntries); ImportTagList("GZTW.AyaNova.BLL.PartCategory", job.GId, TagLists["PartCategory"], importFileName, zipEntries);
//IMPORT Dispatch zones AS TAGS //IMPORT Dispatch zones AS TAGS
tagLists.Add("DispatchZone",new Dictionary<Guid, string>()); TagLists.Add("DispatchZone",new Dictionary<Guid, string>());
ImportTagList("GZTW.AyaNova.BLL.DispatchZone", job.GId, tagLists["DispatchZone"], importFileName, zipEntries); ImportTagList("GZTW.AyaNova.BLL.DispatchZone", job.GId, TagLists["DispatchZone"], importFileName, zipEntries);
//IMPORT Scheduleable User Groups AS TAGS //IMPORT Scheduleable User Groups AS TAGS
tagLists.Add("ScheduleableUserGroup",new Dictionary<Guid, string>()); TagLists.Add("ScheduleableUserGroup",new Dictionary<Guid, string>());
ImportTagList("GZTW.AyaNova.BLL.ScheduleableUserGroup", job.GId, tagLists["ScheduleableUserGroup"], importFileName, zipEntries); ImportTagList("GZTW.AyaNova.BLL.ScheduleableUserGroup", job.GId, TagLists["ScheduleableUserGroup"], importFileName, zipEntries);
//Now can set users to correct tag for scheduleable user group //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); // await ImportTagList("GZTW.AyaNova.BLL.ScheduleableUserGroup", "scheduleableusergrouptags", AyaType.Tag, job.GId, importMap, importFileName, zipEntries);
//IMPORT REGIONS AS TAGS //IMPORT REGIONS AS TAGS
tagLists.Add("Region",new Dictionary<Guid, string>()); TagLists.Add("Region",new Dictionary<Guid, string>());
ImportTagList("GZTW.AyaNova.BLL.Region", job.GId, tagLists["Region"], importFileName, zipEntries); ImportTagList("GZTW.AyaNova.BLL.Region", job.GId, TagLists["Region"], importFileName, zipEntries);
@@ -142,16 +142,16 @@ namespace AyaNova.Biz
// //
//USERS //USERS
await DoImport("GZTW.AyaNova.BLL.User", "main", AyaType.User, job.GId, importMap, importFileName, zipEntries); await DoImport("GZTW.AyaNova.BLL.User", "main", AyaType.User, job.GId, importMap, importFileName, zipEntries, TagLists);
//Now can do event log entries //Now can do event log entries
await DoImport("GZTW.AyaNova.BLL.User", "eventlog", AyaType.User, job.GId, importMap, importFileName, zipEntries); await DoImport("GZTW.AyaNova.BLL.User", "eventlog", AyaType.User, job.GId, importMap, importFileName, zipEntries, TagLists);
//IMPORT LOCALES //IMPORT LOCALES
await DoImport("GZTW.AyaNova.BLL.Locale", "main", AyaType.Locale, job.GId, importMap, importFileName, zipEntries); await DoImport("GZTW.AyaNova.BLL.Locale", "main", AyaType.Locale, job.GId, importMap, importFileName, zipEntries, TagLists);
//Now can do user locale settings properly //Now can do user locale settings properly
await DoImport("GZTW.AyaNova.BLL.User", "locale", AyaType.User, job.GId, importMap, importFileName, zipEntries); await DoImport("GZTW.AyaNova.BLL.User", "locale", AyaType.User, job.GId, importMap, importFileName, zipEntries, TagLists);
//TODO: CLIENT //TODO: CLIENT
//do import for client here //do import for client here
@@ -185,8 +185,10 @@ namespace AyaNova.Biz
/// <param name="importMap"></param> /// <param name="importMap"></param>
/// <param name="importFileName"></param> /// <param name="importFileName"></param>
/// <param name="zipEntries"></param> /// <param name="zipEntries"></param>
/// <param name="tagLists"></param>
/// <returns></returns> /// <returns></returns>
private async Task DoImport(string entryStartsWith, string importTask, AyaType importerType, Guid jobId, List<ImportAyaNova7MapItem> importMap, string importFileName, List<string> zipEntries) private async Task DoImport(string entryStartsWith, string importTask, AyaType importerType, Guid jobId,
List<ImportAyaNova7MapItem> importMap, string importFileName, List<string> zipEntries, Dictionary<string, Dictionary<Guid, string>> tagLists)
{ {
var zipObjectList = zipEntries.Where(m => m.StartsWith(entryStartsWith)).ToList(); var zipObjectList = zipEntries.Where(m => m.StartsWith(entryStartsWith)).ToList();
long importCount = 0; long importCount = 0;
@@ -215,7 +217,7 @@ namespace AyaNova.Biz
j.Add("V7_TYPE", JToken.FromObject(entryStartsWith)); j.Add("V7_TYPE", JToken.FromObject(entryStartsWith));
j.Add("IMPORT_TASK", JToken.FromObject(importTask)); j.Add("IMPORT_TASK", JToken.FromObject(importTask));
bImportSucceeded = await o.ImportV7Async(j, importMap, jobId); bImportSucceeded = await o.ImportV7Async(j, importMap, jobId, tagLists);
if (bImportSucceeded) if (bImportSucceeded)
importCount++; importCount++;
else else

View File

@@ -476,7 +476,7 @@ 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, Dictionary<string, Dictionary<Guid, string>> tagLists)
{ {
//some types need to import from more than one source hence the seemingly redundant switch statement for futureproofing //some types need to import from more than one source hence the seemingly redundant switch statement for futureproofing
switch (j["IMPORT_TASK"].Value<string>()) switch (j["IMPORT_TASK"].Value<string>())

View File

@@ -626,7 +626,7 @@ namespace AyaNova.Biz
public async Task<bool> ImportV7Async(JObject j, List<ImportAyaNova7MapItem> importMap, Guid jobId) public async Task<bool> ImportV7Async(JObject j, List<ImportAyaNova7MapItem> importMap, Guid jobId, Dictionary<string, Dictionary<Guid, string>> tagLists)
{ {
//NEEDS 3 of the tag lists //NEEDS 3 of the tag lists