public TransferStateMachine( ILogger <TransferState> logger, IMapper mapper, IBankAccountClient accountClient) { _accountClient = accountClient; InstanceState(x => x.CurrentState); ConfigureCorrelationIds(); Initially( When(ExecuteTransferEvent) .Then(x => logger.LogInformation($"Банковский перевод со счета {x.Instance.SourceAccountId} на счет {x.Instance.TargetAccountId}.")) .Then(InitStateMachine) .TransitionTo(ReadyToStart) .Publish(x => mapper.Map <StartProcessing>(x.Instance))); During(ReadyToStart, When(ProcessStartedEvent) .TransitionTo(PendingWithdrawalFinalization) .ThenAsync(ProcessOutFlowOperation)); During(PendingWithdrawalFinalization, When(OperationFaultedEvent) .Then(x => logger.LogInformation($"Отмена списания денежных средств со счета {x.Instance.SourceAccountId}.")) .ThenAsync(RollbackWithdrawal), When(WithdrawalCompletedEvent) .Then(x => logger.LogInformation($"Выполнено успешное списание денежных средств в размере {x.Instance.Sum} со счета {x.Instance.SourceAccountId}.")) .TransitionTo(PendingDepositeFinalization) .ThenAsync(ProcessInFlowOperation)); During(PendingDepositeFinalization, When(DepositeCompletedEvent) .Then(x => logger.LogInformation($"Выполнено успешное зачисление денежных средств в размере {x.Instance.Sum} на счет {x.Instance.TargetAccountId}.")) .Then(x => x.Instance.Comment = "Transaction completed successfully.") .TransitionTo(Completed) .Finalize()); DuringAny( When(OperationFaultedEvent) .Then(x => logger.LogInformation($"Перевод денежных средств со счета {x.Instance.SourceAccountId} на счет {x.Instance.TargetAccountId} закончился неудачей! Причина: [{DateTime.Now}] {x.Data.Reason}.")) .ThenAsync(NotifyMonitoringService) .Then(x => x.Instance.Comment = x.Data.Reason) .TransitionTo(Faulted)); }
public async Task <IActionResult> OnGetDownloadMt940BankStatement([FromServices] IBankAccountClient client, [FromServices] IConfiguration configuration, int statementId, double dateFrom) { try { if ((await client.Login()).Status != "CREDENTIALS_CORRECT") { throw new Exception("Błąd logowania do systemu bankowego"); } var bankStatement = await client.DownloadBankStatement("pdf", "download", "pl", statementId, false, "MT940"); var bankStatementDateFrom = Utils.Utils.UnixTimeStampToLocalDateTime(dateFrom); await client.Logout(); return(File(bankStatement.FileContents, bankStatement.ContentType, "wyciag_" + bankStatementDateFrom.ToString("yyyyMMdd") + "_" + DateTime.Now.ToString("HHmmss") + ".txt")); } catch (Exception ex) { ExceptionMessage = ex.Message; return(Page()); } }
public async Task <IActionResult> OnGet([FromServices] IBankAccountClient client, [FromServices] IConfiguration configuration, int numberOfDays = 14) { try { if ((await client.Login()).Status != "CREDENTIALS_CORRECT") { throw new Exception("Błąd logowania do systemu bankowego"); } var bankAccountsList = await client.GetBankAccountsList(configuration["BankApi:Username"]); BankStatementsList = await client.GetBankStatementsList(bankAccountsList.Content.First(s => s.IsVatAccount == false).AccountId, DateTime.Now.AddDays(numberOfDays * -1), DateTime.Now, false); await client.Logout(); return(Page()); } catch (Exception ex) { ExceptionMessage = ex.Message; return(Page()); } }
public BaseActivity(IBankAccountClient accountClient) { _accountClient = accountClient; }
public BalancedService(string key, IBalancedRest rest) { this.accountClient = new AccountClient(this, rest); this.bankClient = new BankAccountClient(this, rest); this.cardClient = new CardClient(this, rest); this.holdClient = new HoldClient(this, rest); this.creditClient = new CreditClient(this, rest); this.debitClient = new DebitClient(this, rest); this.refundClient = new RefundClient(this, rest); this.eventClient = new EventClient(this, rest); this.verificationClient = new VerificationClient(this, rest); this.marketplaceClient = new MarketplaceClient(this, rest); this.key = key; }
public ProcessOutflowActivity(IBankAccountClient accountClient) : base(accountClient) { }