public virtual async Task <Overture.ServiceModel.Customers.Stores.Store> GetStoreByNumberAsync(GetStoreParam param) { if (string.IsNullOrWhiteSpace(param.Scope)) { throw new ArgumentException("scope"); } if (string.IsNullOrWhiteSpace(param.StoreNumber)) { throw new ArgumentException("storeNumber"); } var cacheKey = new CacheKey(CacheConfigurationCategoryNames.Store) { Scope = param.Scope }; cacheKey.AppendKeyParts(GETSTOREBYNUMBER_CACHE_KEYPART, param.StoreNumber); var request = new GetStoreByNumberRequest() { ScopeId = param.Scope, Number = param.StoreNumber, IncludeAddresses = param.IncludeAddresses, IncludeSchedules = param.IncludeSchedules }; return(await CacheProvider.GetOrAddAsync(cacheKey, () => OvertureClient.SendAsync(request)).ConfigureAwait(false)); }
public virtual async Task <FulfillmentSchedule> GetStoreScheduleAsync(GetStoreScheduleParam param) { if (string.IsNullOrWhiteSpace(param.Scope)) { throw new ArgumentException("scope"); } if (param.FulfillmentLocationId == null) { throw new ArgumentException("fulfillmentLocationId"); } var cacheKey = new CacheKey(CacheConfigurationCategoryNames.StoreSchedule) { Scope = param.Scope }; cacheKey.AppendKeyParts(param.FulfillmentLocationId.ToString()); var request = new GetScheduleRequest { ScopeId = param.Scope, FulfillmentLocationId = param.FulfillmentLocationId, ScheduleType = ScheduleType.OpeningHours }; return (await CacheProvider.GetOrAddAsync(cacheKey, () => OvertureClient.SendAsync(request)).ConfigureAwait(false)); }
public virtual async Task <FindStoresQueryResult> GetStoresAsync(GetStoresParam getStoresParam) { if (string.IsNullOrWhiteSpace(getStoresParam.Scope)) { throw new ArgumentException("scope"); } var cacheKey = new CacheKey(CacheConfigurationCategoryNames.Store) { Scope = getStoresParam.Scope }; cacheKey.AppendKeyParts(GETSTORES_CACHE_KEYPART); var request = new FindStoresRequest { ScopeId = getStoresParam.Scope, Query = new Query { StartingIndex = 0, MaximumItems = int.MaxValue, IncludeTotalCount = false, Filter = new FilterGroup { Filters = GetStoreFilters() } } }; var stores = await CacheProvider.GetOrAddAsync(cacheKey, () => OvertureClient.SendAsync(request)) .ConfigureAwait(false); // TODO: Remove this as soon as the FindStoresRequest returns localized display names. if (stores.Results.Any(s => s.DisplayName != null)) { return(stores); } // Try get DisplayNames if (getStoresParam.IncludeExtraInfo) { var ids = stores.Results.Select(x => x.Id).ToList(); var extraStoresInfo = await GetExtraStoresInfoAsync(ids, getStoresParam).ConfigureAwait(false); for (var index = 0; index < stores.Results.Count; index++) { var store = stores.Results[index]; var extraInfo = extraStoresInfo[index]; object displayName = null; extraInfo?.PropertyBag.TryGetValue("DisplayName", out displayName); if (displayName != null) { store.DisplayName = displayName as Overture.ServiceModel.LocalizedString; } } } return(stores); }
public async Task <IActionResult> FindAllInstitutions() { var cacheResult = await _cacheProvider.GetOrAddAsync("getAllInstitution", cacheName, TimeSpan.FromMinutes(15), Core.Enumarations.ExpirationMode.Absolute, async() => { return(await _institutionService.GetAllInstitutionsAsync()); }); var result = _mapper.Map <List <Institution>, List <InstitutionResponseDTO> >(cacheResult); return(new OkObjectResult(result)); }
/// <summary> /// Combine all possible sources of localized string for a given (culture) /// into a single Tree containing the most relevent localizations. /// /// This The localization a found in Resx files /// The Possible sources are resx files configured in most relevent file first /// <example> /// ComposerConfiguration.ResxLocalizationRepositoryConfiguration.PatternsForPossibleSources = { /// "{category}_Custom.{cultureName}.resx", /// "{category}_Custom.{twoLetterISOLanguageName}.resx", /// "{category}_Custom.resx", /// "{category}.{cultureName}.resx", /// "{category}.{twoLetterISOLanguageName}.resx", /// "{category}.resx", /// }; /// </example> /// /// <example> /// string value = await tree.LocalizedCategories[category].LocalizedValues[key].ConfigureAwait(false); /// </example> /// </summary> /// <param name="culture"></param> /// <returns>Tree of most relevant localized values</returns> public Task <LocalizationTree> GetLocalizationTreeAsync(CultureInfo culture) { if (culture == null) { throw new ArgumentNullException("culture"); } CacheKey localizationTreeCacheKey = new CacheKey(CacheConfigurationCategoryNames.LocalizationTree) { CultureInfo = culture, }; var value = CacheProvider.GetOrAddAsync(localizationTreeCacheKey, async() => { string folderPhysicalPath = ""; LocalizationTree tree = new LocalizationTree(culture); foreach (var categoryName in LocalizationRepository.GetAllCategories()) { LocalizationCategory category = new LocalizationCategory(categoryName); foreach (var source in LocalizationRepository.GetPrioritizedSources(categoryName, culture)) { Dictionary <string, string> values = await LocalizationRepository.GetValuesAsync(source).ConfigureAwait(false); foreach (var kvp in values) { if (!category.LocalizedValues.ContainsKey(kvp.Key)) { category.LocalizedValues.Add(kvp.Key, kvp.Value); } } Regex meinReg = new Regex("^[a-zA-Z]{1}:\\.*"); if (string.IsNullOrEmpty(folderPhysicalPath) && !meinReg.IsMatch(source.VirtualPath)) { folderPhysicalPath = HostingEnvironment.MapPath(source.VirtualPath.Substring(0, source.VirtualPath.LastIndexOf(source.Name))); } } tree.LocalizedCategories.Add(categoryName.ToLowerInvariant(), category); } MonitorLocalizationFiles(localizationTreeCacheKey, folderPhysicalPath); return(tree); }); return(value); }
protected virtual async Task <List <CustomProfile> > GetExtraStoresInfoAsync(List <Guid> storesIds, GetStoresParam getStoresParam) { var cacheKey = new CacheKey(CacheConfigurationCategoryNames.Store) { Scope = getStoresParam.Scope }; cacheKey.AppendKeyParts(GETEXSTRASTORESINFO_CACHE_KEYPART); var request = new GetProfileInstancesRequest { Ids = storesIds, EntityTypeName = "Store", ScopeId = getStoresParam.Scope }; return(await CacheProvider.GetOrAddAsync(cacheKey, () => OvertureClient.SendAsync(request)).ConfigureAwait(false)); }
public string BuildSearchQueryUrl(BuildSearchQueryUrlParam param) { var cacheKey = new CacheKey("SearchQuery", param.PageId.ToString(), param.CultureInfo); var categoryBaseUrl = CacheProvider.GetOrAddAsync(cacheKey, () => Task.FromResult(GetPageUrl(param.PageId, param.CultureInfo))).Result; // Category page is not found if (categoryBaseUrl == null) { return(null); } var finalUrl = UrlFormatter.AppendQueryString(categoryBaseUrl, BuildSearchQueryString(new BuildSearchUrlParam { SearchCriteria = param.Criteria })); return(finalUrl); }
public virtual async Task <FindStoresQueryResult> GetStoresAsync(GetStoresParam param) { if (param == null) { throw new ArgumentNullException(nameof(param)); } if (param.CultureInfo == null) { throw new ArgumentException(GetMessageOfNull(nameof(param.CultureInfo)), nameof(param)); } if (string.IsNullOrWhiteSpace(param.Scope)) { throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)), nameof(param)); } var cacheKey = new CacheKey(CacheConfigurationCategoryNames.Store) { Scope = param.Scope }; cacheKey.AppendKeyParts(GETSTORES_CACHE_KEYPART); var request = new FindStoresRequest { ScopeId = param.Scope, IncludeChildScopes = true, CultureName = param.CultureInfo.Name, Query = new Query { StartingIndex = 0, MaximumItems = int.MaxValue, IncludeTotalCount = false, Filter = new FilterGroup { Filters = GetStoreFilters() } } }; var stores = await CacheProvider.GetOrAddAsync(cacheKey, () => OvertureClient.SendAsync(request)).ConfigureAwait(false); // TODO: Remove this as soon as the FindStoresRequest returns localized display names. if (stores.Results.Any(s => s.DisplayName != null)) { return(stores); } // Try get DisplayNames if (param.IncludeExtraInfo) { var ids = stores.Results.Select(x => x.Id).ToList(); var extraStoresInfo = await GetExtraStoresInfoAsync(ids, param).ConfigureAwait(false); extraStoresInfo?.ForEach(extraStoreInfo => { extraStoreInfo.PropertyBag.TryGetValue("DisplayName", out object displayName); if (displayName == null) { return; } var store = stores.Results.FirstOrDefault(st => st.Id == extraStoreInfo.Id); if (store == null) { return; } store.DisplayName = displayName as Overture.ServiceModel.LocalizedString; }); } return(stores); }