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,9 +19,10 @@ namespace AyaNova.Biz
/// <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="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>
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>
/// If true, relaxes validation rules so that incomplete data can be imported
/// </summary>

View File

@@ -94,46 +94,46 @@ namespace AyaNova.Biz
//
//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
tagLists.Add("UnitModelCategory",new Dictionary<Guid, string>());
ImportTagList("GZTW.AyaNova.BLL.UnitModelCategory", job.GId, tagLists["UnitModelCategory"], importFileName, zipEntries);
TagLists.Add("UnitModelCategory",new Dictionary<Guid, string>());
ImportTagList("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);
TagLists.Add("UnitServiceType",new Dictionary<Guid, string>());
ImportTagList("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);
TagLists.Add("WorkorderItemType",new Dictionary<Guid, string>());
ImportTagList("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);
TagLists.Add("ClientGroup",new Dictionary<Guid, string>());
ImportTagList("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);
TagLists.Add("WorkorderCategory",new Dictionary<Guid, string>());
ImportTagList("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);
TagLists.Add("PartCategory",new Dictionary<Guid, string>());
ImportTagList("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);
TagLists.Add("DispatchZone",new Dictionary<Guid, string>());
ImportTagList("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);
TagLists.Add("ScheduleableUserGroup",new Dictionary<Guid, string>());
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<Guid, string>());
ImportTagList("GZTW.AyaNova.BLL.Region", job.GId, tagLists["Region"], importFileName, zipEntries);
TagLists.Add("Region",new Dictionary<Guid, string>());
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
/// <param name="importMap"></param>
/// <param name="importFileName"></param>
/// <param name="zipEntries"></param>
/// <param name="tagLists"></param>
/// <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();
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

View File

@@ -476,7 +476,7 @@ namespace AyaNova.Biz
/////////////////////////////////////////////////////////////////////
/// 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
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