当前位置: 首页>>代码示例>>C#>>正文


C# TransactionMode类代码示例

本文整理汇总了C#中TransactionMode的典型用法代码示例。如果您正苦于以下问题:C# TransactionMode类的具体用法?C# TransactionMode怎么用?C# TransactionMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TransactionMode类属于命名空间,在下文中一共展示了TransactionMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的TransactionMode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。