diff --git a/server/AyaNova/biz/Search.cs b/server/AyaNova/biz/Search.cs index bdaaafa6..e614375e 100644 --- a/server/AyaNova/biz/Search.cs +++ b/server/AyaNova/biz/Search.cs @@ -686,6 +686,7 @@ namespace AyaNova.Biz //npgsql driver will assume it's a string and put quotes around it triggering an error that a string can't be compared to an int AyContext ct = ServiceProviderProvider.DBContext; await ct.Database.ExecuteSqlInterpolatedAsync($"delete from asearchkey where objectid={objectID} and objecttype={(int)objectType}"); + //nothing to save here, it's a direct command already executed } diff --git a/server/AyaNova/biz/TagUtil.cs b/server/AyaNova/biz/TagUtil.cs index 9f7d4105..5f9a6220 100644 --- a/server/AyaNova/biz/TagUtil.cs +++ b/server/AyaNova/biz/TagUtil.cs @@ -53,6 +53,7 @@ namespace AyaNova.Biz //this allows for concurrency issues //I considered a circuit breaker / timeout here, but theoretically it should not be an issue //at some point it should not be a concurrency issue anymore + //And this is not critical functionality requiring a transaction and locking do { //START: Get tag word and concurrency token and count diff --git a/server/AyaNova/biz/WorkOrderBiz.cs b/server/AyaNova/biz/WorkOrderBiz.cs index 27ee0f32..66fa5bb8 100644 --- a/server/AyaNova/biz/WorkOrderBiz.cs +++ b/server/AyaNova/biz/WorkOrderBiz.cs @@ -185,8 +185,6 @@ namespace AyaNova.Biz // internal async Task DeleteAsync(long id) { - - using (var transaction = await ct.Database.BeginTransactionAsync()) { try @@ -200,18 +198,25 @@ namespace AyaNova.Biz var ItemIds = await ct.WorkOrderItem.Where(m => m.WorkOrderId == id).Select(m => m.Id).ToListAsync(); //Delete children - foreach (long ItemId in ItemIds) + foreach (long ItemId in ItemIds) if (!await ItemDeleteAsync(ItemId, transaction)) return false; - + ct.WorkOrder.Remove(dbObject); await ct.SaveChangesAsync(); - //Log event await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Serial.ToString(), ct); await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType); await TagUtil.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags); +#if (DEBUG) + + if (dbObject.Wiki == "INTEGRATION_DELETE_TEST_FAIL_BEFORE_COMMIT") + { + throw new System.Exception("WorkorderBiz::Delete - Test exception"); + } +#endif + //all good do the commit await transaction.CommitAsync(); } @@ -417,7 +422,7 @@ namespace AyaNova.Biz //DELETE // internal async Task ItemDeleteAsync(long id, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction parentTransaction = null) - { + { Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction transaction = null; if (parentTransaction == null) transaction = await ct.Database.BeginTransactionAsync(); @@ -466,7 +471,7 @@ namespace AyaNova.Biz if (parentTransaction == null) await transaction.DisposeAsync(); } - return true; + return true; }