public void getAllLocationsFileReaderLinq()
 {
     ExcelDL target = new ExcelDL(); // TODO: Initialize to an appropriate value
     string filename = @"E:\Fran\Projects\GeoLocalizationService\GeoLocalizationDL\Data\locationsBig.csv"; // TODO: Initialize to an appropriate value
     int nRows = 1013351;
     List<Location> actual;
     actual = target.getAllLocationsFileReaderLinq(filename);
     Assert.AreEqual(nRows, actual.Count);
 }
Example #2
0
        /// <summary>
        /// Method to get all locations
        /// </summary>
        /// <returns>
        ///     A list of Locations
        /// </returns>
        private List <Location> getAllLocationsCacheFileReader()
        {
            try
            {
                if (MemCache == null)
                {
                    MemCache = new MemoryCache("MemCache");
                }
                List <Location> lLocations = new List <Location>();
                if (!MemCache.Contains("ListOfLocations"))
                {
                    string dataSource = ConfigurationManager.AppSettings["dataSource"];
                    switch (dataSource)
                    {
                    case "CSV":
                        string fileName = ConfigurationManager.AppSettings["fileLocations"];

                        using (ExcelDL edl = new ExcelDL())
                        {
                            lLocations = edl.getAllLocationsFileReaderLinq(fileName);
                        }

                        break;

                    default:
                        break;
                    }

                    //Add to the cache
                    CacheItemPolicy policy = getacheItemPolicy();
                    MemCache.Set("ListOfLocations", lLocations, policy);
                }
                else
                {
                    lLocations = (List <Location>)MemCache["ListOfLocations"];
                }

                return(lLocations);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// Method to get all locations 
        /// </summary>
        /// <returns>
        ///     A list of Locations
        /// </returns>
        private List<Location> getAllLocationsCacheFileReader()
        {
            try
            {
                if (MemCache == null) MemCache = new MemoryCache("MemCache");
                List<Location> lLocations = new List<Location>();
                if (!MemCache.Contains("ListOfLocations"))
                {
                    string dataSource = ConfigurationManager.AppSettings["dataSource"];
                    switch (dataSource)
                    {
                        case "CSV":
                            string fileName = ConfigurationManager.AppSettings["fileLocations"];

                            using (ExcelDL edl = new ExcelDL())
                            {
                                lLocations = edl.getAllLocationsFileReaderLinq(fileName);
                            }                           
                            
                            break;
                        default:
                            break;
                    }

                    //Add to the cache
                    CacheItemPolicy policy = getacheItemPolicy();
                    MemCache.Set("ListOfLocations", lLocations, policy);
                }
                else lLocations = (List<Location>)MemCache["ListOfLocations"];

                return lLocations;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }