/// <summary> /// Method to get all locations /// </summary> /// <returns> /// A list of Locations /// </returns> public async Task <List <Location> > getAllLocationsByRange(int index, int offset) { try { List <Location> lLocations = new List <Location>(); string dataSource = ConfigurationManager.AppSettings["dataSource"]; switch (dataSource) { case "CSV": string fileName = ConfigurationManager.AppSettings["fileLocations"]; using (ExcelDL edl = new ExcelDL()) { lLocations = await edl.geLocationsByRange(fileName, index, offset); } break; default: break; } return(lLocations); } catch (Exception ex) { throw ex; } }
/// <summary> /// Method to get all locations /// </summary> /// <returns> /// A list of Locations /// </returns> private List <Location> getAllLocationsNonCacheStreamParallel() { try { List <Location> lLocations = new List <Location>(); string dataSource = ConfigurationManager.AppSettings["dataSource"]; switch (dataSource) { case "CSV": string fileName = ConfigurationManager.AppSettings["fileLocations"]; using (ExcelDL edl = new ExcelDL()) { lLocations = edl.getAllLocationsStreamParallel(fileName); } break; default: break; } return(lLocations); } catch (Exception ex) { throw ex; } }
public void getAllLocationsStreamTest() { ExcelDL target = new ExcelDL(); // TODO: Initialize to an appropriate value string filename = @"E:\Fran\Projects\GeoLocalizationService\GeoLocalizationDL\Data\locationsBig.csv"; int nRows = 1013352; List<Location> actual; actual = target.getAllLocationsStream(filename); Assert.AreEqual(nRows, actual.Count); }
/// <summary> /// Method to get all locations using the Memory Cache and reading the source of data using Stream Object and ParallelFor. /// </summary> /// <returns> /// A list of Locations /// </returns> /// <remarks> /// After testing this is the best option /// </remarks> private List <Location> getAllLocationsCacheStreamParallel() { try { List <Location> lLocations = new List <Location>(); //Check if the list of Locations is already in Cache if (MemCache == null) { MemCache = new MemoryCache("MemCache"); } //If not makes the search 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.getAllLocationsStreamParallel(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; } }
/// <summary> /// Method to get all locations using the Memory Cache and reading the source of data using Stream Object and ParallelFor. /// </summary> /// <returns> /// A list of Locations /// </returns> /// <remarks> /// After testing this is the best option /// </remarks> private List<Location> getAllLocationsCacheStreamParallel() { try { List<Location> lLocations = new List<Location>(); //Check if the list of Locations is already in Cache if (MemCache == null) MemCache = new MemoryCache("MemCache"); //If not makes the search 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.getAllLocationsStreamParallel(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> public async Task<List<Location>> getAllLocationsByRange(int index, int offset) { try { List<Location> lLocations = new List<Location>(); string dataSource = ConfigurationManager.AppSettings["dataSource"]; switch (dataSource) { case "CSV": string fileName = ConfigurationManager.AppSettings["fileLocations"]; using (ExcelDL edl = new ExcelDL()) { lLocations = await edl.geLocationsByRange(fileName, index, offset); } break; default: break; } return lLocations; } catch (Exception ex) { throw ex; } }
/// <summary> /// Method to get all locations /// </summary> /// <returns> /// A list of Locations /// </returns> private List<Location> getAllLocationsNonCacheStreamParallel() { try { List<Location> lLocations = new List<Location>(); string dataSource = ConfigurationManager.AppSettings["dataSource"]; switch (dataSource) { case "CSV": string fileName = ConfigurationManager.AppSettings["fileLocations"]; using (ExcelDL edl = new ExcelDL()) { lLocations = edl.getAllLocationsStreamParallel(fileName); } break; default: break; } 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; } }