From d5691501ae60d6133812b9d064d2b2f2ee7fb80e Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 6 Dec 2018 23:09:21 +0000 Subject: [PATCH] --- server/AyaNova/biz/IImportAyaNova7Object.cs | 5 +- server/AyaNova/biz/ImportAyaNova7Biz.cs | 52 +++++++++++---------- server/AyaNova/biz/LocaleBiz.cs | 2 +- server/AyaNova/biz/UserBiz.cs | 2 +- 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/server/AyaNova/biz/IImportAyaNova7Object.cs b/server/AyaNova/biz/IImportAyaNova7Object.cs index 4f7d3a1e..141bce1b 100644 --- a/server/AyaNova/biz/IImportAyaNova7Object.cs +++ b/server/AyaNova/biz/IImportAyaNova7Object.cs @@ -19,9 +19,10 @@ namespace AyaNova.Biz /// Json object containing source record /// A collection that can be used to match import records to new records, NOT persistent between imports /// JobId for logging or controlling jobs from within processor + /// All the items imported to lists of tags with matching id for attribution / tagging imported object /// True if imported, False if not imported due to invalid or other error (logged in job log) - Task ImportV7Async(JObject v7ImportData, List importMap, Guid JobId); - + Task ImportV7Async(JObject v7ImportData, List importMap, Guid JobId, Dictionary> tagLists); + /// /// If true, relaxes validation rules so that incomplete data can be imported /// diff --git a/server/AyaNova/biz/ImportAyaNova7Biz.cs b/server/AyaNova/biz/ImportAyaNova7Biz.cs index c2b63d70..8912fa9e 100644 --- a/server/AyaNova/biz/ImportAyaNova7Biz.cs +++ b/server/AyaNova/biz/ImportAyaNova7Biz.cs @@ -94,46 +94,46 @@ namespace AyaNova.Biz // //FIRST: import items that will become tags first into temporary cache lists - Dictionary> tagLists=new Dictionary>(); + Dictionary> TagLists=new Dictionary>(); //IMPORT UNIT MODEL CATEGORIES AS TAGS - tagLists.Add("UnitModelCategory",new Dictionary()); - ImportTagList("GZTW.AyaNova.BLL.UnitModelCategory", job.GId, tagLists["UnitModelCategory"], importFileName, zipEntries); + TagLists.Add("UnitModelCategory",new Dictionary()); + ImportTagList("GZTW.AyaNova.BLL.UnitModelCategory", job.GId, TagLists["UnitModelCategory"], importFileName, zipEntries); //IMPORT Unit service type AS TAGS - tagLists.Add("UnitServiceType",new Dictionary()); - ImportTagList("GZTW.AyaNova.BLL.UnitServiceType", job.GId, tagLists["UnitServiceType"], importFileName, zipEntries); + TagLists.Add("UnitServiceType",new Dictionary()); + ImportTagList("GZTW.AyaNova.BLL.UnitServiceType", job.GId, TagLists["UnitServiceType"], importFileName, zipEntries); //IMPORT Workorder Item Type AS TAGS - tagLists.Add("WorkorderItemType",new Dictionary()); - ImportTagList("GZTW.AyaNova.BLL.WorkorderItemType", job.GId, tagLists["WorkorderItemType"], importFileName, zipEntries); + TagLists.Add("WorkorderItemType",new Dictionary()); + ImportTagList("GZTW.AyaNova.BLL.WorkorderItemType", job.GId, TagLists["WorkorderItemType"], importFileName, zipEntries); //IMPORT Client group AS TAGS - tagLists.Add("ClientGroup",new Dictionary()); - ImportTagList("GZTW.AyaNova.BLL.ClientGroup", job.GId, tagLists["ClientGroup"], importFileName, zipEntries); + TagLists.Add("ClientGroup",new Dictionary()); + ImportTagList("GZTW.AyaNova.BLL.ClientGroup", job.GId, TagLists["ClientGroup"], importFileName, zipEntries); //IMPORT Workorder category AS TAGS - tagLists.Add("WorkorderCategory",new Dictionary()); - ImportTagList("GZTW.AyaNova.BLL.WorkorderCategory", job.GId, tagLists["WorkorderCategory"], importFileName, zipEntries); + TagLists.Add("WorkorderCategory",new Dictionary()); + ImportTagList("GZTW.AyaNova.BLL.WorkorderCategory", job.GId, TagLists["WorkorderCategory"], importFileName, zipEntries); //IMPORT Part Category AS TAGS - tagLists.Add("PartCategory",new Dictionary()); - ImportTagList("GZTW.AyaNova.BLL.PartCategory", job.GId, tagLists["PartCategory"], importFileName, zipEntries); + TagLists.Add("PartCategory",new Dictionary()); + ImportTagList("GZTW.AyaNova.BLL.PartCategory", job.GId, TagLists["PartCategory"], importFileName, zipEntries); //IMPORT Dispatch zones AS TAGS - tagLists.Add("DispatchZone",new Dictionary()); - ImportTagList("GZTW.AyaNova.BLL.DispatchZone", job.GId, tagLists["DispatchZone"], importFileName, zipEntries); + TagLists.Add("DispatchZone",new Dictionary()); + ImportTagList("GZTW.AyaNova.BLL.DispatchZone", job.GId, TagLists["DispatchZone"], importFileName, zipEntries); //IMPORT Scheduleable User Groups AS TAGS - tagLists.Add("ScheduleableUserGroup",new Dictionary()); - ImportTagList("GZTW.AyaNova.BLL.ScheduleableUserGroup", job.GId, tagLists["ScheduleableUserGroup"], importFileName, zipEntries); + TagLists.Add("ScheduleableUserGroup",new Dictionary()); + ImportTagList("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()); - ImportTagList("GZTW.AyaNova.BLL.Region", job.GId, tagLists["Region"], importFileName, zipEntries); + TagLists.Add("Region",new Dictionary()); + ImportTagList("GZTW.AyaNova.BLL.Region", job.GId, TagLists["Region"], importFileName, zipEntries); @@ -142,16 +142,16 @@ namespace AyaNova.Biz // //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 - 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 - 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 - 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 //do import for client here @@ -185,8 +185,10 @@ namespace AyaNova.Biz /// /// /// + /// /// - private async Task DoImport(string entryStartsWith, string importTask, AyaType importerType, Guid jobId, List importMap, string importFileName, List zipEntries) + private async Task DoImport(string entryStartsWith, string importTask, AyaType importerType, Guid jobId, + List importMap, string importFileName, List zipEntries, Dictionary> tagLists) { var zipObjectList = zipEntries.Where(m => m.StartsWith(entryStartsWith)).ToList(); long importCount = 0; @@ -215,7 +217,7 @@ namespace AyaNova.Biz j.Add("V7_TYPE", JToken.FromObject(entryStartsWith)); j.Add("IMPORT_TASK", JToken.FromObject(importTask)); - bImportSucceeded = await o.ImportV7Async(j, importMap, jobId); + bImportSucceeded = await o.ImportV7Async(j, importMap, jobId, tagLists); if (bImportSucceeded) importCount++; else diff --git a/server/AyaNova/biz/LocaleBiz.cs b/server/AyaNova/biz/LocaleBiz.cs index 6eddd2db..4348abfd 100644 --- a/server/AyaNova/biz/LocaleBiz.cs +++ b/server/AyaNova/biz/LocaleBiz.cs @@ -476,7 +476,7 @@ namespace AyaNova.Biz ///////////////////////////////////////////////////////////////////// /// IMPORT v7 implementation - public async Task ImportV7Async(JObject j, List importMap, Guid jobId) + public async Task ImportV7Async(JObject j, List importMap, Guid jobId, Dictionary> tagLists) { //some types need to import from more than one source hence the seemingly redundant switch statement for futureproofing switch (j["IMPORT_TASK"].Value()) diff --git a/server/AyaNova/biz/UserBiz.cs b/server/AyaNova/biz/UserBiz.cs index ca66c4b4..64f7a0e8 100644 --- a/server/AyaNova/biz/UserBiz.cs +++ b/server/AyaNova/biz/UserBiz.cs @@ -626,7 +626,7 @@ namespace AyaNova.Biz - public async Task ImportV7Async(JObject j, List importMap, Guid jobId) + public async Task ImportV7Async(JObject j, List importMap, Guid jobId, Dictionary> tagLists) { //NEEDS 3 of the tag lists