diff --git a/source/Plugins/AyaNova.Plugin.V8/V8.cs b/source/Plugins/AyaNova.Plugin.V8/V8.cs index 5519bd1..4252076 100644 --- a/source/Plugins/AyaNova.Plugin.V8/V8.cs +++ b/source/Plugins/AyaNova.Plugin.V8/V8.cs @@ -208,7 +208,7 @@ namespace AyaNova.PlugIn.V8 - private async System.Threading.Tasks.Task Getv7v8IdMap(Guid id, RootObjectTypes desiredType, bool allowPatch = true, bool doNotFail = true, long? extraV8Id=null) + private async System.Threading.Tasks.Task Getv7v8IdMap(Guid id, RootObjectTypes desiredType, bool allowPatch = true, bool doNotFail = true, long? extraV8Id = null) { if (!V7ToV8IdMap.ContainsKey(id)) { @@ -223,7 +223,7 @@ namespace AyaNova.PlugIn.V8 return V7ToV8IdMap[id]; } - private async System.Threading.Tasks.Task Getv7v8IdMapNullOk(Guid id, RootObjectTypes desiredType, bool allowPatch = true, bool doNotFail = false, long? extraV8Id=null) + private async System.Threading.Tasks.Task 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, extraV8Id); @@ -237,14 +237,14 @@ 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, long? extraV8Id=null) + 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"; + 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) { @@ -297,8 +297,8 @@ namespace AyaNova.PlugIn.V8 case RootObjectTypes.Unit: { route = "unit"; - d.serial=sName; - d.customerId=extraV8Id; + d.serial = sName; + d.customerId = extraV8Id; } break; case RootObjectTypes.WorkOrderStatus: @@ -311,13 +311,23 @@ namespace AyaNova.PlugIn.V8 route = "work-order-item-priority"; } break; - + case RootObjectTypes.LoanUnit: { route = "loan-unit"; } break; - + case RootObjectTypes.ServiceRate: + { + route = "service-rate"; + } + break; + case RootObjectTypes.TravelRate: + { + route = "travel-rate"; + } + break; + default: throw new Exception("Error: CreateSubstitute (source id: " + id.ToString() + " for type: " + desiredType.ToString() + ") THIS TYPE NOT CODED YET"); } @@ -915,17 +925,17 @@ namespace AyaNova.PlugIn.V8 if (c.VendorID != Guid.Empty) { d.userType = RavenUserType.ServiceContractor; - d.vendorId = Getv7v8IdMap(c.VendorID, RootObjectTypes.Vendor); + d.vendorId = await Getv7v8IdMap(c.VendorID, RootObjectTypes.Vendor); } if (c.ClientID != Guid.Empty) { - d.customerId = Getv7v8IdMap(c.ClientID, RootObjectTypes.Client); + d.customerId = await Getv7v8IdMap(c.ClientID, RootObjectTypes.Client); } if (c.HeadOfficeID != Guid.Empty) { - d.headOfficeId = Getv7v8IdMap(c.HeadOfficeID, RootObjectTypes.HeadOffice); + d.headOfficeId = await Getv7v8IdMap(c.HeadOfficeID, RootObjectTypes.HeadOffice); } @@ -1007,9 +1017,9 @@ namespace AyaNova.PlugIn.V8 { if (!progress.KeepGoing) return; User c = User.GetItem(i.ID); - var newId = Getv7v8IdMap(c.ID, RootObjectTypes.User); - var creator = Getv7v8IdMap(c.ID, RootObjectTypes.User);//SafeGetUserMap(c.Creator); - var modifier = Getv7v8IdMap(c.ID, RootObjectTypes.User);//SafeGetUserMap(c.Modifier); + var newId = await Getv7v8IdMap(c.ID, RootObjectTypes.User); + var creator = await Getv7v8IdMap(c.ID, RootObjectTypes.User);//SafeGetUserMap(c.Creator); + var modifier = await Getv7v8IdMap(c.ID, RootObjectTypes.User);//SafeGetUserMap(c.Modifier); await util.EventLog(util.AyaType.User, newId, creator, modifier, c.Created, c.Modified); } @@ -1108,7 +1118,7 @@ namespace AyaNova.PlugIn.V8 if (c.HeadOfficeID != Guid.Empty) { - d.headOfficeId = Getv7v8IdMap(c.HeadOfficeID, RootObjectTypes.HeadOffice); + d.headOfficeId = await Getv7v8IdMap(c.HeadOfficeID, RootObjectTypes.HeadOffice); } d.techNotes = c.TechNotes; d.accountNumber = c.AccountNumber; @@ -1118,7 +1128,7 @@ namespace AyaNova.PlugIn.V8 if (c.ContractID != Guid.Empty) { - long? ctId = Getv7v8IdMapNullOk(c.ContractID, RootObjectTypes.Contract, false, true); + long? ctId = await Getv7v8IdMapNullOK(c.ContractID, RootObjectTypes.Contract, false, true); if (ctId != 0 && ctId != null) { @@ -1328,7 +1338,7 @@ namespace AyaNova.PlugIn.V8 if (c.ContractID != Guid.Empty) { - long? ctId = Getv7v8IdMapNullOk(c.ContractID, RootObjectTypes.Contract, false, true); + long? ctId = await Getv7v8IdMapNullOK(c.ContractID, RootObjectTypes.Contract, false, true); if (ctId != 0 && ctId != null) { @@ -1712,11 +1722,11 @@ namespace AyaNova.PlugIn.V8 d.partNumber = GetUniqueName(c.PartNumber); progress.SubOp(""); progress.Op(ObjectTypeName + " " + d.partNumber + " " + d.name); - d.manufacturerId = Getv7v8IdMapNullOk(c.ManufacturerID, RootObjectTypes.Vendor); + d.manufacturerId = await Getv7v8IdMapNullOK(c.ManufacturerID, RootObjectTypes.Vendor); d.manufacturerNumber = c.ManufacturerNumber; - d.wholeSalerId = Getv7v8IdMapNullOk(c.WholesalerID, RootObjectTypes.Vendor); + d.wholeSalerId = await Getv7v8IdMapNullOK(c.WholesalerID, RootObjectTypes.Vendor); d.wholeSalerNumber = c.WholesalerNumber; - d.alternativeWholeSalerId = 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; @@ -1846,7 +1856,7 @@ namespace AyaNova.PlugIn.V8 foreach (PartList.PartListInfo i in pl) { dynamic ditem = new JObject(); - ditem.partId = Getv7v8IdMap(i.LT_O_Part.Value, RootObjectTypes.Part); + ditem.partId = await Getv7v8IdMap(i.LT_O_Part.Value, RootObjectTypes.Part); ditem.partAssemblyId = 0; ditem.quantity = 1; dItems.Add(ditem); @@ -2023,13 +2033,13 @@ namespace AyaNova.PlugIn.V8 _highestPurchaseOrderNumberExported = c.PONumber; d.notes = c.Notes; d.vendorMemo = c.VendorMemo; - d.dropShipToCustomerId = Getv7v8IdMapNullOk(c.DropShipToClientID, RootObjectTypes.Client); + d.dropShipToCustomerId = await Getv7v8IdMapNullOK(c.DropShipToClientID, RootObjectTypes.Client); d.referenceNumber = c.ReferenceNumber; - d.vendorId = Getv7v8IdMap(c.VendorID, RootObjectTypes.Vendor); + 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 = Getv7v8IdMapNullOk(c.ProjectID, RootObjectTypes.Project); + d.projectId = await Getv7v8IdMapNullOK(c.ProjectID, RootObjectTypes.Project); StringBuilder sbText1 = new StringBuilder(); StringBuilder sbText2 = new StringBuilder(); @@ -2061,15 +2071,15 @@ namespace AyaNova.PlugIn.V8 dynamic dItem = new JObject(); dItem.purchaseOrderId = 0; - dItem.partId = Getv7v8IdMap(pi.PartID, RootObjectTypes.Part); - dItem.partWarehouseId = Getv7v8IdMap(pi.PartWarehouseID, RootObjectTypes.PartWarehouse); + dItem.partId = await Getv7v8IdMap(pi.PartID, RootObjectTypes.Part); + dItem.partWarehouseId = await Getv7v8IdMap(pi.PartWarehouseID, RootObjectTypes.PartWarehouse); dItem.quantityOrdered = pi.QuantityOrdered; dItem.quantityReceived = pi.QuantityReceived; //dItem.serials = string.Empty; StringBuilder sbSerials = new StringBuilder(); dItem.purchaseOrderCost = pi.PurchaseOrderCost; - dItem.partRequestedById = Getv7v8IdMapNullOk(pi.PartRequestedByID, RootObjectTypes.User); - dItem.purchaseTaxCodeId = 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 @@ -2247,11 +2257,11 @@ namespace AyaNova.PlugIn.V8 progress.Op(ObjectTypeName + " " + d.serial); d.active = c.Active; d.notes = c.Notes; - d.customerId = Getv7v8IdMap(c.ClientID, RootObjectTypes.Client); - d.unitModelId = Getv7v8IdMapNullOk(c.UnitModelID, RootObjectTypes.UnitModel); + d.customerId = await Getv7v8IdMap(c.ClientID, RootObjectTypes.Client); + d.unitModelId = await Getv7v8IdMapNullOK(c.UnitModelID, RootObjectTypes.UnitModel); d.unitHasOwnAddress = c.UnitHasOwnAddress; d.boughtHere = c.BoughtHere; - d.purchasedFromVendorId = 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; @@ -2333,13 +2343,13 @@ namespace AyaNova.PlugIn.V8 Unit c = Unit.GetItem(i.ID); if (c.ParentID == Guid.Empty && c.ReplacedByUnitID == Guid.Empty) continue; var ObjectTID = new TypeAndID(RootObjectTypes.Unit, c.ID); - long ThisUnitRavenId = Getv7v8IdMap(c.ID, RootObjectTypes.Unit); + long ThisUnitRavenId = await Getv7v8IdMap(c.ID, RootObjectTypes.Unit); var a = await util.GetAsync("unit/" + ThisUnitRavenId.ToString()); dynamic d = a.ObjectResponse["data"]; progress.Op(ObjectTypeName + " " + d.serial); - d.replacedByUnitId = Getv7v8IdMapNullOk(c.ReplacedByUnitID, RootObjectTypes.Unit); - d.parentUnitId = 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()); //----- @@ -2397,7 +2407,7 @@ namespace AyaNova.PlugIn.V8 d.active = c.Active; d.notes = c.Notes; if (c.VendorID != Guid.Empty) - d.vendorId = Getv7v8IdMap(c.VendorID, RootObjectTypes.Vendor); + d.vendorId = await Getv7v8IdMap(c.VendorID, RootObjectTypes.Vendor); d.upc = c.UPC; d.lifeTimeWarranty = c.LifeTimeWarranty; d.introduceDate = util.DateToV8(c.IntroducedDate); @@ -2677,8 +2687,8 @@ namespace AyaNova.PlugIn.V8 } //nope, it's non-existant anywhere if (mustExist) - todo: Used reg getv7 here - throw new Exception("Mandatory Rate missing, cannot proceed, last logged item needs to be fixed"); + return Getv7v8IdMap(rateId, RootObjectTypes.ServiceRate); + //throw new Exception("Mandatory Rate missing, cannot proceed, last logged item needs to be fixed"); else return null; } @@ -2703,8 +2713,8 @@ namespace AyaNova.PlugIn.V8 return ravenId; } //nope, it's non-existant anywhere - if (mustExist) todo: Used reg getv7 here - throw new Exception("Mandatory Rate missing, cannot proceed, last logged item needs to be fixed"); + if (mustExist) + return Getv7v8IdMap(rateId, RootObjectTypes.Travel); else return null; } @@ -3010,9 +3020,9 @@ namespace AyaNova.PlugIn.V8 d.serial = c.WorkorderService.ServiceNumber; if (c.WorkorderService.ServiceNumber > _highestWorkOrderNumberExported) _highestWorkOrderNumberExported = c.WorkorderService.ServiceNumber; - d.customerId = Getv7v8IdMap(c.ClientID, RootObjectTypes.Client); + d.customerId = await Getv7v8IdMap(c.ClientID, RootObjectTypes.Client); d.notes = c.Summary; - d.projectId = 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; @@ -3021,10 +3031,10 @@ namespace AyaNova.PlugIn.V8 d.completeByDate = util.DateToV8(c.WorkorderService.CloseByDate); d.invoiceNumber = c.WorkorderService.InvoiceNumber; d.onsite = c.Onsite; - long? ctId = 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 = 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) @@ -3098,9 +3108,9 @@ namespace AyaNova.PlugIn.V8 { dynamic state = new JObject(); state.workOrderId = RavenId; - state.workOrderStatusId = Getv7v8IdMap(c.WorkorderService.WorkorderStatusID, RootObjectTypes.WorkOrderStatus); + state.workOrderStatusId = await Getv7v8IdMap(c.WorkorderService.WorkorderStatusID, RootObjectTypes.WorkOrderStatus); state.created = util.DateToV8(c.Created, true); - state.userId = Getv7v8IdMap(c.Creator, RootObjectTypes.User); + state.userId = await Getv7v8IdMap(c.Creator, RootObjectTypes.User); await util.PostAsync("workorder/states", state.ToString()); } if (c.ServiceCompleted) @@ -3109,7 +3119,7 @@ namespace AyaNova.PlugIn.V8 state.workOrderId = RavenId; state.workOrderStatusId = ServiceCompletedWorkOrderStatus; state.created = util.DateToV8(c.Created, true); - state.userId = Getv7v8IdMap(c.Creator, RootObjectTypes.User); + state.userId = await Getv7v8IdMap(c.Creator, RootObjectTypes.User); await util.PostAsync("workorder/states", state.ToString()); } if (c.Closed) @@ -3118,7 +3128,7 @@ namespace AyaNova.PlugIn.V8 state.workOrderId = RavenId; state.workOrderStatusId = ClosedWorkOrderStatus; state.created = util.DateToV8(c.Created, true); - state.userId = Getv7v8IdMap(c.Creator, RootObjectTypes.User); + state.userId = await Getv7v8IdMap(c.Creator, RootObjectTypes.User); await util.PostAsync("workorder/states", state.ToString()); } } @@ -3140,7 +3150,7 @@ 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 = Getv7v8IdMapNullOk(wi.PriorityID, RootObjectTypes.WorkOrderItemPriority); + dwi.workOrderItemPriorityId = await Getv7v8IdMapNullOK(wi.PriorityID, RootObjectTypes.WorkOrderItemPriority); dwi.warrantyService = wi.WarrantyService; @@ -3160,7 +3170,7 @@ namespace AyaNova.PlugIn.V8 { //make sure we have a matching unit already - var ravUnitId = 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 @@ -3185,7 +3195,7 @@ namespace AyaNova.PlugIn.V8 dwisu.workOrderId = RavenId; dwisu.workOrderItemId = ravenwoitemid; //null is ok here for a sched user - dwisu.userId = 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; @@ -3201,7 +3211,7 @@ namespace AyaNova.PlugIn.V8 dwip.workOrderId = RavenId; dwip.workOrderItemId = ravenwoitemid; dwip.quantity = wip.Quantity; - var tryPartId = Getv7v8IdMapNullOk(wip.PartID, RootObjectTypes.Part); + var tryPartId = await Getv7v8IdMapNullOK(wip.PartID, RootObjectTypes.Part); if (tryPartId == null) { dwip.partId = UnknownV7PartId; @@ -3210,8 +3220,8 @@ namespace AyaNova.PlugIn.V8 } else dwip.partId = tryPartId; - dwip.partWarehouseId = Getv7v8IdMap(wip.PartWarehouseID, RootObjectTypes.PartWarehouse); - dwip.taxPartSaleId = Getv7v8IdMapNullOk(wip.TaxPartSaleID, RootObjectTypes.TaxCode); + dwip.partWarehouseId = await Getv7v8IdMap(wip.PartWarehouseID, RootObjectTypes.PartWarehouse); + dwip.taxPartSaleId = await Getv7v8IdMapNullOK(wip.TaxPartSaleID, RootObjectTypes.TaxCode); if (wip.Discount != 0) dwip.priceOverride = wip.Price - (wip.Price * wip.Discount); else @@ -3249,7 +3259,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 = 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()); @@ -3288,11 +3298,11 @@ namespace AyaNova.PlugIn.V8 dwil.workOrderId = RavenId; dwil.workOrderItemId = ravenwoitemid; - dwil.loanUnitId = Getv7v8IdMap(wil.LoanItemID, RootObjectTypes.LoanUnit); + dwil.loanUnitId = await Getv7v8IdMap(wil.LoanItemID, RootObjectTypes.LoanUnit); dwil.outDate = util.DateToV8(wil.OutDate); dwil.dueDate = util.DateToV8(wil.DueDate); dwil.returnDate = util.DateToV8(wil.ReturnDate); - dwil.taxCodeId = Getv7v8IdMapNullOk(wil.TaxCodeID, RootObjectTypes.TaxCode); + dwil.taxCodeId = await Getv7v8IdMapNullOK(wil.TaxCodeID, RootObjectTypes.TaxCode); dwil.quantity = wil.Quantity; switch (wil.Rate) { @@ -3331,12 +3341,12 @@ namespace AyaNova.PlugIn.V8 dwl.workOrderId = RavenId; dwl.workOrderItemId = ravenwoitemid; //null is ok here for user - dwl.userId = 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 = Getv7v8IdMapNullOk(wl.TaxRateSaleID, RootObjectTypes.TaxCode); + dwl.taxCodeSaleId = await Getv7v8IdMapNullOK(wl.TaxRateSaleID, RootObjectTypes.TaxCode); dwl.serviceRateId = await GetRate(false, wl.ServiceRateID); dwl.serviceDetails = wl.ServiceDetails; @@ -3351,12 +3361,12 @@ namespace AyaNova.PlugIn.V8 dwt.workOrderId = RavenId; dwt.workOrderItemId = ravenwoitemid; //null is ok here for user - dwt.userId = 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 = 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; @@ -3391,9 +3401,9 @@ namespace AyaNova.PlugIn.V8 dwe.totalCost = we.TotalCost; dwe.chargeAmount = we.ChargeAmount; dwe.taxPaid = we.TaxPaid; - dwe.chargeTaxCodeId = Getv7v8IdMapNullOk(we.ChargeTaxCodeID, RootObjectTypes.TaxCode); + dwe.chargeTaxCodeId = await Getv7v8IdMapNullOK(we.ChargeTaxCodeID, RootObjectTypes.TaxCode); dwe.reimburseUser = we.ReimburseUser; - dwe.userId = 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()); } @@ -3403,7 +3413,7 @@ namespace AyaNova.PlugIn.V8 { //make sure we have a matching unit already - var ravUnitId = 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 @@ -3413,8 +3423,8 @@ namespace AyaNova.PlugIn.V8 dwio.workOrderItemId = ravenwoitemid; dwio.unitId = ravUnitId; dwio.notes = wi.OutsideService.Notes; - dwio.vendorSentToId = Getv7v8IdMapNullOk(wi.OutsideService.VendorSentToID, RootObjectTypes.Vendor); - dwio.vendorSentViaId = 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; @@ -3563,20 +3573,20 @@ namespace AyaNova.PlugIn.V8 d.serial = c.WorkorderQuote.QuoteNumber; if (c.WorkorderQuote.QuoteNumber > _highestQuoteNumberExported) _highestQuoteNumberExported = c.WorkorderQuote.QuoteNumber; - d.customerId = Getv7v8IdMap(c.ClientID, RootObjectTypes.Client); + d.customerId = await Getv7v8IdMap(c.ClientID, RootObjectTypes.Client); d.notes = c.Summary; - d.projectId = 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); - d.preparedById = Getv7v8IdMap(c.WorkorderQuote.PreparedByID, RootObjectTypes.User); + d.preparedById = await Getv7v8IdMap(c.WorkorderQuote.PreparedByID, RootObjectTypes.User); d.introduction = c.WorkorderQuote.Introduction; d.requested = util.DateToV8(c.WorkorderQuote.QuoteRequestDate); d.validUntil = util.DateToV8(c.WorkorderQuote.ValidUntilDate); d.submitted = util.DateToV8(c.WorkorderQuote.DateSubmitted); d.approved = util.DateToV8(c.WorkorderQuote.DateApproved); - long? ctId = 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; @@ -3639,7 +3649,7 @@ namespace AyaNova.PlugIn.V8 state.quoteId = RavenId; state.quoteStatusId = (int)c.WorkorderQuote.QuoteStatus; state.created = util.DateToV8(c.Created, true); - state.userId = Getv7v8IdMap(c.Creator, RootObjectTypes.User); + state.userId = await Getv7v8IdMap(c.Creator, RootObjectTypes.User); await util.PostAsync("quote/states", state.ToString()); } @@ -3663,7 +3673,7 @@ 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 = Getv7v8IdMapNullOk(wi.PriorityID, RootObjectTypes.WorkOrderItemPriority); + dwi.workOrderItemPriorityId = await Getv7v8IdMapNullOK(wi.PriorityID, RootObjectTypes.WorkOrderItemPriority); dwi.warrantyService = wi.WarrantyService; @@ -3683,7 +3693,7 @@ namespace AyaNova.PlugIn.V8 { //make sure we have a matching unit already - var ravUnitId = 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 @@ -3708,7 +3718,7 @@ namespace AyaNova.PlugIn.V8 dwisu.quoteId = RavenId; dwisu.quoteItemId = ravenwoitemid; //null is ok here for a sched user - dwisu.userId = 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; @@ -3724,7 +3734,7 @@ namespace AyaNova.PlugIn.V8 dwip.quoteId = RavenId; dwip.quoteItemId = ravenwoitemid; dwip.quantity = wip.Quantity; - var tryPartId = Getv7v8IdMapNullOk(wip.PartID, RootObjectTypes.Part); + var tryPartId = await Getv7v8IdMapNullOK(wip.PartID, RootObjectTypes.Part); if (tryPartId == null) { dwip.partId = UnknownV7PartId; @@ -3733,8 +3743,8 @@ namespace AyaNova.PlugIn.V8 } else dwip.partId = tryPartId; - dwip.partWarehouseId = Getv7v8IdMap(wip.PartWarehouseID, RootObjectTypes.PartWarehouse); - dwip.taxPartSaleId = Getv7v8IdMapNullOk(wip.TaxPartSaleID, RootObjectTypes.TaxCode); + dwip.partWarehouseId = await Getv7v8IdMap(wip.PartWarehouseID, RootObjectTypes.PartWarehouse); + dwip.taxPartSaleId = await Getv7v8IdMapNullOK(wip.TaxPartSaleID, RootObjectTypes.TaxCode); if (wip.Discount != 0) dwip.priceOverride = wip.Price - (wip.Price * wip.Discount); else @@ -3757,12 +3767,12 @@ namespace AyaNova.PlugIn.V8 dwl.quoteId = RavenId; dwl.quoteItemId = ravenwoitemid; //null is ok here for user - dwl.userId = 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 = Getv7v8IdMapNullOk(wl.TaxRateSaleID, RootObjectTypes.TaxCode); + dwl.taxCodeSaleId = await Getv7v8IdMapNullOK(wl.TaxRateSaleID, RootObjectTypes.TaxCode); dwl.serviceRateId = await GetRate(false, wl.ServiceRateID); dwl.serviceDetails = wl.ServiceDetails; @@ -3777,12 +3787,12 @@ namespace AyaNova.PlugIn.V8 dwt.quoteId = RavenId; dwt.quoteItemId = ravenwoitemid; //null is ok here for user - dwt.userId = 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 = 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; @@ -3870,14 +3880,14 @@ namespace AyaNova.PlugIn.V8 d.serial = c.WorkorderPreventiveMaintenance.PreventiveMaintenanceNumber; if (c.WorkorderPreventiveMaintenance.PreventiveMaintenanceNumber > _highestPMNumberExported) _highestPMNumberExported = c.WorkorderPreventiveMaintenance.PreventiveMaintenanceNumber; - d.customerId = Getv7v8IdMap(c.ClientID, RootObjectTypes.Client); + d.customerId = await Getv7v8IdMap(c.ClientID, RootObjectTypes.Client); d.notes = c.Summary; - d.projectId = 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 = 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; @@ -4014,7 +4024,7 @@ 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 = Getv7v8IdMapNullOk(wi.PriorityID, RootObjectTypes.WorkOrderItemPriority); + dwi.workOrderItemPriorityId = await Getv7v8IdMapNullOK(wi.PriorityID, RootObjectTypes.WorkOrderItemPriority); dwi.warrantyService = wi.WarrantyService; @@ -4034,7 +4044,7 @@ namespace AyaNova.PlugIn.V8 { //make sure we have a matching unit already - var ravUnitId = 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 @@ -4059,7 +4069,7 @@ namespace AyaNova.PlugIn.V8 dwisu.pmId = RavenId; dwisu.pmItemId = ravenwoitemid; //null is ok here for a sched user - dwisu.userId = 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; @@ -4075,7 +4085,7 @@ namespace AyaNova.PlugIn.V8 dwip.pmId = RavenId; dwip.pmItemId = ravenwoitemid; dwip.quantity = wip.Quantity; - var tryPartId = Getv7v8IdMapNullOk(wip.PartID, RootObjectTypes.Part); + var tryPartId = await Getv7v8IdMapNullOK(wip.PartID, RootObjectTypes.Part); if (tryPartId == null) { dwip.partId = UnknownV7PartId; @@ -4084,8 +4094,8 @@ namespace AyaNova.PlugIn.V8 } else dwip.partId = tryPartId; - dwip.partWarehouseId = Getv7v8IdMap(wip.PartWarehouseID, RootObjectTypes.PartWarehouse); - dwip.taxPartSaleId = Getv7v8IdMapNullOk(wip.TaxPartSaleID, RootObjectTypes.TaxCode); + dwip.partWarehouseId = await Getv7v8IdMap(wip.PartWarehouseID, RootObjectTypes.PartWarehouse); + dwip.taxPartSaleId = await Getv7v8IdMapNullOK(wip.TaxPartSaleID, RootObjectTypes.TaxCode); if (wip.Discount != 0) dwip.priceOverride = wip.Price - (wip.Price * wip.Discount); else @@ -4108,12 +4118,12 @@ namespace AyaNova.PlugIn.V8 dwl.pmId = RavenId; dwl.pmItemId = ravenwoitemid; //null is ok here for user - dwl.userId = 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 = Getv7v8IdMapNullOk(wl.TaxRateSaleID, RootObjectTypes.TaxCode); + dwl.taxCodeSaleId = await Getv7v8IdMapNullOK(wl.TaxRateSaleID, RootObjectTypes.TaxCode); dwl.serviceRateId = await GetRate(false, wl.ServiceRateID); dwl.serviceDetails = wl.ServiceDetails; @@ -4128,12 +4138,12 @@ namespace AyaNova.PlugIn.V8 dwt.pmId = RavenId; dwt.pmItemId = ravenwoitemid; //null is ok here for user - dwt.userId = 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 = 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; @@ -4344,13 +4354,13 @@ namespace AyaNova.PlugIn.V8 // } // else // { - // d.sourceId = Getv7v8IdMap(i.LT_ServiceBank_Label_SourceRootObjectType.Value, "Service bank record's source object id"); + // d.sourceId = await Getv7v8IdMap(i.LT_ServiceBank_Label_SourceRootObjectType.Value, "Service bank record's source object id"); // } // } // // // d.sourceType = util.RootObjectToAyaType(i.LT_ServiceBank_Label_SourceRootObjectType.RootObjectType); - // d.objectId = Getv7v8IdMap(bo.Key, "Service bank record's root object id"); + // d.objectId = await Getv7v8IdMap(bo.Key, "Service bank record's root object id"); // d.objectType = util.RootObjectToAyaType(bo.Value); // d.incidents = i.LT_ServiceBank_Label_Incidents; // d.incidentsBalance = i.LT_ServiceBank_Label_IncidentsBalance; @@ -4417,9 +4427,9 @@ namespace AyaNova.PlugIn.V8 else 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,true,false,Getv7v8IdMap(c.ClientID, RootObjectTypes.Client)); - d.workOrderItemId = Getv7v8IdMapNullOk(c.WorkorderItemID, RootObjectTypes.WorkOrderItem, false, false); + 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.requestedByUserId = SafeGetUserMap(c.Creator);//creator should always be a 'outside' user account d.customerReferenceNumber = c.ClientRef; d.priority = (int)c.Priority;//same int value @@ -4472,7 +4482,7 @@ namespace AyaNova.PlugIn.V8 { progress.SubOp("sync part " + i.Name); PartInventoryList v7inv = PartInventoryList.GetListForSingleItem(i.ID); - long v8PartId = Getv7v8IdMap(i.ID, RootObjectTypes.Part); + long v8PartId = await Getv7v8IdMap(i.ID, RootObjectTypes.Part); JObject v8inv = (await util.GetAsync("part/latest-inventory/" + v8PartId)).ObjectResponse; //iterate v8 inventory foreach (JObject v8o in v8inv["data"]) @@ -4483,7 +4493,7 @@ namespace AyaNova.PlugIn.V8 decimal v8OnHand = (decimal)v8o["balance"]; foreach (PartInventoryList.PartInventoryListInfo v7o in v7inv) { - long whsv7tov8id = Getv7v8IdMap(v7o.LT_O_PartWarehouse.Value, RootObjectTypes.PartWarehouse); + long whsv7tov8id = await Getv7v8IdMap(v7o.LT_O_PartWarehouse.Value, RootObjectTypes.PartWarehouse); if (whsv7tov8id == (long)v8o["partWarehouseId"]) { //this is the match, do the fixup @@ -5332,7 +5342,7 @@ namespace AyaNova.PlugIn.V8 //Form data like the bizobject type and id string RavenTypeAsString = ""; int ravenType = 0;//notype is default for orphaned objects - long v8Id = Getv7v8IdMap(tid.ID, tid.RootObjectType, false, true);//default to 0 id if no match which is good for raven as it puts it into a list users can deal with in UI + long v8Id = await Getv7v8IdMap(tid.ID, tid.RootObjectType, false, true);//default to 0 id if no match which is good for raven as it puts it into a list users can deal with in UI if (v8Id != 0) { if (specificRavenType != util.AyaType.NoType) @@ -5437,7 +5447,7 @@ namespace AyaNova.PlugIn.V8 string RavenTypeAsString = ""; int ravenType = 0;//notype is default for orphaned objects - long v8Id = Getv7v8IdMap(tid.ID, tid.RootObjectType, false, true);//default to 0 id if no match which is good for raven as it puts it into a list users can deal with in UI + long v8Id = await Getv7v8IdMap(tid.ID, tid.RootObjectType, false, true);//default to 0 id if no match which is good for raven as it puts it into a list users can deal with in UI if (v8Id != 0) { if (specificRavenType != util.AyaType.NoType) @@ -5495,13 +5505,17 @@ namespace AyaNova.PlugIn.V8 var content = w.GetContentAsString; if (string.IsNullOrWhiteSpace(content)) return null; - //TODO: fixup internal urls using MAP of file attachment uploads - + MatchCollection mc = AyaBizUtils.rxAyaImageTags.Matches(content); foreach (Match m in mc) { - var RavenId = Getv7v8IdMap(new Guid(m.Groups["guid"].Value), tid.Type); ??//Map[new Guid(m.Groups["guid"].Value)]; - content = content.Replace(m.Value, ""); + //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)]; + if (RavenId != null) + content = content.Replace(m.Value, ""); + else + content = content.Replace(m.Value, "[v8migrate deleted / not found]"); } //todo: fixup font size, try to convert to heading tags instead