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
|
//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;
|
AyContext ct = ServiceProviderProvider.DBContext;
|
||||||
await ct.Database.ExecuteSqlInterpolatedAsync($"delete from asearchkey where objectid={objectID} and objecttype={(int)objectType}");
|
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
|
//this allows for concurrency issues
|
||||||
//I considered a circuit breaker / timeout here, but theoretically it should not be an issue
|
//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
|
//at some point it should not be a concurrency issue anymore
|
||||||
|
//And this is not critical functionality requiring a transaction and locking
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
//START: Get tag word and concurrency token and count
|
//START: Get tag word and concurrency token and count
|
||||||
|
|||||||
@@ -185,8 +185,6 @@ namespace AyaNova.Biz
|
|||||||
//
|
//
|
||||||
internal async Task<bool> DeleteAsync(long id)
|
internal async Task<bool> DeleteAsync(long id)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -200,18 +198,25 @@ namespace AyaNova.Biz
|
|||||||
var ItemIds = await ct.WorkOrderItem.Where(m => m.WorkOrderId == id).Select(m => m.Id).ToListAsync();
|
var ItemIds = await ct.WorkOrderItem.Where(m => m.WorkOrderId == id).Select(m => m.Id).ToListAsync();
|
||||||
|
|
||||||
//Delete children
|
//Delete children
|
||||||
foreach (long ItemId in ItemIds)
|
foreach (long ItemId in ItemIds)
|
||||||
if (!await ItemDeleteAsync(ItemId, transaction))
|
if (!await ItemDeleteAsync(ItemId, transaction))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ct.WorkOrder.Remove(dbObject);
|
ct.WorkOrder.Remove(dbObject);
|
||||||
await ct.SaveChangesAsync();
|
await ct.SaveChangesAsync();
|
||||||
|
|
||||||
//Log event
|
|
||||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Serial.ToString(), ct);
|
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Serial.ToString(), ct);
|
||||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType);
|
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType);
|
||||||
await TagUtil.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
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
|
//all good do the commit
|
||||||
await transaction.CommitAsync();
|
await transaction.CommitAsync();
|
||||||
}
|
}
|
||||||
@@ -417,7 +422,7 @@ namespace AyaNova.Biz
|
|||||||
//DELETE
|
//DELETE
|
||||||
//
|
//
|
||||||
internal async Task<bool> ItemDeleteAsync(long id, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction parentTransaction = null)
|
internal async Task<bool> ItemDeleteAsync(long id, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction parentTransaction = null)
|
||||||
{
|
{
|
||||||
Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction transaction = null;
|
Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction transaction = null;
|
||||||
if (parentTransaction == null)
|
if (parentTransaction == null)
|
||||||
transaction = await ct.Database.BeginTransactionAsync();
|
transaction = await ct.Database.BeginTransactionAsync();
|
||||||
@@ -466,7 +471,7 @@ namespace AyaNova.Biz
|
|||||||
if (parentTransaction == null)
|
if (parentTransaction == null)
|
||||||
await transaction.DisposeAsync();
|
await transaction.DisposeAsync();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user