diff --git a/src/Dynamicweb.DataIntegration.Providers.OrderProvider.csproj b/src/Dynamicweb.DataIntegration.Providers.OrderProvider.csproj index 7244ef6..deb1f07 100644 --- a/src/Dynamicweb.DataIntegration.Providers.OrderProvider.csproj +++ b/src/Dynamicweb.DataIntegration.Providers.OrderProvider.csproj @@ -1,6 +1,6 @@  - 10.0.7 + 10.0.8 1.0.0.0 Order Provider Order Provider diff --git a/src/OrderProvider.cs b/src/OrderProvider.cs index fc1e189..25e691c 100644 --- a/src/OrderProvider.cs +++ b/src/OrderProvider.cs @@ -71,8 +71,16 @@ public override void LoadSettings(Job job) public new void Close() { if (job != null && job.Result == JobResult.Completed) - OrderSourceReader.UpdateExportedOrdersInDb(OrderStateAfterExport, connection); - + { + try + { + OrderSourceReader.UpdateExportedOrdersInDb(OrderStateAfterExport, connection); + } + catch (Exception ex) + { + Logger?.Warn(ex.Message); + } + } Connection.Close(); } diff --git a/src/OrderSourceReader.cs b/src/OrderSourceReader.cs index b745597..e25dc94 100644 --- a/src/OrderSourceReader.cs +++ b/src/OrderSourceReader.cs @@ -153,6 +153,8 @@ public static void UpdateExportedOrdersInDb(string orderStateIDAfterExport, SqlC SqlCommand command = new SqlCommand { Connection = connection }; try { + command.Transaction = connection.BeginTransaction("OrderProviderTransaction"); + if (connection.State.ToString() != "Open") connection.Open(); @@ -185,10 +187,12 @@ public static void UpdateExportedOrdersInDb(string orderStateIDAfterExport, SqlC command.ExecuteNonQuery(); ClearOrderCache(_ordersToExport); } + command.Transaction.Commit(); } catch (Exception ex) { - throw new Exception(string.Format("Exception message: {0} Sql query: {1}", ex.Message, command.CommandText), ex); + command.Transaction.Rollback(); + throw new Exception(string.Format("A rollback is made as exception is made with message: {0} Sql query: {1}", ex.Message, command.CommandText), ex); } finally {