This commit is contained in:
2021-08-20 20:00:31 +00:00
parent 787057e3ba
commit d000ab45e8

View File

@@ -306,7 +306,7 @@ namespace AyaNova.PlugIn.V8
route = "work-order-status";
}
break;
case RootObjectTypes.LoanItem:
{
route = "loan-unit";
@@ -327,14 +327,14 @@ namespace AyaNova.PlugIn.V8
}
//post route and dynamic object, insert into map and return
var rMainObject = await util.PostAsync("customer", d);
var rMainObject = await util.PostAsync(route, d);
long RavenId = util.IdFromResponse(rMainObject);
Addv7v8IdMap(id, RavenId);
}
private long XXSafeGetUserMap(Guid id)
private long XXXSafeGetUserMap(Guid id)
{
if (!V7ToV8IdMap.ContainsKey(id)) return 1;//1=raven administrator account
return V7ToV8IdMap[id];
@@ -836,8 +836,8 @@ namespace AyaNova.PlugIn.V8
// if (!progress.KeepGoing) return;
// User c = User.GetItem(i.ID);
// var newId = GetMapMap[c.ID];
// var creator = SafeGetUserMap(c.Creator);
// var modifier = SafeGetUserMap(c.Modifier);
// var creator = await Getv7v8IdMap(c.Creator,RootObjectTypes.User);
// var modifier = await Getv7v8IdMap(c.Modifier,RootObjectTypes.User);
// await util.EventLog(util.AyaType.User, newId, creator, modifier, c.Created, c.Modified);
//}
@@ -1012,8 +1012,8 @@ namespace AyaNova.PlugIn.V8
if (!progress.KeepGoing) return;
User c = User.GetItem(i.ID);
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);
var creator = await Getv7v8IdMap(c.ID, RootObjectTypes.User);//await Getv7v8IdMap(c.Creator,RootObjectTypes.User);
var modifier = await Getv7v8IdMap(c.ID, RootObjectTypes.User);//await Getv7v8IdMap(c.Modifier,RootObjectTypes.User);
await util.EventLog(util.AyaType.User, newId, creator, modifier, c.Created, c.Modified);
}
@@ -1189,7 +1189,7 @@ namespace AyaNova.PlugIn.V8
//-----
//Event log fixup
await util.EventLog(util.AyaType.Customer, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified);
await util.EventLog(util.AyaType.Customer, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified);
//RAVEN Contact type user from Client contact
//note: this is not a login account, it could be in raven but here it's the way to get the
@@ -1230,7 +1230,7 @@ namespace AyaNova.PlugIn.V8
await util.PutAsync("user-option/" + RavenContactId.ToString(), d.ToString());
//Event log fixup (using customer data since the contact is created from the customer)
await util.EventLog(util.AyaType.User, RavenContactId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified);
await util.EventLog(util.AyaType.User, RavenContactId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified);
@@ -1263,14 +1263,14 @@ namespace AyaNova.PlugIn.V8
tags.Clear();
d = new JObject();
d.customerId = RavenId;
d.userId = SafeGetUserMap(cn.Creator);
d.userId = await Getv7v8IdMap(cn.Creator, RootObjectTypes.User);//SafeGetUserMap(cn.Creator);
d.noteDate = util.DateToV8(cn.Created, true);
d.notes = cn.Notes;
TagFromv7Guid(cn.ClientNoteTypeID, tags);
SetTags(d, tags);
var newId = util.IdFromResponse(await util.PostAsync("customer-note", d.ToString()));
//Event log fixup
await util.EventLog(util.AyaType.CustomerNote, newId, SafeGetUserMap(cn.Creator), SafeGetUserMap(cn.Modifier), cn.Created, cn.Modified);
await util.EventLog(util.AyaType.CustomerNote, newId, await Getv7v8IdMap(cn.Creator, RootObjectTypes.User), await Getv7v8IdMap(cn.Modifier, RootObjectTypes.User), cn.Created, cn.Modified);
@@ -1403,7 +1403,7 @@ namespace AyaNova.PlugIn.V8
//-----
//Event log fixup
await util.EventLog(util.AyaType.HeadOffice, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified);
await util.EventLog(util.AyaType.HeadOffice, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified);
@@ -1447,7 +1447,7 @@ namespace AyaNova.PlugIn.V8
await util.PutAsync("user-option/" + RavenContactId.ToString(), d.ToString());
//Event log fixup (using customer data since the contact is created from the customer)
await util.EventLog(util.AyaType.User, RavenContactId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified);
await util.EventLog(util.AyaType.User, RavenContactId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified);
}
@@ -1560,7 +1560,7 @@ namespace AyaNova.PlugIn.V8
//-----
//Event log fixup
await util.EventLog(util.AyaType.Contract, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified);
await util.EventLog(util.AyaType.Contract, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified);
}
}
@@ -1649,7 +1649,7 @@ namespace AyaNova.PlugIn.V8
//-----
//Event log fixup
await util.EventLog(util.AyaType.LoanUnit, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified);
await util.EventLog(util.AyaType.LoanUnit, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified);
}
}
@@ -1767,7 +1767,7 @@ namespace AyaNova.PlugIn.V8
//-----
//Event log fixup
await util.EventLog(util.AyaType.Part, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified);
await util.EventLog(util.AyaType.Part, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified);
//INVENTORY?
if (V7UseInventory)
@@ -1790,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 = MissingDataNamePrefix ;
dx.partNumber = GetUniqueName(MissingDataNamePrefix );
dx.name = MissingDataNamePrefix;
dx.partNumber = GetUniqueName(MissingDataNamePrefix);
progress.Op(ObjectTypeName + " " + dx.partNumber + " " + dx.name);
dx.cost = 0;
dx.retail = 0;
@@ -1863,7 +1863,11 @@ namespace AyaNova.PlugIn.V8
var rMainObject = await util.PostAsync("part-assembly", d.ToString());
long RavenId = util.IdFromResponse(rMainObject);
//Event log fixup
await util.EventLog(util.AyaType.Project, RavenId, SafeGetUserMap(p.Creator), SafeGetUserMap(p.Modifier), p.Created, p.Modified);
//await util.EventLog(util.AyaType.Project, RavenId, SafeGetUserMap(p.Creator), SafeGetUserMap(p.Modifier), p.Created, p.Modified);
long lCreator = await Getv7v8IdMap(p.Creator, RootObjectTypes.User);
long lModifier = await Getv7v8IdMap(p.Modifier, RootObjectTypes.User);
await util.EventLog(util.AyaType.Project, RavenId, lCreator, lModifier, p.Created, p.Modified);
}
}
#endregion part assemblies
@@ -1977,7 +1981,7 @@ namespace AyaNova.PlugIn.V8
//-----
//Event log fixup
await util.EventLog(util.AyaType.Project, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified);
await util.EventLog(util.AyaType.Project, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified);
}
}
@@ -2147,7 +2151,7 @@ namespace AyaNova.PlugIn.V8
//-----
//Event log fixup
await util.EventLog(util.AyaType.PurchaseOrder, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified);
await util.EventLog(util.AyaType.PurchaseOrder, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified);
}//end of PO loop
@@ -2202,7 +2206,7 @@ namespace AyaNova.PlugIn.V8
var rMainObject = await util.PostAsync("task-group", d.ToString());
long RavenId = util.IdFromResponse(rMainObject);
Addv7v8IdMap(c.ID, RavenId);
await util.EventLog(util.AyaType.Project, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified);
await util.EventLog(util.AyaType.Project, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified);
}
}
#endregion Task groups
@@ -2324,7 +2328,7 @@ namespace AyaNova.PlugIn.V8
//DONT DO THIS for second steppers UNTIL THE SECOND STEP BELOW OR IT WILL BE WRONG for them
//Event log fixup
if (c.ParentID == Guid.Empty && c.ReplacedByUnitID == Guid.Empty)
await util.EventLog(util.AyaType.Unit, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified);
await util.EventLog(util.AyaType.Unit, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified);
}
@@ -2348,7 +2352,7 @@ namespace AyaNova.PlugIn.V8
await util.PutAsync("unit", d.ToString());
//-----
//Event log fixup
await util.EventLog(util.AyaType.Unit, ThisUnitRavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified);
await util.EventLog(util.AyaType.Unit, ThisUnitRavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified);
}
}
#endregion Units
@@ -2448,7 +2452,7 @@ namespace AyaNova.PlugIn.V8
//-----
//Event log fixup
await util.EventLog(util.AyaType.UnitModel, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified);
await util.EventLog(util.AyaType.UnitModel, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified);
}
}
@@ -2564,7 +2568,7 @@ namespace AyaNova.PlugIn.V8
//-----
//Event log fixup
await util.EventLog(util.AyaType.Vendor, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified);
await util.EventLog(util.AyaType.Vendor, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified);
}
}
@@ -3092,7 +3096,7 @@ namespace AyaNova.PlugIn.V8
//-----
//Event log fixup
await util.EventLog(util.AyaType.WorkOrder, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified);
await util.EventLog(util.AyaType.WorkOrder, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified);
//######### STATE #######
//if closed then set that state as well but always first set the current state
@@ -3167,7 +3171,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, await Getv7v8IdMap(c.ClientID, RootObjectTypes.Client));
if (ravUnitId != null)
{
//we have a legit unit record, make it for v8
@@ -3295,7 +3299,7 @@ namespace AyaNova.PlugIn.V8
dwil.workOrderId = RavenId;
dwil.workOrderItemId = ravenwoitemid;
dwil.loanUnitId = await Getv7v8IdMap(wil.LoanItemID, RootObjectTypes.LoanUnit);
dwil.loanUnitId = await Getv7v8IdMap(wil.LoanItemID, RootObjectTypes.LoanItem);
dwil.outDate = util.DateToV8(wil.OutDate);
dwil.dueDate = util.DateToV8(wil.DueDate);
dwil.returnDate = util.DateToV8(wil.ReturnDate);
@@ -3410,7 +3414,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, await Getv7v8IdMap(c.ClientID, RootObjectTypes.Client));
if (ravUnitId != null)
{
//we have a legit unit record, make it for v8
@@ -3634,7 +3638,7 @@ namespace AyaNova.PlugIn.V8
//-----
//Event log fixup
await util.EventLog(util.AyaType.WorkOrder, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified);
await util.EventLog(util.AyaType.WorkOrder, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified);
//######### STATE #######
//if closed then set that state as well but always first set the current state
@@ -3691,7 +3695,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, await Getv7v8IdMap(c.ClientID, RootObjectTypes.Client));
if (ravUnitId != null)
{
//we have a legit unit record, make it for v8
@@ -4003,7 +4007,7 @@ namespace AyaNova.PlugIn.V8
//-----
//Event log fixup
await util.EventLog(util.AyaType.WorkOrder, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified);
await util.EventLog(util.AyaType.WorkOrder, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified);
//##### ITEMS
@@ -4043,7 +4047,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, await Getv7v8IdMap(c.ClientID, RootObjectTypes.Client));
if (ravUnitId != null)
{
//we have a legit unit record, make it for v8
@@ -4254,7 +4258,7 @@ namespace AyaNova.PlugIn.V8
d.name = c.Name;
d.notes = c.Notes;
d.userId = V7ToV8IdMap[c.SourceID];
d.assignedByUserId = SafeGetUserMap(c.Creator);
d.assignedByUserId = await Getv7v8IdMap(c.Creator, RootObjectTypes.User);
d.objectId = V7ToV8IdMap[c.FollowID];
d.objectType = util.RootObjectToAyaType(c.FollowType);
SetTags(d, tags);
@@ -4262,7 +4266,7 @@ namespace AyaNova.PlugIn.V8
var rMainObject = await util.PostAsync("review", d.ToString());
long RavenId = util.IdFromResponse(rMainObject);
Addv7v8IdMap(c.ID, RavenId);
await util.EventLog(util.AyaType.Review, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified);
await util.EventLog(util.AyaType.Review, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified);
}
else
{
@@ -4304,7 +4308,7 @@ namespace AyaNova.PlugIn.V8
long RavenId = util.IdFromResponse(rMainObject);
if (!V7ToV8IdMap.ContainsKey(c.ID))
Addv7v8IdMap(c.ID, RavenId);
await util.EventLog(util.AyaType.Reminder, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified);
await util.EventLog(util.AyaType.Reminder, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified);
}
}
}
@@ -4426,10 +4430,10 @@ namespace AyaNova.PlugIn.V8
else
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.requestedByUserId = SafeGetUserMap(c.Creator);//creator should always be a 'outside' user account
d.customerId = await Getv7v8IdMap(c.ClientID, RootObjectTypes.Client);
d.unitId = await Getv7v8IdMapNullOk(c.UnitID, RootObjectTypes.Unit, true, false, await Getv7v8IdMap(c.ClientID, RootObjectTypes.Client));
d.workOrderItemId = await Getv7v8IdMapNullOk(c.WorkorderItemID, RootObjectTypes.WorkorderItem, false, false);
d.requestedByUserId = await Getv7v8IdMap(c.Creator, RootObjectTypes.User);//creator should always be a 'outside' user account
d.customerReferenceNumber = c.ClientRef;
d.priority = (int)c.Priority;//same int value
if (c.Status == ClientServiceRequestStatus.Closed)
@@ -4458,7 +4462,7 @@ namespace AyaNova.PlugIn.V8
//-----
//Event log fixup
await util.EventLog(util.AyaType.CustomerServiceRequest, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified);
await util.EventLog(util.AyaType.CustomerServiceRequest, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified);
}
}