///<summary>Returns a deep copy of fee cache including _queueFeeUdpates and the current transaction status. If the current cache contains no fees ///we fill with the HQ and current clinic fees before making the copy.</summary> public IFeeCache GetCopy() { FeeCache retVal = new FeeCache(doInitialize: false); if (_dict.Count == 0) { Initialize(); //There is nothing in the cache, at least initialize to include the default/clinic 0 fees. } //If a fee has been invalidated, we will want to retrieve it from the db before we copy the cache List <long> listFeeSchedsToRefresh = _dict.Where(x => x.Value == null).Select(x => x.Key.FeeSchedNum).Distinct().ToList(); foreach (long feeSched in listFeeSchedsToRefresh) { RefreshInvalidFees(feeSched); } retVal._dict = new FeeCacheDictionary(_dict); retVal._queueClinicNums = this._queueClinicNums.Copy(); retVal._queueFeeUpdates = new ConcurrentQueue <FeeUpdate>(this._queueFeeUpdates.Select(x => x.Copy())); retVal._hasTransStarted = this._hasTransStarted; return(retVal); }
///<summary>Initializes the Cache, with fees for the HQ Clinic, and for the current user's selected clinic.</summary> public static void FillCache() { //No need to check RemotingRole; no call to db. IFeeCache cache; if (RemotingClient.RemotingRole == RemotingRole.ServerWeb) { if (PrefC.GetBool(PrefName.MiddleTierCacheFees)) { cache = new FeeCache(numClinics: Int32.MaxValue, doInitialize: true); //No limit to the number of clinics stored } else { cache = new FeeNoCache(); } } else { cache = new FeeCache(); } _Cache = cache; }