This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -185,8 +185,6 @@ namespace AyaNova.Biz
|
||||
//
|
||||
internal async Task<bool> 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<bool> 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user