public AccountCacheModel GetAccountCacheModel() { var accountCacheModel = new AccountCacheModel { Accounts = new List <ValueObjects.Accounts.AccountMasterVO>(), TaxRates = new List <ValueObjects.Accounts.TaxRateVO>() }; var accountCacheController = AccountCacheController.Instance(cachingRepository, lazyLoaderController); accountCacheModel.TaxRates = accountCacheController.GetTaxRateVOs(); accountCacheModel.Accounts = accountCacheController.GetAccountsVOs(); return(accountCacheModel); }
private List <Account> GetAccountsWithAcctBookId() { AccountCacheModel accounts = _cache.GetAccountCache(_cache.GetUserCache().AccountBookID); if (accounts == null) { AccountBook accountBook = _acctBook.GetCurrentBook(); if (accountBook == null) { throw new Exception("未找到账套"); } accounts = new AccountCacheModel(); accounts.AccountBookID = accountBook.AbId; accounts.Accounts = accountBook.Accounts.ToList(); _cache.SetAccountCache(accounts); } return(accounts.Accounts); }
public AccountCacheModel SetAccountCache(AccountCacheModel acctCache) { if (acctCache == null) { return(null); } string key = this.AccountCacheKey(acctCache.AccountBookID); AccountCacheModel acct = (AccountCacheModel)_context.Cache.Get(key); if (acct == null) { _context.Cache.Add(key, acctCache, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(Constants.AccountCacheExpiration), CacheItemPriority.Default, null); } else { _context.Cache[key] = acctCache; } return(acctCache); }