public static void LoadTypes() { VoucherIssuedEvent v = new VoucherIssuedEvent(Guid.NewGuid(), Guid.NewGuid(), DateTime.Now, "", ""); TransactionHasStartedEvent t = new TransactionHasStartedEvent(Guid.Parse("2AA2D43B-5E24-4327-8029-1135B20F35CE"), Guid.NewGuid(), Guid.NewGuid(), DateTime.Now, "", "", "", "", null); ReconciliationHasStartedEvent r = new ReconciliationHasStartedEvent(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), DateTime.Now); EstateCreatedEvent e = new EstateCreatedEvent(Guid.NewGuid(), ""); MerchantCreatedEvent m = new MerchantCreatedEvent(Guid.NewGuid(), Guid.NewGuid(), "", DateTime.Now); ContractCreatedEvent c = new ContractCreatedEvent(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), ""); MerchantBalanceChangedEvent mb = new MerchantBalanceChangedEvent(Guid.NewGuid(), Guid.NewGuid(), DateTime.Now, Guid.NewGuid(), Guid.NewGuid(), 0, 0, 0, ""); ImportLogCreatedEvent i = new ImportLogCreatedEvent(Guid.NewGuid(), Guid.NewGuid(), DateTime.MinValue); FileCreatedEvent f = new FileCreatedEvent(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), String.Empty, DateTime.MinValue); SettlementCreatedForDateEvent s = new SettlementCreatedForDateEvent(Guid.NewGuid(), Guid.NewGuid(), DateTime.Now); StatementCreatedEvent ms = new StatementCreatedEvent(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), DateTime.Now); TypeProvider.LoadDomainEventsTypeDynamically(); }
public void Run() { var result = _database.ListCollections(); var collections = result.ToList(); var names = collections.Select(x => x["name"]?.AsString) .Where(x => x.Contains("Account-", StringComparison.OrdinalIgnoreCase)).ToList(); var accountBalances = new Dictionary <string, long>(); #if DEBUG var todaysDate = DateTime.UtcNow.AddMonths(1); #else var todaysDate = DateTime.UtcNow; #endif var firstDayOfMonth = new DateTime(todaysDate.Year, todaysDate.AddMonths(-1).Month, 1, 23, 59, 59); var lastDayOfMonth = firstDayOfMonth.AddMonths(1).AddDays(-1); foreach (var name in names) { var transaction = _database.GetCollection <TransactionReadModel>(name).AsQueryable() .Where(x => x.MetaData.EventCreated <= lastDayOfMonth) .OrderByDescending(x => x.MetaData.EventCreated) .FirstOrDefault(); accountBalances.Add( name.TrimEnd('t', 'r', 'a', 'n', 's', 'a', 'c', 't', 'i', 'o', 'n', 's').TrimEnd('-'), transaction?.AccountBalance == null || transaction.AccountBalance > -1 ? 0 : transaction.AccountBalance); } foreach (var account in accountBalances) { var statementCreatedEvent = new StatementCreatedEvent(account.Value, lastDayOfMonth); _conn.AppendToStreamAsync(account.Key, ExpectedVersion.Any, statementCreatedEvent.EventData).Wait(); } }
private async Task HandleSpecificDomainEvent(StatementCreatedEvent domainEvent, CancellationToken cancellationToken) { await this.EstateReportingRepository.CreateStatement(domainEvent, cancellationToken); }