From b55693b6ef829a1e6257ac13c5fa1a8c5ea6e52b Mon Sep 17 00:00:00 2001 From: Savorboard Date: Thu, 30 Aug 2018 14:09:21 +0800 Subject: [PATCH] add summary comment --- README.md | 2 +- .../ICapTransaction.MongoDB.cs | 7 ++++ .../ICapTransaction.MySql.cs | 14 ++++++++ .../ICapTransaction.PostgreSql.cs | 14 ++++++++ .../ICapTransaction.SqlServer.cs | 32 +++++++++++++------ src/DotNetCore.CAP/ICapPublisher.cs | 3 ++ src/DotNetCore.CAP/ICapTransaction.cs | 22 +++++++++++-- 7 files changed, 82 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 9283672..3839343 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ public class PublishController : Controller { //your business code - _capBus.Publish(""xxx.services.show.time", DateTime.Now); + _capBus.Publish("xxx.services.show.time", DateTime.Now); } return Ok(); diff --git a/src/DotNetCore.CAP.MongoDB/ICapTransaction.MongoDB.cs b/src/DotNetCore.CAP.MongoDB/ICapTransaction.MongoDB.cs index a2ae5a0..ccf7899 100644 --- a/src/DotNetCore.CAP.MongoDB/ICapTransaction.MongoDB.cs +++ b/src/DotNetCore.CAP.MongoDB/ICapTransaction.MongoDB.cs @@ -58,6 +58,13 @@ namespace DotNetCore.CAP return transaction; } + /// + /// Start the CAP transaction + /// + /// The . + /// The . + /// Whether the transaction is automatically committed when the message is published + /// The of MongoDB transaction session object. public static IClientSessionHandle StartTransaction(this IMongoClient client, ICapPublisher publisher, bool autoCommit = false) { diff --git a/src/DotNetCore.CAP.MySql/ICapTransaction.MySql.cs b/src/DotNetCore.CAP.MySql/ICapTransaction.MySql.cs index 749622b..df72d60 100644 --- a/src/DotNetCore.CAP.MySql/ICapTransaction.MySql.cs +++ b/src/DotNetCore.CAP.MySql/ICapTransaction.MySql.cs @@ -74,6 +74,13 @@ namespace DotNetCore.CAP return transaction; } + /// + /// Start the CAP transaction + /// + /// The . + /// The . + /// Whether the transaction is automatically committed when the message is published + /// The of EF dbcontext transaction object. public static IDbContextTransaction BeginTransaction(this DatabaseFacade database, ICapPublisher publisher, bool autoCommit = false) { @@ -82,6 +89,13 @@ namespace DotNetCore.CAP return new CapEFDbTransaction(capTrans); } + /// + /// Start the CAP transaction + /// + /// The . + /// The . + /// Whether the transaction is automatically committed when the message is published + /// The object. public static ICapTransaction BeginTransaction(this IDbConnection dbConnection, ICapPublisher publisher, bool autoCommit = false) { diff --git a/src/DotNetCore.CAP.PostgreSql/ICapTransaction.PostgreSql.cs b/src/DotNetCore.CAP.PostgreSql/ICapTransaction.PostgreSql.cs index 2b5b864..136d132 100644 --- a/src/DotNetCore.CAP.PostgreSql/ICapTransaction.PostgreSql.cs +++ b/src/DotNetCore.CAP.PostgreSql/ICapTransaction.PostgreSql.cs @@ -73,6 +73,13 @@ namespace DotNetCore.CAP return transaction; } + /// + /// Start the CAP transaction + /// + /// The . + /// The . + /// Whether the transaction is automatically committed when the message is published + /// The object. public static ICapTransaction BeginTransaction(this IDbConnection dbConnection, ICapPublisher publisher, bool autoCommit = false) { @@ -85,6 +92,13 @@ namespace DotNetCore.CAP return publisher.Transaction.Begin(dbTransaction, autoCommit); } + /// + /// Start the CAP transaction + /// + /// The . + /// The . + /// Whether the transaction is automatically committed when the message is published + /// The of EF dbcontext transaction object. public static IDbContextTransaction BeginTransaction(this DatabaseFacade database, ICapPublisher publisher, bool autoCommit = false) { diff --git a/src/DotNetCore.CAP.SqlServer/ICapTransaction.SqlServer.cs b/src/DotNetCore.CAP.SqlServer/ICapTransaction.SqlServer.cs index 6cbba35..5ba0e54 100644 --- a/src/DotNetCore.CAP.SqlServer/ICapTransaction.SqlServer.cs +++ b/src/DotNetCore.CAP.SqlServer/ICapTransaction.SqlServer.cs @@ -122,6 +122,22 @@ namespace DotNetCore.CAP return transaction; } + public static ICapTransaction Begin(this ICapTransaction transaction, + IDbContextTransaction dbTransaction, bool autoCommit = false) + { + transaction.DbTransaction = dbTransaction; + transaction.AutoCommit = autoCommit; + + return transaction; + } + + /// + /// Start the CAP transaction + /// + /// The . + /// The . + /// Whether the transaction is automatically committed when the message is published + /// The object. public static IDbTransaction BeginTransaction(this IDbConnection dbConnection, ICapPublisher publisher, bool autoCommit = false) { @@ -135,15 +151,13 @@ namespace DotNetCore.CAP return (IDbTransaction)capTransaction.DbTransaction; } - public static ICapTransaction Begin(this ICapTransaction transaction, - IDbContextTransaction dbTransaction, bool autoCommit = false) - { - transaction.DbTransaction = dbTransaction; - transaction.AutoCommit = autoCommit; - - return transaction; - } - + /// + /// Start the CAP transaction + /// + /// The . + /// The . + /// Whether the transaction is automatically committed when the message is published + /// The of EF dbcontext transaction object. public static IDbContextTransaction BeginTransaction(this DatabaseFacade database, ICapPublisher publisher, bool autoCommit = false) { diff --git a/src/DotNetCore.CAP/ICapPublisher.cs b/src/DotNetCore.CAP/ICapPublisher.cs index 9410516..eebdbd8 100644 --- a/src/DotNetCore.CAP/ICapPublisher.cs +++ b/src/DotNetCore.CAP/ICapPublisher.cs @@ -11,6 +11,9 @@ namespace DotNetCore.CAP /// public interface ICapPublisher { + /// + /// CAP transaction context object + /// ICapTransaction Transaction { get; } /// diff --git a/src/DotNetCore.CAP/ICapTransaction.cs b/src/DotNetCore.CAP/ICapTransaction.cs index 7134438..f73865d 100644 --- a/src/DotNetCore.CAP/ICapTransaction.cs +++ b/src/DotNetCore.CAP/ICapTransaction.cs @@ -1,15 +1,33 @@ -using System; +// Copyright (c) .NET Core Community. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System; namespace DotNetCore.CAP { + /// + /// CAP transaction wrapper, used to wrap database transactions, provides a consistent user interface + /// public interface ICapTransaction : IDisposable { + /// + /// A flag is used to indicate whether the transaction is automatically committed after the message is published + /// bool AutoCommit { get; set; } + /// + /// Database transaction object, can be converted to a specific database transaction object or IDBTransaction when used + /// object DbTransaction { get; set; } + /// + /// Submit the transaction context of the CAP, we will send the message to the message queue at the time of submission + /// void Commit(); + /// + /// We will delete the message data that has not been sstore in the buffer data of current transaction context. + /// void Rollback(); } -} +} \ No newline at end of file