Posted on 04/10/2023 18:34:26
Hi Mikkel,
I think it follows the flow I outlined earlier. Here are the relevant bits from GetResponse:
private static XmlDocument GetResponse(Settings settings, string requestXml, Order order, bool createOrder, Logger logger)
{
XmlDocument response = null;
..
Notifications.Order.OnBeforeSendingOrderToErpArgs onBeforeSendingOrderToErpArgs = new Notifications.Order.OnBeforeSendingOrderToErpArgs(order, createOrder, settings, logger);
NotificationManager.Notify(Notifications.Order.OnBeforeSendingOrderToErp, onBeforeSendingOrderToErpArgs);
if (!onBeforeSendingOrderToErpArgs.Cancel)
{
response = Connector.CalculateOrder
...
}
else
{
OrderDebuggingInfo.Save(order, DateTime.Now, "Order not sent to ERP because a subscriber cancelled sending it", OrderErpCallCancelled, DebuggingInfoType.Undefined);
}
}
It defines the response as null, then calls the subscriber. When Cancel is false it creates the response and returns it. When Cancel is set to true however, it returns null. The last log line you refer to doesn't log to the LI log file but to the OrderDebuggingInfo table in the database. Pretty sure you'll find records for these orders there.
The null response from GetResponse then causes issues in UpdateOrder:
XmlDocument response = GetResponse(settings, requestXml, order, createOrder, logger);
if (response != null && !string.IsNullOrWhiteSpace(response.InnerXml))
{
bool processResponseResult = ProcessResponse(settings, response, order, createOrder, successOrderStateId, failedOrderStateId, logger);
Diagnostics.ExecutionTable.Current.Add("DynamicwebLiveIntegration.OrderHandler.UpdateOrder END");
return processResponseResult;
}
else
{
// error occurred
if(createOrder)
{
HandleIntegrationFailure(settings, order, failedOrderStateId, orderId, null, logger);
Services.OrderDebuggingInfos.Save(order, $"ERP communication failed with null response returned.", OrderErpCallFailed, DebuggingInfoType.Undefined);
}
Diagnostics.ExecutionTable.Current.Add("DynamicwebLiveIntegration.OrderHandler.UpdateOrder END");
return false;
}
Because response is null, HandleIntegrationFailure is called which records the last error log line.
So, I think it works in the sense that it does cancel the error. However, it also seems to log false positive error messages as the ERP communication didn't really fail, it just never happened. It might be nice if GetResponse could somehow flag that it didn't fail but that it just didn't do anything so the error can be skipped. Maybe GetResponse could return some kind of constant Null object that signals the calling code that it didn't do anything.
@Dmitriy: any thoughts on this?
Imar