diff --git a/src/AbpDesk/Web_PlugIns/AbpDesk.MongoBlog.dll b/src/AbpDesk/Web_PlugIns/AbpDesk.MongoBlog.dll index 484411d11e..8d7194d4e6 100644 Binary files a/src/AbpDesk/Web_PlugIns/AbpDesk.MongoBlog.dll and b/src/AbpDesk/Web_PlugIns/AbpDesk.MongoBlog.dll differ diff --git a/src/Volo.Abp/Volo/Abp/Uow/ChildUnitOfWork.cs b/src/Volo.Abp/Volo/Abp/Uow/ChildUnitOfWork.cs index 3c054bbd5d..b476bc5996 100644 --- a/src/Volo.Abp/Volo/Abp/Uow/ChildUnitOfWork.cs +++ b/src/Volo.Abp/Volo/Abp/Uow/ChildUnitOfWork.cs @@ -13,27 +13,9 @@ namespace Volo.Abp.Uow public IUnitOfWork Outer => _parent.Outer; - public bool IsReserved - { - get => _parent.IsReserved; - set => _parent.IsReserved = value; - } - - public string ReservationName - { - get => _parent.ReservationName; - set => _parent.ReservationName = value; - } - - public void SetOuter(IUnitOfWork outer) - { - _parent.SetOuter(outer); - } + public bool IsReserved => _parent.IsReserved; - public void Initialize(UnitOfWorkOptions options) - { - _parent.Initialize(options); - } + public string ReservationName => _parent.ReservationName; public event EventHandler Completed; public event EventHandler Failed; @@ -54,6 +36,21 @@ namespace Volo.Abp.Uow _parent.Disposed += (sender, args) => { Disposed.InvokeSafely(sender, args); }; } + public void SetOuter(IUnitOfWork outer) + { + _parent.SetOuter(outer); + } + + public void Initialize(UnitOfWorkOptions options) + { + _parent.Initialize(options); + } + + public void Reserve(string reservationName) + { + _parent.Reserve(reservationName); + } + public void SaveChanges() { _parent.SaveChanges(); diff --git a/src/Volo.Abp/Volo/Abp/Uow/IBasicUnitOfWork.cs b/src/Volo.Abp/Volo/Abp/Uow/IBasicUnitOfWork.cs deleted file mode 100644 index 11d26a7640..0000000000 --- a/src/Volo.Abp/Volo/Abp/Uow/IBasicUnitOfWork.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Threading; -using System.Threading.Tasks; - -namespace Volo.Abp.Uow -{ - //TODO: Find a better naming :( - public interface IBasicUnitOfWork : IDisposable - { - Guid Id { get; } - - event EventHandler Completed; - - event EventHandler Failed; - - event EventHandler Disposed; - - void SaveChanges(); - - Task SaveChangesAsync(CancellationToken cancellationToken = default(CancellationToken)); - - void Complete(); - - Task CompleteAsync(CancellationToken cancellationToken = default(CancellationToken)); - } -} \ No newline at end of file diff --git a/src/Volo.Abp/Volo/Abp/Uow/IUnitOfWork.cs b/src/Volo.Abp/Volo/Abp/Uow/IUnitOfWork.cs index acee44e91d..f3436023c9 100644 --- a/src/Volo.Abp/Volo/Abp/Uow/IUnitOfWork.cs +++ b/src/Volo.Abp/Volo/Abp/Uow/IUnitOfWork.cs @@ -1,19 +1,40 @@ -using JetBrains.Annotations; +using System; +using System.Threading; +using System.Threading.Tasks; +using JetBrains.Annotations; namespace Volo.Abp.Uow { - public interface IUnitOfWork : IBasicUnitOfWork, IDatabaseApiContainer, ITransactionApiContainer + public interface IUnitOfWork : IDatabaseApiContainer, ITransactionApiContainer, IDisposable { + Guid Id { get; } + + event EventHandler Completed; + + event EventHandler Failed; + + event EventHandler Disposed; + IUnitOfWorkOptions Options { get; } IUnitOfWork Outer { get; } - bool IsReserved { get; set; } + bool IsReserved { get; } - string ReservationName { get; set; } + string ReservationName { get; } void SetOuter([CanBeNull] IUnitOfWork outer); void Initialize([NotNull] UnitOfWorkOptions options); + + void Reserve([NotNull] string reservationName); + + void SaveChanges(); + + Task SaveChangesAsync(CancellationToken cancellationToken = default(CancellationToken)); + + void Complete(); + + Task CompleteAsync(CancellationToken cancellationToken = default(CancellationToken)); } } diff --git a/src/Volo.Abp/Volo/Abp/Uow/IUnitOfWorkManager.cs b/src/Volo.Abp/Volo/Abp/Uow/IUnitOfWorkManager.cs index d1f8c534fb..264390fbbe 100644 --- a/src/Volo.Abp/Volo/Abp/Uow/IUnitOfWorkManager.cs +++ b/src/Volo.Abp/Volo/Abp/Uow/IUnitOfWorkManager.cs @@ -8,10 +8,10 @@ namespace Volo.Abp.Uow IUnitOfWork Current { get; } [NotNull] - IBasicUnitOfWork Begin([NotNull] UnitOfWorkOptions options, bool requiresNew = false); + IUnitOfWork Begin([NotNull] UnitOfWorkOptions options, bool requiresNew = false); [NotNull] - IBasicUnitOfWork Reserve([NotNull] string reservationName, bool requiresNew = false); + IUnitOfWork Reserve([NotNull] string reservationName, bool requiresNew = false); void BeginReserved([NotNull] string reservationName, [NotNull] UnitOfWorkOptions options); diff --git a/src/Volo.Abp/Volo/Abp/Uow/UnitOfWork.cs b/src/Volo.Abp/Volo/Abp/Uow/UnitOfWork.cs index d6441ab01f..b481bd5da4 100644 --- a/src/Volo.Abp/Volo/Abp/Uow/UnitOfWork.cs +++ b/src/Volo.Abp/Volo/Abp/Uow/UnitOfWork.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; +using JetBrains.Annotations; using Microsoft.Extensions.Options; using Volo.Abp.DependencyInjection; @@ -52,6 +53,15 @@ namespace Volo.Abp.Uow } Options = _defaultOptions.Normalize(options.Clone()); + IsReserved = false; + } + + public void Reserve(string reservationName) + { + Check.NotNull(reservationName, nameof(reservationName)); + + ReservationName = reservationName; + IsReserved = true; } public void SetOuter(IUnitOfWork outer) diff --git a/src/Volo.Abp/Volo/Abp/Uow/UnitOfWorkFailedEventArgs.cs b/src/Volo.Abp/Volo/Abp/Uow/UnitOfWorkFailedEventArgs.cs index 870f125f4f..e17dfa4bc0 100644 --- a/src/Volo.Abp/Volo/Abp/Uow/UnitOfWorkFailedEventArgs.cs +++ b/src/Volo.Abp/Volo/Abp/Uow/UnitOfWorkFailedEventArgs.cs @@ -9,12 +9,12 @@ namespace Volo.Abp.Uow public class UnitOfWorkFailedEventArgs : EventArgs { /// - /// Exception that caused failure. This is set only if an error occured during . - /// Can be null if there is no exception, but is not called. + /// Exception that caused failure. This is set only if an error occured during . + /// Can be null if there is no exception, but is not called. /// Can be null if another exception occurred during the UOW. /// [CanBeNull] - public Exception Exception { get; private set; } + public Exception Exception { get; } /// /// Creates a new object. diff --git a/src/Volo.Abp/Volo/Abp/Uow/UnitOfWorkManager.cs b/src/Volo.Abp/Volo/Abp/Uow/UnitOfWorkManager.cs index 077481ffa1..447a6c182e 100644 --- a/src/Volo.Abp/Volo/Abp/Uow/UnitOfWorkManager.cs +++ b/src/Volo.Abp/Volo/Abp/Uow/UnitOfWorkManager.cs @@ -19,7 +19,7 @@ namespace Volo.Abp.Uow _ambientUnitOfWork = ambientUnitOfWork; } - public IBasicUnitOfWork Begin(UnitOfWorkOptions options, bool requiresNew = false) + public IUnitOfWork Begin(UnitOfWorkOptions options, bool requiresNew = false) { Check.NotNull(options, nameof(options)); @@ -34,7 +34,7 @@ namespace Volo.Abp.Uow return unitOfWork; } - public IBasicUnitOfWork Reserve(string reservationName, bool requiresNew = false) + public IUnitOfWork Reserve(string reservationName, bool requiresNew = false) { Check.NotNull(reservationName, nameof(reservationName)); @@ -46,9 +46,7 @@ namespace Volo.Abp.Uow } var unitOfWork = CreateNewUnitOfWork(); - - unitOfWork.IsReserved = true; - unitOfWork.ReservationName = reservationName; + unitOfWork.Reserve(reservationName); return unitOfWork; } @@ -78,7 +76,6 @@ namespace Volo.Abp.Uow return false; } - uow.IsReserved = false; uow.Initialize(options); return true; diff --git a/src/Volo.Abp/Volo/Abp/Uow/UnitOfWorkManagerExtensions.cs b/src/Volo.Abp/Volo/Abp/Uow/UnitOfWorkManagerExtensions.cs index 3a9f949017..c9f888f275 100644 --- a/src/Volo.Abp/Volo/Abp/Uow/UnitOfWorkManagerExtensions.cs +++ b/src/Volo.Abp/Volo/Abp/Uow/UnitOfWorkManagerExtensions.cs @@ -5,7 +5,7 @@ namespace Volo.Abp.Uow public static class UnitOfWorkManagerExtensions { [NotNull] - public static IBasicUnitOfWork Begin([NotNull] this IUnitOfWorkManager unitOfWorkManager, bool requiresNew = false) + public static IUnitOfWork Begin([NotNull] this IUnitOfWorkManager unitOfWorkManager, bool requiresNew = false) { Check.NotNull(unitOfWorkManager, nameof(unitOfWorkManager));