This commit is contained in:
2022-08-19 21:27:54 +00:00
parent 736c33ebfd
commit 191cbe3f56

View File

@@ -238,6 +238,28 @@ namespace AyaNova.PlugIn.V8
return l; return l;
} }
//case 4177 creator modifier user missing should not fail to get a user however means necessary
private long EventLogSubstituteUserId = 0;
private async System.Threading.Tasks.Task<long> Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(Guid id)
{
if (id == Guid.Empty)
{
if (EventLogSubstituteUserId == 0)//make a User just for this, doesn't matter what Guid we use ebecause it's temporary and we cache the v8 id anyway
EventLogSubstituteUserId = await Getv7v8IdMap(Guid.NewGuid(), RootObjectTypes.User, true, true);
return EventLogSubstituteUserId;
};
//Normal default path for proper user that exists and was exported already
if (V7ToV8IdMap.ContainsKey(id))
return V7ToV8IdMap[id];
//Ok, we have a guid but it doesn't exist so it's likely a deleted User record of some kind or missing one
//since there is a valid guid we should create a user for that ID as it likely is set on other records too
return await Getv7v8IdMap(id, RootObjectTypes.User, true, true);
}
//UNKNOWN / MISSING RECORD OBJECT STAND INs //UNKNOWN / MISSING RECORD OBJECT STAND INs
@@ -1053,14 +1075,19 @@ namespace AyaNova.PlugIn.V8
//EVENT LOG //EVENT LOG
//NOTE: This sets the event log for **ALL** inside and outside users and is called here because all users are now exported
//Because this is the User's we need to do the event log *after* they have all been posted as event log requires all user's id //Because this is the User's we need to do the event log *after* they have all been posted as event log requires all user's id
foreach (UserPickList.UserPickListInfo i in pl) foreach (UserPickList.UserPickListInfo i in pl)
{ {
if (!progress.KeepGoing) return; if (!progress.KeepGoing) return;
User c = User.GetItem(i.ID); User c = User.GetItem(i.ID);
var newId = await Getv7v8IdMap(c.ID, RootObjectTypes.User); var newId = await Getv7v8IdMap(c.ID, RootObjectTypes.User);
var creator = await Getv7v8IdMap(c.ID, RootObjectTypes.User);//await Getv7v8IdMap(c.Creator,RootObjectTypes.User); //Note: seems there was a bug here, assuming so anyway, for some reason it's using the User id as the creator modifier of itself
var modifier = await Getv7v8IdMap(c.ID, RootObjectTypes.User);//await Getv7v8IdMap(c.Modifier,RootObjectTypes.User); //instead of the actual one, this is weird and makes no sense so switching back again
//with th enew code for case 4177 it will not fail in any case anyway
var creator = await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Creator);//await Getv7v8IdMap(c.ID, RootObjectTypes.User);//await Getv7v8IdMap(c.Creator,RootObjectTypes.User);
var modifier = await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Modifier);//Getv7v8IdMap(c.ID, RootObjectTypes.User);//await Getv7v8IdMap(c.Modifier,RootObjectTypes.User);
await util.EventLog(util.AyaType.User, newId, creator, modifier, c.Created, c.Modified); await util.EventLog(util.AyaType.User, newId, creator, modifier, c.Created, c.Modified);
} }
@@ -1236,7 +1263,7 @@ namespace AyaNova.PlugIn.V8
//----- //-----
//Event log fixup //Event log fixup
await util.EventLog(util.AyaType.Customer, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified); await util.EventLog(util.AyaType.Customer, RavenId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Modifier), c.Created, c.Modified);
//RAVEN Contact type user from Client contact //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 //note: this is not a login account, it could be in raven but here it's the way to get the
@@ -1277,7 +1304,7 @@ namespace AyaNova.PlugIn.V8
await util.PutAsync("user-option/" + RavenContactId.ToString(), d); await util.PutAsync("user-option/" + RavenContactId.ToString(), d);
//Event log fixup (using customer data since the contact is created from the customer) //Event log fixup (using customer data since the contact is created from the customer)
await util.EventLog(util.AyaType.User, RavenContactId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified); await util.EventLog(util.AyaType.User, RavenContactId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Modifier), c.Created, c.Modified);
@@ -1317,7 +1344,7 @@ namespace AyaNova.PlugIn.V8
SetTags(d, tags); SetTags(d, tags);
var newId = util.IdFromResponse(await util.PostAsync("customer-note", d.ToString())); var newId = util.IdFromResponse(await util.PostAsync("customer-note", d.ToString()));
//Event log fixup //Event log fixup
await util.EventLog(util.AyaType.CustomerNote, newId, await Getv7v8IdMap(cn.Creator, RootObjectTypes.User), await Getv7v8IdMap(cn.Modifier, RootObjectTypes.User), cn.Created, cn.Modified); await util.EventLog(util.AyaType.CustomerNote, newId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(cn.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(cn.Modifier), cn.Created, cn.Modified);
@@ -1450,7 +1477,7 @@ namespace AyaNova.PlugIn.V8
//----- //-----
//Event log fixup //Event log fixup
await util.EventLog(util.AyaType.HeadOffice, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified); await util.EventLog(util.AyaType.HeadOffice, RavenId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Modifier), c.Created, c.Modified);
@@ -1494,7 +1521,7 @@ namespace AyaNova.PlugIn.V8
await util.PutAsync("user-option/" + RavenContactId.ToString(), d); await util.PutAsync("user-option/" + RavenContactId.ToString(), d);
//Event log fixup (using customer data since the contact is created from the customer) //Event log fixup (using customer data since the contact is created from the customer)
await util.EventLog(util.AyaType.User, RavenContactId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified); await util.EventLog(util.AyaType.User, RavenContactId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Modifier), c.Created, c.Modified);
} }
@@ -1531,7 +1558,12 @@ namespace AyaNova.PlugIn.V8
var ObjectTID = new TypeAndID(RootObjectTypes.Contract, c.ID); var ObjectTID = new TypeAndID(RootObjectTypes.Contract, c.ID);
dynamic d = new JObject(); dynamic d = new JObject();
d.name = GetUniqueName(c.Name); //in v8 names are mandatory but not in v7
//case 4176
if (string.IsNullOrWhiteSpace(c.Name))
d.name = GetUniqueName("No name contract");
else
d.name = GetUniqueName(c.Name);
if (IsDuplicatev7v8IdMapItem(c.ID, c.Name, progress)) continue; if (IsDuplicatev7v8IdMapItem(c.ID, c.Name, progress)) continue;
progress.Op(ObjectTypeName + " " + d.name); progress.Op(ObjectTypeName + " " + d.name);
d.active = c.Active; d.active = c.Active;
@@ -1607,7 +1639,7 @@ namespace AyaNova.PlugIn.V8
//----- //-----
//Event log fixup //Event log fixup
await util.EventLog(util.AyaType.Contract, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified); await util.EventLog(util.AyaType.Contract, RavenId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Modifier), c.Created, c.Modified);
} }
} }
@@ -1694,7 +1726,7 @@ namespace AyaNova.PlugIn.V8
//----- //-----
//Event log fixup //Event log fixup
await util.EventLog(util.AyaType.LoanUnit, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified); await util.EventLog(util.AyaType.LoanUnit, RavenId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Modifier), c.Created, c.Modified);
} }
} }
@@ -1909,7 +1941,7 @@ namespace AyaNova.PlugIn.V8
//----- //-----
//Event log fixup //Event log fixup
await util.EventLog(util.AyaType.Part, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified); await util.EventLog(util.AyaType.Part, RavenId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Modifier), c.Created, c.Modified);
//INVENTORY? //INVENTORY?
if (V7UseInventory) if (V7UseInventory)
@@ -2013,8 +2045,8 @@ namespace AyaNova.PlugIn.V8
var rMainObject = await util.PostAsync("part-assembly", d); var rMainObject = await util.PostAsync("part-assembly", d);
long RavenId = util.IdFromResponse(rMainObject); long RavenId = util.IdFromResponse(rMainObject);
//Event log fixup //Event log fixup
long lCreator = await Getv7v8IdMap(p.Creator, RootObjectTypes.User); long lCreator = await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(p.Creator);
long lModifier = await Getv7v8IdMap(p.Modifier, RootObjectTypes.User); long lModifier = await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(p.Modifier);
await util.EventLog(util.AyaType.Project, RavenId, lCreator, lModifier, p.Created, p.Modified); await util.EventLog(util.AyaType.Project, RavenId, lCreator, lModifier, p.Created, p.Modified);
} }
@@ -2062,7 +2094,7 @@ namespace AyaNova.PlugIn.V8
long RavenId = util.IdFromResponse(rMainObject); long RavenId = util.IdFromResponse(rMainObject);
Addv7v8IdMap(i.ID, RavenId); Addv7v8IdMap(i.ID, RavenId);
Allv8WarehouseIds.Add(RavenId); Allv8WarehouseIds.Add(RavenId);
await util.EventLog(util.AyaType.PartWarehouse, RavenId, await Getv7v8IdMap(i.Creator, RootObjectTypes.User), await Getv7v8IdMap(i.Modifier, RootObjectTypes.User), i.Created, i.Modified); await util.EventLog(util.AyaType.PartWarehouse, RavenId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(i.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(i.Modifier), i.Created, i.Modified);
} }
} }
#endregion warehouses #endregion warehouses
@@ -2135,7 +2167,7 @@ namespace AyaNova.PlugIn.V8
//----- //-----
//Event log fixup //Event log fixup
await util.EventLog(util.AyaType.Project, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified); await util.EventLog(util.AyaType.Project, RavenId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Modifier), c.Created, c.Modified);
} }
} }
@@ -2306,7 +2338,7 @@ namespace AyaNova.PlugIn.V8
//----- //-----
//Event log fixup //Event log fixup
await util.EventLog(util.AyaType.PurchaseOrder, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified); await util.EventLog(util.AyaType.PurchaseOrder, RavenId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Modifier), c.Created, c.Modified);
}//end of PO loop }//end of PO loop
@@ -2486,7 +2518,7 @@ namespace AyaNova.PlugIn.V8
var rMainObject = await util.PostAsync("task-group", d); var rMainObject = await util.PostAsync("task-group", d);
long RavenId = util.IdFromResponse(rMainObject); long RavenId = util.IdFromResponse(rMainObject);
Addv7v8IdMap(c.ID, RavenId); Addv7v8IdMap(c.ID, RavenId);
await util.EventLog(util.AyaType.Project, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified); await util.EventLog(util.AyaType.Project, RavenId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Modifier), c.Created, c.Modified);
} }
} }
#endregion Task groups #endregion Task groups
@@ -2606,7 +2638,7 @@ namespace AyaNova.PlugIn.V8
//DONT DO THIS for second steppers UNTIL THE SECOND STEP BELOW OR IT WILL BE WRONG for them //DONT DO THIS for second steppers UNTIL THE SECOND STEP BELOW OR IT WILL BE WRONG for them
//Event log fixup //Event log fixup
if (c.ParentID == Guid.Empty && c.ReplacedByUnitID == Guid.Empty) if (c.ParentID == Guid.Empty && c.ReplacedByUnitID == Guid.Empty)
await util.EventLog(util.AyaType.Unit, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified); await util.EventLog(util.AyaType.Unit, RavenId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Modifier), c.Created, c.Modified);
} }
@@ -2630,7 +2662,7 @@ namespace AyaNova.PlugIn.V8
await util.PutAsync("unit", d); await util.PutAsync("unit", d);
//----- //-----
//Event log fixup //Event log fixup
await util.EventLog(util.AyaType.Unit, ThisUnitRavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified); await util.EventLog(util.AyaType.Unit, ThisUnitRavenId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Modifier), c.Created, c.Modified);
} }
} }
@@ -2775,7 +2807,7 @@ namespace AyaNova.PlugIn.V8
//----- //-----
//Event log fixup //Event log fixup
await util.EventLog(util.AyaType.UnitModel, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified); await util.EventLog(util.AyaType.UnitModel, RavenId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Modifier), c.Created, c.Modified);
} }
} }
@@ -2891,7 +2923,7 @@ namespace AyaNova.PlugIn.V8
//----- //-----
//Event log fixup //Event log fixup
await util.EventLog(util.AyaType.Vendor, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified); await util.EventLog(util.AyaType.Vendor, RavenId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Modifier), c.Created, c.Modified);
} }
} }
@@ -2980,7 +3012,7 @@ namespace AyaNova.PlugIn.V8
//----- //-----
//Event log fixup //Event log fixup
await util.EventLog(ravenType, RavenId, await Getv7v8IdMap(i.Creator, RootObjectTypes.User), await Getv7v8IdMap(i.Modifier, RootObjectTypes.User), i.Created, i.Modified); await util.EventLog(ravenType, RavenId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(i.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(i.Modifier), i.Created, i.Modified);
} }
} }
@@ -3094,7 +3126,7 @@ namespace AyaNova.PlugIn.V8
//----- //-----
//Event log fixup //Event log fixup
await util.EventLog(util.AyaType.TaxCode, RavenId, await Getv7v8IdMap(i.Creator, RootObjectTypes.User), await Getv7v8IdMap(i.Modifier, RootObjectTypes.User), i.Created, i.Modified); await util.EventLog(util.AyaType.TaxCode, RavenId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(i.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(i.Modifier), i.Created, i.Modified);
} }
} }
@@ -3179,7 +3211,7 @@ namespace AyaNova.PlugIn.V8
var rMainObject = await util.PostAsync("work-order-item-priority", d); var rMainObject = await util.PostAsync("work-order-item-priority", d);
long RavenId = util.IdFromResponse(rMainObject); long RavenId = util.IdFromResponse(rMainObject);
Addv7v8IdMap(s.ID, RavenId); Addv7v8IdMap(s.ID, RavenId);
await util.EventLog(util.AyaType.WorkOrderItemPriority, RavenId, await Getv7v8IdMap(s.Creator, RootObjectTypes.User), await Getv7v8IdMap(s.Modifier, RootObjectTypes.User), s.Created, s.Modified); await util.EventLog(util.AyaType.WorkOrderItemPriority, RavenId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(s.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(s.Modifier), s.Created, s.Modified);
} }
@@ -3223,7 +3255,7 @@ namespace AyaNova.PlugIn.V8
long RavenId = util.IdFromResponse(rMainObject); long RavenId = util.IdFromResponse(rMainObject);
Addv7v8IdMap(s.ID, RavenId); Addv7v8IdMap(s.ID, RavenId);
//Event log fixup //Event log fixup
await util.EventLog(util.AyaType.WorkOrderStatus, RavenId, await Getv7v8IdMap(s.Creator, RootObjectTypes.User), await Getv7v8IdMap(s.Modifier, RootObjectTypes.User), s.Created, s.Modified); await util.EventLog(util.AyaType.WorkOrderStatus, RavenId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(s.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(s.Modifier), s.Created, s.Modified);
} }
//Second export for workorder items //Second export for workorder items
@@ -3241,7 +3273,7 @@ namespace AyaNova.PlugIn.V8
var rMainObject = await util.PostAsync("work-order-item-status", d); var rMainObject = await util.PostAsync("work-order-item-status", d);
long RavenId = util.IdFromResponse(rMainObject); long RavenId = util.IdFromResponse(rMainObject);
Addv7v8WorkOrderItemStatusIdMap(s.ID, RavenId); Addv7v8WorkOrderItemStatusIdMap(s.ID, RavenId);
await util.EventLog(util.AyaType.WorkOrderItemStatus, RavenId, await Getv7v8IdMap(s.Creator, RootObjectTypes.User), await Getv7v8IdMap(s.Modifier, RootObjectTypes.User), s.Created, s.Modified); await util.EventLog(util.AyaType.WorkOrderItemStatus, RavenId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(s.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(s.Modifier), s.Created, s.Modified);
} }
@@ -3439,7 +3471,7 @@ namespace AyaNova.PlugIn.V8
//----- //-----
//Event log fixup //Event log fixup
await util.EventLog(util.AyaType.WorkOrder, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified); await util.EventLog(util.AyaType.WorkOrder, RavenId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Modifier), c.Created, c.Modified);
//######### STATE ####### //######### STATE #######
//if closed then set that state as well but always first set the current state //if closed then set that state as well but always first set the current state
@@ -3451,7 +3483,7 @@ namespace AyaNova.PlugIn.V8
state.workOrderId = RavenId; 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.created = util.DateToV8(c.Created, true);
state.userId = await Getv7v8IdMap(c.Creator, RootObjectTypes.User); state.userId = await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Creator);
await util.PostAsync("workorder/states", state.ToString()); await util.PostAsync("workorder/states", state.ToString());
} }
if (c.ServiceCompleted) if (c.ServiceCompleted)
@@ -3460,7 +3492,7 @@ namespace AyaNova.PlugIn.V8
state.workOrderId = RavenId; state.workOrderId = RavenId;
state.workOrderStatusId = ServiceCompletedWorkOrderStatus; state.workOrderStatusId = ServiceCompletedWorkOrderStatus;
state.created = util.DateToV8(c.Created, true); state.created = util.DateToV8(c.Created, true);
state.userId = await Getv7v8IdMap(c.Creator, RootObjectTypes.User); state.userId = await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Creator);
await util.PostAsync("workorder/states", state.ToString()); await util.PostAsync("workorder/states", state.ToString());
} }
if (c.Closed) if (c.Closed)
@@ -3469,7 +3501,7 @@ namespace AyaNova.PlugIn.V8
state.workOrderId = RavenId; state.workOrderId = RavenId;
state.workOrderStatusId = ClosedWorkOrderStatus; state.workOrderStatusId = ClosedWorkOrderStatus;
state.created = util.DateToV8(c.Created, true); state.created = util.DateToV8(c.Created, true);
state.userId = await Getv7v8IdMap(c.Creator, RootObjectTypes.User); state.userId = await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Creator);
await util.PostAsync("workorder/states", state.ToString()); await util.PostAsync("workorder/states", state.ToString());
} }
} }
@@ -3507,7 +3539,7 @@ namespace AyaNova.PlugIn.V8
var ravenwoitemid = util.IdFromResponse(await util.PostAsync("workorder/items", dwi.ToString())); var ravenwoitemid = util.IdFromResponse(await util.PostAsync("workorder/items", dwi.ToString()));
await util.EventLog(util.AyaType.WorkOrderItem, ravenwoitemid, await Getv7v8IdMap(wi.Creator, RootObjectTypes.User), await Getv7v8IdMap(wi.Modifier, RootObjectTypes.User), wi.Created, wi.Modified); await util.EventLog(util.AyaType.WorkOrderItem, ravenwoitemid, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(wi.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(wi.Modifier), wi.Created, wi.Modified);
//##### WORKORDER ITEM UNIT //##### WORKORDER ITEM UNIT
if (wi.UnitID != Guid.Empty) if (wi.UnitID != Guid.Empty)
@@ -3998,7 +4030,7 @@ namespace AyaNova.PlugIn.V8
//----- //-----
//Event log fixup //Event log fixup
await util.EventLog(util.AyaType.WorkOrder, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified); await util.EventLog(util.AyaType.WorkOrder, RavenId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Modifier), c.Created, c.Modified);
//######### STATE ####### //######### STATE #######
//if closed then set that state as well but always first set the current state //if closed then set that state as well but always first set the current state
@@ -4010,7 +4042,7 @@ namespace AyaNova.PlugIn.V8
state.quoteId = RavenId; state.quoteId = RavenId;
state.quoteStatusId = (int)c.WorkorderQuote.QuoteStatus; state.quoteStatusId = (int)c.WorkorderQuote.QuoteStatus;
state.created = util.DateToV8(c.Created, true); state.created = util.DateToV8(c.Created, true);
state.userId = await Getv7v8IdMap(c.Creator, RootObjectTypes.User); state.userId = await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Creator);
await util.PostAsync("quote/states", state.ToString()); await util.PostAsync("quote/states", state.ToString());
} }
@@ -4048,7 +4080,7 @@ namespace AyaNova.PlugIn.V8
var ravenwoitemid = util.IdFromResponse(await util.PostAsync("quote/items", dwi.ToString())); var ravenwoitemid = util.IdFromResponse(await util.PostAsync("quote/items", dwi.ToString()));
await util.EventLog(util.AyaType.WorkOrderItem, ravenwoitemid, await Getv7v8IdMap(wi.Creator, RootObjectTypes.User), await Getv7v8IdMap(wi.Modifier, RootObjectTypes.User), wi.Created, wi.Modified); await util.EventLog(util.AyaType.WorkOrderItem, ravenwoitemid, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(wi.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(wi.Modifier), wi.Created, wi.Modified);
//##### WORKORDER ITEM UNIT //##### WORKORDER ITEM UNIT
if (wi.UnitID != Guid.Empty) if (wi.UnitID != Guid.Empty)
@@ -4368,7 +4400,7 @@ namespace AyaNova.PlugIn.V8
//----- //-----
//Event log fixup //Event log fixup
await util.EventLog(util.AyaType.WorkOrder, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified); await util.EventLog(util.AyaType.WorkOrder, RavenId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Modifier), c.Created, c.Modified);
//##### ITEMS //##### ITEMS
@@ -4401,7 +4433,7 @@ namespace AyaNova.PlugIn.V8
var ravenwoitemid = util.IdFromResponse(await util.PostAsync("pm/items", dwi.ToString())); var ravenwoitemid = util.IdFromResponse(await util.PostAsync("pm/items", dwi.ToString()));
await util.EventLog(util.AyaType.WorkOrderItem, ravenwoitemid, await Getv7v8IdMap(wi.Creator, RootObjectTypes.User), await Getv7v8IdMap(wi.Modifier, RootObjectTypes.User), wi.Created, wi.Modified); await util.EventLog(util.AyaType.WorkOrderItem, ravenwoitemid, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(wi.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(wi.Modifier), wi.Created, wi.Modified);
//##### WORKORDER ITEM UNIT //##### WORKORDER ITEM UNIT
if (wi.UnitID != Guid.Empty) if (wi.UnitID != Guid.Empty)
@@ -4616,7 +4648,7 @@ namespace AyaNova.PlugIn.V8
d.name = c.Name; d.name = c.Name;
d.notes = c.Notes; d.notes = c.Notes;
d.userId = V7ToV8IdMap[c.SourceID]; d.userId = V7ToV8IdMap[c.SourceID];
d.assignedByUserId = await Getv7v8IdMap(c.Creator, RootObjectTypes.User); d.assignedByUserId = await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Creator);
long? v8FollowId = null; long? v8FollowId = null;
switch (c.FollowType) switch (c.FollowType)
{ {
@@ -4707,7 +4739,7 @@ namespace AyaNova.PlugIn.V8
var rMainObject = await util.PostAsync("review", d); var rMainObject = await util.PostAsync("review", d);
long RavenId = util.IdFromResponse(rMainObject); long RavenId = util.IdFromResponse(rMainObject);
Addv7v8IdMap(c.ID, RavenId); Addv7v8IdMap(c.ID, RavenId);
await util.EventLog(util.AyaType.Review, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified); await util.EventLog(util.AyaType.Review, RavenId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Modifier), c.Created, c.Modified);
} }
else else
{ {
@@ -4749,7 +4781,7 @@ namespace AyaNova.PlugIn.V8
long RavenId = util.IdFromResponse(rMainObject); long RavenId = util.IdFromResponse(rMainObject);
if (!V7ToV8IdMap.ContainsKey(c.ID)) if (!V7ToV8IdMap.ContainsKey(c.ID))
Addv7v8IdMap(c.ID, RavenId); Addv7v8IdMap(c.ID, RavenId);
await util.EventLog(util.AyaType.Reminder, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified); await util.EventLog(util.AyaType.Reminder, RavenId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Modifier), c.Created, c.Modified);
} }
} }
} }
@@ -4888,7 +4920,7 @@ namespace AyaNova.PlugIn.V8
} }
} }
d.requestedByUserId = await Getv7v8IdMap(c.Creator, RootObjectTypes.User);//creator should always be a 'outside' user account d.requestedByUserId = await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Creator);//creator should always be a 'outside' user account, but don't let it fail either way
d.customerReferenceNumber = c.ClientRef; d.customerReferenceNumber = c.ClientRef;
d.priority = (int)c.Priority;//same int value d.priority = (int)c.Priority;//same int value
if (c.Status == ClientServiceRequestStatus.Closed) if (c.Status == ClientServiceRequestStatus.Closed)
@@ -4917,7 +4949,7 @@ namespace AyaNova.PlugIn.V8
//----- //-----
//Event log fixup //Event log fixup
await util.EventLog(util.AyaType.CustomerServiceRequest, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified); await util.EventLog(util.AyaType.CustomerServiceRequest, RavenId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(c.Modifier), c.Created, c.Modified);
} }
} }
@@ -5834,7 +5866,7 @@ namespace AyaNova.PlugIn.V8
await util.PutAsync("form-custom/" + formCustomKey, d); await util.PutAsync("form-custom/" + formCustomKey, d);
//Event log fixup //Event log fixup
await util.EventLog(util.AyaType.FormCustom, RavenFormCustomId, await Getv7v8IdMap(Creator, RootObjectTypes.User), await Getv7v8IdMap(Modifier, RootObjectTypes.User), Created, Modified); await util.EventLog(util.AyaType.FormCustom, RavenFormCustomId, await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(Creator), await Getv7v8UserIdAlwaysNoFailSubstituteIfNecessary(Modifier), Created, Modified);
return ret; return ret;