本文整理汇总了C#中TransactionMode类的典型用法代码示例。如果您正苦于以下问题:C# TransactionMode类的具体用法?C# TransactionMode怎么用?C# TransactionMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TransactionMode类属于命名空间,在下文中一共展示了TransactionMode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: StandardTransaction
public StandardTransaction(TransactionDelegate onTransactionCommitted, TransactionDelegate onTransactionRolledback,
TransactionMode transactionMode, IsolationMode isolationMode, bool distributedTransaction) :
this(transactionMode, isolationMode, distributedTransaction)
{
this.onTransactionCommitted = onTransactionCommitted;
this.onTransactionRolledback = onTransactionRolledback;
}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:7,代码来源:StandardTransaction.cs
示例2: ProcessPayment
/// <summary>
/// Processes the Authorize and AuthorizeAndCapture transactions
/// </summary>
/// <param name="invoice">The <see cref="IInvoice" /> to be paid</param>
/// <param name="payment">The <see cref="IPayment" /> record</param>
/// <param name="transactionMode">Authorize or AuthorizeAndCapture</param>
/// <param name="amount">The money amount to be processed</param>
/// <returns>The <see cref="IPaymentResult" /></returns>
public IPaymentResult ProcessPayment(IInvoice invoice, IPayment payment, TransactionMode transactionMode, decimal amount)
{
if (!IsValidCurrencyCode(invoice.CurrencyCode()))
return new PaymentResult(Attempt<IPayment>.Fail(payment, new Exception(string.Format("Invalid currency. Invoice Currency: '{0}'", invoice.CurrencyCode()))), invoice, false);
if (transactionMode == TransactionMode.Authorize) {
//var paymentId = payment.ExtendedData.GetValue(Constants.ExtendedDataKeys.QuickpayPaymentId);
var currency = payment.ExtendedData.GetValue(Constants.ExtendedDataKeys.PaymentCurrency);
var amountAuthorizedMinorString = payment.ExtendedData.GetValue(Constants.ExtendedDataKeys.PaymentAmount);
var amountAuthorized = decimal.Parse(amountAuthorizedMinorString) / (IsZeroDecimalCurrency(currency) ? 100 : 1);
if (invoice.CurrencyCode() != currency) {
return new PaymentResult(Attempt<IPayment>.Fail(payment, new Exception(string.Format("Currency mismatch. Invoice Currency: {0}, Payment Currency: {1}", invoice.CurrencyCode(), currency))), invoice, false);
}
if (invoice.Total > amountAuthorized) {
return new PaymentResult(Attempt<IPayment>.Fail(payment, new Exception(string.Format("Amount mismatch. Invoice Amount: {0}, Payment Amount: {1}", invoice.Total.ToString("F2"), amountAuthorized.ToString("F2")))), invoice, false);
}
payment.Authorized = true;
return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice, invoice.ShippingLineItems().Any());
}
return new PaymentResult(Attempt<IPayment>.Fail(payment, new Exception(string.Format("{0}", "QuickPay Payment AuthorizeAndCapture Not Implemented Yet"))), invoice, false);
}
开发者ID:joelbhansen,项目名称:MerchelloQuickPayProvider,代码行数:35,代码来源:QuickPayPaymentProcessor.cs
示例3: Hurl
public int Hurl(string storedProcedureName, System.Collections.Generic.List<dynamic> objects, TransactionMode transMode)
{
// This has slightly different logic because we need to scope the transaction differently.
int numberOfRecordsAffected = 0;
SqlTransaction transaction = null;
using (SqlConnection dbConn = new SqlConnection(this.ConnectionString))
{
using (SqlCommand dbComm = new SqlCommand(storedProcedureName, dbConn) { CommandType = System.Data.CommandType.StoredProcedure })
{
if (transMode == TransactionMode.On)
{
transaction = dbConn.BeginTransaction();
}
foreach (dynamic obj in objects)
{
dbComm.Parameters.Clear();
string jsonString = JsonConvert.SerializeObject(obj);
dbComm.Parameters.AddRange(jsonString.DeserializeJsonIntoSqlParameters());
if (dbConn.State != System.Data.ConnectionState.Open) { dbConn.Open(); }
numberOfRecordsAffected += dbComm.ExecuteNonQuery();
}
if (transaction != null) { transaction.Commit(); }
}
}
return numberOfRecordsAffected;
}
开发者ID:khabilepravin,项目名称:retriever.net,代码行数:31,代码来源:SqlDataRequest.cs
示例4: ProcessPayment
private IPaymentResult ProcessPayment(IInvoice invoice, TransactionMode transactionMode, decimal amount, ProcessorArgumentCollection args)
{
var po = args.AsPurchaseOrderFormData();
var payment = GatewayProviderService.CreatePayment(PaymentMethodType.PurchaseOrder, invoice.Total, PaymentMethod.Key);
payment.CustomerKey = invoice.CustomerKey;
payment.Authorized = false;
payment.Collected = false;
payment.PaymentMethodName = "Purchase Order";
var result = _processor.ProcessPayment(invoice, payment, amount, po);
GatewayProviderService.Save(payment);
if (!result.Payment.Success)
{
GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Denied, result.Payment.Exception.Message, 0);
}
else
{
MerchelloContext.Current.Services.InvoiceService.Save(invoice, false);
GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Debit,
payment.ExtendedData.GetValue(Constants.ExtendedDataKeys.AuthorizationTransactionResult) +
(transactionMode == TransactionMode.AuthorizeAndCapture ? string.Empty : " to show record of Authorization"),
transactionMode == TransactionMode.AuthorizeAndCapture ? invoice.Total : 0);
}
return result;
}
开发者ID:drpeck,项目名称:Merchello,代码行数:30,代码来源:PurchaseOrderPaymentGatewayMethod.cs
示例5: OnNewTransaction
private void OnNewTransaction(ITransaction transaction, TransactionMode transactionMode, IsolationMode isolationMode, bool distributedTransaction)
{
if (!transaction.DistributedTransaction)
{
transaction.Enlist(new RhinoTransactionResourceAdapter(transactionMode));
}
}
开发者ID:JackWangCUMT,项目名称:rhino-tools,代码行数:7,代码来源:RhinoTransactionFacility.cs
示例6: ProcessPayment
private IPaymentResult ProcessPayment(IInvoice invoice, TransactionMode transactionMode, decimal amount, ProcessorArgumentCollection args)
{
var cc = args.AsCreditCardFormData();
var payment = GatewayProviderService.CreatePayment(PaymentMethodType.CreditCard, invoice.Total, PaymentMethod.Key);
payment.CustomerKey = invoice.CustomerKey;
payment.Authorized = false;
payment.Collected = false;
payment.PaymentMethodName = string.Format("{0} Stripe Credit Card", cc.CreditCardType);
payment.ExtendedData.SetValue(Constants.ExtendedDataKeys.CcLastFour, cc.CardNumber.Substring(cc.CardNumber.Length - 4, 4).EncryptWithMachineKey());
var result = _processor.ProcessPayment(invoice, payment, transactionMode, amount, cc);
GatewayProviderService.Save(payment);
if (!result.Payment.Success)
{
GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Denied, result.Payment.Exception.Message, 0);
}
else
{
GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Debit,
//payment.ExtendedData.GetValue(Constants.ExtendedDataKeys.AuthorizationTransactionResult) +
(transactionMode == TransactionMode.AuthorizeAndCapture ? string.Empty : " to show record of Authorization"),
transactionMode == TransactionMode.AuthorizeAndCapture ? invoice.Total : 0);
}
return result;
}
开发者ID:drpeck,项目名称:Merchello,代码行数:30,代码来源:StripePaymentGatewayMethod.cs
示例7: TransactionBase
protected TransactionBase(string name, TransactionMode mode, IsolationMode isolationMode)
{
theName = name ?? string.Empty;
_TransactionMode = mode;
_IsolationMode = isolationMode;
Status = TransactionStatus.NoTransaction;
Context = new Hashtable();
}
开发者ID:mahara,项目名称:Castle.Transactions,代码行数:8,代码来源:TransactionBase.cs
示例8: CreateTransaction
public ITransaction CreateTransaction(TransactionMode transactionMode, IsolationMode isolationMode,
bool distributedTransaction)
{
_current = new MockTransaction();
_transactions++;
return _current;
}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:9,代码来源:MockTransactionManager.cs
示例9: BeginTransaction
public ITransaction BeginTransaction(IsolationLevel isolationLevel, TransactionMode mode)
{
Guard.Against<InvalidOperationException>(Transaction != null, "There is a active transcation, cannot begin a new transaction.");
var scope = TransactionScopeHelper.CreateScope(isolationLevel, mode);
var transaction = new UnitOfWorkTransaction(this, scope);
return transaction;
}
开发者ID:devworker55,项目名称:Mammatus,代码行数:10,代码来源:UnitOfWorkScope.cs
示例10: CreateScope
///<summary>
/// Create a new <typeparamref name="TransactionScope"/> using the supplied parameters.
///</summary>
///<param name="isolationLevel"></param>
///<param name="txMode"></param>
///<returns></returns>
///<exception cref="NotImplementedException"></exception>
public static TransactionScope CreateScope(IsolationLevel isolationLevel, TransactionMode txMode) {
if (txMode == TransactionMode.New) {
Logger.Debug(x => x("Creating a new TransactionScope with TransactionScopeOption.RequiresNew"));
return new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions { IsolationLevel = isolationLevel });
}
if (txMode == TransactionMode.Supress) {
Logger.Debug(x => x("Creating a new TransactionScope with TransactionScopeOption.Supress"));
return new TransactionScope(TransactionScopeOption.Suppress);
}
Logger.Debug(x => x("Creating a new TransactionScope with TransactionScopeOption.Required"));
return new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = isolationLevel });
}
开发者ID:BenAlabaster,项目名称:Wcf.TechDemo,代码行数:19,代码来源:TransactionScopeHelper.cs
示例11: CreateTransaction
public ITransaction CreateTransaction(TransactionMode txMode, IsolationMode iMode, bool isAmbient, bool isReadOnly)
{
txMode = ObtainDefaultTransactionMode(txMode);
AssertModeSupported(txMode);
if (CurrentTransaction == null &&
(txMode == TransactionMode.Supported ||
txMode == TransactionMode.NotSupported))
{
return null;
}
TransactionBase transaction = null;
if (CurrentTransaction != null)
{
if (txMode == TransactionMode.Requires || txMode == TransactionMode.Supported)
{
transaction = ((TransactionBase)CurrentTransaction).CreateChildTransaction();
logger.DebugFormat("Child transaction \"{0}\" created with mode '{1}'.", transaction.Name, txMode);
}
}
if (transaction == null)
{
transaction = InstantiateTransaction(txMode, iMode, isAmbient, isReadOnly);
if (isAmbient)
{
#if MONO
throw new NotSupportedException("Distributed transactions are not supported on Mono");
#else
transaction.CreateAmbientTransaction();
#endif
}
logger.DebugFormat("Transaction \"{0}\" created. ", transaction.Name);
}
activityManager.CurrentActivity.Push(transaction);
if (transaction.IsChildTransaction)
ChildTransactionCreated.Fire(this, new TransactionEventArgs(transaction));
else
TransactionCreated.Fire(this, new TransactionEventArgs(transaction));
return transaction;
}
开发者ID:gusgorman,项目名称:Castle.Services.Transaction,代码行数:50,代码来源:DefaultTransactionManager.cs
示例12: BeginTransactionWithMode
internal static string BeginTransactionWithMode(TransactionMode mode)
{
switch (mode)
{
case TransactionMode.Deferred:
return "BEGIN DEFERRED TRANSACTION";
case TransactionMode.Exclusive:
return "BEGIN EXCLUSIVE TRANSACTION";
case TransactionMode.Immediate:
return "BEGIN IMMEDIATE TRANSACTION";
default:
throw new ArgumentException("Not a valid TransactionMode");
}
}
开发者ID:matrostik,项目名称:SQLitePCL.pretty,代码行数:14,代码来源:SQLBuilder.cs
示例13: BeginThreadTransaction
public override void BeginThreadTransaction(TransactionMode mode)
{
if (mode != TransactionMode.ReplicationSlave)
{
throw new ArgumentException("Illegal transaction mode");
}
lck.SharedLock();
Page pg = pool.getPage(0);
header.unpack(pg.data);
pool.unfix(pg);
currIndex = 1 - header.curr;
currIndexSize = header.root[1 - currIndex].indexUsed;
committedIndexSize = currIndexSize;
usedSize = header.root[currIndex].size;
}
开发者ID:kjk,项目名称:volante,代码行数:15,代码来源:ReplicationSlaveStorageImpl.cs
示例14: AbstractTransaction
public AbstractTransaction(TransactionMode transactionMode, IsolationMode isolationMode, bool distributedTransaction,
string name) : this()
{
this.transactionMode = transactionMode;
this.isolationMode = isolationMode;
this.distributedTransaction = distributedTransaction;
if (String.IsNullOrEmpty(name))
{
this.name = ObtainName();
}
else
{
this.name = name;
}
}
开发者ID:ralescano,项目名称:castle,代码行数:16,代码来源:AbstractTransaction.cs
示例15: FileBasedPersistentSource
public FileBasedPersistentSource(string basePath, string prefix, TransactionMode transactionMode)
{
SyncLock = new object();
this.basePath = basePath;
this.prefix = prefix;
this.transactionMode = transactionMode;
dataPath = Path.Combine(basePath, prefix + ".data");
logPath = Path.Combine(basePath, prefix + ".log");
RecoverFromFailedRename(dataPath);
RecoverFromFailedRename(logPath);
CreatedNew = File.Exists(logPath) == false;
OpenFiles();
}
开发者ID:Rationalle,项目名称:ravendb,代码行数:17,代码来源:FileBasedPersistentSource.cs
示例16: CreateContext
/// <summary>
/// Creates a context with an optionally open database and SMTP connection.
/// </summary>
/// <param name="openConnection">True if a database connection should be opened.</param>
/// <param name="beginTransaction">True if a transaction is required.</param>
/// <param name="openSmtp">True if an SMTP connection should be opened.</param>
/// <returns>A valid connection.</returns>
public Context CreateContext(ConnectionMode connectionMode, TransactionMode transactionMode)
{
var context = new Context()
{
ConnectionString = connectionString,
ConnectionMode = connectionMode,
TransactionMode = transactionMode,
UserGuid = userGuid,
UserName = userName,
};
context.ClusterProperty.Name = clusterName;
context.DomainProperty.Name = domainName;
context.FederationProperty.Name = federationName;
return context;
}
开发者ID:skyquery,项目名称:graywulf,代码行数:25,代码来源:ContextManager.cs
示例17: ProcessPayment
/// <summary>
/// Processes the Authorize and AuthorizeAndCapture transactions
/// </summary>
/// <param name="invoice">The <see cref="IInvoice" /> to be paid</param>
/// <param name="payment">The <see cref="IPayment" /> record</param>
/// <param name="transactionMode">Authorize or AuthorizeAndCapture</param>
/// <param name="amount">The money amount to be processed</param>
/// <param name="creditCard">The <see cref="CreditCardFormData" /></param>
/// <returns>The <see cref="IPaymentResult" /></returns>
public IPaymentResult ProcessPayment(IInvoice invoice, IPayment payment, TransactionMode transactionMode,
decimal amount, CreditCardFormData creditCard)
{
if (!IsValidCurrencyCode(invoice.CurrencyCode()))
return new PaymentResult(Attempt<IPayment>.Fail(payment, new Exception("Invalid currency")), invoice,
false);
// The minimum amount is $0.50 (or equivalent in charge currency).
// Test that the payment meets the minimum amount (for USD only).
if (invoice.CurrencyCode() == "USD")
{
if (amount < 0.5m)
return
new PaymentResult(
Attempt<IPayment>.Fail(payment, new Exception("Invalid amount (less than 0.50 USD)")),
invoice, false);
}
else
{
if (amount < 1)
return
new PaymentResult(
Attempt<IPayment>.Fail(payment,
new Exception("Invalid amount (less than 1 " + invoice.CurrencyCode() + ")")),
invoice, false);
}
var requestParams = StripeHelper.PreparePostDataForProcessPayment(invoice.GetBillingAddress(), transactionMode,
ConvertAmount(invoice, amount), invoice.CurrencyCode(), creditCard, invoice.PrefixedInvoiceNumber(),
string.Format("Full invoice #{0}", invoice.PrefixedInvoiceNumber()));
// https://stripe.com/docs/api#create_charge
try
{
var response = StripeHelper.MakeStripeApiRequest("https://api.stripe.com/v1/charges", "POST", requestParams, _settings);
return GetProcessPaymentResult(invoice, payment, response);
}
catch (WebException ex)
{
return GetProcessPaymentResult(invoice, payment, (HttpWebResponse) ex.Response);
}
}
开发者ID:vonbv,项目名称:MerchelloStripeProvider,代码行数:51,代码来源:StripePaymentProcessor.cs
示例18: TransactionScope
/// <summary>
/// Initializes a new instance of the <see cref="TransactionScope"/> class.
/// </summary>
public TransactionScope(
TransactionMode mode = TransactionMode.New,
IsolationLevel isolation = IsolationLevel.Unspecified,
OnDispose ondispose = OnDispose.Commit,
ISessionScope parent = null,
ISessionFactoryHolder holder = null,
IThreadScopeInfo scopeinfo = null
)
: base(FlushAction.Config, isolation, ondispose, parent, holder, scopeinfo)
{
this.mode = mode;
parentTransactionScope = ParentScope as TransactionScope;
if (mode == TransactionMode.New) {
if (parentTransactionScope != null) {
parentTransactionScope = null;
ParentScope = null;
} else {
parentTransactionScope = null;
}
}
}
开发者ID:shosca,项目名称:ActiveRecord,代码行数:26,代码来源:TransactionScope.cs
示例19: EnlistScope
/// <summary>
/// Enlists a <see cref="UnitOfWorkScope"/> instance with the transaction manager,
/// with the specified transaction mode.
/// </summary>
/// <param name="scope">The <see cref="IUnitOfWorkScope"/> to register.</param>
/// <param name="mode">A <see cref="TransactionMode"/> enum specifying the transaciton
/// mode of the unit of work.</param>
public void EnlistScope(IUnitOfWorkScope scope, TransactionMode mode)
{
_logger.Info(string.Format("Enlisting scope {0} with transaction manager {1} with transaction mode {2}",
scope.ScopeId,
_transactionManagerId,
mode));
var uowFactory = ServiceLocator.Current.GetInstance<IUnitOfWorkFactory>();
if (_transactions.Count == 0 ||
mode == TransactionMode.New ||
mode == TransactionMode.Supress)
{
_logger.Debug(string.Format("Enlisting scope {0} with mode {1} requires a new TransactionScope to be created.", scope.ScopeId, mode));
var txScope = TransactionScopeHelper.CreateScope(UnitOfWorkSettings.DefaultIsolation, mode);
var unitOfWork = uowFactory.Create();
var transaction = new UnitOfWorkTransaction(unitOfWork, txScope);
transaction.TransactionDisposing += OnTransactionDisposing;
transaction.EnlistScope(scope);
_transactions.AddFirst(transaction);
return;
}
CurrentTransaction.EnlistScope(scope);
}
开发者ID:zbw911,项目名称:MyFramework,代码行数:30,代码来源:TransactionManager.cs
示例20: CreateTransaction
/// <summary>
/// Creates a transaction.
/// </summary>
/// <param name="transactionMode">The transaction mode.</param>
/// <param name="isolationMode">The isolation mode.</param>
/// <returns></returns>
public virtual ITransaction CreateTransaction(TransactionMode transactionMode, IsolationMode isolationMode)
{
return CreateTransaction(transactionMode, isolationMode, false);
}
开发者ID:ralescano,项目名称:castle,代码行数:10,代码来源:DefaultTransactionManager.cs
注:本文中的TransactionMode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论