internal static SoaRowsRepo1 CreateInMemoryShard(this MonthShardPassbookDB monthDb)
        {
            var moRepo = monthDb.GetSoaRepo();
            var pbkDB  = new PassbookDB(monthDb.BankAccountId, new MemoryStream(), monthDb.CurrentUser);

            return(new SoaRowsRepo1(moRepo.BaseBalance, moRepo.BaseDate, pbkDB));
        }
        internal static string GetShardsDir(this MonthShardPassbookDB monthDb)
        {
            var dir = Path.Combine(Path.GetDirectoryName(monthDb.DbPath), SHARDS_DIR);

            Directory.CreateDirectory(dir);
            return(dir);
        }
        internal static SoaRowsRepo1 CreateFileBasedShard(this MonthShardPassbookDB monthDb, DateTime day1)
        {
            var moRepo = monthDb.GetSoaRepo();
            var dbPath = Path.Combine(monthDb.GetShardsDir(), GetFilename(day1));
            var pbkDB  = new PassbookDB(monthDb.BankAccountId, dbPath, monthDb.CurrentUser);

            return(new SoaRowsRepo1(moRepo.BaseBalance, moRepo.BaseDate, pbkDB));
        }
        internal static Dictionary <DateTime, SoaRowsRepo1> CreateMemoryBasedIndex(this MonthShardPassbookDB monthDb, int dictLength = 10)
        {
            var dict     = new Dictionary <DateTime, SoaRowsRepo1>();
            var monthNow = DateTime.Now.MonthFirstDay();

            for (int i = 0; i < dictLength; i++)
            {
                var repo = monthDb.CreateInMemoryShard();
                dict.Add(monthNow.AddMonths(i * -1), repo);
            }
            return(dict);
        }
 private static IEnumerable <string> GetMatchingFiles(MonthShardPassbookDB monthDb)
 => Directory.EnumerateFiles(monthDb.GetShardsDir(), "*" + DB_SUFFIX);
        private static (DateTime FirstDay, SoaRowsRepo1 Repo) CreateMonthlyRepo(string filePath, MonthShardPassbookDB monthDb)
        {
            var day1 = ToFirstDay(filePath);
            var repo = monthDb.CreateFileBasedShard(day1);

            return(day1, repo);
        }
 internal static Dictionary <DateTime, SoaRowsRepo1> CreateFileBasedIndex(this MonthShardPassbookDB monthDb)
 => GetMatchingFiles(monthDb)
 .Select(_ => CreateMonthlyRepo(_, monthDb))
 .ToDictionary(_ => _.FirstDay,
               _ => _.Repo);
 public MonthShardSoaRepo(decimal baseBalance, DateTime baseDate, MonthShardPassbookDB db) : base(baseBalance, baseDate, db)
 {
     _moDB = db;
 }