|
@ -2,6 +2,7 @@ |
|
|
using Hangfire; |
|
|
using Hangfire; |
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
using Microsoft.EntityFrameworkCore; |
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
|
|
using Microsoft.EntityFrameworkCore.Storage; |
|
|
using Microsoft.Extensions.Configuration; |
|
|
using Microsoft.Extensions.Configuration; |
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
using System; |
|
|
using System; |
|
@ -257,12 +258,35 @@ namespace Wood.Service.Controllers |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
var mmrplist = _context.Database.GetDbConnection().Query<T>($"select * from {tablename} where taskid='{taskId}' and writestate=0"); |
|
|
var mmrplist = _context.Database.GetDbConnection().Query<T>($"select * from {tablename} where taskid='{taskId}' and writestate=0"); |
|
|
foreach (var item in mmrplist) |
|
|
using (var transaction = await _context.Database.BeginTransactionAsync(System.Data.IsolationLevel.ReadUncommitted)) |
|
|
{ |
|
|
{ |
|
|
item.ReadState = false; |
|
|
var tran = transaction.GetDbTransaction(); |
|
|
item.WriteState = false; |
|
|
try |
|
|
|
|
|
{ |
|
|
|
|
|
var first = _context.TaskSub.FirstOrDefault(p => p.TaskId == taskId); |
|
|
|
|
|
if (first != null) |
|
|
|
|
|
{ |
|
|
|
|
|
first.FailedCount = 0; |
|
|
|
|
|
_context.Update(first); |
|
|
|
|
|
} |
|
|
|
|
|
foreach (var item in mmrplist) |
|
|
|
|
|
{ |
|
|
|
|
|
item.ReadState = false; |
|
|
|
|
|
item.WriteState = false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await _context.BulkUpdateAsync(mmrplist,options=>options.Transaction=tran); |
|
|
|
|
|
_context.SaveChanges(); |
|
|
|
|
|
// 提交事务
|
|
|
|
|
|
await transaction.CommitAsync(); |
|
|
|
|
|
} |
|
|
|
|
|
catch (Exception ex) |
|
|
|
|
|
{ |
|
|
|
|
|
await transaction.RollbackAsync(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
await _context.BulkUpdateAsync(mmrplist); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
catch (Exception ex) |
|
|
catch (Exception ex) |
|
|