baseline: 小军 WMS 二开代码原始快照(含 SynOABusiness.cs Debugger.Break)
This commit is contained in:
commit
c2b0e7be0d
6522 files changed
+3530643
No files matched your search
+43
@@ -0,0 +1,43 @@
|
||||
using Opsoft.NetCore.O3App.Domain;
|
||||
using Opsoft.NetCore.O3App.Shared;
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace Opsoft.NetCore.O3App.Infrastructure.Repositories
|
||||
{
|
||||
internal class DapperUnitOfWork : IDapperUnitOfWork
|
||||
{
|
||||
private readonly IDapperContext dapperContext;
|
||||
|
||||
public DapperUnitOfWork(IDapperContext dapperContext)
|
||||
{
|
||||
this.dapperContext = Guard.ArgumentNotNull(dapperContext, nameof(dapperContext));
|
||||
this.dapperContext.BeginTransaction();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (dapperContext.IsTransactionStarted)
|
||||
{
|
||||
dapperContext.Rollback();
|
||||
}
|
||||
DebugPrint($"{nameof(DapperUnitOfWork)} disposed.");
|
||||
}
|
||||
|
||||
public void SaveChanges()
|
||||
{
|
||||
if (!dapperContext.IsTransactionStarted)
|
||||
{
|
||||
throw new InvalidOperationException("Transaction have already been commited or disposed.");
|
||||
}
|
||||
|
||||
dapperContext.Commit();
|
||||
}
|
||||
protected virtual void DebugPrint(string message)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("{0:yyyy-MM-dd HH:mm:ss} [INFO] Thread {1}: {2}", DateTime.Now, Thread.CurrentThread.ManagedThreadId, message);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user