public RegionAndCityProcessor(string connection) { _connectionStr = connection; Regions = new List <Region>(); Cityes = new List <City>(); _parent = new List <Parent>(); _trans = new RuEngParser(Schema.A); FillRegion(); FillCity(); }
public async Task <List <GoogleDriveFolder> > SeedCacheAsync(bool force = false) { var categories = MemoryCache.Default.Get("categories") as List <GoogleDriveFolder>; if (force || categories == null) { logger.Info("seeding cache"); var dataSvc = new PhotoDataSvcWrapper(); categories = await Task.Run(async() => await dataSvc.GetCategoriesAsync()); var translitParser = new RuEngParser(); var separators = new[] { ' ', ',', '_', '.' }; Func <string, string> aliasFactory = (e) => { return(string.Join("-", e.Split(separators, StringSplitOptions.RemoveEmptyEntries) .Select(ee => translitParser.Transliterate(ee) .Replace("`", "")))); }; categories.ForEach(e => { e.Alias = aliasFactory(e.Name); }); foreach (var category in categories) { var byCategory = await Task.Run(async() => await dataSvc.GetByCategoryAsync(category.Id)); byCategory.ForEach(e => { e.Alias = aliasFactory(e.Name); e.ParentAlias = category.Alias; }); category.Children = byCategory; } MemoryCache.Default.Remove("categories"); MemoryCache.Default.Set("categories", categories, new CacheItemPolicy()); } return(categories); }