private async Task ProcessPostImportAsync()
        {
            int updates;

            DictPostImport();

            using (BankingDbContext db = new BankingDbContext(Options.DbConnection))
            {
                foreach (var item in PostImport)
                {
                    try
                    {
                        updates = await db.Database.ExecuteSqlCommandAsync(item.Value);

                        Log(item.Key, updates);
                    }
                    catch (Exception ex)
                    {
                        Log($"Error in SQL '{item.Key}' with [{ex}]");
                    }
                }
            }

            PostImport.Clear();
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ParameterizationsRepository"/> class.
 /// </summary>
 /// <param name="bankingDbContext">
 /// The banking database context.
 /// </param>
 /// <param name="humanRepository">
 /// The human Repository.
 /// </param>
 /// <param name="accountRepository">
 /// The account Repository.
 /// </param>
 /// <param name="cacheProvider">
 /// The cache Provider.
 /// </param>
 public ParameterizationsRepository(BankingDbContext bankingDbContext, IHumanRepository humanRepository, IAccountRepository accountRepository, Domain.ICacheProvider cacheProvider)
 {
     this.context           = bankingDbContext;
     this.humanRepository   = humanRepository;
     this.cacheProvider     = cacheProvider;
     this.accountRepository = accountRepository;
 }
        public ImportINGViewModel(string fileName, OptionViewModel options)
        {
            if (ImportFile(fileName))
            {
                try
                {
                    using (BankingDbContext db = new BankingDbContext(options.DbConnection))
                    {
                        foreach (Import record in Cache)
                        {
                            db.Imports.Add(record);
                            db.SaveChanges();
                        }
                    }

                    Log.Write($"{Cache.Count} records are imported from ING file");
                    MessageBox.Show($"{Cache.Count} records are imported.",
                                    "Import ING",
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Information);
                }
                catch
                {
                    Log.Write("Failed importing ING file");
                    throw new ImportException("Import ING file has failed");
                }
            }
        }
        private async Task ProcessImportToBankAsync()
        {
            int updates;

            Log($"Start ProcessImportToBank() with {CheckMissedTallies()} missed tallies");

            DictImportToBank();

            using (BankingDbContext db = new BankingDbContext(Options.DbConnection))
            {
                foreach (var item in ImportToBank)
                {
                    try
                    {
                        updates = await db.Database.ExecuteSqlCommandAsync(item.Value);

                        Log(item.Key, updates);
                    }
                    catch (Exception ex)
                    {
                        Log($"Error in SQL '{item.Key}' with [{ex}]");
                    }
                }
            }

            ImportToBank.Clear();

            await MainVM.GetAccountSummaryAsync();

            MissedTalliesCount = CheckMissedTallies();
            Log($"After ProcessImportToBank() has {MissedTalliesCount} missed tallies");
        }
        private void ProcessImportABNModelView(string fileName, OptionViewModel options)
        {
            if (ImportFile(fileName))
            {
                try
                {
                    using (BankingDbContext db = new BankingDbContext(options.DbConnection))
                    {
                        foreach (Import record in Cache)
                        {
                            db.Imports.Add(record);
                            db.SaveChanges();
                        }
                    }

                    Log.Write($"{Cache.Count} records are imported from ABN file");
                    MessageBox.Show($"{Cache.Count} records are imported.",
                                    "Import ABN",
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Information);
                }
                catch (Exception ex)
                {
                    Log.Write($"Import ABN file has failed after record {Cache.Count}", ex.Message, ex.InnerException.ToString());
                    throw new ImportException("Import ABN file has failed");
                }
            }
        }
示例#6
0
 public IntegrationEventLogService(
     BankingDbContext bankingDbContext
     , IServiceBusEndpoint endpoint
     )
 {
     _bankingDbContext = bankingDbContext;
     _endpoint         = endpoint;
 }
        public EFPersistenceContext(BankingDbContext context)
        {
            this.dbContext = context;

            CustomerRepository = new EFCustomerRepository(context);
            CardRepository     = new EFCardRepository(context);
            //CardTransactionRepository = new EFCardTransactionRepository(context);
        }
示例#8
0
        private async void OpenImportTable()
        {
            using BankingDbContext db = new BankingDbContext(Options.DbConnection);
            var Imports = await(from a in db.Imports
                                orderby a.Date descending
                                select a).ToListAsync();

            View.ImportDataGrid.ItemsSource = Imports;
        }
示例#9
0
        private void OpenCards()
        {
            using BankingDbContext db = new BankingDbContext(Options.DbConnection);
            var cards = (from a in db.OVCards
                         orderby a.Id descending
                         select a).ToList();

            Cards = new List <OVCard>(cards);
        }
示例#10
0
        public static BankingDbContext GetDatabaseContext()
        {
            var options = new DbContextOptionsBuilder <BankingDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                          .Options;
            var context = new BankingDbContext(options);

            Initialize(context);
            return(context);
        }
示例#11
0
 private static bool CheckAccountNumber(string accountNumber, BankingDbContext context)
 {
     foreach (var num in context.Accounts)
     {
         if (accountNumber == num.Number)
         {
             return(true);
         }
     }
     return(false);
 }
示例#12
0
        private static string CreateNewAccountNumber(BankingDbContext context)
        {
            var    r = new Random();
            string accountNumber;

            while (CheckAccountNumber(accountNumber = ((long)(r.NextDouble() * 100000000000000)).ToString(), context))
            {
                ;
            }
            return(accountNumber);
        }
        public TransactionBehaviour(BankingDbContext dbContext,
                                    IIntegrationEventLogService integrationEventLogService,
                                    ILogger <TransactionBehaviour <TRequest, TResponse> > logger
                                    , IServiceBusEndpoint endpoint
                                    )
        {
            _dbContext = dbContext ?? throw new ArgumentException(nameof(BankingDbContext));
            //_orderingIntegrationEventService = orderingIntegrationEventService ?? throw new ArgumentException(nameof(orderingIntegrationEventService));
            _integrationEventLogService = integrationEventLogService;
            _logger = logger ?? throw new ArgumentException(nameof(ILogger));

            _endpoint = endpoint;
        }
示例#14
0
        public async void OpenBankTable(string TallyName = null, string Month = null)
        {
            Db = new BankingDbContext(Options.DbConnection);
            {
                List <Bank> accounts = await(from a in Db.Accounts
                                             orderby a.Date descending
                                             select a).ToListAsync();
                Accounts = new ObservableCollection <Bank>(accounts);

                Tallies = Accounts
                          .Select(x => x.TallyName)
                          .Distinct()
                          .OrderBy(x => x)
                          .ToList();

                if (HasMissedTallies)
                {
                    List <Bank> filteredAccounts = Accounts
                                                   .Where(x => x.TallyName is null)
                                                   .ToList();

                    FilteredAccounts = new ObservableCollection <Bank>(filteredAccounts);
                    View.BankingDataGrid.ItemsSource = FilteredAccounts;
                    View.Title = "Gemiste markeringen";
                }
                else if (!(string.IsNullOrWhiteSpace(TallyName) && string.IsNullOrWhiteSpace(Month)))
                {
                    List <Bank> filteredAccounts = Accounts
                                                   .Where(x => x.TallyName == TallyName && x.Month == Month)
                                                   .ToList();

                    FilteredAccounts = new ObservableCollection <Bank>(filteredAccounts);
                    View.BankingDataGrid.ItemsSource = FilteredAccounts;
                }
                else if (!string.IsNullOrWhiteSpace(AccountFilter))
                {
                    List <Bank> filteredAccounts = Accounts
                                                   .Where(x => x.RawText.ToLower().Contains(AccountFilter.ToLower()) ||
                                                          x.Name.ToLower().Contains(AccountFilter.ToLower()))
                                                   .ToList();

                    FilteredAccounts = new ObservableCollection <Bank>(filteredAccounts);
                    View.BankingDataGrid.ItemsSource = FilteredAccounts;
                }
                else
                {
                    View.BankingDataGrid.ItemsSource = Accounts;
                }
            }
        }
示例#15
0
        public void ClearImportTable()
        {
            using BankingDbContext db = new BankingDbContext(Options.DbConnection);
            MessageBoxResult result = MessageBox.Show("Are you sure to clear the import table?", "Clear import table", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result != MessageBoxResult.Yes)
            {
                return;
            }

            db.Database.ExecuteSqlCommand("TRUNCATE TABLE Import");
            Thread.Sleep(1000);

            GetSummaries();
        }
        private async Task ProcessMissedTallies()
        {
            int updates;
            int totalUpdates = 0;

            Log($"Start ProcessMissedTallies() with {CheckMissedTallies()} missed tallies");

            if (MainVM.TalliesRules.Count == 0)
            {
                MainVM.ReadTalliesRules();
            }

            using (BankingDbContext db = new BankingDbContext(Options.DbConnection))
            {
                foreach (var item in MainVM.TalliesRules)
                {
                    try
                    {
                        updates = await db.Database.ExecuteSqlCommandAsync(item.Value);

                        totalUpdates += updates;

                        if (updates > 0)
                        {
                            Log(item.Key, updates);
                        }
                    }
                    catch (Exception ex)
                    {
                        Log($"Error in SQL '{item.Key}' with [{ex}]");
                    }
                }
            }

            Log($"Total {totalUpdates} updates");
            //MainVM.TalliesRules.Clear();

            await MainVM.GetAccountSummaryAsync();

            MissedTalliesCount = CheckMissedTallies();
            Log($"After ProcessImportToBank() has {MissedTalliesCount} missed tallies");
        }
示例#17
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, BankingDbContext dbContext)
        {
            dbContext.Database.Migrate();
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            // app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseSwagger();
            app.UseSwaggerUI(o => { o.SwaggerEndpoint("/swagger/v1/swagger.json", "Banking Microservice V1"); });


            app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
        }
