Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>10.4.35</Version>
<Version>10.4.36</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Title>Live Integration</Title>
<Description>Live Integration</Description>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Dynamicweb.Caching;
using Dynamicweb.Core;
using Dynamicweb.Core.Helpers;
using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Cache;
using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Configuration;
using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Connectors;
Expand Down Expand Up @@ -131,8 +132,8 @@

// save this hash for next calls
SaveOrderHash(settings, currentHash);
XmlDocument response = GetResponse(settings, requestXml, order, createOrder, logger, out bool? requestCancelled, liveIntegrationSubmitType);

XmlDocument response = GetResponse(settings, requestXml, order, createOrder, logger, out bool? requestCancelled, liveIntegrationSubmitType, out var errorMessage);
if (response != null && !string.IsNullOrWhiteSpace(response.InnerXml))
{
bool processResponseResult = ProcessResponse(settings, response, order, createOrder, successOrderStateId, failedOrderStateId, logger);
Expand All @@ -144,7 +145,7 @@
// error occurred
if (createOrder && (!requestCancelled.HasValue || !requestCancelled.Value))
{
HandleIntegrationFailure(settings, order, failedOrderStateId, orderId, null, logger);
HandleIntegrationFailure(settings, order, failedOrderStateId, orderId, null, logger, errorMessage);
}

Diagnostics.ExecutionTable.Current.Add("DynamicwebLiveIntegration.OrderHandler.UpdateOrder END");
Expand Down Expand Up @@ -265,10 +266,11 @@
/// <param name="order">The order.</param>
/// <param name="createOrder">if set to <c>true</c> [create order].</param>
/// <returns>XmlDocument.</returns>
private static XmlDocument GetResponse(Settings settings, string requestXml, Order order, bool createOrder, Logger logger, out bool? requestCancelled, SubmitType submitType)
private static XmlDocument GetResponse(Settings settings, string requestXml, Order order, bool createOrder, Logger logger, out bool? requestCancelled, SubmitType submitType, out string? errorMessage)

Check warning on line 269 in src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/OrderHandler.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 269 in src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/OrderHandler.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
XmlDocument response = null;
requestCancelled = null;
requestCancelled = null;
errorMessage = null;

string orderIdentifier = Helpers.OrderIdentifier(order);

Expand All @@ -287,10 +289,13 @@
{
response = Connector.CalculateOrder(settings, requestXml, order, createOrder, out Exception error, logger, submitType);

if (createOrder && error != null)
if (error is not null)
{
string msg = !string.IsNullOrEmpty(error.Message) ? error.Message : error.ToString();
Services.OrderDebuggingInfos.Save(order, $"ERP communication failed with error: {msg}", OrderErpCallFailed, DebuggingInfoType.Undefined);
errorMessage = !string.IsNullOrEmpty(error.Message) ? error.Message : error.ToString();
if (createOrder)
{
Services.OrderDebuggingInfos.Save(order, $"ERP communication failed with error: {errorMessage}", OrderErpCallFailed, DebuggingInfoType.Undefined);
}
}

NotificationManager.Notify(Notifications.Order.OnAfterSendingOrderToErp, new Notifications.Order.OnAfterSendingOrderToErpArgs(order, createOrder, response, error, settings, logger));
Expand Down Expand Up @@ -320,7 +325,7 @@
/// <param name="failedState">State of the failed.</param>
/// <param name="orderId">The order identifier.</param>
/// <param name="discountOrderLines">The discount order lines.</param>
private static void HandleIntegrationFailure(Settings settings, Order order, string failedState, string orderId, OrderLineCollection discountOrderLines, Logger logger)
private static void HandleIntegrationFailure(Settings settings, Order order, string failedState, string orderId, OrderLineCollection discountOrderLines, Logger logger, string? errorMessage = null)

Check warning on line 328 in src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/OrderHandler.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 328 in src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/OrderHandler.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
if (discountOrderLines != null && Global.EnableCartCommunication(settings, order.Complete))
{
Expand All @@ -347,6 +352,11 @@
order.StateId = failedState;
}

if (!string.IsNullOrEmpty(errorMessage))
{
order.Comment += $"{DateTime.Now.ToString(DateHelper.DateFormatStringShort)}: ERP response: {errorMessage}{System.Environment.NewLine}";
}

Services.Orders.Save(order);
}

Expand Down Expand Up @@ -652,7 +662,7 @@
{
continue;
}
linesToRemove.Add(orderLine);
linesToRemove.Add(orderLine);
}
foreach (var orderLine in linesToRemove)
{
Expand Down Expand Up @@ -1177,7 +1187,7 @@
var warning = node.InnerText;
if (!string.IsNullOrEmpty(warning))
{
order.Comment = warning;
order.Comment += $"{DateTime.Now.ToString(DateHelper.DateFormatStringShort)}: {warning}.{System.Environment.NewLine} ";
}
}
}
Expand Down
Loading