public override void UpdatedTransactions(SKPaymentQueue queue, SKPaymentTransaction[] transactions) { var rt = transactions.Where(pt => pt.TransactionState == SKPaymentTransactionState.Restored); // Add our restored transactions to the list // We might still get more from the initial request so we won't raise the event until // RestoreCompletedTransactionsFinished is called if (rt?.Any() ?? false) { restoredTransactions.AddRange(rt); } foreach (SKPaymentTransaction transaction in transactions) { switch (transaction.TransactionState) { case SKPaymentTransactionState.Purchased: TransactionCompleted?.Invoke(transaction, true); break; case SKPaymentTransactionState.Failed: TransactionCompleted?.Invoke(transaction, false); break; default: break; } } }
public static async void WithdrawMoneyAsync(decimal money, Shift shift) { using (CashboxModel db = new CashboxModel()) { try { db.DBConnectionCheck(); db.Shifts.Attach(shift); if (shift.CurrentCash >= money) { shift.CurrentCash -= money; shift.CashWithdrawn += money; await db.SaveChangesAsync(); TransactionCompleted?.Invoke(shift, new ShiftTransactionEventArgs("—редства успешно изъ¤ты!", true)); } else { TransactionCompleted?.Invoke(shift, new ShiftTransactionEventArgs("Ќевозможно изъ¤ть введенную сумму, так как в кассе находитс¤ меньше средств, чем требуетс¤", false)); } } catch (Exception e) { TransactionCompleted?.Invoke(shift, new ShiftTransactionEventArgs(e.Message + "\n—редства изъ¤ты не были!", false)); } } }
public async Task Handle(TransactionCompleted message, IMessageHandlerContext context) { var scoringId = await _scoringService.StartAsync(Data.ProjectId); await SendOffersAsync(context, scoringId); MarkAsComplete(); }
private async Task CompleteAsync(IMessageHandlerContext context) { await _ethereumTransactionService.CompleteAsync(Data.TransactionHash); var message = new TransactionCompleted { TransactionHash = Data.TransactionHash }; await context.Publish(message); MarkAsComplete(); }
public override void Commit() { try { base.Commit(); this.Logger.TryLogFail(() => TransactionCompleted.Fire(this, new TransactionEventArgs(this))); } catch (TransactionException e) { this.Logger.TryLogFail(() => TransactionFailed.Fire(this, new TransactionFailedEventArgs(this, e))); throw; } }
public override void UpdatedTransactions(SKPaymentQueue queue, SKPaymentTransaction[] transactions) { var rt = transactions.Where(pt => pt.TransactionState == SKPaymentTransactionState.Restored); // Add our restored transactions to the list // We might still get more from the initial request so we won't raise the event until // RestoreCompletedTransactionsFinished is called if (rt?.Any() ?? false) { restoredTransactions.AddRange(rt); } foreach (var transaction in transactions) { if (transaction?.TransactionState == null) { break; } Debug.WriteLine($"Updated Transaction | {transaction.ToStatusString()}"); switch (transaction.TransactionState) { case SKPaymentTransactionState.Restored: case SKPaymentTransactionState.Purchased: TransactionCompleted?.Invoke(transaction, true); if (TransactionCompleted != null) { onPurchaseSuccess?.Invoke(transaction.ToIABPurchase()); } SKPaymentQueue.DefaultQueue.FinishTransaction(transaction); break; case SKPaymentTransactionState.Failed: TransactionCompleted?.Invoke(transaction, false); SKPaymentQueue.DefaultQueue.FinishTransaction(transaction); break; default: break; } } }
public static async void AddMoneyAsync(decimal money, Shift shift) { using (CashboxModel db = new CashboxModel()) { try { db.DBConnectionCheck(); db.Shifts.Attach(shift); shift.CashAdded += money; shift.CurrentCash += money; await db.SaveChangesAsync(); TransactionCompleted?.Invoke(shift, new ShiftTransactionEventArgs("—редства успешно добавлены!", true)); } catch (Exception e) { TransactionCompleted?.Invoke(shift, new ShiftTransactionEventArgs(e.Message + "\n—редства добавлены не были!", false)); } } }
public void Complete() { if (IsAborted) { throw new Exception("This transaction is already aborted, probably due to a nested transaction not being completed."); } IsCompleted = true; if (Root == this) { // I'm the root: Connections.Do(x => x.Value.Item2.Commit()); TransactionCompleted?.Invoke(this, EventArgs.Empty); } else { // Ignore, and wait for the parent Completion. } }
public void Rollback() { Status = DeltaTransactionStatus.Aborted; TransactionCompleted?.Invoke(this, new DeltaTransactionEventArgs(this)); DoDispose(); }
public void Commit() { Status = DeltaTransactionStatus.Committed; TransactionCompleted?.Invoke(this, new DeltaTransactionEventArgs(this)); DoDispose(); }
public void CompleteTransaction(decimal sum) { TransactionCompleted?.Invoke(this, new TransactionEventArgs(sum)); }
public void Dispose() { TransactionCompleted?.Invoke(this, null); }
internal virtual void OnTransactionCompleted(TransactionEventArgs e) { TransactionCompleted?.Invoke(this, e); }
public async Task Handle(TransactionCompleted message, IMessageHandlerContext context) { await _allotmentEventService.UpdateAsync(Data.AllotmentEventId); MarkAsComplete(); }
/// <inheritdoc/> public void CompleteTransaction(Transaction transaction) { lock (lockObject) { try { if (transactionsInProgress.Count == 0) { throw new TransactionException("There is not transaction in progress in the transaction stack."); } if (transaction != transactionsInProgress.Pop()) { throw new TransactionException("The transaction being completed is not that last created transaction."); } // Check if we're completing the last transaction TransactionInProgress = transactionsInProgress.Count > 0; // Ignore the transaction if it is empty if (transaction.IsEmpty) { return; } // If this transaction has no effect, discard it. if (transaction.Operations.All(x => !x.HasEffect)) { return; } // If we're not the last transaction, consider this transaction as an operation of its parent transaction if (TransactionInProgress) { // Avoid useless nested transaction if we have a single operation inside. PushOperation(transaction.Operations.Count == 1 ? transaction.Operations.Single() : transaction); return; } // Remove transactions that will be overwritten by this one if (currentPosition < transactions.Count) { PurgeFromIndex(currentPosition); } if (currentPosition == Capacity) { // If the stack has a capacity of 0, immediately freeze the new transaction. var oldestTransaction = Capacity > 0 ? transactions[0] : transaction; oldestTransaction.Interface.Freeze(); for (var i = 1; i < transactions.Count; ++i) { transactions[i - 1] = transactions[i]; } if (Capacity > 0) { transactions[--currentPosition] = null; } TransactionDiscarded?.Invoke(this, new TransactionsDiscardedEventArgs(oldestTransaction, DiscardReason.StackFull)); } if (Capacity > 0) { if (currentPosition == transactions.Count) { transactions.Add(transaction); } else { transactions[currentPosition] = transaction; } ++currentPosition; } } finally { if (!TransactionInProgress) { TransactionCompleted?.Invoke(this, new TransactionEventArgs(transaction)); } } } }
private void CompletedHandler(object sender, TransactionEventArgs e) { TransactionCompleted.Fire(this, e); }
public async Task Handle(TransactionCompleted message, IMessageHandlerContext context) { await _expertService.UpdateExpertAreasAsync(Data.ExpertId); MarkAsComplete(); }