/// <include file='doc\WebMethodAttribute.uex' path='docs/doc[@for="WebMethodAttribute.WebMethodAttribute3"]/*' /> /// <devdoc> /// <para>Initializes a new instance of the <see cref='System.Web.Services.WebMethodAttribute'/> /// class.</para> /// </devdoc> public WebMethodAttribute(bool enableSession, TransactionOption transactionOption, int cacheDuration) { EnableSession = enableSession; this.transactionOption = (int)transactionOption; transactionOptionSpecified = true; CacheDuration = cacheDuration; BufferResponse = true; }
public void Execute(Action <IUnitOfWork> action, TransactionOption option = TransactionOption.Context) { if (action == null) { throw new ArgumentException("Action can not be null", "action"); } using (var uow = this.UnitOfWork) { switch (option) { case TransactionOption.Context: this.DoCommand(action, uow); break; case TransactionOption.Database: this.DoDbCommand(action, uow); break; case TransactionOption.MSDTC: this.DoMsdtcCommand(action, uow); break; default: this.DoCommand(action, uow); break; } } }
//进入事务上下文 private void EnterTxContext(TransactionOption txOption) { ServiceConfig config = new ServiceConfig(); config.Transaction = txOption; ServiceDomain.Enter(config); }
/// <summary> /// Processes the payment. /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="option"> /// The option. /// </param> /// <param name="amount"> /// The amount. /// </param> /// <param name="token"> /// The token. /// </param> /// <param name="email"> /// The email. /// </param> /// <returns> /// The <see cref="IPaymentResult"/>. /// </returns> protected override IPaymentResult ProcessPayment(IInvoice invoice, TransactionOption option, decimal amount, string token, string email = "") { var payment = GatewayProviderService.CreatePayment(PaymentMethodType.CreditCard, amount, PaymentMethod.Key); payment.CustomerKey = invoice.CustomerKey; payment.Authorized = false; payment.Collected = false; payment.PaymentMethodName = "Braintree Vault Transaction"; payment.ExtendedData.SetValue(Braintree.Constants.ProcessorArguments.PaymentMethodNonce, token); var result = BraintreeApiService.Transaction.VaultSale(invoice, token, option); if (result.IsSuccess()) { payment.ExtendedData.SetBraintreeTransaction(result.Target); if (option == TransactionOption.Authorize) { payment.Authorized = true; } if (option == TransactionOption.SubmitForSettlement) { payment.Authorized = true; payment.Collected = true; } return(new PaymentResult(Attempt <IPayment> .Succeed(payment), invoice, true)); } var error = new BraintreeApiException(result.Errors, result.Message); return(new PaymentResult(Attempt <IPayment> .Fail(payment, error), invoice, false)); }
public TResult Execute <TResult>(Func <IUnitOfWork, TResult> action, TransactionOption option = TransactionOption.Context) { TResult result = default(TResult); if (action == null) { throw new ArgumentException("Action can not be null", "action"); } using (var uow = this.UnitOfWork) { switch (option) { case TransactionOption.Context: result = this.DoCommand(action, uow); break; case TransactionOption.Database: result = this.DoDbCommand(action, uow); break; case TransactionOption.MSDTC: result = this.DoMsdtcCommand(action, uow); break; default: result = this.DoCommand(action, uow); break; } } return(result); }
public void NewOrder_Test() { Wallet wallet = Wallet.Open("{privateKey}", EnvironmentInfo.TESTNET); NewOrder newOrder = new NewOrder() { Symbol = "BNB_BTC", OrderType = OrderTypes.LimitOrder, Side = OrderSides.Buy, Price = "10", Quantity = "1", TimeInForce = TimeInForce.GoodTillExpire }; TransactionOption option = new TransactionOption() { Memo = null, Source = 1, Data = null }; var api = BinanceApiFactory.CreateApiClient(EnvironmentInfo.TESTNET); var result = api.NewOrder(newOrder, wallet, option); Assert.IsTrue(result != null); }
/// <summary> /// Initializes a new instance of the <see cref="GenerateWebMethodAttribute"/> class. /// </summary> /// <param name="enableSession">Initializes whether session state is enabled for the XML Web service method.</param> /// <param name="transactionOption">Initializes the transaction support of an XML Web service method.</param> /// <param name="cacheDuration">Initializes the number of seconds the response is cached.</param> public GenerateWebMethodAttribute( bool enableSession, TransactionOption transactionOption, int cacheDuration) : base(typeof(WebMethodAttribute), enableSession, transactionOption, cacheDuration) { }
public TransactionOption GetTransaction(int transactionId) { Transaction transaction = dbContext.Transactions .Include(o => o.Backer) .FirstOrDefault(x => x.Id == transactionId); Backer backer = dbContext.Backers.Find(transaction.Backer.Id); List <int> rewardpackages = new List <int>(); List <TransactionPackage> tranactionPackages = dbContext.TransactionPackages .Include(rp => rp.RewardPackage) .Where(rp => rp.Transaction.Equals(transaction)) .ToList(); tranactionPackages.ForEach(rp => rewardpackages.Add(rp.RewardPackage.Id)); TransactionOption transactionOption = new TransactionOption { BackerName = backer.LastName + " " + backer.FirstName + " ", TransactionId = transaction.Id //ProjectId = project.Id, //RewardPackages = rewardpackages }; return(transactionOption); }
/// <summary> /// Initializes a new instance of the <see cref="GenerateWebMethodAttribute"/> class. /// </summary> /// <param name="enableSession">Initializes whether session state is enabled for the XML Web service method.</param> /// <param name="transactionOption">Initializes the transaction support of an XML Web service method.</param> /// <param name="cacheDuration">Initializes the number of seconds the response is cached.</param> public GenerateWebMethodAttribute( bool enableSession, TransactionOption transactionOption, int cacheDuration) : base(typeof(WebMethodAttribute), enableSession, transactionOption, cacheDuration) { }
public ComAdminClassInfo(ICatalogObject compObj, ICatalogCollection compColl) { this.clsid = new Guid((string)compObj.Key()); this.progid = (string)compObj.Name(); this.isPrivate = (bool)compObj.GetValue(PropertyName.IsPrivateComponent); this.transactionOption = (TransactionOption)compObj.GetValue(PropertyName.TransactionOption); this.BuildInterfaces(compObj, compColl); }
public static void InvokeTransacted (TransactedCallback callback, TransactionOption mode, ref bool transactionAborted) { // note: this is the documented exception for (Windows) OS prior to NT // so in this case we won't throw a NotImplementedException throw new PlatformNotSupportedException ("Not supported on mono"); }
public static void InvokeTransacted(TransactedCallback callback, TransactionOption mode, ref bool transactionAborted) { // note: this is the documented exception for (Windows) OS prior to NT // so in this case we won't throw a NotImplementedException throw new PlatformNotSupportedException("Not supported on mono"); }
public int Update(DataTable dataTable, TransactionOption transactionOption) { using (var scope = new Scope(new DaScopeContext(transactionOption))) { var returnValue = DataAdapter.Update(dataTable); scope.Complete(); return(returnValue); } }
/// <summary> /// Turns a command string into a <see cref="TransactionOption"/>. /// </summary> /// <param name="payCommand">Transaction command from command line.</param> /// <returns>The class with transaction properties.</returns> public static TransactionOption DecodeTransaction(this string payCommand) { string[] args = payCommand.Split(' '); TransactionOption transaction = new TransactionOption(); CommandLine.Parser.Default.ParseArguments(args, transaction); return(transaction); }
public VoteMessage(Vote vote, Wallet wallet, TransactionOption options) { this.wallet = wallet; this.options = options; this.message = new VoteProto(); this.message.ProposalId = vote.ProposalId; this.message.Option = vote.Option; }
private void EnterTxContext(TransactionOption txOption) { ServiceConfig config = new ServiceConfig(); config.Transaction = txOption; ServiceDomain.Enter(config); // Since Enter can throw, the next statement will track the success // In the case of success will we need to call Leave in Dispose this.EnterSucceeded = true; }
/// <summary> /// Create a transaction for use with the environment. /// /// The transaction handle may be discarded using Abort() or Commit(); /// NOTE: A transaction and its cursors must only be used by a single /// thread, and a thread may only have a single transaction at a time. /// If MDBX_NOTLS is in use, this does not apply to read-only transactions. /// NOTE: Cursors may not span transactions. /// </summary> /// <param name="flags"></param> /// <returns></returns> public MdbxTransaction BeginTransaction(TransactionOption flags = TransactionOption.Unspecific) { if (!closed && _envPtr != IntPtr.Zero) { IntPtr ptr = Txn.Begin(_envPtr, IntPtr.Zero, flags); return(new MdbxTransaction(this, ptr)); } throw new InvalidOperationException("MDBX environment is not open."); }
public CancelOrderMessage(CancelOrder cancelOrder, Wallet wallet, TransactionOption options) { this.wallet = wallet; this.options = options; this.message = new CancelOrderProto(); this.message.Symbol = cancelOrder.Symbol; this.message.RefId = cancelOrder.RefId; }
public TokenUnfreezeMessage(TokenUnfreeze tokenUnfreeze, Wallet wallet, TransactionOption options) { this.wallet = wallet; this.options = options; this.message = new TokenUnfreezeProto(); this.message.From = wallet.Address; this.message.Symbol = tokenUnfreeze.Symbol; this.message.Amount = StringDecimalToLong(tokenUnfreeze.Amount); }
public WebMethodAttribute (bool enableSession, TransactionOption transactionOption, int cacheDuration, bool bufferResponse) { this.bufferResponse = bufferResponse; this.cacheDuration = cacheDuration; this.enableSession = enableSession; this.transactionOption = transactionOption; this.description = String.Empty; this.messageName = String.Empty; }
/// <summary> /// Authorizes a payment. /// </summary> /// <param name="transaction">Transaction to authorize.</param> /// <returns>The report returned from Stone Authorizer, or null if something /// went wrong.</returns> public IAuthorizationReport Authorize(TransactionOption transaction) { // Verify if the authorizer is eligible to do something: if (this.IsUsable == false) { return(null); } // Setup transaction data: ITransactionEntry transactionEntry = new TransactionEntry { Amount = transaction.Amount, CaptureTransaction = true, InitiatorTransactionKey = transaction.Itk, Type = transaction.AccountType }; IAuthorizationReport authReport = null; try { // Authorize the transaction setup and return it's value: ResponseStatus authorizationStatus; authReport = this.StoneAuthorizer.Authorize(transactionEntry, out authorizationStatus); // Show result on console: if (authReport.WasSuccessful == true) { authReport.ShowTransactionOnScreen(); this.Transactions.Add(new TransactionTableEntry(authReport, false)); } else { authReport.ShowErrorOnTransaction(); this.Transactions.Add(new TransactionTableEntry(authReport, true)); } } catch (CardHasChipException) { Console.WriteLine("O cartao possui chip. For favor, insira-o."); this.Transactions.Add(new TransactionTableEntry(transactionEntry, true)); } catch (ExpiredCardException) { Console.WriteLine("Cartão expirado."); this.Transactions.Add(new TransactionTableEntry(transactionEntry, true)); } catch (Exception) { Console.WriteLine("Ocorreu um erro na transacao."); this.Transactions.Add(new TransactionTableEntry(transactionEntry, true)); } return(authReport); }
/// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public static void InvokeTransacted(TransactedCallback callback, TransactionOption mode, ref bool transactionAborted) { // check for hosting permission even if no user code on the stack HttpRuntime.CheckAspNetHostingPermission(AspNetHostingPermissionLevel.Medium, SR.Transaction_not_supported_in_low_trust); bool executeWithoutTransaction = false; #if !FEATURE_PAL // FEATURE_PAL does not enable Transactions if (Environment.OSVersion.Platform != PlatformID.Win32NT || Environment.OSVersion.Version.Major <= 4) throw new PlatformNotSupportedException(SR.GetString(SR.RequiresNT)); #else // !FEATURE_PAL throw new NotImplementedException("ROTORTODO"); #endif // !FEATURE_PAL if (mode == TransactionOption.Disabled) executeWithoutTransaction = true; if (executeWithoutTransaction) { // bypass the transaction logic callback(); transactionAborted = false; return; } TransactedInvocation call = new TransactedInvocation(callback); TransactedExecCallback execCallback = new TransactedExecCallback(call.ExecuteTransactedCode); PerfCounters.IncrementCounter(AppPerfCounter.TRANSACTIONS_PENDING); int rc; try { rc = UnsafeNativeMethods.TransactManagedCallback(execCallback, (int)mode); } finally { PerfCounters.DecrementCounter(AppPerfCounter.TRANSACTIONS_PENDING); } // rethrow the expection originally caught in managed code if (call.Error != null) throw new HttpException(null, call.Error); PerfCounters.IncrementCounter(AppPerfCounter.TRANSACTIONS_TOTAL); if (rc == 1) { PerfCounters.IncrementCounter(AppPerfCounter.TRANSACTIONS_COMMITTED); transactionAborted = false; } else if (rc == 0) { PerfCounters.IncrementCounter(AppPerfCounter.TRANSACTIONS_ABORTED); transactionAborted = true; } else { throw new HttpException(SR.GetString(SR.Cannot_execute_transacted_code)); } }
/// <summary> /// Performs a Braintree Transaction using a vaulted credit card. /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="paymentMethodToken"> /// The payment method token. /// </param> /// <param name="customer"> /// The customer. /// </param> /// <param name="option"> /// The option. /// </param> /// <returns> /// The <see cref="Result{Transaction}"/>. /// </returns> public Result <Transaction> VaultSale( IInvoice invoice, string paymentMethodToken, TransactionOption option = TransactionOption.SubmitForSettlement) { var request = RequestFactory.CreateVaultTransactionRequest(invoice, paymentMethodToken, option); var attempt = TryGetApiResult(() => BraintreeGateway.Transaction.Sale(request)); return(attempt.Success ? attempt.Result : null); }
internal static IntPtr Begin(IntPtr env, IntPtr parent, TransactionOption flags) { IntPtr ptr; int err = _beginDelegate(env, parent, (int)flags, out ptr); if (err != 0) { throw new MdbxException("mdbx_txn_begin", err); } return(ptr); }
public TransactionOption UpdateCurrentBudget(TransactionOption transactionOption) { Project project = dbContext.Projects .Where(o => o.Id == transactionOption.RewardPackage.ProjectId) .Include(o => o.ProjectCreator) .SingleOrDefault(); project.CurrentBudget += transactionOption.RewardPackage.Price; dbContext.SaveChanges(); return(transactionOption); }
public byte[] EncodeSignature(byte[] signature, Wallet wallet, TransactionOption options) { StdSignatureProto stdSignature = new StdSignatureProto { PubKey = wallet.PubKeyForSign, Signature = signature, AccountNumber = wallet.AccountNumber.Value, Sequence = wallet.Sequence.Value }; return(EncodeMessage <StdSignatureProto>(stdSignature, MessagePrefixes.StdSignature)); }
/// <summary> /// Performs a Braintree sales transaction. /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="paymentMethodNonce"> /// The payment method nonce. /// </param> /// <param name="customer"> /// The customer. /// </param> /// <param name="option"> /// The option. /// </param> /// <param name="email"> /// The email. /// </param> /// <returns> /// The <see cref="Result{Transaction}"/>. /// </returns> public Result<Transaction> Sale(IInvoice invoice, string paymentMethodNonce = "", ICustomer customer = null, TransactionOption option = TransactionOption.SubmitForSettlement, string email = "") { var request = RequestFactory.CreateTransactionRequest(invoice, paymentMethodNonce, customer, option); if (customer == null && !string.IsNullOrEmpty(email)) { request.Customer = new CustomerRequest() { Email = email }; } var attempt = TryGetApiResult(() => BraintreeGateway.Transaction.Sale(request)); return attempt.Success ? attempt.Result : null; }
/// <summary> /// Performs a Braintree Transaction using a vaulted credit card. /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="paymentMethodToken"> /// The payment method token. /// </param> /// <param name="customer"> /// The customer. /// </param> /// <param name="option"> /// The option. /// </param> /// <returns> /// The <see cref="Result{Transaction}"/>. /// </returns> public Result <Transaction> VaultSale( IInvoice invoice, string paymentMethodToken, TransactionOption option = TransactionOption.SubmitForSettlement) { var request = this.RequestFactory.CreateVaultTransactionRequest(invoice, paymentMethodToken, option); LogHelper.Info <BraintreeTransactionApiService>(string.Format("Braintree Vault Transaction attempt ({0}) for Invoice {1}", option.ToString(), invoice.PrefixedInvoiceNumber())); var attempt = this.TryGetApiResult(() => this.BraintreeGateway.Transaction.Sale(request)); return(attempt.Success ? attempt.Result : null); }
public static bool TryGetTransactionOption(MethodInfo methodInfo, out TransactionOption option) { option = TransactionOption.Suppress; TransactionAttribute transactionAttribute = methodInfo.GetCustomAttribute <TransactionAttribute>(true); if (transactionAttribute != null) { option = transactionAttribute.Requirement; return(true); } return(false); }
public static void InvokeTransacted(TransactedCallback callback, TransactionOption mode, ref bool transactionAborted) { HttpRuntime.CheckAspNetHostingPermission(AspNetHostingPermissionLevel.Medium, "Transaction_not_supported_in_low_trust"); bool flag = false; if ((Environment.OSVersion.Platform != PlatformID.Win32NT) || (Environment.OSVersion.Version.Major <= 4)) { throw new PlatformNotSupportedException(System.Web.SR.GetString("RequiresNT")); } if (mode == TransactionOption.Disabled) { flag = true; } if (flag) { callback(); transactionAborted = false; } else { int num; TransactedInvocation invocation = new TransactedInvocation(callback); TransactedExecCallback callback2 = new TransactedExecCallback(invocation.ExecuteTransactedCode); PerfCounters.IncrementCounter(AppPerfCounter.TRANSACTIONS_PENDING); try { num = UnsafeNativeMethods.TransactManagedCallback(callback2, (int)mode); } finally { PerfCounters.DecrementCounter(AppPerfCounter.TRANSACTIONS_PENDING); } if (invocation.Error != null) { throw new HttpException(null, invocation.Error); } PerfCounters.IncrementCounter(AppPerfCounter.TRANSACTIONS_TOTAL); switch (num) { case 1: PerfCounters.IncrementCounter(AppPerfCounter.TRANSACTIONS_COMMITTED); transactionAborted = false; return; case 0: PerfCounters.IncrementCounter(AppPerfCounter.TRANSACTIONS_ABORTED); transactionAborted = true; return; } throw new HttpException(System.Web.SR.GetString("Cannot_execute_transacted_code")); } }
private static void CalculateTransactionSupport() { TransactionSupportAttribute transactionSupport = ReflectionCache.GetCustomAttribute <TransactionSupportAttribute>(typeof(T), true); if (transactionSupport != null) { _transactionOptions = transactionSupport.TransactionOption; } else { _transactionOptions = TransactionOption.None; } }
public byte[] EncodeStandardTx(byte[] message, byte[] signature, TransactionOption options) { StdTxProto stdTx = new StdTxProto() { Msgs = message, Signatures = signature, Memo = options.Memo, Source = options.Source, Data = options.Data != null ? options.Data : null }; return(EncodeMessage <StdTxProto>(stdTx, MessagePrefixes.StdTx)); }
public async Task RunTransaction(TransactionOption transactionOption, Func <Task> transactionDelegate) { if (transactionDelegate is null) { throw new ArgumentNullException(nameof(transactionDelegate)); } await RunTransaction(transactionOption, async() => { await transactionDelegate(); return(true); }); }
public static void PostfixUBFTransactionScopeConstructor(UBFTransactionScope __instance, TransactionOption option) { if (_debugConfig == null) { return; } string enterpriseID = PlatformContext.Current.EnterpriseID; string orgCode = PlatformContext.Current.OrgCode; string userCode = PlatformContext.Current.UserCode; if (!IsLog(enterpriseID, orgCode, userCode)) { return; } StringBuilder sb = new StringBuilder(); StackTrace stackTrace = new StackTrace(true); for (int i = 0; i < stackTrace.FrameCount; i++) { StackFrame frame = stackTrace.GetFrame(i); MethodBase method = frame.GetMethod(); if (method.DeclaringType == null) { continue; } if (method.DeclaringType == typeof(SQLDebug)) { continue; } string assemblyFullName = method.DeclaringType.Assembly.FullName; sb.AppendFormat("自定义事务:"); if (!string.IsNullOrEmpty(assemblyFullName)) { sb.Append(assemblyFullName.Split(',')[0]); sb.Append("!"); } sb.AppendFormat("{0}.{1} 事务类型:{2} 事务ID:{3}", method.DeclaringType.FullName, method.Name, option, Transaction.Current == null ? string.Empty : Transaction.Current.TransactionInformation.LocalIdentifier); break; } if (_debugConfig.IsOutputTransactionStack) { sb.AppendLine(); sb.Append(StackTraceHelper.GetCurrentStackTraceString(4)); } Logger.Debug(sb.ToString()); }
public static void InvokeTransacted(TransactedCallback callback, TransactionOption mode, ref bool transactionAborted) { HttpRuntime.CheckAspNetHostingPermission(AspNetHostingPermissionLevel.Medium, "Transaction_not_supported_in_low_trust"); bool flag = false; if ((Environment.OSVersion.Platform != PlatformID.Win32NT) || (Environment.OSVersion.Version.Major <= 4)) { throw new PlatformNotSupportedException(System.Web.SR.GetString("RequiresNT")); } if (mode == TransactionOption.Disabled) { flag = true; } if (flag) { callback(); transactionAborted = false; } else { int num; TransactedInvocation invocation = new TransactedInvocation(callback); TransactedExecCallback callback2 = new TransactedExecCallback(invocation.ExecuteTransactedCode); PerfCounters.IncrementCounter(AppPerfCounter.TRANSACTIONS_PENDING); try { num = UnsafeNativeMethods.TransactManagedCallback(callback2, (int) mode); } finally { PerfCounters.DecrementCounter(AppPerfCounter.TRANSACTIONS_PENDING); } if (invocation.Error != null) { throw new HttpException(null, invocation.Error); } PerfCounters.IncrementCounter(AppPerfCounter.TRANSACTIONS_TOTAL); switch (num) { case 1: PerfCounters.IncrementCounter(AppPerfCounter.TRANSACTIONS_COMMITTED); transactionAborted = false; return; case 0: PerfCounters.IncrementCounter(AppPerfCounter.TRANSACTIONS_ABORTED); transactionAborted = true; return; } throw new HttpException(System.Web.SR.GetString("Cannot_execute_transacted_code")); } }
public NewOrderMessage(NewOrder order, Wallet wallet, TransactionOption options) { this.wallet = wallet; this.options = options; this.message = new NewOrderProto(); this.message.Sender = wallet.Address; this.message.Id = GenerateOrderId(wallet); this.message.Symbol = order.Symbol; this.message.OrderType = order.OrderType; this.message.Side = order.Side; this.message.Price = base.StringDecimalToLong(order.Price); this.message.Quantity = base.StringDecimalToLong(order.Quantity); this.message.TimeInForce = order.TimeInForce; }
public IActionResult TransactionOption([FromBody] TransactionOption model) { try { appConfigRepo.LoadJSON(); appConfigRepo.AppConfig.TransactionOption = model; appConfigRepo.SaveJSON(); return(Ok(appConfigRepo.AppConfig.TransactionOption)); } catch (Exception ex) { logger.LogError(ex.GetExceptionMessages()); return(StatusCode(StatusCodes.Status500InternalServerError, Constants.ErrorMessages.UpdateError)); } }
public TResult Execute <TResult>(Func <IUnitOfWork, TResult> work, TransactionOption option = TransactionOption.CTX) { if (work == null) { throw new ArgumentException("Work can not be null", "work"); } Tuple <bool, Exception, TResult> result = null; using (var uow = this.UnitOfWork) { switch (option) { case TransactionOption.CTX: result = this.DoCommand(work, uow); break; case TransactionOption.DB: result = this.DoDBCommand(work, uow); break; case TransactionOption.DTC: result = this.DoDTCCommand(work, uow); break; default: result = this.DoCommand(work, uow); break; } } if (!result.Item1) { Exception ex = result.Item2; Log.ErrorFormat("Exception: {0} \n{1}", ex.Message, ex.StackTrace); if (ex.InnerException != null) { Log.ErrorFormat("InnerException: {0} \n{1}", ex.InnerException.Message, ex.InnerException.StackTrace); } Log.Debug("------------------------------------------------------------"); throw ex; } return(result.Item3); }
protected override IPaymentResult ProcessPayment(IInvoice invoice, TransactionOption option, decimal amount, string paymentMethodNonce) { var payment = GatewayProviderService.CreatePayment(PaymentMethodType.CreditCard, amount, PaymentMethod.Key); payment.CustomerKey = invoice.CustomerKey; payment.Authorized = false; payment.Collected = false; payment.PaymentMethodName = "Braintree Transaction"; payment.ExtendedData.SetValue(Braintree.Constants.ProcessorArguments.PaymentMethodNonce, paymentMethodNonce); var merchCustomer = invoice.Customer(); if (merchCustomer == null) { var customerError = new NullReferenceException("A customer is not associated with the invoice. Braintree vault transactions require a customer reference."); return new PaymentResult(Attempt<IPayment>.Fail(payment, customerError), invoice, false); } var result = BraintreeApiService.Transaction.Sale(invoice, paymentMethodNonce, merchCustomer, invoice.GetBillingAddress(), option); if (result.IsSuccess()) { payment.ExtendedData.SetBraintreeTransaction(result.Target); if (option == TransactionOption.Authorize) payment.Authorized = true; if (option == TransactionOption.SubmitForSettlement) { payment.Authorized = true; payment.Collected = true; } return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice, true); } var error = new BraintreeApiException(result.Errors, result.Message); return new PaymentResult(Attempt<IPayment>.Fail(payment, error), invoice, false); }
public ComAdminClassInfo(ICatalogObject compObj, ICatalogCollection compColl) { this.clsid = new Guid((string)compObj.Key()); this.progid = (string)compObj.Name(); this.isPrivate = (bool)compObj.GetValue(PropertyName.IsPrivateComponent); this.transactionOption = (TransactionOption)compObj.GetValue(PropertyName.TransactionOption); this.BuildInterfaces(compObj, compColl); }
// NOTE: Construction of this thing is quite inefficient-- it // has several nested loops that could probably be // improved. Such optimizations have been left for when // it turns out to be a performance problem, for the // sake of simplicity. // public ServiceInfo(Guid clsid, ServiceElement service, ComCatalogObject application, ComCatalogObject classObject, HostingMode hostingMode) { // Simple things... // this.service = service; this.clsid = clsid; this.appid = Fx.CreateGuid((string)application.GetValue("ID")); this.partitionId = Fx.CreateGuid((string)application.GetValue("AppPartitionID")); this.bitness = (Bitness)classObject.GetValue("Bitness"); this.transactionOption = (TransactionOption)classObject.GetValue("Transaction"); this.hostingMode = hostingMode; this.managedType = TypeCacheManager.ResolveClsidToType(clsid); this.serviceName = application.Name + "." + classObject.Name; this.udts = new Dictionary<Guid, List<Type>>(); // Isolation Level COMAdminIsolationLevel adminIsolationLevel; adminIsolationLevel = (COMAdminIsolationLevel)classObject.GetValue("TxIsolationLevel"); switch (adminIsolationLevel) { case COMAdminIsolationLevel.Any: this.isolationLevel = IsolationLevel.Unspecified; break; case COMAdminIsolationLevel.ReadUncommitted: this.isolationLevel = IsolationLevel.ReadUncommitted; break; case COMAdminIsolationLevel.ReadCommitted: this.isolationLevel = IsolationLevel.ReadCommitted; break; case COMAdminIsolationLevel.RepeatableRead: this.isolationLevel = IsolationLevel.RepeatableRead; break; case COMAdminIsolationLevel.Serializable: this.isolationLevel = IsolationLevel.Serializable; break; default: throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed( SR.GetString(SR.InvalidIsolationLevelValue, this.clsid, adminIsolationLevel))); } // Threading Model // COMAdminThreadingModel adminThreadingModel; adminThreadingModel = (COMAdminThreadingModel)classObject.GetValue("ThreadingModel"); switch (adminThreadingModel) { case COMAdminThreadingModel.Apartment: case COMAdminThreadingModel.Main: this.threadingModel = ThreadingModel.STA; objectPoolingEnabled = false; break; default: this.threadingModel = ThreadingModel.MTA; objectPoolingEnabled = (bool)classObject.GetValue("ObjectPoolingEnabled"); break; } // Object Pool settings // if (objectPoolingEnabled) { maxPoolSize = (int)classObject.GetValue("MaxPoolSize"); } else maxPoolSize = 0; // Security Settings // bool appSecurityEnabled; appSecurityEnabled = (bool)application.GetValue( "ApplicationAccessChecksEnabled"); if (appSecurityEnabled) { bool classSecurityEnabled; classSecurityEnabled = (bool)classObject.GetValue( "ComponentAccessChecksEnabled"); if (classSecurityEnabled) { this.checkRoles = true; } } // Component Roles // ComCatalogCollection roles; roles = classObject.GetCollection("RolesForComponent"); this.componentRoleMembers = CatalogUtil.GetRoleMembers(application, roles); // Contracts // One ContractInfo per unique IID exposed, so we need to // filter duplicates. // this.contracts = new List<ContractInfo>(); ComCatalogCollection interfaces; interfaces = classObject.GetCollection("InterfacesForComponent"); foreach (ServiceEndpointElement endpoint in service.Endpoints) { ContractInfo contract = null; if (endpoint.Contract == ServiceMetadataBehavior.MexContractName) continue; Guid iid; if (DiagnosticUtility.Utility.TryCreateGuid(endpoint.Contract, out iid)) { // (Filter duplicates.) bool duplicate = false; foreach (ContractInfo otherContract in this.contracts) { if (iid == otherContract.IID) { duplicate = true; break; } } if (duplicate) continue; foreach (ComCatalogObject interfaceObject in interfaces) { Guid otherInterfaceID; if (DiagnosticUtility.Utility.TryCreateGuid((string)interfaceObject.GetValue("IID"), out otherInterfaceID)) { if (otherInterfaceID == iid) { contract = new ContractInfo(iid, endpoint, interfaceObject, application); break; } } } } if (contract == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed( SR.GetString(SR.EndpointNotAnIID, clsid.ToString("B").ToUpperInvariant(), endpoint.Contract))); } this.contracts.Add(contract); } }
public TransactionAttribute(TransactionOption val) { }
public TransactionScope(TransactionOption txOption) { EnterTxContext(txOption); }
public static void InvokeTransacted(TransactedCallback callback, TransactionOption mode) { bool transactionAborted = false; InvokeTransacted(callback, mode, ref transactionAborted); }
/// <summary> /// Performs a Braintree sales transaction. /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="paymentMethodNonce"> /// The payment method nonce. /// </param> /// <param name="customer"> /// The customer. /// </param> /// <param name="billingAddress"> /// The billing address. /// </param> /// <param name="shippingAddress"> /// The shipping address. /// </param> /// <param name="option"> /// The option. /// </param> /// <returns> /// The <see cref="IPaymentResult"/>. /// </returns> public Result<Transaction> Sale(IInvoice invoice, string paymentMethodNonce, ICustomer customer, IAddress billingAddress, IAddress shippingAddress, TransactionOption option = TransactionOption.SubmitForSettlement) { var request = RequestFactory.CreateTransactionRequest(invoice, paymentMethodNonce, customer, option); if (billingAddress != null) request.BillingAddress = RequestFactory.CreateAddressRequest(billingAddress); if (shippingAddress != null) request.ShippingAddress = RequestFactory.CreateAddressRequest(shippingAddress); var attempt = TryGetApiResult(() => BraintreeGateway.Transaction.Sale(request)); return attempt.Success ? attempt.Result : null; }
public static void InvokeTransacted (TransactedCallback callback, TransactionOption mode, ref bool transactionAborted) { throw new PlatformNotSupportedException ("Not supported on mono"); }
/// <summary> /// Processes a payment against the Braintree API using the BraintreeApiService. /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="option"> /// The option. /// </param> /// <param name="amount"> /// The amount. /// </param> /// <param name="paymentMethodNonce"> /// The payment method nonce. /// </param> /// <returns> /// The <see cref="IPaymentResult"/>. /// </returns> /// <remarks> /// This converts the <see cref="Result{Transaction}"/> into Merchello's <see cref="IPaymentResult"/> /// </remarks> protected abstract IPaymentResult ProcessPayment(IInvoice invoice, TransactionOption option, decimal amount, string paymentMethodNonce);
/// <summary> /// Processes the payment. /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="option"> /// The option. /// </param> /// <param name="amount"> /// The amount. /// </param> /// <param name="token"> /// The token. /// </param> /// <param name="email"> /// The email. /// </param> /// <returns> /// The <see cref="IPaymentResult"/>. /// </returns> protected override IPaymentResult ProcessPayment(IInvoice invoice, TransactionOption option, decimal amount, string token, string email = "") { var payment = this.GatewayProviderService.CreatePayment(PaymentMethodType.CreditCard, amount, this.PaymentMethod.Key); payment.CustomerKey = invoice.CustomerKey; payment.Authorized = false; payment.Collected = false; payment.PaymentMethodName = this.BackOfficePaymentMethodName; payment.ExtendedData.SetValue(Constants.Braintree.ProcessorArguments.PaymentMethodNonce, token); var result = this.BraintreeApiService.Transaction.VaultSale(invoice, token, option); if (result.IsSuccess()) { payment.ExtendedData.SetBraintreeTransaction(result.Target); if (option == TransactionOption.Authorize) payment.Authorized = true; if (option == TransactionOption.SubmitForSettlement) { payment.Authorized = true; payment.Collected = true; } return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice, true); } var error = new BraintreeApiException(result.Errors, result.Message); return new PaymentResult(Attempt<IPayment>.Fail(payment, error), invoice, false); }
public TransactionAttribute(TransactionOption val) { this.val = val; this.isolation = TransactionIsolationLevel.Serializable; this.timeout = -1; }
/// <summary> /// Initializes a new instance of the <see cref="PublishMethodAttribute"/> class. /// </summary> /// <param name="enableSession">if set to <c>true</c> enable session.</param> /// <param name="transactionOption">The transaction option.</param> public PublishMethodAttribute(bool enableSession, TransactionOption transactionOption) : this(enableSession) { this.transactionOption = (int) transactionOption; }
/// <summary> /// Processes a payment against the Braintree API using the BraintreeApiService. /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="option"> /// The option. /// </param> /// <param name="amount"> /// The amount. /// </param> /// <param name="token"> /// The payment method nonce. /// </param> /// <param name="email">The email</param> /// <returns> /// The <see cref="IPaymentResult"/>. /// </returns> /// <remarks> /// This converts the <see cref="Result{Transaction}"/> into Merchello's <see cref="IPaymentResult"/> /// </remarks> protected abstract IPaymentResult ProcessPayment(IInvoice invoice, TransactionOption option, decimal amount, string token, string email = "");
/// <summary> /// Initializes a new instance of the <see cref="PublishMethodAttribute"/> class. /// </summary> /// <param name="enableSession">if set to <c>true</c> enable session.</param> /// <param name="transactionOption">The transaction option.</param> /// <param name="cacheDuration">The cache duration.</param> public PublishMethodAttribute(bool enableSession, TransactionOption transactionOption, int cacheDuration) : this(enableSession, transactionOption) { this.cacheDuration = cacheDuration; }
/// <summary> /// Creates a <see cref="TransactionRequest"/>. /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="paymentMethodNonce"> /// The payment Method Nonce. /// </param> /// <param name="customer"> /// The customer. /// </param> /// <param name="transactionOption"> /// The transaction Option. /// </param> /// <returns> /// The <see cref="TransactionRequest"/>. /// </returns> public TransactionRequest CreateTransactionRequest(IInvoice invoice, string paymentMethodNonce, ICustomer customer = null, TransactionOption transactionOption = TransactionOption.Authorize) { var request = new TransactionRequest() { Amount = invoice.Total, OrderId = invoice.PrefixedInvoiceNumber(), PaymentMethodNonce = paymentMethodNonce, BillingAddress = CreateAddressRequest(invoice.GetBillingAddress()), Channel = Constants.TransactionChannel }; if (customer != null) request.Customer = CreateCustomerRequest(customer); if (transactionOption == TransactionOption.SubmitForSettlement) { request.Options = new TransactionOptionsRequest() { SubmitForSettlement = true }; } return request; }
/// <summary> /// The create vault transaction request. /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="paymentMethodToken"> /// The payment method token. /// </param> /// <param name="transactionOption"> /// The transaction option. /// </param> /// <returns> /// The <see cref="TransactionRequest"/>. /// </returns> public TransactionRequest CreateVaultTransactionRequest(IInvoice invoice, string paymentMethodToken, TransactionOption transactionOption = TransactionOption.SubmitForSettlement) { var request = new TransactionRequest() { Amount = invoice.Total, OrderId = invoice.PrefixedInvoiceNumber(), PaymentMethodToken = paymentMethodToken, BillingAddress = CreateAddressRequest(invoice.GetBillingAddress()), Channel = Constants.TransactionChannel }; if (transactionOption == TransactionOption.SubmitForSettlement) { request.Options = new TransactionOptionsRequest() { SubmitForSettlement = true }; } return request; }
public TransactionAttribute(TransactionOption option = TransactionOption.Required, IsolationLevel il = IsolationLevel.ReadCommitted) { _option = option; _isolationLevel = il; }
public WebMethodAttribute (bool enableSession, TransactionOption transactionOption) : this (enableSession, transactionOption, 0, true) { }
/// <summary> /// Performs a Braintree sales transaction. /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="paymentMethodNonce"> /// The payment method nonce. /// </param> /// <param name="customer"> /// The customer. /// </param> /// <param name="option"> /// The option. /// </param> /// <returns> /// The <see cref="Result{Transaction}"/>. /// </returns> public Result<Transaction> Sale(IInvoice invoice, string paymentMethodNonce = "", ICustomer customer = null, TransactionOption option = TransactionOption.SubmitForSettlement) { return Sale(invoice, paymentMethodNonce, customer, null, option); }
public WebMethodAttribute (bool enableSession, TransactionOption transactionOption, int cacheDuration) : this (enableSession, transactionOption, cacheDuration, true) { }
public static void InvokeTransacted (TransactedCallback callback, TransactionOption mode) { bool abortedTransaction = false; InvokeTransacted (callback, mode, ref abortedTransaction); }
/// <summary> /// Initializes a new instance of the <see cref="PublishMethodAttribute"/> class. /// </summary> /// <param name="enableSession">if set to <c>true</c> enable session.</param> /// <param name="transactionOption">The transaction option.</param> /// <param name="cacheDuration">The cache duration.</param> /// <param name="bufferResponse">if set to <c>true</c> buffer response.</param> public PublishMethodAttribute(bool enableSession, TransactionOption transactionOption, int cacheDuration, bool bufferResponse) : this(enableSession, transactionOption, cacheDuration) { this.bufferResponse = bufferResponse; }