This commit is contained in:
2018-08-31 20:21:55 +00:00
parent 0a3e98c27f
commit 57f5d38a28
4 changed files with 89 additions and 23 deletions

View File

@@ -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

View File

@@ -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<ImportAyaNova7MapItem> importMap, AyaType ayaType, AyContext ct)
{
var V7Id = new Guid(j["ID"].Value<string>());
var RavenId = importMap.Where(m => m.V7ObjectId == V7Id).First().NewObjectAyaTypeId.ObjectId;
var Creator = importMap.Where(m => m.V7ObjectId == new Guid(j["Creator"].Value<string>())).First().NewObjectAyaTypeId.ObjectId;
var Modifier = importMap.Where(m => m.V7ObjectId == new Guid(j["Modifier"].Value<string>())).First().NewObjectAyaTypeId.ObjectId;
var Created = j["Created"].Value<DateTime>();
var Modified = j["Modified"].Value<DateTime>();
//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

View File

@@ -259,6 +259,41 @@ namespace AyaNova.Biz
case "GZTW.AyaNova.BLL.ScheduleableUserGroup":
{
var NewTagName = j["Name"].Value<string>();
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<string>());
//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();
}
}

View File

@@ -474,20 +474,7 @@ namespace AyaNova.Biz
break;
case "eventlog":
{
var V7Id = new Guid(j["ID"].Value<string>());
var RavenUserId = importMap.Where(m => m.V7ObjectId == V7Id).First().NewObjectAyaTypeId.ObjectId;
var Creator = importMap.Where(m => m.V7ObjectId == new Guid(j["Creator"].Value<string>())).First().NewObjectAyaTypeId.ObjectId;
var Modifier = importMap.Where(m => m.V7ObjectId == new Guid(j["Modifier"].Value<string>())).First().NewObjectAyaTypeId.ObjectId;
var Created = j["Created"].Value<DateTime>();
var Modified = j["Modified"].Value<DateTime>();
//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<ImportAyaNova7MapItem> importMap, AyaType ayaType, AyContext ct)
// {
// var V7Id = new Guid(j["ID"].Value<string>());
// var RavenUserId = importMap.Where(m => m.V7ObjectId == V7Id).First().NewObjectAyaTypeId.ObjectId;
// var Creator = importMap.Where(m => m.V7ObjectId == new Guid(j["Creator"].Value<string>())).First().NewObjectAyaTypeId.ObjectId;
// var Modifier = importMap.Where(m => m.V7ObjectId == new Guid(j["Modifier"].Value<string>())).First().NewObjectAyaTypeId.ObjectId;
// var Created = j["Created"].Value<DateTime>();
// var Modified = j["Modified"].Value<DateTime>();
// //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...