From 787057e3ba432f7c8f97594956cd79c897024535 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 20 Aug 2021 19:34:56 +0000 Subject: [PATCH] --- source/Plugins/AyaNova.Plugin.V8/V8.cs | 191 ++++++++++++------------- 1 file changed, 95 insertions(+), 96 deletions(-) diff --git a/source/Plugins/AyaNova.Plugin.V8/V8.cs b/source/Plugins/AyaNova.Plugin.V8/V8.cs index 4252076..34dc61b 100644 --- a/source/Plugins/AyaNova.Plugin.V8/V8.cs +++ b/source/Plugins/AyaNova.Plugin.V8/V8.cs @@ -233,7 +233,7 @@ namespace AyaNova.PlugIn.V8 //UNKNOWN / MISSING RECORD OBJECT STAND INs - private long XUnknownV7PartId = 0;//used when there is no part id on a workorderitempart record + private long UnknownV7PartId = 0;//used when there is no part id on a workorderitempart record private string MissingDataNamePrefix = "zV8migrate_substitute";//append guid to ensure uniqueness @@ -301,33 +301,27 @@ namespace AyaNova.PlugIn.V8 d.customerId = extraV8Id; } break; - case RootObjectTypes.WorkOrderStatus: + case RootObjectTypes.WorkorderStatus: { route = "work-order-status"; } break; - case RootObjectTypes.WorkOrderItemPriority: - { - route = "work-order-item-priority"; - } - break; - - case RootObjectTypes.LoanUnit: + + case RootObjectTypes.LoanItem: { route = "loan-unit"; } break; - case RootObjectTypes.ServiceRate: + case RootObjectTypes.Rate: { - route = "service-rate"; - } - break; - case RootObjectTypes.TravelRate: - { - route = "travel-rate"; + if (extraV8Id == 1) + route = "service-rate"; + else + route = "travel-rate"; } break; + default: throw new Exception("Error: CreateSubstitute (source id: " + id.ToString() + " for type: " + desiredType.ToString() + ") THIS TYPE NOT CODED YET"); } @@ -678,7 +672,7 @@ namespace AyaNova.PlugIn.V8 if (hasWiki) { await ExportAttachments(adminTid, progress, util.AyaType.NoType);//admin account - AdminWikiContent = GetWikiContent(adminTid); + AdminWikiContent = await GetWikiContent(adminTid); } //docs @@ -812,7 +806,7 @@ namespace AyaNova.PlugIn.V8 // wiki if (WikiPage.HasWiki(c.ID)) { - d.wiki = GetWikiContent(ObjectTID); + d.wiki = await GetWikiContent(ObjectTID); repost = true; } @@ -989,7 +983,7 @@ namespace AyaNova.PlugIn.V8 // wiki if (WikiPage.HasWiki(c.ID)) { - d.wiki = GetWikiContent(ObjectTID); + d.wiki = await GetWikiContent(ObjectTID); repost = true; } @@ -1128,7 +1122,7 @@ namespace AyaNova.PlugIn.V8 if (c.ContractID != Guid.Empty) { - long? ctId = await Getv7v8IdMapNullOK(c.ContractID, RootObjectTypes.Contract, false, true); + long? ctId = await Getv7v8IdMapNullOk(c.ContractID, RootObjectTypes.Contract, false, true); if (ctId != 0 && ctId != null) { @@ -1179,7 +1173,7 @@ namespace AyaNova.PlugIn.V8 // wiki if (WikiPage.HasWiki(c.ID)) { - d.wiki = GetWikiContent(ObjectTID); + d.wiki = await GetWikiContent(ObjectTID); repost = true; } @@ -1338,7 +1332,7 @@ namespace AyaNova.PlugIn.V8 if (c.ContractID != Guid.Empty) { - long? ctId = await Getv7v8IdMapNullOK(c.ContractID, RootObjectTypes.Contract, false, true); + long? ctId = await Getv7v8IdMapNullOk(c.ContractID, RootObjectTypes.Contract, false, true); if (ctId != 0 && ctId != null) { @@ -1393,7 +1387,7 @@ namespace AyaNova.PlugIn.V8 if (WikiPage.HasWiki(c.ID)) { - d.wiki = GetWikiContent(ObjectTID); + d.wiki = await GetWikiContent(ObjectTID); repost = true; } @@ -1550,7 +1544,7 @@ namespace AyaNova.PlugIn.V8 if (WikiPage.HasWiki(c.ID)) { - d.wiki = GetWikiContent(ObjectTID); + d.wiki = await GetWikiContent(ObjectTID); repost = true; } @@ -1639,7 +1633,7 @@ namespace AyaNova.PlugIn.V8 if (WikiPage.HasWiki(c.ID)) { - d.wiki = GetWikiContent(ObjectTID); + d.wiki = await GetWikiContent(ObjectTID); repost = true; } @@ -1722,11 +1716,11 @@ namespace AyaNova.PlugIn.V8 d.partNumber = GetUniqueName(c.PartNumber); progress.SubOp(""); progress.Op(ObjectTypeName + " " + d.partNumber + " " + d.name); - d.manufacturerId = await Getv7v8IdMapNullOK(c.ManufacturerID, RootObjectTypes.Vendor); + d.manufacturerId = await Getv7v8IdMapNullOk(c.ManufacturerID, RootObjectTypes.Vendor); d.manufacturerNumber = c.ManufacturerNumber; - d.wholeSalerId = await Getv7v8IdMapNullOK(c.WholesalerID, RootObjectTypes.Vendor); + d.wholeSalerId = await Getv7v8IdMapNullOk(c.WholesalerID, RootObjectTypes.Vendor); d.wholeSalerNumber = c.WholesalerNumber; - d.alternativeWholeSalerId = await Getv7v8IdMapNullOK(c.AlternativeWholesalerID, RootObjectTypes.Vendor); + d.alternativeWholeSalerId = await Getv7v8IdMapNullOk(c.AlternativeWholesalerID, RootObjectTypes.Vendor); d.alternativeWholeSalerNumber = c.AlternativeWholesalerNumber; d.cost = c.Cost; d.retail = c.Retail; @@ -1757,7 +1751,7 @@ namespace AyaNova.PlugIn.V8 if (WikiPage.HasWiki(c.ID)) { - d.wiki = GetWikiContent(ObjectTID); + d.wiki = await GetWikiContent(ObjectTID); repost = true; } @@ -1796,8 +1790,8 @@ namespace AyaNova.PlugIn.V8 //create a part just to hold untracked parts from v7 which are partid guid.empty on workorderitempart records which was allowed in v7 but not in v8 dynamic dx = new JObject(); - dx.name = "v8 Migrate untracked / missing v7 part"; - dx.partNumber = GetUniqueName("v8 Migrate part"); + dx.name = MissingDataNamePrefix ; + dx.partNumber = GetUniqueName(MissingDataNamePrefix ); progress.Op(ObjectTypeName + " " + dx.partNumber + " " + dx.name); dx.cost = 0; dx.retail = 0; @@ -1968,7 +1962,7 @@ namespace AyaNova.PlugIn.V8 if (WikiPage.HasWiki(c.ID)) { - d.wiki = GetWikiContent(ObjectTID); + d.wiki = await GetWikiContent(ObjectTID); repost = true; } //docs @@ -2033,13 +2027,13 @@ namespace AyaNova.PlugIn.V8 _highestPurchaseOrderNumberExported = c.PONumber; d.notes = c.Notes; d.vendorMemo = c.VendorMemo; - d.dropShipToCustomerId = await Getv7v8IdMapNullOK(c.DropShipToClientID, RootObjectTypes.Client); + d.dropShipToCustomerId = await Getv7v8IdMapNullOk(c.DropShipToClientID, RootObjectTypes.Client); d.referenceNumber = c.ReferenceNumber; d.vendorId = await Getv7v8IdMap(c.VendorID, RootObjectTypes.Vendor); d.orderedDate = util.DateToV8(c.OrderedDate); d.expectedReceiveDate = util.DateToV8(c.ExpectedReceiveDate); d.status = (int)c.Status;//same enum id's so this is kosher - d.projectId = await Getv7v8IdMapNullOK(c.ProjectID, RootObjectTypes.Project); + d.projectId = await Getv7v8IdMapNullOk(c.ProjectID, RootObjectTypes.Project); StringBuilder sbText1 = new StringBuilder(); StringBuilder sbText2 = new StringBuilder(); @@ -2078,8 +2072,8 @@ namespace AyaNova.PlugIn.V8 //dItem.serials = string.Empty; StringBuilder sbSerials = new StringBuilder(); dItem.purchaseOrderCost = pi.PurchaseOrderCost; - dItem.partRequestedById = await Getv7v8IdMapNullOK(pi.PartRequestedByID, RootObjectTypes.User); - dItem.purchaseTaxCodeId = await Getv7v8IdMapNullOK(pi.PurchaseTaxCodeID, RootObjectTypes.TaxCode); + dItem.partRequestedById = await Getv7v8IdMapNullOk(pi.PartRequestedByID, RootObjectTypes.User); + dItem.purchaseTaxCodeId = await Getv7v8IdMapNullOk(pi.PurchaseTaxCodeID, RootObjectTypes.TaxCode); if (pi.WorkorderItemPartRequestID != Guid.Empty) { dItem.vendorPartNumber = pi.WorkorderItemPartRequestID.ToString();//temp holder for guid, not used in v7 so available @@ -2143,7 +2137,7 @@ namespace AyaNova.PlugIn.V8 if (WikiPage.HasWiki(c.ID)) { - d.wiki = GetWikiContent(ObjectTID); + d.wiki = await GetWikiContent(ObjectTID); repost = true; } @@ -2258,10 +2252,10 @@ namespace AyaNova.PlugIn.V8 d.active = c.Active; d.notes = c.Notes; d.customerId = await Getv7v8IdMap(c.ClientID, RootObjectTypes.Client); - d.unitModelId = await Getv7v8IdMapNullOK(c.UnitModelID, RootObjectTypes.UnitModel); + d.unitModelId = await Getv7v8IdMapNullOk(c.UnitModelID, RootObjectTypes.UnitModel); d.unitHasOwnAddress = c.UnitHasOwnAddress; d.boughtHere = c.BoughtHere; - d.purchasedFromVendorId = await Getv7v8IdMapNullOK(c.PurchasedFromID, RootObjectTypes.Vendor); + d.purchasedFromVendorId = await Getv7v8IdMapNullOk(c.PurchasedFromID, RootObjectTypes.Vendor); d.receipt = c.Receipt; d.purchasedDate = util.DateToV8(c.PurchasedDate); d.description = c.Description; @@ -2312,7 +2306,7 @@ namespace AyaNova.PlugIn.V8 if (WikiPage.HasWiki(c.ID)) { - d.wiki = GetWikiContent(ObjectTID); + d.wiki = await GetWikiContent(ObjectTID); repost = true; } @@ -2348,8 +2342,8 @@ namespace AyaNova.PlugIn.V8 dynamic d = a.ObjectResponse["data"]; progress.Op(ObjectTypeName + " " + d.serial); - d.replacedByUnitId = await Getv7v8IdMapNullOK(c.ReplacedByUnitID, RootObjectTypes.Unit); - d.parentUnitId = await Getv7v8IdMapNullOK(c.ParentID, RootObjectTypes.Unit); + d.replacedByUnitId = await Getv7v8IdMapNullOk(c.ReplacedByUnitID, RootObjectTypes.Unit); + d.parentUnitId = await Getv7v8IdMapNullOk(c.ParentID, RootObjectTypes.Unit); if (d.parentUnitId != null || d.replacedByUnitId != null) await util.PutAsync("unit", d.ToString()); //----- @@ -2438,7 +2432,7 @@ namespace AyaNova.PlugIn.V8 if (WikiPage.HasWiki(c.ID)) { - d.wiki = GetWikiContent(ObjectTID); + d.wiki = await GetWikiContent(ObjectTID); repost = true; } @@ -2554,7 +2548,7 @@ namespace AyaNova.PlugIn.V8 if (WikiPage.HasWiki(c.ID)) { - d.wiki = GetWikiContent(ObjectTID); + d.wiki = await GetWikiContent(ObjectTID); repost = true; } @@ -2687,7 +2681,7 @@ namespace AyaNova.PlugIn.V8 } //nope, it's non-existant anywhere if (mustExist) - return Getv7v8IdMap(rateId, RootObjectTypes.ServiceRate); + return await Getv7v8IdMap(rateId, RootObjectTypes.Rate, true, true, 1); //throw new Exception("Mandatory Rate missing, cannot proceed, last logged item needs to be fixed"); else return null; @@ -2714,7 +2708,7 @@ namespace AyaNova.PlugIn.V8 } //nope, it's non-existant anywhere if (mustExist) - return Getv7v8IdMap(rateId, RootObjectTypes.Travel); + return await Getv7v8IdMap(rateId, RootObjectTypes.Rate, true, true, 0); else return null; } @@ -3022,7 +3016,7 @@ namespace AyaNova.PlugIn.V8 _highestWorkOrderNumberExported = c.WorkorderService.ServiceNumber; d.customerId = await Getv7v8IdMap(c.ClientID, RootObjectTypes.Client); d.notes = c.Summary; - d.projectId = await Getv7v8IdMapNullOK(c.ProjectID, RootObjectTypes.Project); + d.projectId = await Getv7v8IdMapNullOk(c.ProjectID, RootObjectTypes.Project); d.internalReferenceNumber = c.InternalReferenceNumber; d.customerReferenceNumber = c.CustomerReferenceNumber; d.customerContactName = c.CustomerContactName; @@ -3031,10 +3025,10 @@ namespace AyaNova.PlugIn.V8 d.completeByDate = util.DateToV8(c.WorkorderService.CloseByDate); d.invoiceNumber = c.WorkorderService.InvoiceNumber; d.onsite = c.Onsite; - long? ctId = await Getv7v8IdMapNullOK(c.ContractIDResolved(), RootObjectTypes.Contract, false, true); + long? ctId = await Getv7v8IdMapNullOk(c.ContractIDResolved(), RootObjectTypes.Contract, false, true); if (ctId == 0) ctId = null; d.contractId = ctId; - d.lastStatusId = await Getv7v8IdMapNullOK(c.WorkorderService.WorkorderStatusID, RootObjectTypes.WorkOrderStatus);//workorder status is in regular map, only item status is special + d.lastStatusId = await Getv7v8IdMapNullOk(c.WorkorderService.WorkorderStatusID, RootObjectTypes.WorkorderStatus);//workorder status is in regular map, only item status is special var client = c.uiClient; if (client != null) @@ -3077,7 +3071,7 @@ namespace AyaNova.PlugIn.V8 if (WikiPage.HasWiki(c.ID)) { - d.wiki = GetWikiContent(ObjectTID); + d.wiki = await GetWikiContent(ObjectTID); } @@ -3108,7 +3102,7 @@ namespace AyaNova.PlugIn.V8 { dynamic state = new JObject(); state.workOrderId = RavenId; - state.workOrderStatusId = await Getv7v8IdMap(c.WorkorderService.WorkorderStatusID, RootObjectTypes.WorkOrderStatus); + state.workOrderStatusId = await Getv7v8IdMap(c.WorkorderService.WorkorderStatusID, RootObjectTypes.WorkorderStatus); state.created = util.DateToV8(c.Created, true); state.userId = await Getv7v8IdMap(c.Creator, RootObjectTypes.User); await util.PostAsync("workorder/states", state.ToString()); @@ -3150,7 +3144,10 @@ namespace AyaNova.PlugIn.V8 dwi.techNotes = wi.TechNotes; dwi.requestDate = util.DateToV8(wi.RequestDate);//allow empty dates if empty source dwi.workOrderItemStatusId = Getv7v8WorkOrderItemStatusIdNullOk(wi.WorkorderStatusID); - dwi.workOrderItemPriorityId = await Getv7v8IdMapNullOK(wi.PriorityID, RootObjectTypes.WorkOrderItemPriority); + + if (V7ToV8IdMap.ContainsKey(wi.PriorityID)) + dwi.workOrderItemPriorityId = V7ToV8IdMap[wi.PriorityID]; + dwi.warrantyService = wi.WarrantyService; @@ -3170,7 +3167,7 @@ namespace AyaNova.PlugIn.V8 { //make sure we have a matching unit already - var ravUnitId = await Getv7v8IdMapNullOK(wi.UnitID, RootObjectTypes.Unit, true, false, Getv7v8IdMap(c.ClientID, RootObjectTypes.Client)); + var ravUnitId = await 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 @@ -3195,7 +3192,7 @@ namespace AyaNova.PlugIn.V8 dwisu.workOrderId = RavenId; dwisu.workOrderItemId = ravenwoitemid; //null is ok here for a sched user - dwisu.userId = await Getv7v8IdMapNullOK(wisu.UserID, RootObjectTypes.User); + dwisu.userId = await Getv7v8IdMapNullOk(wisu.UserID, RootObjectTypes.User); dwisu.startDate = util.DateToV8(wisu.StartDate); dwisu.stopDate = util.DateToV8(wisu.StopDate); dwisu.estimatedQuantity = wisu.EstimatedQuantity; @@ -3211,7 +3208,7 @@ namespace AyaNova.PlugIn.V8 dwip.workOrderId = RavenId; dwip.workOrderItemId = ravenwoitemid; dwip.quantity = wip.Quantity; - var tryPartId = await Getv7v8IdMapNullOK(wip.PartID, RootObjectTypes.Part); + var tryPartId = await Getv7v8IdMapNullOk(wip.PartID, RootObjectTypes.Part); if (tryPartId == null) { dwip.partId = UnknownV7PartId; @@ -3221,7 +3218,7 @@ namespace AyaNova.PlugIn.V8 else dwip.partId = tryPartId; dwip.partWarehouseId = await Getv7v8IdMap(wip.PartWarehouseID, RootObjectTypes.PartWarehouse); - dwip.taxPartSaleId = await Getv7v8IdMapNullOK(wip.TaxPartSaleID, RootObjectTypes.TaxCode); + dwip.taxPartSaleId = await Getv7v8IdMapNullOk(wip.TaxPartSaleID, RootObjectTypes.TaxCode); if (wip.Discount != 0) dwip.priceOverride = wip.Price - (wip.Price * wip.Discount); else @@ -3259,7 +3256,7 @@ namespace AyaNova.PlugIn.V8 //iterate po and look for item with the vendorpartnumber set to this woitempartid by guid string //update the po item with the raven partrequestid //save po - long? v8poid = await Getv7v8IdMapNullOK(pto.v7poid, RootObjectTypes.PurchaseOrder); + long? v8poid = await Getv7v8IdMapNullOk(pto.v7poid, RootObjectTypes.PurchaseOrder); if (v8poid != null) { var a = await util.GetAsync("purchase-order/" + v8poid.ToString()); @@ -3302,7 +3299,7 @@ namespace AyaNova.PlugIn.V8 dwil.outDate = util.DateToV8(wil.OutDate); dwil.dueDate = util.DateToV8(wil.DueDate); dwil.returnDate = util.DateToV8(wil.ReturnDate); - dwil.taxCodeId = await Getv7v8IdMapNullOK(wil.TaxCodeID, RootObjectTypes.TaxCode); + dwil.taxCodeId = await Getv7v8IdMapNullOk(wil.TaxCodeID, RootObjectTypes.TaxCode); dwil.quantity = wil.Quantity; switch (wil.Rate) { @@ -3341,12 +3338,12 @@ namespace AyaNova.PlugIn.V8 dwl.workOrderId = RavenId; dwl.workOrderItemId = ravenwoitemid; //null is ok here for user - dwl.userId = await Getv7v8IdMapNullOK(wl.UserID, RootObjectTypes.User); + dwl.userId = await Getv7v8IdMapNullOk(wl.UserID, RootObjectTypes.User); dwl.serviceStartDate = util.DateToV8(wl.ServiceStartDate); dwl.serviceStopDate = util.DateToV8(wl.ServiceStopDate); dwl.serviceRateQuantity = wl.ServiceRateQuantity; dwl.noChargeQuantity = wl.NoChargeQuantity; - dwl.taxCodeSaleId = await Getv7v8IdMapNullOK(wl.TaxRateSaleID, RootObjectTypes.TaxCode); + dwl.taxCodeSaleId = await Getv7v8IdMapNullOk(wl.TaxRateSaleID, RootObjectTypes.TaxCode); dwl.serviceRateId = await GetRate(false, wl.ServiceRateID); dwl.serviceDetails = wl.ServiceDetails; @@ -3361,12 +3358,12 @@ namespace AyaNova.PlugIn.V8 dwt.workOrderId = RavenId; dwt.workOrderItemId = ravenwoitemid; //null is ok here for user - dwt.userId = await Getv7v8IdMapNullOK(wt.UserID, RootObjectTypes.User); + dwt.userId = await Getv7v8IdMapNullOk(wt.UserID, RootObjectTypes.User); dwt.travelStartDate = util.DateToV8(wt.TravelStartDate); dwt.travelStopDate = util.DateToV8(wt.TravelStopDate); dwt.travelRateQuantity = wt.TravelRateQuantity; dwt.noChargeQuantity = wt.NoChargeQuantity; - dwt.taxCodeSaleId = await Getv7v8IdMapNullOK(wt.TaxRateSaleID, RootObjectTypes.TaxCode); + dwt.taxCodeSaleId = await Getv7v8IdMapNullOk(wt.TaxRateSaleID, RootObjectTypes.TaxCode); dwt.travelRateId = await GetRate(true, wt.TravelRateID); dwt.travelDetails = wt.TravelDetails; dwt.distance = wt.Distance; @@ -3401,9 +3398,9 @@ namespace AyaNova.PlugIn.V8 dwe.totalCost = we.TotalCost; dwe.chargeAmount = we.ChargeAmount; dwe.taxPaid = we.TaxPaid; - dwe.chargeTaxCodeId = await Getv7v8IdMapNullOK(we.ChargeTaxCodeID, RootObjectTypes.TaxCode); + dwe.chargeTaxCodeId = await Getv7v8IdMapNullOk(we.ChargeTaxCodeID, RootObjectTypes.TaxCode); dwe.reimburseUser = we.ReimburseUser; - dwe.userId = await Getv7v8IdMapNullOK(we.UserID, RootObjectTypes.User); + dwe.userId = await Getv7v8IdMapNullOk(we.UserID, RootObjectTypes.User); dwe.chargeToCustomer = we.ChargeToClient; await util.PostAsync("workorder/items/expenses", dwe.ToString()); } @@ -3413,7 +3410,7 @@ namespace AyaNova.PlugIn.V8 { //make sure we have a matching unit already - var ravUnitId = await Getv7v8IdMapNullOK(wi.UnitID, RootObjectTypes.Unit, true, false, Getv7v8IdMap(c.ClientID, RootObjectTypes.Client)); + var ravUnitId = await 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 @@ -3423,8 +3420,8 @@ namespace AyaNova.PlugIn.V8 dwio.workOrderItemId = ravenwoitemid; dwio.unitId = ravUnitId; dwio.notes = wi.OutsideService.Notes; - dwio.vendorSentToId = await Getv7v8IdMapNullOK(wi.OutsideService.VendorSentToID, RootObjectTypes.Vendor); - dwio.vendorSentViaId = await Getv7v8IdMapNullOK(wi.OutsideService.VendorSentViaID, RootObjectTypes.Vendor); + dwio.vendorSentToId = await Getv7v8IdMapNullOk(wi.OutsideService.VendorSentToID, RootObjectTypes.Vendor); + dwio.vendorSentViaId = await Getv7v8IdMapNullOk(wi.OutsideService.VendorSentViaID, RootObjectTypes.Vendor); dwio.rMANumber = wi.OutsideService.RMANumber; dwio.trackingNumber = wi.OutsideService.TrackingNumber; dwio.repairCost = wi.OutsideService.RepairCost; @@ -3575,7 +3572,7 @@ namespace AyaNova.PlugIn.V8 _highestQuoteNumberExported = c.WorkorderQuote.QuoteNumber; d.customerId = await Getv7v8IdMap(c.ClientID, RootObjectTypes.Client); d.notes = c.Summary; - d.projectId = await Getv7v8IdMapNullOK(c.ProjectID, RootObjectTypes.Project); + d.projectId = await Getv7v8IdMapNullOk(c.ProjectID, RootObjectTypes.Project); d.internalReferenceNumber = c.InternalReferenceNumber; d.customerReferenceNumber = c.CustomerReferenceNumber; d.customerContactName = c.CustomerContactName; @@ -3586,7 +3583,7 @@ 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); - long? ctId = await Getv7v8IdMapNullOK(c.ContractIDResolved(), RootObjectTypes.Contract, false, true); + long? ctId = await Getv7v8IdMapNullOk(c.ContractIDResolved(), RootObjectTypes.Contract, false, true); if (ctId == 0) ctId = null; d.contractId = ctId; d.lastStatusId = (int)c.WorkorderQuote.QuoteStatus; @@ -3625,7 +3622,7 @@ namespace AyaNova.PlugIn.V8 // wiki if (WikiPage.HasWiki(c.ID)) - d.wiki = GetWikiContent(ObjectTID); + d.wiki = await GetWikiContent(ObjectTID); //docs string NonFileUrls = await ExportDocs(ObjectTID, c.Docs, progress, util.AyaType.Quote); @@ -3673,7 +3670,8 @@ namespace AyaNova.PlugIn.V8 dwi.techNotes = wi.TechNotes; dwi.requestDate = util.DateToV8(wi.RequestDate);//allow empty dates if empty source dwi.workOrderItemStatusId = Getv7v8WorkOrderItemStatusIdNullOk(wi.WorkorderStatusID); - dwi.workOrderItemPriorityId = await Getv7v8IdMapNullOK(wi.PriorityID, RootObjectTypes.WorkOrderItemPriority); + if (V7ToV8IdMap.ContainsKey(wi.PriorityID)) + dwi.workOrderItemPriorityId = V7ToV8IdMap[wi.PriorityID]; dwi.warrantyService = wi.WarrantyService; @@ -3693,7 +3691,7 @@ namespace AyaNova.PlugIn.V8 { //make sure we have a matching unit already - var ravUnitId = await Getv7v8IdMapNullOK(wi.UnitID, RootObjectTypes.Unit, true, false, Getv7v8IdMap(c.ClientID, RootObjectTypes.Client)); + var ravUnitId = await 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 @@ -3718,7 +3716,7 @@ namespace AyaNova.PlugIn.V8 dwisu.quoteId = RavenId; dwisu.quoteItemId = ravenwoitemid; //null is ok here for a sched user - dwisu.userId = await Getv7v8IdMapNullOK(wisu.UserID, RootObjectTypes.User); + dwisu.userId = await Getv7v8IdMapNullOk(wisu.UserID, RootObjectTypes.User); dwisu.startDate = util.DateToV8(wisu.StartDate); dwisu.stopDate = util.DateToV8(wisu.StopDate); dwisu.estimatedQuantity = wisu.EstimatedQuantity; @@ -3734,7 +3732,7 @@ namespace AyaNova.PlugIn.V8 dwip.quoteId = RavenId; dwip.quoteItemId = ravenwoitemid; dwip.quantity = wip.Quantity; - var tryPartId = await Getv7v8IdMapNullOK(wip.PartID, RootObjectTypes.Part); + var tryPartId = await Getv7v8IdMapNullOk(wip.PartID, RootObjectTypes.Part); if (tryPartId == null) { dwip.partId = UnknownV7PartId; @@ -3744,7 +3742,7 @@ namespace AyaNova.PlugIn.V8 else dwip.partId = tryPartId; dwip.partWarehouseId = await Getv7v8IdMap(wip.PartWarehouseID, RootObjectTypes.PartWarehouse); - dwip.taxPartSaleId = await Getv7v8IdMapNullOK(wip.TaxPartSaleID, RootObjectTypes.TaxCode); + dwip.taxPartSaleId = await Getv7v8IdMapNullOk(wip.TaxPartSaleID, RootObjectTypes.TaxCode); if (wip.Discount != 0) dwip.priceOverride = wip.Price - (wip.Price * wip.Discount); else @@ -3767,12 +3765,12 @@ namespace AyaNova.PlugIn.V8 dwl.quoteId = RavenId; dwl.quoteItemId = ravenwoitemid; //null is ok here for user - dwl.userId = await Getv7v8IdMapNullOK(wl.UserID, RootObjectTypes.User); + dwl.userId = await Getv7v8IdMapNullOk(wl.UserID, RootObjectTypes.User); dwl.serviceStartDate = util.DateToV8(wl.ServiceStartDate); dwl.serviceStopDate = util.DateToV8(wl.ServiceStopDate); dwl.serviceRateQuantity = wl.ServiceRateQuantity; dwl.noChargeQuantity = wl.NoChargeQuantity; - dwl.taxCodeSaleId = await Getv7v8IdMapNullOK(wl.TaxRateSaleID, RootObjectTypes.TaxCode); + dwl.taxCodeSaleId = await Getv7v8IdMapNullOk(wl.TaxRateSaleID, RootObjectTypes.TaxCode); dwl.serviceRateId = await GetRate(false, wl.ServiceRateID); dwl.serviceDetails = wl.ServiceDetails; @@ -3787,12 +3785,12 @@ namespace AyaNova.PlugIn.V8 dwt.quoteId = RavenId; dwt.quoteItemId = ravenwoitemid; //null is ok here for user - dwt.userId = await Getv7v8IdMapNullOK(wt.UserID, RootObjectTypes.User); + dwt.userId = await Getv7v8IdMapNullOk(wt.UserID, RootObjectTypes.User); dwt.travelStartDate = util.DateToV8(wt.TravelStartDate); dwt.travelStopDate = util.DateToV8(wt.TravelStopDate); dwt.travelRateQuantity = wt.TravelRateQuantity; dwt.noChargeQuantity = wt.NoChargeQuantity; - dwt.taxCodeSaleId = await Getv7v8IdMapNullOK(wt.TaxRateSaleID, RootObjectTypes.TaxCode); + dwt.taxCodeSaleId = await Getv7v8IdMapNullOk(wt.TaxRateSaleID, RootObjectTypes.TaxCode); dwt.travelRateId = await GetRate(true, wt.TravelRateID); dwt.travelDetails = wt.TravelDetails; dwt.distance = wt.Distance; @@ -3882,12 +3880,12 @@ namespace AyaNova.PlugIn.V8 _highestPMNumberExported = c.WorkorderPreventiveMaintenance.PreventiveMaintenanceNumber; d.customerId = await Getv7v8IdMap(c.ClientID, RootObjectTypes.Client); d.notes = c.Summary; - d.projectId = await Getv7v8IdMapNullOK(c.ProjectID, RootObjectTypes.Project); + d.projectId = await Getv7v8IdMapNullOk(c.ProjectID, RootObjectTypes.Project); d.internalReferenceNumber = c.InternalReferenceNumber; d.customerReferenceNumber = c.CustomerReferenceNumber; d.customerContactName = c.CustomerContactName; d.createdDate = util.DateToV8(c.Created, true); - long? ctId = await Getv7v8IdMapNullOK(c.ContractIDResolved(), RootObjectTypes.Contract, false, true); + long? ctId = await Getv7v8IdMapNullOk(c.ContractIDResolved(), RootObjectTypes.Contract, false, true); if (ctId == 0) ctId = null; d.contractId = ctId; @@ -3992,7 +3990,7 @@ namespace AyaNova.PlugIn.V8 // wiki if (WikiPage.HasWiki(c.ID)) - d.wiki = GetWikiContent(ObjectTID); + d.wiki = await GetWikiContent(ObjectTID); //docs string NonFileUrls = await ExportDocs(ObjectTID, c.Docs, progress, util.AyaType.PM); @@ -4024,7 +4022,8 @@ namespace AyaNova.PlugIn.V8 dwi.techNotes = wi.TechNotes; dwi.requestDate = util.DateToV8(wi.RequestDate);//allow empty dates if empty source dwi.workOrderItemStatusId = Getv7v8WorkOrderItemStatusIdNullOk(wi.WorkorderStatusID); - dwi.workOrderItemPriorityId = await Getv7v8IdMapNullOK(wi.PriorityID, RootObjectTypes.WorkOrderItemPriority); + if (V7ToV8IdMap.ContainsKey(wi.PriorityID)) + dwi.workOrderItemPriorityId = V7ToV8IdMap[wi.PriorityID]; dwi.warrantyService = wi.WarrantyService; @@ -4044,7 +4043,7 @@ namespace AyaNova.PlugIn.V8 { //make sure we have a matching unit already - var ravUnitId = await Getv7v8IdMapNullOK(wi.UnitID, RootObjectTypes.Unit, true, false, Getv7v8IdMap(c.ClientID, RootObjectTypes.Client)); + var ravUnitId = await 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 @@ -4069,7 +4068,7 @@ namespace AyaNova.PlugIn.V8 dwisu.pmId = RavenId; dwisu.pmItemId = ravenwoitemid; //null is ok here for a sched user - dwisu.userId = await Getv7v8IdMapNullOK(wisu.UserID, RootObjectTypes.User); + dwisu.userId = await Getv7v8IdMapNullOk(wisu.UserID, RootObjectTypes.User); dwisu.startDate = util.DateToV8(wisu.StartDate); dwisu.stopDate = util.DateToV8(wisu.StopDate); dwisu.estimatedQuantity = wisu.EstimatedQuantity; @@ -4085,7 +4084,7 @@ namespace AyaNova.PlugIn.V8 dwip.pmId = RavenId; dwip.pmItemId = ravenwoitemid; dwip.quantity = wip.Quantity; - var tryPartId = await Getv7v8IdMapNullOK(wip.PartID, RootObjectTypes.Part); + var tryPartId = await Getv7v8IdMapNullOk(wip.PartID, RootObjectTypes.Part); if (tryPartId == null) { dwip.partId = UnknownV7PartId; @@ -4095,7 +4094,7 @@ namespace AyaNova.PlugIn.V8 else dwip.partId = tryPartId; dwip.partWarehouseId = await Getv7v8IdMap(wip.PartWarehouseID, RootObjectTypes.PartWarehouse); - dwip.taxPartSaleId = await Getv7v8IdMapNullOK(wip.TaxPartSaleID, RootObjectTypes.TaxCode); + dwip.taxPartSaleId = await Getv7v8IdMapNullOk(wip.TaxPartSaleID, RootObjectTypes.TaxCode); if (wip.Discount != 0) dwip.priceOverride = wip.Price - (wip.Price * wip.Discount); else @@ -4118,12 +4117,12 @@ namespace AyaNova.PlugIn.V8 dwl.pmId = RavenId; dwl.pmItemId = ravenwoitemid; //null is ok here for user - dwl.userId = await Getv7v8IdMapNullOK(wl.UserID, RootObjectTypes.User); + dwl.userId = await Getv7v8IdMapNullOk(wl.UserID, RootObjectTypes.User); dwl.serviceStartDate = util.DateToV8(wl.ServiceStartDate); dwl.serviceStopDate = util.DateToV8(wl.ServiceStopDate); dwl.serviceRateQuantity = wl.ServiceRateQuantity; dwl.noChargeQuantity = wl.NoChargeQuantity; - dwl.taxCodeSaleId = await Getv7v8IdMapNullOK(wl.TaxRateSaleID, RootObjectTypes.TaxCode); + dwl.taxCodeSaleId = await Getv7v8IdMapNullOk(wl.TaxRateSaleID, RootObjectTypes.TaxCode); dwl.serviceRateId = await GetRate(false, wl.ServiceRateID); dwl.serviceDetails = wl.ServiceDetails; @@ -4138,12 +4137,12 @@ namespace AyaNova.PlugIn.V8 dwt.pmId = RavenId; dwt.pmItemId = ravenwoitemid; //null is ok here for user - dwt.userId = await Getv7v8IdMapNullOK(wt.UserID, RootObjectTypes.User); + dwt.userId = await Getv7v8IdMapNullOk(wt.UserID, RootObjectTypes.User); dwt.travelStartDate = util.DateToV8(wt.TravelStartDate); dwt.travelStopDate = util.DateToV8(wt.TravelStopDate); dwt.travelRateQuantity = wt.TravelRateQuantity; dwt.noChargeQuantity = wt.NoChargeQuantity; - dwt.taxCodeSaleId = await Getv7v8IdMapNullOK(wt.TaxRateSaleID, RootObjectTypes.TaxCode); + dwt.taxCodeSaleId = await Getv7v8IdMapNullOk(wt.TaxRateSaleID, RootObjectTypes.TaxCode); dwt.travelRateId = await GetRate(true, wt.TravelRateID); dwt.travelDetails = wt.TravelDetails; dwt.distance = wt.Distance; @@ -4428,8 +4427,8 @@ namespace AyaNova.PlugIn.V8 d.notes = c.Details; d.dateRequested = util.DateToV8(c.Created, true); d.customerId = await Getv7v8IdMap(c.ClientID, RootObjectTypes.Customer); - d.unitId = await Getv7v8IdMapNullOK(c.UnitID, RootObjectTypes.Unit, true, false, Getv7v8IdMap(c.ClientID, RootObjectTypes.Client)); - d.workOrderItemId = await Getv7v8IdMapNullOK(c.WorkorderItemID, RootObjectTypes.WorkOrderItem, false, false); + d.unitId = await Getv7v8IdMapNullOk(c.UnitID, RootObjectTypes.Unit, true, false, Getv7v8IdMap(c.ClientID, RootObjectTypes.Client)); + d.workOrderItemId = await Getv7v8IdMapNullOk(c.WorkorderItemID, RootObjectTypes.WorkOrderItem, false, false); d.requestedByUserId = SafeGetUserMap(c.Creator);//creator should always be a 'outside' user account d.customerReferenceNumber = c.ClientRef; d.priority = (int)c.Priority;//same int value @@ -5496,7 +5495,7 @@ namespace AyaNova.PlugIn.V8 //WIKI - private string GetWikiContent(TypeAndID tid) + private async System.Threading.Tasks.Task GetWikiContent(TypeAndID tid) { //may not exist // if (!WikiPage.HasWiki(tid.ID)) return null; @@ -5505,13 +5504,13 @@ namespace AyaNova.PlugIn.V8 var content = w.GetContentAsString; if (string.IsNullOrWhiteSpace(content)) return null; - + MatchCollection mc = AyaBizUtils.rxAyaImageTags.Matches(content); foreach (Match m in mc) { //this is image links to file attachments //if there is no match then chuck it, it's not critically important and already was missing in v7 anyway - var RavenId = await Getv7v8IdMapNullOK(new Guid(m.Groups["guid"].Value), tid.Type, false);//Map[new Guid(m.Groups["guid"].Value)]; + var RavenId = await Getv7v8IdMapNullOk(new Guid(m.Groups["guid"].Value), tid.RootObjectType, false);//Map[new Guid(m.Groups["guid"].Value)]; if (RavenId != null) content = content.Replace(m.Value, ""); else