From ed569f775afab6a0f770c158cdf9fc47a873e58a Mon Sep 17 00:00:00 2001 From: Dmitriy Benyuk Date: Tue, 7 Jul 2026 14:46:41 +0300 Subject: [PATCH] Add option to log order creation requests and responses (#28831) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New 'Log order creation request and response' setting in the Logs group. When enabled, order creation ERP calls (CreateOrder=true) are always written to the log — including the request, response, connection errors, and response errors — even when general request/response logging is off. Co-Authored-By: Claude Sonnet 4.6 --- .../Configuration/ISettings.cs | 5 +++++ .../Configuration/Settings.cs | 7 +++++++ ...icweb.Ecommerce.DynamicwebLiveIntegration.csproj | 2 +- .../LiveIntegrationAddIn.cs | 9 +++++++++ .../Logging/Logger.cs | 13 ++++++++++--- .../OrderHandler.cs | 2 ++ 6 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Configuration/ISettings.cs b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Configuration/ISettings.cs index f89c013..c5c01f1 100644 --- a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Configuration/ISettings.cs +++ b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Configuration/ISettings.cs @@ -128,6 +128,11 @@ public interface ISettings /// bool LogResponseErrors { get; set; } + /// + /// Gets or sets a value that determines if order creation requests and responses should always be logged. + /// + bool LogOrderCreationRequests { get; set; } + /// /// Gets or sets the recipient's email address for notification emails. /// diff --git a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Configuration/Settings.cs b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Configuration/Settings.cs index 46743a7..a68c1f2 100644 --- a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Configuration/Settings.cs +++ b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Configuration/Settings.cs @@ -428,6 +428,12 @@ public string InstanceName /// true if a copy should be saved; otherwise, false. public bool SaveCopyOfOrderXml { get; set; } + /// + /// Gets or sets a value that determines if order creation requests and responses should always be logged, + /// even when general request/response logging is disabled. + /// + public bool LogOrderCreationRequests { get; set; } + #endregion Logs parameters /// @@ -481,6 +487,7 @@ public static void UpdateFrom(ISettings source, ISettings target) target.LogResponseErrors = source.LogResponseErrors; target.LogGeneralErrors = source.LogGeneralErrors; target.LogDebugInfo = source.LogDebugInfo; + target.LogOrderCreationRequests = source.LogOrderCreationRequests; target.LogMaxSize = source.LogMaxSize; target.KeepLogFiles = source.KeepLogFiles; diff --git a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.csproj b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.csproj index c5a7b99..66d42dc 100644 --- a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.csproj +++ b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.csproj @@ -1,6 +1,6 @@  - 10.21.7 + 10.21.8 1.0.0.0 Live Integration Live Integration diff --git a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/LiveIntegrationAddIn.cs b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/LiveIntegrationAddIn.cs index d9d1e04..c4ee907 100644 --- a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/LiveIntegrationAddIn.cs +++ b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/LiveIntegrationAddIn.cs @@ -639,6 +639,15 @@ public LiveIntegrationAddIn() [AddInParameterOrder(370)] public bool LogDebugInfo { get; set; } + /// + /// Gets or sets a value that determines if order creation requests and responses should always be logged. + /// + [AddInParameter("Log order creation request and response")] + [AddInParameterEditor(typeof(YesNoParameterEditor), "")] + [AddInParameterGroup("Logs")] + [AddInParameterOrder(375)] + public bool LogOrderCreationRequests { get; set; } + #endregion Logs parameters #endregion Configuration parameters diff --git a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Logging/Logger.cs b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Logging/Logger.cs index 5c81b35..1f73546 100644 --- a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Logging/Logger.cs +++ b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Logging/Logger.cs @@ -54,6 +54,13 @@ public Logger(Settings settings) /// true if [log debug information]; otherwise, false. private bool LogDebugInfo => _settings.LogDebugInfo; + /// + /// Set to true before an order-creation ERP call to enable per-call logging + /// when is on but general debug + /// logging is off. Reset to false immediately after the call. + /// + public bool IsOrderCreationContext { get; set; } + /// /// Gets or sets a value that determines if general info should be logged. /// @@ -169,11 +176,11 @@ private bool IsAllowedAddToLog(ErrorLevel level) switch (level) { case ErrorLevel.ConnectionError: - result = LogConnectionErrors; + result = LogConnectionErrors || (IsOrderCreationContext && _settings.LogOrderCreationRequests); break; case ErrorLevel.ResponseError: - result = LogResponseErrors; + result = LogResponseErrors || (IsOrderCreationContext && _settings.LogOrderCreationRequests); break; case ErrorLevel.Error: @@ -181,7 +188,7 @@ private bool IsAllowedAddToLog(ErrorLevel level) break; case ErrorLevel.DebugInfo: - result = LogDebugInfo; + result = LogDebugInfo || (IsOrderCreationContext && _settings.LogOrderCreationRequests); break; case ErrorLevel.EmailSend: diff --git a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/OrderHandler.cs b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/OrderHandler.cs index 891b0dd..3a82699 100644 --- a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/OrderHandler.cs +++ b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/OrderHandler.cs @@ -137,7 +137,9 @@ private static ResponseCacheLevel GetOrderCacheLevel(Settings settings) var ctx = new OrderResponseContext(settings, erpControlsDiscount); + logger.IsOrderCreationContext = createOrder; XmlDocument response = GetResponse(ctx, requestXml, order, createOrder, logger, out bool? requestCancelled, liveIntegrationSubmitType); + logger.IsOrderCreationContext = false; if (response != null && !string.IsNullOrWhiteSpace(response.InnerXml)) { bool processResponseResult = ProcessResponse(ctx, response, order, createOrder, successOrderStateId, failedOrderStateId, logger);