From 720bca9f685c2cb46f764ef10744215b558ef2af Mon Sep 17 00:00:00 2001 From: Dmitriy Benyuk Date: Fri, 20 Feb 2026 13:31:45 +0200 Subject: [PATCH 1/3] Capture ERP Error Messages in Order Comment --- .vscode/launch.json | 14 ++++++++ ...Ecommerce.DynamicwebLiveIntegration.csproj | 2 +- .../OrderHandler.cs | 32 ++++++++++++------- src/src.sln | 30 +++++++++++++++++ 4 files changed, 66 insertions(+), 12 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 src/src.sln diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..6be2c2f --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,14 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processName":"Dynamicweb.CoreUI.Host.exe" + } + ] +} \ No newline at end of file diff --git a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.csproj b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.csproj index 8365b8a..0e6cccb 100644 --- a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.csproj +++ b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.csproj @@ -1,6 +1,6 @@  - 10.4.35 + 10.4.36 1.0.0.0 Live Integration Live Integration diff --git a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/OrderHandler.cs b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/OrderHandler.cs index f1ab29e..e8c4323 100644 --- a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/OrderHandler.cs +++ b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/OrderHandler.cs @@ -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; @@ -131,8 +132,8 @@ private static ResponseCacheLevel GetOrderCacheLevel(Settings settings) // 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); @@ -144,7 +145,7 @@ private static ResponseCacheLevel GetOrderCacheLevel(Settings settings) // 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"); @@ -265,10 +266,11 @@ private static OrderLine CreateOrderLine(Order order, string productNumber, Logg /// The order. /// if set to true [create order]. /// XmlDocument. - 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) { XmlDocument response = null; - requestCancelled = null; + requestCancelled = null; + errorMessage = null; string orderIdentifier = Helpers.OrderIdentifier(order); @@ -287,10 +289,13 @@ private static XmlDocument GetResponse(Settings settings, string requestXml, Ord { 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)); @@ -320,7 +325,7 @@ private static XmlDocument GetResponse(Settings settings, string requestXml, Ord /// State of the failed. /// The order identifier. /// The discount order lines. - 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) { if (discountOrderLines != null && Global.EnableCartCommunication(settings, order.Complete)) { @@ -347,6 +352,11 @@ private static void HandleIntegrationFailure(Settings settings, Order order, str order.StateId = failedState; } + if (!string.IsNullOrEmpty(errorMessage)) + { + order.Comment += $"{DateTime.Now.ToString(DateHelper.DateFormatStringShort)}: ERP response: {errorMessage}{System.Environment.NewLine}"; + } + Services.Orders.Save(order); } @@ -652,7 +662,7 @@ private static void ProcessOrderLines(Settings settings, XmlDocument response, O { continue; } - linesToRemove.Add(orderLine); + linesToRemove.Add(orderLine); } foreach (var orderLine in linesToRemove) { @@ -1177,7 +1187,7 @@ private static void SetShippingWarning(Settings settings, Order order, XmlNode o var warning = node.InnerText; if (!string.IsNullOrEmpty(warning)) { - order.Comment = warning; + order.Comment += $"{DateTime.Now.ToString(DateHelper.DateFormatStringShort)}: {warning}.{System.Environment.NewLine} "; } } } diff --git a/src/src.sln b/src/src.sln new file mode 100644 index 0000000..198caed --- /dev/null +++ b/src/src.sln @@ -0,0 +1,30 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.2.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dynamicweb.Ecommerce.DynamicwebLiveIntegration", "Dynamicweb.Ecommerce.DynamicwebLiveIntegration\Dynamicweb.Ecommerce.DynamicwebLiveIntegration.csproj", "{709A9004-4381-6061-7010-AEC6915A5DAE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Examples", "Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Examples\Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Examples.csproj", "{8196B35F-F909-8895-4C12-975178796473}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {709A9004-4381-6061-7010-AEC6915A5DAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {709A9004-4381-6061-7010-AEC6915A5DAE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {709A9004-4381-6061-7010-AEC6915A5DAE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {709A9004-4381-6061-7010-AEC6915A5DAE}.Release|Any CPU.Build.0 = Release|Any CPU + {8196B35F-F909-8895-4C12-975178796473}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8196B35F-F909-8895-4C12-975178796473}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8196B35F-F909-8895-4C12-975178796473}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8196B35F-F909-8895-4C12-975178796473}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {32BFDA5E-5A20-4F6C-8915-BEC03B744781} + EndGlobalSection +EndGlobal From 0f4b1b1ef327e4832bbddb246e786e217661c3e7 Mon Sep 17 00:00:00 2001 From: Dmitriy Benyuk Date: Fri, 20 Feb 2026 13:34:20 +0200 Subject: [PATCH 2/3] remove --- .vscode/launch.json | 14 -------------- src/src.sln | 30 ------------------------------ 2 files changed, 44 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 6be2c2f..e69de29 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,14 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": ".NET Core Attach", - "type": "coreclr", - "request": "attach", - "processName":"Dynamicweb.CoreUI.Host.exe" - } - ] -} \ No newline at end of file diff --git a/src/src.sln b/src/src.sln index 198caed..e69de29 100644 --- a/src/src.sln +++ b/src/src.sln @@ -1,30 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.5.2.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dynamicweb.Ecommerce.DynamicwebLiveIntegration", "Dynamicweb.Ecommerce.DynamicwebLiveIntegration\Dynamicweb.Ecommerce.DynamicwebLiveIntegration.csproj", "{709A9004-4381-6061-7010-AEC6915A5DAE}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Examples", "Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Examples\Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Examples.csproj", "{8196B35F-F909-8895-4C12-975178796473}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {709A9004-4381-6061-7010-AEC6915A5DAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {709A9004-4381-6061-7010-AEC6915A5DAE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {709A9004-4381-6061-7010-AEC6915A5DAE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {709A9004-4381-6061-7010-AEC6915A5DAE}.Release|Any CPU.Build.0 = Release|Any CPU - {8196B35F-F909-8895-4C12-975178796473}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8196B35F-F909-8895-4C12-975178796473}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8196B35F-F909-8895-4C12-975178796473}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8196B35F-F909-8895-4C12-975178796473}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {32BFDA5E-5A20-4F6C-8915-BEC03B744781} - EndGlobalSection -EndGlobal From b01de74933958aa1bfaa7dfe22c94a49aba72771 Mon Sep 17 00:00:00 2001 From: Dmitriy Benyuk Date: Fri, 20 Feb 2026 13:36:45 +0200 Subject: [PATCH 3/3] delete --- .vscode/launch.json | 0 src/src.sln | 0 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .vscode/launch.json delete mode 100644 src/src.sln diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index e69de29..0000000 diff --git a/src/src.sln b/src/src.sln deleted file mode 100644 index e69de29..0000000