This commit is contained in:
2021-08-20 18:56:59 +00:00
parent 9322cbf00c
commit 7f356877ec

View File

@@ -208,7 +208,7 @@ namespace AyaNova.PlugIn.V8
private async System.Threading.Tasks.Task<long> Getv7v8IdMap(Guid id, RootObjectTypes desiredType, bool allowPatch = true, bool doNotFail = true)
private async System.Threading.Tasks.Task<long> Getv7v8IdMap(Guid id, RootObjectTypes desiredType, bool allowPatch = true, bool doNotFail = true, long? extraV8Id=null)
{
if (!V7ToV8IdMap.ContainsKey(id))
{
@@ -218,15 +218,15 @@ namespace AyaNova.PlugIn.V8
return 0;
//not found, patch allowed, create a substitute record for it and put it in the map
await CreateSubstitute(id, desiredType);
await CreateSubstitute(id, desiredType, extraV8Id);
}
return V7ToV8IdMap[id];
}
private async System.Threading.Tasks.Task<long?> Getv7v8IdMapNullOk(Guid id, RootObjectTypes desiredType, bool allowPatch = true, bool doNotFail = false)
private async System.Threading.Tasks.Task<long?> Getv7v8IdMapNullOk(Guid id, RootObjectTypes desiredType, bool allowPatch = true, bool doNotFail = false, long? extraV8Id=null)
{
if (id == Guid.Empty) return null;
long l = await Getv7v8IdMap(id, desiredType, allowPatch, doNotFail);
long l = await Getv7v8IdMap(id, desiredType, allowPatch, doNotFail, extraV8Id);
if (l == 0) return null;//this is the no patch no fail path
return l;
}
@@ -237,26 +237,26 @@ namespace AyaNova.PlugIn.V8
private string MissingDataNamePrefix = "zV8migrate_substitute";//append guid to ensure uniqueness
private async System.Threading.Tasks.Task CreateSubstitute(Guid id, RootObjectTypes desiredType)
private async System.Threading.Tasks.Task CreateSubstitute(Guid id, RootObjectTypes desiredType, long? extraV8Id=null)
{
//create the simplest possible version of this object desired
dynamic d = new JObject();
string sName = MissingDataNamePrefix + " " + id.ToString();
d.name = sName;//usually this will suffice, for the rare cases it doesn't add to the correct property below, the name property will be ignored if it's not applicable
d.active=false;
d.notes="This object created during v8 migrate as a substitute for a missing linked record in v7";
string route = "";
switch (desiredType)
{
//I guess go through export* and find everything exported and if it can have any of the above then it needs to be here for docs/wiki/attachments
//set route and make dynamic object
case RootObjectTypes.Part:
{
route = "part";
d.partNumber = sName;
}
break;
case RootObjectTypes.PartWarehouse:
{
route = "part-warehouse";
}
break;
case RootObjectTypes.Client:
@@ -267,27 +267,16 @@ namespace AyaNova.PlugIn.V8
case RootObjectTypes.Vendor:
{
route = "vendor";
}
break;
case RootObjectTypes.HeadOffice:
{
route = "headoffice";
route = "head-office";
}
break;
case RootObjectTypes.User:
{
route = "user";
}
break;
case RootObjectTypes.Contract:
{
//needs expiry date as well and I guess inactive
route = "contract";
}
break;
case RootObjectTypes.Project:
@@ -297,7 +286,7 @@ namespace AyaNova.PlugIn.V8
break;
case RootObjectTypes.TaxCode:
{
route = "taxcode";
route = "tax-code";
}
break;
case RootObjectTypes.UnitModel:
@@ -308,193 +297,27 @@ namespace AyaNova.PlugIn.V8
case RootObjectTypes.Unit:
{
route = "unit";
d.serial=sName;
d.customerId=extraV8Id;
}
break;
case RootObjectTypes.WorkOrderStatus:???????
case RootObjectTypes.WorkOrderStatus:
{
route = "work-order-status";???
route = "work-order-status";
}
break;
case RootObjectTypes.WorkOrderItemPriority:???
case RootObjectTypes.WorkOrderItemPriority:
{
route = "work-order-item-priority";???
}
break;
case RootObjectTypes.PurchaseOrder:
{
route = "purchase-order";
route = "work-order-item-priority";
}
break;
case RootObjectTypes.LoanUnit:
{
route = "loan-unit";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
case RootObjectTypes.XXXX:
{
route = "YYYYYYY";
}
break;
default:
throw new Exception("Error: CreateSubstitute (source id: " + id.ToString() + " for type: " + desiredType.ToString() + ") THIS TYPE NOT CODED YET");
}
@@ -1295,9 +1118,14 @@ namespace AyaNova.PlugIn.V8
if (c.ContractID != Guid.Empty)
{
d.contractId = Getv7v8IdMap(c.ContractID, RootObjectTypes.Contract);
long? ctId = Getv7v8IdMapNullOk(c.ContractID, RootObjectTypes.Contract, false, true);
if (ctId != 0 && ctId != null)
{
d.contractId = ctId;
d.contractExpires = c.ContractExpires;
}
}
d.phone1 = c.Phone1;
@@ -1500,9 +1328,14 @@ namespace AyaNova.PlugIn.V8
if (c.ContractID != Guid.Empty)
{
d.contractId = Getv7v8IdMap(c.ContractID, RootObjectTypes.Contract);
long? ctId = Getv7v8IdMapNullOk(c.ContractID, RootObjectTypes.Contract, false, true);
if (ctId != 0 && ctId != null)
{
d.contractId = ctId;
d.contractExpires = c.ContractExpires;
}
}
d.phone1 = c.Phone1;
@@ -3188,7 +3021,9 @@ namespace AyaNova.PlugIn.V8
d.completeByDate = util.DateToV8(c.WorkorderService.CloseByDate);
d.invoiceNumber = c.WorkorderService.InvoiceNumber;
d.onsite = c.Onsite;
d.contractId = Getv7v8IdMapNullOk(c.ContractIDResolved(), RootObjectTypes.Contract);
long? ctId = Getv7v8IdMapNullOk(c.ContractIDResolved(), RootObjectTypes.Contract, false, true);
if (ctId == 0) ctId = null;
d.contractId = ctId;
d.lastStatusId = Getv7v8IdMapNullOk(c.WorkorderService.WorkorderStatusID, RootObjectTypes.WorkOrderStatus);//workorder status is in regular map, only item status is special
var client = c.uiClient;
@@ -3325,7 +3160,7 @@ namespace AyaNova.PlugIn.V8
{
//make sure we have a matching unit already
var ravUnitId = Getv7v8IdMapNullOk(wi.UnitID, RootObjectTypes.Unit);
var ravUnitId = Getv7v8IdMapNullOk(wi.UnitID, RootObjectTypes.Unit, true,false,Getv7v8IdMap(c.ClientID, RootObjectTypes.Client));
if (ravUnitId != null)
{
//we have a legit unit record, make it for v8
@@ -3568,7 +3403,7 @@ namespace AyaNova.PlugIn.V8
{
//make sure we have a matching unit already
var ravUnitId = Getv7v8IdMapNullOk(wi.UnitID, RootObjectTypes.Unit);
var ravUnitId = Getv7v8IdMapNullOk(wi.UnitID, RootObjectTypes.Unit,true,false,Getv7v8IdMap(c.ClientID, RootObjectTypes.Client));
if (ravUnitId != null)
{
//we have a legit unit record, make it for v8
@@ -3741,8 +3576,9 @@ namespace AyaNova.PlugIn.V8
d.validUntil = util.DateToV8(c.WorkorderQuote.ValidUntilDate);
d.submitted = util.DateToV8(c.WorkorderQuote.DateSubmitted);
d.approved = util.DateToV8(c.WorkorderQuote.DateApproved);
d.contractId = Getv7v8IdMapNullOk(c.ContractIDResolved(), RootObjectTypes.Contract);
long? ctId = Getv7v8IdMapNullOk(c.ContractIDResolved(), RootObjectTypes.Contract, false, true);
if (ctId == 0) ctId = null;
d.contractId = ctId;
d.lastStatusId = (int)c.WorkorderQuote.QuoteStatus;
var client = c.uiClient;
@@ -3847,7 +3683,7 @@ namespace AyaNova.PlugIn.V8
{
//make sure we have a matching unit already
var ravUnitId = Getv7v8IdMapNullOk(wi.UnitID, RootObjectTypes.Unit);
var ravUnitId = Getv7v8IdMapNullOk(wi.UnitID, RootObjectTypes.Unit,true,false,Getv7v8IdMap(c.ClientID, RootObjectTypes.Client));
if (ravUnitId != null)
{
//we have a legit unit record, make it for v8
@@ -4041,7 +3877,9 @@ namespace AyaNova.PlugIn.V8
d.customerReferenceNumber = c.CustomerReferenceNumber;
d.customerContactName = c.CustomerContactName;
d.createdDate = util.DateToV8(c.Created, true);
d.contractId = Getv7v8IdMapNullOk(c.ContractIDResolved(), RootObjectTypes.Contract);
long? ctId = Getv7v8IdMapNullOk(c.ContractIDResolved(), RootObjectTypes.Contract, false, true);
if (ctId == 0) ctId = null;
d.contractId = ctId;
//PM specific fields
d.copyWiki = false;
@@ -4196,7 +4034,7 @@ namespace AyaNova.PlugIn.V8
{
//make sure we have a matching unit already
var ravUnitId = Getv7v8IdMapNullOk(wi.UnitID, RootObjectTypes.Unit);
var ravUnitId = Getv7v8IdMapNullOk(wi.UnitID, RootObjectTypes.Unit,true,false,Getv7v8IdMap(c.ClientID, RootObjectTypes.Client));
if (ravUnitId != null)
{
//we have a legit unit record, make it for v8
@@ -4580,7 +4418,7 @@ namespace AyaNova.PlugIn.V8
d.notes = c.Details;
d.dateRequested = util.DateToV8(c.Created, true);
d.customerId = Getv7v8IdMap(c.ClientID, RootObjectTypes.Customer);
d.unitId = Getv7v8IdMapNullOk(c.UnitID, RootObjectTypes.Unit);
d.unitId = Getv7v8IdMapNullOk(c.UnitID, RootObjectTypes.Unit,true,false,Getv7v8IdMap(c.ClientID, RootObjectTypes.Client));
d.workOrderItemId = Getv7v8IdMapNullOk(c.WorkorderItemID, RootObjectTypes.WorkOrderItem, false, false);
d.requestedByUserId = SafeGetUserMap(c.Creator);//creator should always be a 'outside' user account
d.customerReferenceNumber = c.ClientRef;