This commit is contained in:
@@ -24,6 +24,7 @@ SON OF TAGS
|
||||
- Add new tag code to all taggable objects, their models and schema
|
||||
- Update seeder to tag objects with known set of tags for test and eval purposes
|
||||
- Seed widget with predictable tags (Maybe colour names "red", "green", "blue" etc)
|
||||
- Test v7 import tags users with correct scheduleable user group or whatever they will be tagged with
|
||||
|
||||
SERVER SCHEMA
|
||||
- Add unique constraint to all name columns in all tables in ayschema and run tests (how did I miss that before??)
|
||||
|
||||
@@ -94,47 +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>>();
|
||||
|
||||
//IMPORT UNIT MODEL CATEGORIES AS TAGS
|
||||
Dictionary<Guid, string> UnitModelCategoryTags = new Dictionary<Guid, string>();
|
||||
ImportTagList("GZTW.AyaNova.BLL.UnitModelCategory", job.GId, UnitModelCategoryTags, 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
|
||||
Dictionary<Guid, string> UnitServiceTypeTags = new Dictionary<Guid, string>();
|
||||
ImportTagList("GZTW.AyaNova.BLL.UnitServiceType", job.GId, UnitServiceTypeTags, 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
|
||||
Dictionary<Guid, string> WorkorderItemTypeTags = new Dictionary<Guid, string>();
|
||||
ImportTagList("GZTW.AyaNova.BLL.WorkorderItemType", job.GId, WorkorderItemTypeTags, 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
|
||||
Dictionary<Guid, string> ClientGroupTags = new Dictionary<Guid, string>();
|
||||
ImportTagList("GZTW.AyaNova.BLL.ClientGroup", job.GId, ClientGroupTags, 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
|
||||
Dictionary<Guid, string> WorkorderCategoryTags = new Dictionary<Guid, string>();
|
||||
ImportTagList("GZTW.AyaNova.BLL.WorkorderCategory", job.GId, WorkorderCategoryTags, 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
|
||||
Dictionary<Guid, string> PartCategoryTags = new Dictionary<Guid, string>();
|
||||
ImportTagList("GZTW.AyaNova.BLL.PartCategory", job.GId, PartCategoryTags, 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
|
||||
Dictionary<Guid, string> DispatchZoneTags = new Dictionary<Guid, string>();
|
||||
ImportTagList("GZTW.AyaNova.BLL.DispatchZone", job.GId, DispatchZoneTags, 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
|
||||
Dictionary<Guid, string> ScheduleableUserGroupTags = new Dictionary<Guid, string>();
|
||||
ImportTagList("GZTW.AyaNova.BLL.ScheduleableUserGroup", job.GId, ScheduleableUserGroupTags, 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
|
||||
Dictionary<Guid, string> RegionTags = new Dictionary<Guid, string>();
|
||||
ImportTagList("GZTW.AyaNova.BLL.Region", job.GId, RegionTags, importFileName, zipEntries);
|
||||
tagLists.Add("Region",new Dictionary<Guid, string>());
|
||||
ImportTagList("GZTW.AyaNova.BLL.Region", job.GId, tagLists["Region"], importFileName, zipEntries);
|
||||
|
||||
|
||||
|
||||
@@ -266,171 +265,52 @@ namespace AyaNova.Biz
|
||||
{
|
||||
|
||||
//------- IMPORT OBJECTS NAME AND ID TO LIST ------
|
||||
switch (SourceType)
|
||||
#region main import task
|
||||
var NewTagName = j["Name"].Value<string>();
|
||||
|
||||
var ShortTypeName = string.Empty;
|
||||
switch (entryStartsWith)
|
||||
{
|
||||
case "GZTW.AyaNova.BLL.Region":
|
||||
case "GZTW.AyaNova.BLL.UnitModelCategory":
|
||||
case "GZTW.AyaNova.BLL.UnitServiceType":
|
||||
case "GZTW.AyaNova.BLL.WorkorderItemType":
|
||||
case "GZTW.AyaNova.BLL.ClientGroup":
|
||||
case "GZTW.AyaNova.BLL.WorkorderCategory":
|
||||
case "GZTW.AyaNova.BLL.PartCategory":
|
||||
case "GZTW.AyaNova.BLL.DispatchZone":
|
||||
case "GZTW.AyaNova.BLL.ScheduleableUserGroup":
|
||||
{
|
||||
switch (j["IMPORT_TASK"].Value<string>())
|
||||
{
|
||||
case "main":
|
||||
{
|
||||
#region main import task
|
||||
var NewTagName = j["Name"].Value<string>();
|
||||
|
||||
var ShortTypeName = string.Empty;
|
||||
switch (SourceType)
|
||||
{
|
||||
case "GZTW.AyaNova.BLL.Region":
|
||||
ShortTypeName = "rgn";
|
||||
break;
|
||||
case "GZTW.AyaNova.BLL.UnitModelCategory":
|
||||
ShortTypeName = "unitmdlctgry";
|
||||
break;
|
||||
case "GZTW.AyaNova.BLL.UnitServiceType":
|
||||
ShortTypeName = "unitsvtyp";
|
||||
break;
|
||||
case "GZTW.AyaNova.BLL.WorkorderItemType":
|
||||
ShortTypeName = "woitemtyp";
|
||||
break;
|
||||
case "GZTW.AyaNova.BLL.ClientGroup":
|
||||
ShortTypeName = "clntgrp";
|
||||
break;
|
||||
case "GZTW.AyaNova.BLL.WorkorderCategory":
|
||||
ShortTypeName = "woctgry";
|
||||
break;
|
||||
case "GZTW.AyaNova.BLL.PartCategory":
|
||||
ShortTypeName = "prtctgry";
|
||||
break;
|
||||
case "GZTW.AyaNova.BLL.DispatchZone":
|
||||
ShortTypeName = "dspchzn";
|
||||
break;
|
||||
case "GZTW.AyaNova.BLL.ScheduleableUserGroup":
|
||||
ShortTypeName = "schdusrgrp";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
NewTagName += "." + ShortTypeName;
|
||||
var OldV7Id = new Guid(j["ID"].Value<string>());
|
||||
|
||||
//Ensure it follows the rules
|
||||
NewTagName = CleanTagName(NewTagName);
|
||||
|
||||
//There might already be a tag of the same name since so many different types of V7 objects are becoming tags
|
||||
//Weighed the pros and cons of uniquifying by object type versus just using the same name for different object types:
|
||||
//it seems to me at this point that people might desire the same exact name because if they used it that way they probably
|
||||
//intended it that way, so decision is to check if it already exists and then use that ID in the importMap instead
|
||||
//for matching other objects imported to tags
|
||||
|
||||
//Already present?
|
||||
var ExistingTag = ct.Tag.Where(m => m.Name == NewTagName).FirstOrDefault();
|
||||
if (ExistingTag != null)
|
||||
{
|
||||
//map it to the existing tag of same name
|
||||
var mapItem = new ImportAyaNova7MapItem(OldV7Id, AyaType.Tag, ExistingTag.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Tag o = await CreateAsync(NewTagName);
|
||||
if (HasErrors)
|
||||
{
|
||||
//If there are any validation errors, log in joblog and move on
|
||||
JobsBiz.LogJob(jobId, $"TagBiz::ImportV7Async -> import object \"{NewTagName}\" of type \"{SourceType}\" source id {OldV7Id.ToString()} failed validation and was not imported: {GetErrorsAsString()} ", ct);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
await ct.SaveChangesAsync();
|
||||
var mapItem = new ImportAyaNova7MapItem(OldV7Id, AyaType.Tag, o.Id);
|
||||
importMap.Add(mapItem);
|
||||
ImportAyaNova7Biz.LogEventCreatedModifiedEvents(j, importMap, AyaType.Tag, ct);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
break;
|
||||
case "scheduleableusergrouptags":
|
||||
{
|
||||
#region attribute sched user group tags
|
||||
//
|
||||
// {
|
||||
// "ID": "871e77b2-979a-4f26-930b-46f7c05fc19f",
|
||||
// "Created": "08/30/2018 08:12 AM",
|
||||
// "Modified": "08/30/2018 08:13 AM",
|
||||
// "Creator": "2ecc77fc-69e2-4a7e-b88d-bd0ecaf36aed",
|
||||
// "Modifier": "2ecc77fc-69e2-4a7e-b88d-bd0ecaf36aed",
|
||||
// "Name": "Yet another test group",
|
||||
// "Active": true,
|
||||
// "Description": "More testing yay!",
|
||||
// "ScheduleableUsers": [
|
||||
// {
|
||||
// "Created": "08/30/2018 08:13 AM",
|
||||
// "Creator": "2ecc77fc-69e2-4a7e-b88d-bd0ecaf36aed",
|
||||
// "Modified": "08/30/2018 08:13 AM",
|
||||
// "Modifier": "2ecc77fc-69e2-4a7e-b88d-bd0ecaf36aed",
|
||||
// "ID": "676475be-8301-47d0-bd54-af9dbd1fe7eb",
|
||||
// "ScheduleableUserID": "1d859264-3f32-462a-9b0c-a67dddfdf4d3",
|
||||
// "ScheduleableUserGroupID": "871e77b2-979a-4f26-930b-46f7c05fc19f"
|
||||
// },
|
||||
// {
|
||||
// "Created": "08/30/2018 08:13 AM",
|
||||
// "Creator": "2ecc77fc-69e2-4a7e-b88d-bd0ecaf36aed",
|
||||
// "Modified": "08/30/2018 08:13 AM",
|
||||
// "Modifier": "2ecc77fc-69e2-4a7e-b88d-bd0ecaf36aed",
|
||||
// "ID": "173499c3-a616-42a0-b08c-74008f8fa352",
|
||||
// "ScheduleableUserID": "42b282bb-100b-4b31-aa14-5c831d7cda66",
|
||||
// "ScheduleableUserGroupID": "871e77b2-979a-4f26-930b-46f7c05fc19f"
|
||||
// },
|
||||
// {
|
||||
// "Created": "08/30/2018 08:13 AM",
|
||||
// "Creator": "2ecc77fc-69e2-4a7e-b88d-bd0ecaf36aed",
|
||||
// "Modified": "08/30/2018 08:13 AM",
|
||||
// "Modifier": "2ecc77fc-69e2-4a7e-b88d-bd0ecaf36aed",
|
||||
// "ID": "19c9b3d6-eeb2-44ac-be4e-6ec93d15b02a",
|
||||
// "ScheduleableUserID": "e6ff9bc6-a550-4242-8c41-857f740e2841",
|
||||
// "ScheduleableUserGroupID": "871e77b2-979a-4f26-930b-46f7c05fc19f"
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
//
|
||||
var V7Id = new Guid(j["ID"].Value<string>());
|
||||
var RavenTagId = importMap.Where(m => m.V7ObjectId == V7Id).First().NewObjectAyaTypeId.ObjectId;
|
||||
|
||||
foreach (JToken t in j["ScheduleableUsers"])
|
||||
{
|
||||
var techId = new Guid(t["ScheduleableUserID"].Value<String>());
|
||||
var RavenUserId = importMap.Where(m => m.V7ObjectId == techId).First().NewObjectAyaTypeId.ObjectId;
|
||||
var Creator = importMap.Where(m => m.V7ObjectId == new Guid(t["Creator"].Value<string>())).First().NewObjectAyaTypeId.ObjectId;
|
||||
|
||||
TagMap tm = new TagMap();
|
||||
tm.TagToObjectId = RavenUserId;
|
||||
tm.TagToObjectType = AyaType.User;
|
||||
tm.TagId = RavenTagId;
|
||||
tm.OwnerId = Creator;
|
||||
ct.TagMap.Add(tm);
|
||||
}
|
||||
ct.SaveChanges();
|
||||
|
||||
#endregion
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
ShortTypeName = "region";
|
||||
break;
|
||||
case "GZTW.AyaNova.BLL.UnitModelCategory":
|
||||
ShortTypeName = "unitmodelcategory";
|
||||
break;
|
||||
case "GZTW.AyaNova.BLL.UnitServiceType":
|
||||
ShortTypeName = "unitservicetype";
|
||||
break;
|
||||
case "GZTW.AyaNova.BLL.WorkorderItemType":
|
||||
ShortTypeName = "workorderitemtype";
|
||||
break;
|
||||
case "GZTW.AyaNova.BLL.ClientGroup":
|
||||
ShortTypeName = "clientgroup";
|
||||
break;
|
||||
case "GZTW.AyaNova.BLL.WorkorderCategory":
|
||||
ShortTypeName = "workordercategory";
|
||||
break;
|
||||
case "GZTW.AyaNova.BLL.PartCategory":
|
||||
ShortTypeName = "partcategory";
|
||||
break;
|
||||
case "GZTW.AyaNova.BLL.DispatchZone":
|
||||
ShortTypeName = "dispatchzone";
|
||||
break;
|
||||
case "GZTW.AyaNova.BLL.ScheduleableUserGroup":
|
||||
ShortTypeName = "scheduleableusergroup";
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
NewTagName += "." + ShortTypeName;
|
||||
var OldV7Id = new Guid(j["ID"].Value<string>());
|
||||
|
||||
//Ensure it follows the rules
|
||||
NewTagName = TagUtil.NormalizeTag(NewTagName);
|
||||
|
||||
//Add to dictionary if not present
|
||||
tagDictionary.Add(OldV7Id, NewTagName);
|
||||
|
||||
#endregion
|
||||
|
||||
//-----------------------------------------------
|
||||
importCount++;
|
||||
|
||||
|
||||
@@ -13,13 +13,13 @@ namespace AyaNova.Biz
|
||||
List<string> outTags = new List<string>();
|
||||
foreach (var tag in inTags)
|
||||
{
|
||||
outTags.Add(CleanTagName(tag));
|
||||
outTags.Add(NormalizeTag(tag));
|
||||
}
|
||||
return outTags;
|
||||
}
|
||||
|
||||
|
||||
private static string CleanTagName(string inObj)
|
||||
public static string NormalizeTag(string inObj)
|
||||
{
|
||||
//Must be lowercase per rules
|
||||
//This may be naive when we get international customers but for now supporting utf-8 and it appears it's safe to do this with unicode
|
||||
|
||||
@@ -628,6 +628,9 @@ namespace AyaNova.Biz
|
||||
|
||||
public async Task<bool> ImportV7Async(JObject j, List<ImportAyaNova7MapItem> importMap, Guid jobId)
|
||||
{
|
||||
|
||||
//NEEDS 3 of the tag lists
|
||||
|
||||
//TODO: Some of these items will need to be imported in future USEROPTIONS object that doesn't exist yet
|
||||
#region V7 record format
|
||||
/*
|
||||
@@ -638,7 +641,7 @@ namespace AyaNova.Biz
|
||||
"Active": true,
|
||||
"ClientID": "00000000-0000-0000-0000-000000000000",
|
||||
"HeadOfficeID": "00000000-0000-0000-0000-000000000000",
|
||||
"MemberOfGroup": "0f8a80ff-4b03-4114-ae51-2d13b812dd65",
|
||||
* "MemberOfGroup": "0f8a80ff-4b03-4114-ae51-2d13b812dd65",
|
||||
"Created": "03/21/2005 07:19 AM",
|
||||
"Modified": "09/15/2015 12:22 PM",
|
||||
"Creator": "2ecc77fc-69e2-4a7e-b88d-bd0ecaf36aed",
|
||||
@@ -688,8 +691,8 @@ namespace AyaNova.Biz
|
||||
],
|
||||
"Notes": "",
|
||||
"VendorID": "06e502c2-69ba-4e88-8efb-5b53c1687740",
|
||||
"RegionID": "f856423a-d468-4344-b7b8-121e466738c6",
|
||||
"DispatchZoneID": "00000000-0000-0000-0000-000000000000",
|
||||
* "RegionID": "f856423a-d468-4344-b7b8-121e466738c6",
|
||||
* "DispatchZoneID": "00000000-0000-0000-0000-000000000000",
|
||||
"SubContractor": false,//This is not actually a feature in v7, you can just pick a vendorId for subcontractor but still be of type technician
|
||||
"DefaultWarehouseID": "d45eab37-b6e6-4ad2-9163-66d7ba83a98c",
|
||||
"Custom1": "",
|
||||
|
||||
Reference in New Issue
Block a user