Beispiel #1
0
        protected virtual IList <LocalizedPropertyForCaching> GetAllLocalizedPropertiesCached()
        {
            //cache
            var key = string.Format(LOCALIZEDPROPERTY_ALL_KEY);

            return(_cacheManager.Al(key, () =>
            {
                var query = from lp in _localizedPropertyRepository.Tablo
                            select lp;
                var localizedProperties = query.ToList();
                var list = new List <LocalizedPropertyForCaching>();
                foreach (var lp in localizedProperties)
                {
                    var localizedPropertyForCaching = new LocalizedPropertyForCaching
                    {
                        Id = lp.Id,
                        EntityId = lp.EntityId,
                        LanguageId = lp.LanguageId,
                        LocaleKeyGroup = lp.LocaleKeyGroup,
                        LocaleKey = lp.LocaleKey,
                        LocaleValue = lp.LocaleValue
                    };
                    list.Add(localizedPropertyForCaching);
                }
                return list;
            }));
        }
        public virtual Dictionary <string, KeyValuePair <int, string> > GetAllResourceValues(int languageId, bool?loadPublicLocales)
        {
            var key = string.Format(LOCALSTRINGRESOURCES_ALL_KEY, languageId);

            if (!loadPublicLocales.HasValue || _cacheManager.Ayarlandı(key))
            {
                var rez = _cacheManager.Al(key, () =>
                {
                    var query = from l in _lsrRepository.Tabloİzlemesiz
                                orderby l.ResourceName
                                where l.LanguageId == languageId
                                select l;

                    return(ResourceValuesToDictionary(query));
                });

                _cacheManager.Sil(string.Format(LOCALSTRINGRESOURCES_ALL_PUBLIC_KEY, languageId));
                _cacheManager.Sil(string.Format(LOCALSTRINGRESOURCES_ALL_ADMIN_KEY, languageId));

                return(rez);
            }
            key = string.Format(loadPublicLocales.Value ? LOCALSTRINGRESOURCES_ALL_PUBLIC_KEY : LOCALSTRINGRESOURCES_ALL_ADMIN_KEY, languageId);

            return(_cacheManager.Al(key, () =>
            {
                var query = from l in _lsrRepository.Tabloİzlemesiz
                            orderby l.ResourceName
                            where l.LanguageId == languageId
                            select l;
                query = loadPublicLocales.Value ? query.Where(r => !r.ResourceName.StartsWith(ADMIN_LOCALSTRINGRESOURCES_PATTERN)) : query.Where(r => r.ResourceName.StartsWith(ADMIN_LOCALSTRINGRESOURCES_PATTERN));
                return ResourceValuesToDictionary(query);
            }));
        }
Beispiel #3
0
        public virtual List <RenderWidgetModel> PrepareRenderWidgetModel(string widgetZone, object additionalData = null)
        {
            var cacheKey = string.Format(ModelÖnbellekOlayTüketici.WIDGET_MODEL_KEY,
                                         _workContext.MevcutKullanıcı.Id, _storeContext.MevcutSite.Id, widgetZone, _themeContext.MevcutTemaAdı);

            additionalData = new RouteValueDictionary()
            {
                { "widgetZone", widgetZone },
                { "additionalData", additionalData }
            };

            var cachedModel = _cacheManager.Al(cacheKey, () =>
            {
                //model
                var model = new List <RenderWidgetModel>();

                var widgets = _widgetService.BölgedenAktifWidgetleriYükle(widgetZone, _workContext.MevcutKullanıcı, _storeContext.MevcutSite.Id);
                foreach (var widget in widgets)
                {
                    widget.PublicViewBileşeniAl(widgetZone, out string viewComponentName);

                    var widgetModel = new RenderWidgetModel
                    {
                        WidgetViewComponentName      = viewComponentName,
                        WidgetViewComponentArguments = additionalData
                    };

                    model.Add(widgetModel);
                }
                return(model);
            });
            var clonedModel = new List <RenderWidgetModel>();

            foreach (var widgetModel in cachedModel)
            {
                var clonedWidgetModel = new RenderWidgetModel
                {
                    WidgetViewComponentName = widgetModel.WidgetViewComponentName
                };

                if (widgetModel.WidgetViewComponentArguments != null)
                {
                    clonedWidgetModel.WidgetViewComponentArguments = new RouteValueDictionary(widgetModel.WidgetViewComponentArguments);
                }

                if (additionalData != null)
                {
                    if (clonedWidgetModel.WidgetViewComponentArguments == null)
                    {
                        clonedWidgetModel.WidgetViewComponentArguments = new RouteValueDictionary();
                    }

                    clonedWidgetModel.WidgetViewComponentArguments = additionalData;
                }

                clonedModel.Add(clonedWidgetModel);
            }

            return(clonedModel);
        }
Beispiel #4
0
        public virtual IList <Dil> GetAllLanguages(bool showHidden = false, int siteId = 0, bool loadCacheableCopy = true)
        {
            Func <IList <Dil> > loadLanguagesFunc = () =>
            {
                var query = _languageRepository.Tablo;
                if (!showHidden)
                {
                    query = query.Where(l => l.Yayınlandı);
                }
                query = query.OrderBy(l => l.GörüntülenmeSırası).ThenBy(l => l.Id);
                return(query.ToList());
            };

            IList <Dil> languages;

            if (loadCacheableCopy)
            {
                //cacheable copy
                var key = string.Format(LANGUAGES_ALL_KEY, showHidden);
                languages = _cacheManager.Al(key, () =>
                {
                    var result = new List <Dil>();
                    foreach (var language in loadLanguagesFunc())
                    {
                        result.Add(new LanguageForCaching(language));
                    }
                    return(result);
                });
            }
            else
            {
                languages = loadLanguagesFunc();
            }

            //store mapping
            if (siteId > 0)
            {
                languages = languages
                            .Where(l => _siteMappingService.YetkiVer(l, siteId))
                            .ToList();
            }
            return(languages);
        }
 protected virtual async Task <bool> OluşturulanThumbMevcutAsync(string thumbDosyaYolu, string thumbDosyaAdı)
 {
     try
     {
         var key = string.Format(THUMB_EXISTS_KEY, thumbDosyaAdı);
         return(await _önbellekYönetici.Al(key, async() =>
         {
             var blockBlob = _container.GetBlockBlobReference(thumbDosyaAdı);
             return await blockBlob.ExistsAsync();
         }));
     }
     catch { return(false); }
 }