This commit is contained in:
@@ -233,45 +233,54 @@ namespace AyaNova.Biz
|
|||||||
/// IMPORT v7 implementation
|
/// 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)
|
||||||
{
|
{
|
||||||
string SourceType=j["V7_TYPE"].Value<string>();
|
string SourceType = j["V7_TYPE"].Value<string>();
|
||||||
switch (SourceType)
|
switch (SourceType)
|
||||||
{
|
{
|
||||||
case "GZTW.AyaNova.BLL.Region":
|
case "GZTW.AyaNova.BLL.Region":
|
||||||
case "GZTW.AyaNova.BLL.UnitModelCategory":
|
case "GZTW.AyaNova.BLL.UnitModelCategory":
|
||||||
{
|
{
|
||||||
var name = j["Name"].Value<string>();
|
var NewTagName = j["Name"].Value<string>();
|
||||||
var oldId = new Guid(j["ID"].Value<string>());
|
var OldV7Id = new Guid(j["ID"].Value<string>());
|
||||||
|
|
||||||
//In RAVEN tags can only be 35 characters
|
//In RAVEN tags can only be 35 characters
|
||||||
name = StringUtil.MaxLength(name, 35);
|
NewTagName = StringUtil.MaxLength(NewTagName, 35);
|
||||||
|
|
||||||
//There might already be a tag of the same name since so many different types of V7 objects are becoming tags
|
//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:
|
//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
|
//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 this bit of code will check if it already exists and then use that ID in the importMap instead
|
//intended it that way, so this bit of code will check if it already exists and then use that ID in the importMap instead
|
||||||
//for matching other objects imported to tags
|
//for matching other objects imported to tags
|
||||||
if (ct.Tag.Where(m => m.Name == inObj).FirstOrDefault() != null)
|
|
||||||
|
|
||||||
|
//Already present?
|
||||||
Tag o = await CreateAsync(name);
|
var AlreadyTag = ct.Tag.Where(m => m.Name == NewTagName).FirstOrDefault();
|
||||||
if (HasErrors)
|
if (AlreadyTag != null)
|
||||||
{
|
{
|
||||||
//If there are any validation errors, log in joblog and move on
|
//map it to the existing tag of same name
|
||||||
JobsBiz.LogJob(jobId, $"TagBiz::ImportV7Async -> import object \"{name}\" of type \"{SourceType}\" source id {oldId.ToString()} failed validation and was not imported: {GetErrorsAsString()} ", ct);
|
var mapItem = new ImportAyaNova7MapItem(OldV7Id, AyaType.Tag, AlreadyTag.Id);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await ct.SaveChangesAsync();
|
|
||||||
var mapItem = new ImportAyaNova7MapItem(oldId, AyaType.Tag, o.Id);
|
Tag o = await CreateAsync(NewTagName);
|
||||||
//Log
|
if (HasErrors)
|
||||||
EventLogProcessor.AddEntry(new Event(userId, o.Id, AyaType.Tag, AyaEvent.Created), ct);
|
{
|
||||||
await ct.SaveChangesAsync();
|
//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);
|
||||||
|
//Log
|
||||||
|
EventLogProcessor.AddEntry(new Event(userId, o.Id, AyaType.Tag, AyaEvent.Created), ct);
|
||||||
|
await ct.SaveChangesAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//this is the equivalent of returning void for a Task signature with nothing to return
|
//this is the equivalent of returning void for a Task signature with nothing to return
|
||||||
|
|||||||
Reference in New Issue
Block a user