From 57f5d38a2825179d2a6027314d8f2c5047fefd1b Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 31 Aug 2018 20:21:55 +0000 Subject: [PATCH] --- devdocs/todo.txt | 2 ++ server/AyaNova/biz/ImportAyaNova7Biz.cs | 37 +++++++++++++++++----- server/AyaNova/biz/TagBiz.cs | 41 +++++++++++++++++++++++-- server/AyaNova/biz/UserBiz.cs | 32 ++++++++++--------- 4 files changed, 89 insertions(+), 23 deletions(-) diff --git a/devdocs/todo.txt b/devdocs/todo.txt index 74cf046f..aeb1b06d 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -23,6 +23,8 @@ Overall plan for now: anything standing in the way of making the initial client - Do a First test run of importing from v7 just to ensure it's fundamentally working - Then continue on to flesh out the User import second pass stuff - Then test + - V7 import tags and other objects make sure the proper attribution and dates are set in the event log, + - Right now it looks like it just defaults to manager and today and created and that's it. - Why are inactive users allowed to login? - Seed data is seeding users inactive, sb active - Event log make sure can set the date and time to prior values for importing diff --git a/server/AyaNova/biz/ImportAyaNova7Biz.cs b/server/AyaNova/biz/ImportAyaNova7Biz.cs index 12122595..941d3e70 100644 --- a/server/AyaNova/biz/ImportAyaNova7Biz.cs +++ b/server/AyaNova/biz/ImportAyaNova7Biz.cs @@ -208,25 +208,25 @@ namespace AyaNova.Biz if (importCount > 0) { if (importTask != "main") - { + { JobsBiz.LogJob(jobId, $"Successfully ran import subtask {importTask} on {importCount.ToString()} of {zipObjectList.Count.ToString()} {entryStartsWith} objects", ct); } else { JobsBiz.LogJob(jobId, $"Successfully imported {importCount.ToString()} of {zipObjectList.Count.ToString()} {entryStartsWith} objects", ct); - } + } } if (notImportCount > 0) { - if (importTask != "main") - { - JobsBiz.LogJob(jobId, $"Failed to run import subtask {importTask} on {notImportCount.ToString()} of {zipObjectList.Count.ToString()} {entryStartsWith} objects", ct); + if (importTask != "main") + { + JobsBiz.LogJob(jobId, $"Failed to run import subtask {importTask} on {notImportCount.ToString()} of {zipObjectList.Count.ToString()} {entryStartsWith} objects", ct); } else { - JobsBiz.LogJob(jobId, $"Did not import {notImportCount.ToString()} of {zipObjectList.Count.ToString()} {entryStartsWith} objects", ct); - } + JobsBiz.LogJob(jobId, $"Did not import {notImportCount.ToString()} of {zipObjectList.Count.ToString()} {entryStartsWith} objects", ct); + } } } } @@ -235,6 +235,29 @@ namespace AyaNova.Biz + + + + + ////////////////////////////////////////////////////////////////// + //UTILITIES + internal static async Task LogEventCreatedModifiedEvents(JObject j, List importMap, AyaType ayaType, AyContext ct) + { + var V7Id = new Guid(j["ID"].Value()); + var RavenId = importMap.Where(m => m.V7ObjectId == V7Id).First().NewObjectAyaTypeId.ObjectId; + var Creator = importMap.Where(m => m.V7ObjectId == new Guid(j["Creator"].Value())).First().NewObjectAyaTypeId.ObjectId; + var Modifier = importMap.Where(m => m.V7ObjectId == new Guid(j["Modifier"].Value())).First().NewObjectAyaTypeId.ObjectId; + var Created = j["Created"].Value(); + var Modified = j["Modified"].Value(); + + //handle EventLog entries for users now that we have the user's created + //Created + EventLogProcessor.AddEntry(new Event(Creator, RavenId, ayaType, AyaEvent.Created, Created), ct); + //MODIFIED + EventLogProcessor.AddEntry(new Event(Modifier, RavenId, ayaType, AyaEvent.Modified, Modified), ct); + await ct.SaveChangesAsync(); + } + ///////////////////////////////////////////////////////////////////// }//eoc diff --git a/server/AyaNova/biz/TagBiz.cs b/server/AyaNova/biz/TagBiz.cs index 4562a97f..ae724917 100644 --- a/server/AyaNova/biz/TagBiz.cs +++ b/server/AyaNova/biz/TagBiz.cs @@ -259,6 +259,41 @@ namespace AyaNova.Biz case "GZTW.AyaNova.BLL.ScheduleableUserGroup": { var NewTagName = j["Name"].Value(); + + var ShortTypeName = string.Empty; + switch (SourceType) + { + case "GZTW.AyaNova.BLL.Region": + ShortTypeName = "region"; + break; + case "GZTW.AyaNova.BLL.UnitModelCategory": + ShortTypeName = "unit-mdl-ctgry"; + break; + case "GZTW.AyaNova.BLL.UnitServiceType": + ShortTypeName = "unit-svc-typ"; + break; + case "GZTW.AyaNova.BLL.WorkorderItemType": + ShortTypeName = "wo-item-typ"; + break; + case "GZTW.AyaNova.BLL.ClientGroup": + ShortTypeName = "clnt-grp"; + break; + case "GZTW.AyaNova.BLL.WorkorderCategory": + ShortTypeName = "wo-ctgry"; + break; + case "GZTW.AyaNova.BLL.PartCategory": + ShortTypeName = "prt-ctgry"; + break; + case "GZTW.AyaNova.BLL.DispatchZone": + ShortTypeName = "dspch-zn"; + break; + case "GZTW.AyaNova.BLL.ScheduleableUserGroup": + ShortTypeName = "schd-usr-grp"; + break; + } + + + NewTagName += "." + ShortTypeName; var OldV7Id = new Guid(j["ID"].Value()); //Ensure it follows the rules @@ -291,9 +326,11 @@ namespace AyaNova.Biz { await ct.SaveChangesAsync(); var mapItem = new ImportAyaNova7MapItem(OldV7Id, AyaType.Tag, o.Id); + importMap.Add(mapItem); + await ImportAyaNova7Biz.LogEventCreatedModifiedEvents(j, importMap, AyaType.Tag, ct); //Log - EventLogProcessor.AddEntry(new Event(userId, o.Id, AyaType.Tag, AyaEvent.Created), ct); - await ct.SaveChangesAsync(); + // EventLogProcessor.AddEntry(new Event(userId, o.Id, AyaType.Tag, AyaEvent.Created), ct); + // await ct.SaveChangesAsync(); } } diff --git a/server/AyaNova/biz/UserBiz.cs b/server/AyaNova/biz/UserBiz.cs index ea9350cb..51b6fa77 100644 --- a/server/AyaNova/biz/UserBiz.cs +++ b/server/AyaNova/biz/UserBiz.cs @@ -474,20 +474,7 @@ namespace AyaNova.Biz break; case "eventlog": { - var V7Id = new Guid(j["ID"].Value()); - var RavenUserId = importMap.Where(m => m.V7ObjectId == V7Id).First().NewObjectAyaTypeId.ObjectId; - var Creator = importMap.Where(m => m.V7ObjectId == new Guid(j["Creator"].Value())).First().NewObjectAyaTypeId.ObjectId; - var Modifier = importMap.Where(m => m.V7ObjectId == new Guid(j["Modifier"].Value())).First().NewObjectAyaTypeId.ObjectId; - var Created = j["Created"].Value(); - var Modified = j["Modified"].Value(); - - //handle EventLog entries for users now that we have the user's created - //Created - EventLogProcessor.AddEntry(new Event(Creator, RavenUserId, AyaType.User, AyaEvent.Created, Created), ct); - //MODIFIED - EventLogProcessor.AddEntry(new Event(Modifier, RavenUserId, AyaType.User, AyaEvent.Modified, Modified), ct); - await ct.SaveChangesAsync(); - + await ImportAyaNova7Biz.LogEventCreatedModifiedEvents(j, importMap, AyaType.User, ct); } break; case "locale": @@ -577,6 +564,23 @@ namespace AyaNova.Biz } + // private static async Task LogEventCreatedModifiedEvents(JObject j, List importMap, AyaType ayaType, AyContext ct) + // { + // var V7Id = new Guid(j["ID"].Value()); + // var RavenUserId = importMap.Where(m => m.V7ObjectId == V7Id).First().NewObjectAyaTypeId.ObjectId; + // var Creator = importMap.Where(m => m.V7ObjectId == new Guid(j["Creator"].Value())).First().NewObjectAyaTypeId.ObjectId; + // var Modifier = importMap.Where(m => m.V7ObjectId == new Guid(j["Modifier"].Value())).First().NewObjectAyaTypeId.ObjectId; + // var Created = j["Created"].Value(); + // var Modified = j["Modified"].Value(); + + // //handle EventLog entries for users now that we have the user's created + // //Created + // EventLogProcessor.AddEntry(new Event(Creator, RavenUserId, AyaType.User, AyaEvent.Created, Created), ct); + // //MODIFIED + // EventLogProcessor.AddEntry(new Event(Modifier, RavenUserId, AyaType.User, AyaEvent.Modified, Modified), ct); + // await ct.SaveChangesAsync(); + // } + //Other job handlers here...