示例#18
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(
            IApplicationBuilder app,
            IHostingEnvironment env,
            AppContext appContext,
            BankingDbContext bankingDbContext,
            MarketingDbContext marketingDbContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseMvc();

            appContext.Seed().Wait();

            // Normally I shouldn't need these extra Seed methods
            // But somehow UseInMemoryDatabase won't let me share data across contexts
            bankingDbContext.Seed().Wait();
            marketingDbContext.Seed().Wait();
        }
 public AccountRepository(BankingDbContext ctx)
 {
     _ctx = ctx ?? throw new ArgumentNullException(nameof(ctx));
 }
 public AccountController(BankingDbContext context, AccountValidator validator)
     : base(context, validator)
 {
 }
示例#21
0
 public AccountDAL(BankingDbContext ctx)
 {
     _ctx = ctx;
 }
示例#22
0
 public AccountRepository(BankingDbContext dbContext) : base(dbContext)
 {
     myOwnDbContext = dbContext;
 }
示例#23
0
 public AccountRepository(BankingDbContext dbContext)
 {
     _dbContext = dbContext;
 }
示例#24
0
 public AccountRepository(BankingDbContext context)
 {
     _context = context;
 }
示例#25
0
 public RoundUpRepository(BankingDbContext dbContext, IUow <RoundUp> uow)
 {
     _dbContext = dbContext;
     Uow        = uow;
 }
 public IntegrationEventLogRepository(BankingDbContext dbContext) : base(dbContext)
 {
 }
示例#27
0
 public AccountRepository(BankingDbContext bankingDbContext)
 {
     _bankingDbContext = bankingDbContext;
 }
 public TransactionHistoriesRepository(BankingDbContext dbContext) : base(dbContext)
 {
 }
示例#29
0
 public AccountRepository(BankingDbContext ctx)
 {
     _ctx = ctx;
 }
示例#30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CurrencyRepository"/> class.
 /// </summary>
 /// <param name="bankingDbContext">
 /// The banking database context.
 /// </param>
 public CurrencyRepository(BankingDbContext bankingDbContext)
 {
     this.context = bankingDbContext;
 }