/// <summary>
        /// Retrieve a list of crashes from the cache, or retrieve a list from the database, and add to the cache.
        /// </summary>
        /// <param name="DateFrom">The date of the earliest crash to consider.</param>
        /// <param name="DateTo">The date of the most recent crash to consider.</param>
        /// <returns>A list of crashes between the start and end dates.</returns>
        public List <Crash> GetCrashes(DateTime DateFrom, DateTime DateTo)
        {
            string       Key  = CacheKeyPrefix + DateFrom + DateTo;
            List <Crash> Data = (List <Crash>)CacheInstance[Key];

            if (Data == null)
            {
                IQueryable <Crash> DataQuery = LocalCrashRepository.ListAll();
                DataQuery = LocalCrashRepository.FilterByDate(DataQuery, DateFrom, DateTo);
                Data      = DataQuery.ToList();
                CacheInstance.Insert(Key, Data);
            }

            return(Data);
        }
예제 #2
0
        /// <summary>
        /// Retrieve a list of crashes from the cache, or retrieve a list from the database, and add to the cache.
        /// </summary>
        /// <param name="DateFrom">The date of the earliest crash to consider.</param>
        /// <param name="DateTo">The date of the most recent crash to consider.</param>
        /// <returns>A list of crashes between the start and end dates.</returns>
        public List <Crash> GetCrashes(DateTime DateFrom, DateTime DateTo)
        {
            using (FAutoScopedLogTimer LogTimer = new FAutoScopedLogTimer(this.GetType().ToString()))
            {
                string       Key  = CacheKeyPrefix + DateFrom + DateTo;
                List <Crash> Data = (List <Crash>)CacheInstance[Key];
                if (Data == null)
                {
                    IQueryable <Crash> DataQuery = LocalCrashRepository.ListAll();
                    DataQuery = LocalCrashRepository.FilterByDate(DataQuery, DateFrom, DateTo);
                    Data      = DataQuery.ToList();
                    CacheInstance.Insert(Key, Data);
                }

                return(Data);
            }
        }