Skip to content
Merged
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
Expand Up @@ -85,6 +85,11 @@ public static XmlDocument CalculateOrder(Settings settings, string orderXml, Ord

try
{
if (createOrder)
{
OrderHandler.SetCurrentlyProcessingOrder(order);
}

Diagnostics.ExecutionTable.Current.Add("DynamicwebLiveIntegration.Connector.CalculateOrder START");
// only retry if is not create order, for create order schedule task will send later
document = Communicate(settings, orderXml, $"CalculateOrder (ID: {order.Id}, CreateOrder: {createOrder})", logger, submitType, !createOrder, true, order);
Expand All @@ -96,6 +101,13 @@ public static XmlDocument CalculateOrder(Settings settings, string orderXml, Ord
$"Error CalculateOrder Order Id:'{order.Id}' CreateOrder:'{createOrder}' Message:'{ex.Message}'.");
error = ex;
}
finally
{
if (createOrder)
{
OrderHandler.RemoveCurrentlyProcessingOrder(order);
}
}

if (EnableThrowExceptions && error != null)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>10.4.29</Version>
<Version>10.4.30</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,4 +1,5 @@
using Dynamicweb.Core;
using Dynamicweb.Caching;
using Dynamicweb.Core;
using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Cache;
using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Configuration;
using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Connectors;
Expand Down Expand Up @@ -1374,5 +1375,24 @@ private static void SaveOrderHash(Settings settings, string hashValue)
}

#endregion Hash helper methods

private static string OrderCacheKey(Order order) => $"OrderHandlerSentOrder{order.Id}";

internal static void SetCurrentlyProcessingOrder(Order order)
{
string key = OrderCacheKey(order);
if (!Caching.Cache.Current.Contains(key))
{
Caching.Cache.Current.Set(key, key, new CacheItemPolicy() { SlidingExpiration = TimeSpan.FromMinutes(30) });
}
}

internal static bool IsOrderCurrentlyProcessing(Order order) => Caching.Cache.Current.Contains(OrderCacheKey(order));

internal static void RemoveCurrentlyProcessingOrder(Order order)
{
string key = $"OrderHandlerSentOrder{order.Id}";
Caching.Cache.Current.Remove(key);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
[AddInDescription("Capture orders payments updated through Batch Integration and updating using Live Integration")]
[AddInIgnore(false)]
[AddInUseParameterGrouping(true)]
public class CaptureOrdersScheduledTask : BatchIntegrationScheduledTaskAddinBase, IDropDownOptions

Check warning on line 21 in src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/ScheduledTasks/CaptureOrdersScheduledTask.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

'IDropDownOptions' is obsolete: 'Use IParameterOptions instead.'

Check warning on line 21 in src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/ScheduledTasks/CaptureOrdersScheduledTask.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

'IDropDownOptions' is obsolete: 'Use IParameterOptions instead.'
{
private readonly Dictionary<string, CheckoutHandler> _paymentHandlers = new Dictionary<string, CheckoutHandler>();
private string _processError;
Expand Down Expand Up @@ -347,6 +347,12 @@

foreach (var order in ordersToSync)
{
if (OrderHandler.IsOrderCurrentlyProcessing(order))
{
Logger.Log($"Skipping order: {order.Id} as it is currently processing");
continue;
}

Settings orderSettings = shopSettings;
if (orderSettings == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
[AddInDescription("Sync queued orders using Dynamicweb Live Integration")]
[AddInIgnore(false)]
[AddInUseParameterGrouping(true)]
public class QueuedOrdersSyncScheduledTask : BatchIntegrationScheduledTaskAddin, IDropDownOptions

Check warning on line 25 in src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/ScheduledTasks/QueuedOrdersSyncScheduledTask.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

'IDropDownOptions' is obsolete: 'Use IParameterOptions instead.'

Check warning on line 25 in src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/ScheduledTasks/QueuedOrdersSyncScheduledTask.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

'IDropDownOptions' is obsolete: 'Use IParameterOptions instead.'
{
/// <summary>
/// Initializes a new instance of the <see cref="QueuedOrdersSyncScheduledTask"/> class.
Expand Down Expand Up @@ -142,6 +142,11 @@
Settings shopSettings = SettingsManager.GetSettingsByShop(ShopId);
foreach (var order in ordersToSync.GetResultOrders())
{
if (OrderHandler.IsOrderCurrentlyProcessing(order))
{
Logger.Log($"Skipping order: {order.Id} as it is currently processing");
continue;
}
Settings settings = shopSettings;
if (settings == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
[AddInDescription("Update orders based on custom fields to update order state and this will generate emails notifications.")]
[AddInIgnore(false)]
[AddInUseParameterGrouping(true)]
public class UpdateOrdersScheduledTask : BatchIntegrationScheduledTaskAddinBase, IDropDownOptions

Check warning on line 20 in src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/ScheduledTasks/UpdateOrdersScheduledTask.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

'IDropDownOptions' is obsolete: 'Use IParameterOptions instead.'
{
private string _processErrorForEmail;

Expand Down Expand Up @@ -277,6 +277,12 @@

foreach (var order in ordersToSync)
{
if (OrderHandler.IsOrderCurrentlyProcessing(order))
{
Logger.Log($"Skipping order: {order.Id} as it is currently processing");
continue;
}

var erpUpdated = SendToErp(order);
if (!SkipCustomFieldUpdateOnErpFailure || erpUpdated)
UpdateOrderCustomField(order);
Expand Down
Loading