Example #1
0
 public ProductsController(INews news, IModule module, IPhoto photo, ICacheManager cache)
 {
     _news = news;
     _module = module;
     _cache = cache;
     _photo = photo;
 }
Example #2
0
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="cacheManager">Cache manager</param>
 /// <param name="notificationRepository">Notification repository</param>
 /// <param name="eventPublisher">Event published</param>
 public NotificationService(ICacheManager cacheManager,
     IRepository<Notification> notificationRepository,
     ISignals signals) {
     _cacheManager = cacheManager;
     _notificationRepository = notificationRepository;
     _signals = signals;
 }
 public AccountController(
     UserManager userManager,
     IMultiTenancyConfig multiTenancyConfig,
     IUserEmailer userEmailer,
     RoleManager roleManager,
     TenantManager tenantManager,
     IUnitOfWorkManager unitOfWorkManager,
     ITenancyNameFinder tenancyNameFinder,
     ICacheManager cacheManager,
     IAppNotifier appNotifier,
     IWebUrlService webUrlService,
     AbpLoginResultTypeHelper abpLoginResultTypeHelper,
     IUserLinkManager userLinkManager,
     INotificationSubscriptionManager notificationSubscriptionManager)
 {
     _userManager = userManager;
     _multiTenancyConfig = multiTenancyConfig;
     _userEmailer = userEmailer;
     _roleManager = roleManager;
     _tenantManager = tenantManager;
     _unitOfWorkManager = unitOfWorkManager;
     _tenancyNameFinder = tenancyNameFinder;
     _cacheManager = cacheManager;
     _webUrlService = webUrlService;
     _appNotifier = appNotifier;
     _abpLoginResultTypeHelper = abpLoginResultTypeHelper;
     _userLinkManager = userLinkManager;
     _notificationSubscriptionManager = notificationSubscriptionManager;
 }
        public CustomerRoleController(ICustomerService customerService,
            ILocalizationService localizationService, 
            ICustomerActivityService customerActivityService,
            IPermissionService permissionService,
            IProductService productService,
            ICategoryService categoryService,
            IManufacturerService manufacturerService,
            IStoreService storeService,
            IVendorService vendorService,
            IWorkContext workContext,
            ILanguageService languageService,
            ILocalizedEntityService localizedEntityService,
            ICacheManager cacheManager)
		{
            this._customerService = customerService;
            this._localizationService = localizationService;
            this._customerActivityService = customerActivityService;
            this._permissionService = permissionService;
            this._productService = productService;
            this._categoryService = categoryService;
            this._manufacturerService = manufacturerService;
            this._storeService = storeService;
            this._vendorService = vendorService;
            this._workContext = workContext;
            this._languageService = languageService;
            this._localizedEntityService = localizedEntityService;
            this._cacheManager = cacheManager;
        }
Example #5
0
        public BlogController(IBlogService blogService, 
            IWorkContext workContext,
            IStoreContext storeContext,
            IPictureService pictureService, 
            ILocalizationService localizationService,
            IDateTimeHelper dateTimeHelper,
            IWorkflowMessageService workflowMessageService, 
            IWebHelper webHelper,
            ICacheManager cacheManager, 
            ICustomerActivityService customerActivityService,
            IStoreMappingService storeMappingService,
            MediaSettings mediaSettings,
            BlogSettings blogSettings,
            LocalizationSettings localizationSettings, 
            CustomerSettings customerSettings,
            CaptchaSettings captchaSettings)
        {
            this._blogService = blogService;
            this._workContext = workContext;
            this._storeContext = storeContext;
            this._pictureService = pictureService;
            this._localizationService = localizationService;
            this._dateTimeHelper = dateTimeHelper;
            this._workflowMessageService = workflowMessageService;
            this._webHelper = webHelper;
            this._cacheManager = cacheManager;
            this._customerActivityService = customerActivityService;
            this._storeMappingService = storeMappingService;

            this._mediaSettings = mediaSettings;
            this._blogSettings = blogSettings;
            this._localizationSettings = localizationSettings;
            this._customerSettings = customerSettings;
            this._captchaSettings = captchaSettings;
        }
 //private readonly ILifetimeScope container;
 public GenericCharacteristicService()
 {
     //this.container = AutofacHostFactory.Container;
     this.genericCharacteristicRepository =
         EngineContext.Current.Resolve<IRepository<GenericCharacteristic>>();
     this.cacheManager = EngineContext.Current.Resolve<ICacheManager>();
 }
Example #7
0
 /// <summary>
 /// Debug constructor
 /// </summary>
 /// <param name="signInSystem">The sign in system to use</param>
 /// <param name="dnaDataReaderCreator">A DnaDataReaderCreator object for creating the procedure this class needs.
 /// If NULL, it uses the connection stringsfrom the configuration manager</param>
 /// <param name="dnaDiagnostics">A DnaDiagnostics object for logging purposes</param>
 /// <param name="caching">The caching object that the class can use for caching</param>
 /// <param name="debugUserID">A userid for debugging/testing purposes</param>
 /// <param name="siteList">A SiteList object for getting siteoption values</param>
 public CallingUser(SignInSystem signInSystem, IDnaDataReaderCreator dnaDataReaderCreator, IDnaDiagnostics dnaDiagnostics, ICacheManager caching, string debugUserID, ISiteList siteList)
     : base(dnaDataReaderCreator, dnaDiagnostics, caching)
 {
     _signInSystem = signInSystem;
     _debugUserID = debugUserID;
     _siteList = siteList;
 }
 public ApplicationService(IRepository<Application> applicationRepository,
     IEventPublisher eventPublisher, ICacheManager cacheManager)
 {
     _applicationRepository = applicationRepository;
     _eventPublisher = eventPublisher;
     _cacheManager = cacheManager;
 }
Example #9
0
 public SiteService(
     IContentManager contentManager,
     ICacheManager cacheManager) {
     _contentManager = contentManager;
     _cacheManager = cacheManager;
     Logger = NullLogger.Instance;
 }
        public WebWorkContext(Func<string, ICacheManager> cacheManager,
            HttpContextBase httpContext,
            ICustomerService customerService,
			IStoreContext storeContext,
            IAuthenticationService authenticationService,
            ILanguageService languageService,
            ICurrencyService currencyService,
			IGenericAttributeService attrService,
            TaxSettings taxSettings, CurrencySettings currencySettings,
            LocalizationSettings localizationSettings, Lazy<ITaxService> taxService,
            IStoreService storeService, ISettingService settingService,
			IUserAgent userAgent)
        {
            this._cacheManager = cacheManager("static");
            this._httpContext = httpContext;
            this._customerService = customerService;
            this._storeContext = storeContext;
            this._authenticationService = authenticationService;
            this._languageService = languageService;
            this._attrService = attrService;
            this._currencyService = currencyService;
            this._taxSettings = taxSettings;
            this._taxService = taxService;
            this._currencySettings = currencySettings;
            this._localizationSettings = localizationSettings;
            this._storeService = storeService;
            this._settingService = settingService;
            this._userAgent = userAgent;
        }
 public MiscFacebookShopController(IAclService aclService,
     ICacheManager cacheManager,
     CatalogSettings catalogSettings,
     ICategoryService categoryService,
     ICurrencyService currencyService,
     ILocalizationService localizationService,
     IPermissionService permissionService,
     IPictureService pictureService,
     IPriceCalculationService priceCalculationService,
     IPriceFormatter priceFormatter,
     IProductService productService,
     IStoreContext storeContext,
     IStoreMappingService storeMappingService,
     ITaxService taxService,
     IWorkContext workContext)
 {
     this._aclService = aclService;
     this._cacheManager = cacheManager;
     this._catalogSettings = catalogSettings;
     this._categoryService = categoryService;
     this._currencyService = currencyService;
     this._localizationService = localizationService;
     this._permissionService = permissionService;
     this._pictureService = pictureService;
     this._priceCalculationService = priceCalculationService;
     this._priceFormatter = priceFormatter;
     this._productService = productService;
     this._storeContext = storeContext;
     this._storeMappingService = storeMappingService;
     this._taxService = taxService;
     this._workContext = workContext;
 }
Example #12
0
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="cacheManager">Cache manager</param>
 /// <param name="forumGroupRepository">Forum group repository</param>
 /// <param name="forumRepository">Forum repository</param>
 /// <param name="forumTopicRepository">Forum topic repository</param>
 /// <param name="forumPostRepository">Forum post repository</param>
 /// <param name="forumPrivateMessageRepository">Private message repository</param>
 /// <param name="forumSubscriptionRepository">Forum subscription repository</param>
 /// <param name="forumSettings">Forum settings</param>
 /// <param name="customerRepository">Customer repository</param>
 /// <param name="genericAttributeService">Generic attribute service</param>
 /// <param name="customerService">Customer service</param>
 /// <param name="workContext">Work context</param>
 /// <param name="workflowMessageService">Workflow message service</param>
 /// <param name="eventPublisher">Event published</param>
 public ForumService(ICacheManager cacheManager,
     IRepository<ForumGroup> forumGroupRepository,
     IRepository<Forum> forumRepository,
     IRepository<ForumTopic> forumTopicRepository,
     IRepository<ForumPost> forumPostRepository,
     IRepository<ForumPostVote> forumPostVoteRepository,
     IRepository<PrivateMessage> forumPrivateMessageRepository,
     IRepository<ForumSubscription> forumSubscriptionRepository,
     ForumSettings forumSettings,
     IRepository<Customer> customerRepository,
     IGenericAttributeService genericAttributeService,
     ICustomerService customerService,
     IWorkContext workContext,
     IWorkflowMessageService workflowMessageService,
     IEventPublisher eventPublisher
     )
 {
     this._cacheManager = cacheManager;
     this._forumGroupRepository = forumGroupRepository;
     this._forumRepository = forumRepository;
     this._forumTopicRepository = forumTopicRepository;
     this._forumPostRepository = forumPostRepository;
     this._forumPostVoteRepository = forumPostVoteRepository;
     this._forumPrivateMessageRepository = forumPrivateMessageRepository;
     this._forumSubscriptionRepository = forumSubscriptionRepository;
     this._forumSettings = forumSettings;
     this._customerRepository = customerRepository;
     this._genericAttributeService = genericAttributeService;
     this._customerService = customerService;
     this._workContext = workContext;
     this._workflowMessageService = workflowMessageService;
     _eventPublisher = eventPublisher;
 }
        public OutputCacheFilter(
            ICacheManager cacheManager,
            IOutputCacheStorageProvider cacheStorageProvider,
            ITagCache tagCache,
            IDisplayedContentItemHandler displayedContentItemHandler,
            IWorkContextAccessor workContextAccessor,
            IThemeManager themeManager,
            IClock clock,
            ICacheService cacheService,
            ISignals signals,
            ShellSettings shellSettings) {

            _cacheManager = cacheManager;
            _cacheStorageProvider = cacheStorageProvider;
            _tagCache = tagCache;
            _displayedContentItemHandler = displayedContentItemHandler;
            _workContextAccessor = workContextAccessor;
            _themeManager = themeManager;
            _clock = clock;
            _cacheService = cacheService;
            _signals = signals;
            _shellSettings = shellSettings;

            Logger = NullLogger.Instance;
        }
Example #14
0
 public ScanWatchFolder(ICacheManager cacheManager, IDiskScanService diskScanService, IDiskProvider diskProvider, Logger logger)
 {
     _logger = logger;
     _diskProvider = diskProvider;
     _diskScanService = diskScanService;
     _watchFolderItemCache = cacheManager.GetCache<Dictionary<string, WatchFolderItem>>(GetType());
 }
        public DefaultExtensionDependenciesManager(ICacheManager cacheManager, IAppDataFolder appDataFolder) {
            _cacheManager = cacheManager;
            _appDataFolder = appDataFolder;
            _writeThroughToken = new InvalidationToken();

            Logger = NullLogger.Instance;
        }
        public static IList<ProductSpecificationModel> PrepareProductSpecificationModel(this Controller controller,
            IWorkContext workContext,
            ISpecificationAttributeService specificationAttributeService,
            ICacheManager cacheManager,
            Product product)
        {
            if (product == null)
                throw new ArgumentNullException("product");

            string cacheKey = string.Format(ModelCacheEventConsumer.PRODUCT_SPECS_MODEL_KEY, product.Id, workContext.WorkingLanguage.Id);
            return cacheManager.Get(cacheKey, () =>
            {
                var model = specificationAttributeService.GetProductSpecificationAttributesByProductId(product.Id, null, true)
                   .Select(psa =>
                   {
                       return new ProductSpecificationModel()
                       {
                           SpecificationAttributeId = psa.SpecificationAttributeOption.SpecificationAttributeId,
                           SpecificationAttributeName = psa.SpecificationAttributeOption.SpecificationAttribute.GetLocalized(x => x.Name),
                           SpecificationAttributeOption = !String.IsNullOrEmpty(psa.CustomValue) ? psa.CustomValue : psa.SpecificationAttributeOption.GetLocalized(x => x.Name),
                       };
                   }).ToList();
                return model;
            });
        }
        /// <summary>
        /// Ctor
        /// </summary>
        /// <param name="cacheManager">Cache manager</param>
        /// <param name="categoryRepository">Category repository</param>
        /// <param name="productCategoryRepository">ProductCategory repository</param>
        /// <param name="productRepository">Product repository</param>
        /// <param name="aclRepository">ACL record repository</param>
		/// <param name="storeMappingRepository">Store mapping repository</param>
        /// <param name="workContext">Work context</param>
		/// <param name="storeContext">Store context</param>
        /// <param name="eventPublisher">Event publisher</param>
        public CategoryService(ICacheManager cacheManager,
            IRepository<Category> categoryRepository,
            IRepository<ProductCategory> productCategoryRepository,
            IRepository<Product> productRepository,
            IRepository<AclRecord> aclRepository,
			IRepository<StoreMapping> storeMappingRepository,
            IWorkContext workContext,
			IStoreContext storeContext,
            IEventPublisher eventPublisher,
			IStoreMappingService storeMappingService,
			IAclService aclService,
            Lazy<IEnumerable<ICategoryNavigationFilter>> navigationFilters,
            ICustomerService customerService,
            IProductService productService,
            IStoreService storeService)
        {
            this._cacheManager = cacheManager;
            this._categoryRepository = categoryRepository;
            this._productCategoryRepository = productCategoryRepository;
            this._productRepository = productRepository;
            this._aclRepository = aclRepository;
			this._storeMappingRepository = storeMappingRepository;
            this._workContext = workContext;
			this._storeContext = storeContext;
            this._eventPublisher = eventPublisher;
			this._storeMappingService = storeMappingService;
			this._aclService = aclService;
            this._navigationFilters = navigationFilters;
            this._customerService = customerService;
            this._productService = productService;
            this._storeService = storeService;

			this.QuerySettings = DbQuerySettings.Default;
        }
 public ReturnRequestController(IReturnRequestService returnRequestService,
     IOrderService orderService,
     IWorkContext workContext,
     IStoreContext storeContext,
     ICurrencyService currencyService,
     IPriceFormatter priceFormatter,
     IOrderProcessingService orderProcessingService,
     ILocalizationService localizationService,
     ICustomerService customerService,
     IWorkflowMessageService workflowMessageService,
     IDateTimeHelper dateTimeHelper,
     LocalizationSettings localizationSettings,
     ICacheManager cacheManager,
     ICustomNumberFormatter customNumberFormatter)
 {
     this._returnRequestService = returnRequestService;
     this._orderService = orderService;
     this._workContext = workContext;
     this._storeContext = storeContext;
     this._currencyService = currencyService;
     this._priceFormatter = priceFormatter;
     this._orderProcessingService = orderProcessingService;
     this._localizationService = localizationService;
     this._customerService = customerService;
     this._workflowMessageService = workflowMessageService;
     this._dateTimeHelper = dateTimeHelper;
     this._localizationSettings = localizationSettings;
     this._cacheManager = cacheManager;
     this._customNumberFormatter = customNumberFormatter;
 }
 public DiyGroupController(IPermissionService permissionService,
     IDiyService branchService, 
     ILanguageService languageService, 
     ILocalizationService localizationService, 
     IStoreMappingService storeMappingService, 
     ILocalizedEntityService localizedEntityService, 
     IStoreService storeService,
     IPictureService pictureService, 
     IUrlRecordService urlRecordService, 
     ICustomerActivityService customerActivityService, 
     IWorkContext workContext,
     ICacheManager cacheManager, 
     DiySettings diySettings, 
     IWebHelper webHelper)
 {
     _permissionService = permissionService;
     _diyService = branchService;
     _languageService = languageService;
     _localizationService = localizationService;
     _storeMappingService = storeMappingService;
     _localizedEntityService = localizedEntityService;
     _storeService = storeService;
     _pictureService = pictureService;
     _urlRecordService = urlRecordService;
     _customerActivityService = customerActivityService;
     _workContext = workContext;
     _cacheManager = cacheManager;
     _diySettings = diySettings;
     _webHelper = webHelper;
 }
Example #20
0
 /// <summary>
 /// Constructs objects
 /// </summary>
 public User(IDnaDataReaderCreator dnaDataReaderCreator, IDnaDiagnostics dnaDiagnostics, ICacheManager cacheManager)
 {
     _dnaDataReaderCreator = dnaDataReaderCreator;
     _dnaDiagnostics = dnaDiagnostics;
     _cacheManager = cacheManager;
     Groups = new List<Group>();
 }
Example #21
0
 /// <summary>
 /// Constructs objects
 /// </summary>
 public User()
 {
     _dnaDataReaderCreator = null;
     _dnaDiagnostics = null;
     _cacheManager = null;
     Groups = new List<Group>();
 }
        public ThumbnailsService(ShellSettings settings, IWorkContextAccessor wca, ICacheManager cacheManager, IMediaService mediaService, ISignals signals, IStorageProvider storageProvider)
        {
            _wca = wca;
            _cacheManager = cacheManager;
            _mediaService = mediaService;
            _signals = signals;
            _storageProvider = storageProvider;
            var appPath = "";
            if (HostingEnvironment.IsHosted)
            {
                appPath = HostingEnvironment.ApplicationVirtualPath;
            }
            if (!appPath.EndsWith("/"))
                appPath = appPath + '/';
            if (!appPath.StartsWith("/"))
                appPath = '/' + appPath;

            _publicPath = appPath + "Media/" + settings.Name + "/";

            var physPath = ThumbnailsCacheMediaPath.Replace('/', Path.DirectorySeparatorChar);
            var parent = Path.GetDirectoryName(physPath);
            var folder = Path.GetFileName(physPath);
            if (_mediaService.GetMediaFolders(parent).All(f => f.Name != folder))
            {
                _mediaService.CreateFolder(parent, folder);
            }
        }
Example #23
0
        public NewsController(INewsService newsService, 
            IWorkContext workContext, IPictureService pictureService, ILocalizationService localizationService,
            ICustomerContentService customerContentService, IDateTimeHelper dateTimeHelper,
            IWorkflowMessageService workflowMessageService, IWebHelper webHelper,
            ICacheManager cacheManager, ICustomerActivityService customerActivityService,
            MediaSettings mediaSettings, NewsSettings newsSettings,
            LocalizationSettings localizationSettings, CustomerSettings customerSettings,
            StoreInformationSettings storeInformationSettings, CaptchaSettings captchaSettings)
        {
            this._newsService = newsService;
            this._workContext = workContext;
            this._pictureService = pictureService;
            this._localizationService = localizationService;
            this._customerContentService = customerContentService;
            this._dateTimeHelper = dateTimeHelper;
            this._workflowMessageService = workflowMessageService;
            this._webHelper = webHelper;
            this._cacheManager = cacheManager;
            this._customerActivityService = customerActivityService;

            this._mediaSettings = mediaSettings;
            this._newsSettings = newsSettings;
            this._localizationSettings = localizationSettings;
            this._customerSettings = customerSettings;
            this._storeInformationSettings = storeInformationSettings;
            this._captchaSettings = captchaSettings;
        }
        public ShopifyLiquidThemeEngine(ICacheManager<object> cacheManager, Func<WorkContext> workContextFactory, Func<IStorefrontUrlBuilder> storeFrontUrlBuilderFactory, string themesLocalPath, string themesAssetsRelativeUrl, string globalThemeAssetsRelativeUrl)
        {
            _workContextFactory = workContextFactory;
            _storeFrontUrlBuilderFactory = storeFrontUrlBuilderFactory;
            _themesLocalPath = themesLocalPath;
            _themesAssetsRelativeUrl = themesAssetsRelativeUrl;
            _globalThemeAssetsRelativeUrl = globalThemeAssetsRelativeUrl;
            _cacheManager = cacheManager;

            Liquid.UseRubyDateFormat = true;
            // Register custom tags (Only need to do this once)
            Template.RegisterFilter(typeof(CommonFilters));
            Template.RegisterFilter(typeof(CommerceFilters));
            Template.RegisterFilter(typeof(TranslationFilter));
            Template.RegisterFilter(typeof(UrlFilters));
            Template.RegisterFilter(typeof(DateFilters));
            Template.RegisterFilter(typeof(MoneyFilters));
            Template.RegisterFilter(typeof(HtmlFilters));
            Template.RegisterFilter(typeof(StringFilters));

            Condition.Operators["contains"] = CommonOperators.ContainsMethod;

            Template.RegisterTag<LayoutTag>("layout");
            Template.RegisterTag<FormTag>("form");
            Template.RegisterTag<PaginateTag>("paginate");
            //Observe themes file system changes to invalidate cache if changes occur
            _fileSystemWatcher = MonitorThemeFileSystemChanges();
        }
Example #25
0
        public StatusCommand(
            ICacheManager cacheManager,
            IRemote remote,
            string[] args)
        {
            if (args.Length > 1)
                throw new ArgumentException();

            if (args.Length == 1)
            {
                if (args[0] == ShowRemoteArgument)
                {
                    _shouldShowRemote = true;
                }
                else
                {
                    throw new ArgumentException("status command only has one valid option: " + ShowRemoteArgument);
                }
            }

            _cacheManager = cacheManager;
            _remote = remote;

            _filesInLocalCache = _cacheManager.ListFiles();
        }
 public AdminController(IContentManager contentManager,
     IOrchardServices services,
     IShapeFactory shapeFactory,
     IContentDefinitionManager contentDefinitionManager,
     IRemoteContentFetchService remoteContentFetchService,
     ISynchronisationMapFactory synchronisationMapFactory,
     IRepository<ContentSyncSettings> contentSyncSettingsRepository,
     ISignals signals,
     ILoggerFactory loggerFactory,
     ICacheManager cacheManager,
     IImportExportService importExportService,
     IRecipeParser recipeParser,
     IRemoteImportService remoteImportService,
     IEnumerable<IHardComparer> hardComparers, 
     IEnumerable<ISoftComparer> softComparers) {
     _contentManager = contentManager;
     _services = services;
     _shapeFactory = shapeFactory;
     _contentDefinitionManager = contentDefinitionManager;
     _remoteContentFetchService = remoteContentFetchService;
     _synchronisationMapFactory = synchronisationMapFactory;
     _contentSyncSettingsRepository = contentSyncSettingsRepository;
     _signals = signals;
     _loggerFactory = loggerFactory;
     _cacheManager = cacheManager;
     _importExportService = importExportService;
     _recipeParser = recipeParser;
     _remoteImportService = remoteImportService;
     _hardComparers = hardComparers;
     _softComparers = softComparers;
     Logger = loggerFactory.CreateLogger(typeof (AdminController));
     }
Example #27
0
 public Context(IDnaDiagnostics dnaDiagnostics, IDnaDataReaderCreator dataReaderCreator, ICacheManager cacheManager, ISiteList siteList)
 {
     DnaDiagnostics = dnaDiagnostics;
     DnaDataReaderCreator = dataReaderCreator;
     CacheManager = cacheManager;
     SiteList = siteList;
 }
Example #28
0
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="cacheManager">Cache manager</param>
 /// <param name="jPushUserRepository">JPushUser repository</param>
 /// <param name="eventPublisher">Event published</param>
 public JPushUserService(ICacheManager cacheManager,
     IRepository<JPushUser> jPushUserRepository,
     ISignals signals) {
     _cacheManager = cacheManager;
     _jPushUserRepository = jPushUserRepository;
     _signals = signals;
 }
 public AdvancedSitemapService(
     IRepository<SitemapRouteRecord> routeRepository, 
     IRepository<SitemapSettingsRecord> settingsRepository,
     IRepository<SitemapCustomRouteRecord> customRouteRepository,
     IContentManager contentManager,
     ICacheManager cacheManager,
     ISignals signals,
     IClock clock,
     IContentDefinitionManager contentDefinitionManager,
     IEnumerable<ISitemapRouteFilter> routeFilters,
     IEnumerable<ISitemapRouteProvider> routeProviders, 
     ISiteService siteService, 
     IEnumerable<ISpecializedSitemapProvider> specializedSitemapProviders)
 {
     _routeRepository = routeRepository;
     _settingsRepository = settingsRepository;
     _customRouteRepository = customRouteRepository;
     _contentManager = contentManager;
     _cacheManager = cacheManager;
     _signals = signals;
     _clock = clock;
     _contentDefinitionManager = contentDefinitionManager;
     _routeFilters = routeFilters;
     _routeProviders = routeProviders;
     _siteService = siteService;
     _specializedSitemapProviders = specializedSitemapProviders;
 }
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="cacheManager">Cache manager</param>
 /// <param name="categoryTemplateRepository">Category template repository</param>
 /// <param name="eventPublisher">Event published</param>
 public CategoryTemplateService(ICacheManager cacheManager,
     IRepository<CategoryTemplate> categoryTemplateRepository, IEventPublisher eventPublisher)
 {
     _cacheManager = cacheManager;
     _categoryTemplateRepository = categoryTemplateRepository;
     _eventPublisher = eventPublisher;
 }
Example #31
0
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="context">Object context</param>
 public XMSaleInfoService(HozestERPObjectContext context)
 {
     this._context      = context;
     this._cacheManager = new HozestERPRequestCache();
 }
 public static ITypedCache <string, SwitchToLinkedAccountCacheItem> GetSwitchToLinkedAccountCache(this ICacheManager cacheManager)
 {
     return(cacheManager.GetCache <string, SwitchToLinkedAccountCacheItem>(SwitchToLinkedAccountCacheItem.CacheName));
 }
Example #33
0
 public CustomerCacheEventConsumer()
 {
     //TODO inject static cache manager using constructor
     this._cacheManager = EngineContext.Current.ContainerManager.Resolve <ICacheManager>("nop_cache_static");
 }
 /// <summary>
 /// Gets user settings cache.
 /// 获取用户缓存设置
 /// </summary>
 public static ITypedCache <string, Dictionary <string, SettingInfo> > GetUserSettingsCache(this ICacheManager cacheManager)
 {
     return(cacheManager
            .GetCache <string, Dictionary <string, SettingInfo> >(AbpCacheNames.UserSettings));
 }
Example #35
0
 public InterestedPartyController(IUcbService UcbService, ISessionManager sessionManager, ICacheManager cacheManager)
     : base(sessionManager, cacheManager)
 {
     this.UcbService = UcbService;
 }
Example #36
0
 public UserManager(IUserStore <TUser> store, IRoleManager <TRole> roleManager, IOptions <IdentityOptions> optionsAccessor, IPasswordHasher <TUser> passwordHasher, IEnumerable <IUserValidator <TUser> > userValidators, IEnumerable <IPasswordValidator <TUser> > passwordValidators, ILookupNormalizer keyNormalizer, IdentityErrorDescriber errors, IServiceProvider services, IPermissionStore permissionStore, ICacheManager cacheManager, ILogger <UserManager <TUser> > logger) : base(store, roleManager, optionsAccessor, passwordHasher, userValidators, passwordValidators, keyNormalizer, errors, services, permissionStore, cacheManager, logger)
 {
 }
Example #37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BucketCacheHandle"/> class.
 /// </summary>
 /// <param name="manager">The manager.</param>
 /// <param name="configuration">The configuration.</param>
 public BucketCacheHandle(ICacheManager <object> manager, CacheHandleConfiguration configuration)
     : base(manager, configuration)
 {
 }
Example #38
0
 public DiscogsHelper(IRoadieSettings configuration, ICacheManager cacheManager, ILogger <DiscogsHelper> logger) : base(
         configuration, cacheManager, logger)
 {
     _apiKey = configuration.Integrations.ApiKeys.FirstOrDefault(x => x.ApiName == "DiscogsConsumerKey") ?? new ApiKey();
 }
Example #39
0
 public CacheHealthCheck(ICacheManager cacheManager)
 {
     _cacheManager = cacheManager;
 }
Example #40
0
 public DefaultSettingService(IRepository <Setting, int> repository, IEventBus eventBus, ICacheManager cacheManager, ISignals signals)
     : base(repository, eventBus)
 {
     this.cacheManager = cacheManager;
     this.signals      = signals;
 }
Example #41
0
 public UpdateUserClaimCommandHandler(IUserClaimRepository userClaimRepository, ICacheManager cacheManager)
 {
     _userClaimRepository = userClaimRepository;
     _cacheManager        = cacheManager;
 }
Example #42
0
 /// <summary>
 ///     Variable (lock) to support thread-safe
 /// </summary>
 /// <summary>
 ///     Get a cached item. If it's not in the cache yet, then load and cache it
 /// </summary>
 /// <typeparam name="T">Type</typeparam>
 /// <param name="cacheManager">Cache manager</param>
 /// <param name="key">Cache key</param>
 /// <param name="acquire">Function to load item if it's not in the cache yet</param>
 /// <returns>Cached item</returns>
 public static T Get <T>(this ICacheManager cacheManager, string key, Func <T> acquire)
 {
     return(Get(cacheManager, key, 60, acquire));
 }
Example #43
0
        public static void CacheThreadTest(ICacheManager <string> cache, int seed)
        {
            cache.Clear();

            var threads          = 10;
            var numItems         = 1000;
            var eventAddCount    = 0;
            var eventRemoveCount = 0;
            var eventGetCount    = 0;

            cache.OnAdd    += (sender, args) => { Interlocked.Increment(ref eventAddCount); };
            cache.OnRemove += (sender, args) => { Interlocked.Increment(ref eventRemoveCount); };
            cache.OnGet    += (sender, args) => { Interlocked.Increment(ref eventGetCount); };

            Func <int, string> keyGet = (index) => "key" + ((index + 1) * seed);

            Action test = () =>
            {
                for (int i = 0; i < numItems; i++)
                {
                    cache.AddOrUpdate(keyGet(i), i.ToString(), _ => i.ToString() + "update");
                }

                for (int i = 0; i < numItems; i++)
                {
                    if (i % 10 == 0)
                    {
                        cache.Remove(keyGet(i));
                    }
                }

                for (int i = 0; i < numItems; i++)
                {
                    string val = cache.Get(keyGet(i));
                }
            };

            Parallel.Invoke(new ParallelOptions()
            {
                MaxDegreeOfParallelism = 8
            }, Enumerable.Repeat(test, threads).ToArray());

            foreach (var handle in cache.CacheHandles)
            {
                var stats = handle.Stats;
                Console.WriteLine(string.Format(
                                      "Items: {0}, Hits: {1}, Miss: {2}, Remove: {3}, ClearRegion: {4}, Clear: {5}, Adds: {6}, Puts: {7}, Gets: {8}",
                                      stats.GetStatistic(CacheStatsCounterType.Items),
                                      stats.GetStatistic(CacheStatsCounterType.Hits),
                                      stats.GetStatistic(CacheStatsCounterType.Misses),
                                      stats.GetStatistic(CacheStatsCounterType.RemoveCalls),
                                      stats.GetStatistic(CacheStatsCounterType.ClearRegionCalls),
                                      stats.GetStatistic(CacheStatsCounterType.ClearCalls),
                                      stats.GetStatistic(CacheStatsCounterType.AddCalls),
                                      stats.GetStatistic(CacheStatsCounterType.PutCalls),
                                      stats.GetStatistic(CacheStatsCounterType.GetCalls)));
            }

            cache.Dispose();

            Console.WriteLine(string.Format(
                                  "Event - Adds {0} Hits {1} Removes {2}",
                                  eventAddCount,
                                  eventGetCount,
                                  eventRemoveCount));
        }
Example #44
0
 public static ITypedCache <string, SmsVerificationCodeCacheItem> GetSmsVerificationCodeCache(this ICacheManager cacheManager)
 {
     return(cacheManager.GetCache <string, SmsVerificationCodeCacheItem>(SmsVerificationCodeCacheItem.CacheName));
 }
Example #45
0
        public virtual void Setup()
        {
            _permissionRepository        = MockRepository.GenerateMock <IRepository <PermissionRecord> >();
            _permissionMappingRepository = MockRepository.GenerateMock <IRepository <PermissionRoleMapping> >();
            _customerService             = MockRepository.GenerateMock <Lazy <ICustomerService> >();
            _localizationService         = MockRepository.GenerateMock <ILocalizationService>();
            _workContext  = MockRepository.GenerateMock <IWorkContext>();
            _cacheManager = NullCache.Instance;

            _permissionService = new PermissionService(
                _permissionRepository,
                _permissionMappingRepository,
                _customerService,
                _localizationService,
                _workContext,
                _cacheManager);

            _cAdmin.CustomerRoleMappings.Add(new CustomerRoleMapping
            {
                CustomerId     = _cAdmin.Id,
                CustomerRoleId = _rAdmin.Id,
                CustomerRole   = _rAdmin
            });

            _cModerator.CustomerRoleMappings.Add(new CustomerRoleMapping
            {
                CustomerId     = _cModerator.Id,
                CustomerRoleId = _rGuest.Id,
                CustomerRole   = _rGuest
            });
            _cModerator.CustomerRoleMappings.Add(new CustomerRoleMapping
            {
                CustomerId     = _cModerator.Id,
                CustomerRoleId = _rModerator.Id,
                CustomerRole   = _rModerator
            });

            _cGuest.CustomerRoleMappings.Add(new CustomerRoleMapping
            {
                CustomerId     = _cGuest.Id,
                CustomerRoleId = _rGuest.Id,
                CustomerRole   = _rGuest
            });

            var pCatalog = new PermissionRecord {
                Id = 1, SystemName = "catalog"
            };

            var pManu = new PermissionRecord {
                Id = 10, SystemName = "catalog.manufacturer"
            };
            var pManuRead = new PermissionRecord {
                Id = 100, SystemName = "catalog.manufacturer.read"
            };
            var pManuWrite = new PermissionRecord {
                Id = 101, SystemName = "catalog.manufacturer.write"
            };

            var pCategory = new PermissionRecord {
                Id = 20, SystemName = "catalog.category"
            };
            var pCategoryRead = new PermissionRecord {
                Id = 200, SystemName = "catalog.category.read"
            };
            var pCategoryWrite = new PermissionRecord {
                Id = 201, SystemName = "catalog.category.write"
            };

            AddMapping(pManu, _rAdmin, true);
            AddMapping(pCategory, _rAdmin, true);

            AddMapping(pManu, _rModerator, false);
            AddMapping(pManuRead, _rModerator, true);
            AddMapping(pManuWrite, _rModerator, false);

            AddMapping(pCategory, _rGuest, false);

            var permissions = new List <PermissionRecord> {
                pCatalog, pManu, pManuRead, pManuWrite, pCategory, pCategoryRead, pCategoryWrite
            };

            _permissionRepository.Expect(x => x.Table).Return(permissions.AsQueryable());
            _permissionRepository.Expect(x => x.TableUntracked).Return(permissions.AsQueryable());
        }
Example #46
0
        public static void RandomRWTest(ICacheManager <Item> cache)
        {
            cache.Clear();

            const string keyPrefix           = "RWKey_";
            const int    actionsPerIteration = 104;
            const int    initialLoad         = 1000;
            int          iterations          = 0;
            int          removeFails         = 0;
            var          keyIndex            = 0;
            var          random = new Random();

            Action create = () =>
            {
                if (keyIndex > 10000)
                {
                    keyIndex = initialLoad;
                }

                Interlocked.Increment(ref keyIndex);
                var key      = keyPrefix + keyIndex;
                var newValue = Guid.NewGuid().ToString();
                var item     = Item.Generate();

                cache.AddOrUpdate(key, item, p =>
                {
                    p.SomeStrings.Add(newValue);
                    return(p);
                });
            };

            Action read = () =>
            {
                for (var i = 0; i < 100; i++)
                {
                    var val = cache.Get(keyPrefix + random.Next(1, keyIndex));
                }
            };

            Action remove = () =>
            {
                const int maxTries = 10;
                bool      result   = false;
                var       tries    = 0;
                string    key;
                do
                {
                    tries++;
                    key    = keyPrefix + random.Next(1, keyIndex);
                    result = cache.Remove(key);
                    if (!result)
                    {
                        Interlocked.Increment(ref removeFails);
                    }
                }while (!result && tries < maxTries);
            };

            Action report = () =>
            {
                while (true)
                {
                    Thread.Sleep(1000);
                    Console.WriteLine(
                        "Index is at {0} Items in Cache: {1} failed removes {4} runs: {2} \t{3}",
                        keyIndex,
                        cache.CacheHandles.First().Count,
                        iterations,
                        iterations * actionsPerIteration,
                        removeFails);

                    Console.ForegroundColor = ConsoleColor.DarkGray;
                    foreach (var handle in cache.CacheHandles)
                    {
                        var stats = handle.Stats;
                        Console.WriteLine(string.Format(
                                              "Items: {0}, Hits: {1}, Miss: {2}, Remove: {3} Adds: {4}",
                                              stats.GetStatistic(CacheStatsCounterType.Items),
                                              stats.GetStatistic(CacheStatsCounterType.Hits),
                                              stats.GetStatistic(CacheStatsCounterType.Misses),
                                              stats.GetStatistic(CacheStatsCounterType.RemoveCalls),
                                              stats.GetStatistic(CacheStatsCounterType.AddCalls)));
                    }

                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.WriteLine();

                    iterations  = 0;
                    removeFails = 0;
                }
            };

            for (var i = 0; i < initialLoad; i++)
            {
                create();
            }

            Task.Factory.StartNew(report);

            while (true)
            {
                try
                {
                    create();
                    create();
                    read();
                    remove();
                    remove();
                    iterations++;
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error: " + e.Message + "\n" + e.StackTrace);
                    Thread.Sleep(1000);
                }
            }
        }
Example #47
0
 public DMOSService(IBackendUnitOfWork backendUnitOfWork,
                    ICacheManager <object> cacheManager)
 {
     _backendUnitOfWork = backendUnitOfWork;
     _cacheManager      = cacheManager;
 }
Example #48
0
 public LastFMScrobbler(IRoadieSettings configuration, ILogger <LastFMScrobbler> logger, IRoadieDbContext dbContext,
                        ICacheManager cacheManager, ILastFmHelper lastFmHelper, IHttpContext httpContext)
     : base(configuration, logger, dbContext, cacheManager, httpContext)
 {
     LastFmHelper = lastFmHelper;
 }
Example #49
0
 public RoleManager(AbpRoleStore <Role, User> store, IEnumerable <IRoleValidator <Role> > roleValidators, ILookupNormalizer keyNormalizer, IdentityErrorDescriber errors, ILogger <AbpRoleManager <Role, User> > logger, IPermissionManager permissionManager, ICacheManager cacheManager, IUnitOfWorkManager unitOfWorkManager, IRoleManagementConfig roleManagementConfig, IRepository <OrganizationUnit, long> organizationUnitRepository, IRepository <OrganizationUnitRole, long> organizationUnitRoleRepository) :
     base(store, roleValidators, keyNormalizer, errors, logger, permissionManager, cacheManager, unitOfWorkManager, roleManagementConfig, organizationUnitRepository, organizationUnitRoleRepository)
 {
 }
Example #50
0
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="context">Object context</param>
 public SearchLogService(NopObjectContext context)
 {
     this._context      = context;
     this._cacheManager = new NopRequestCache();
 }
Example #51
0
        public CommentService(ICacheManager cacheManager, IRepository <int, Comment> bookRepository)
        {
            _cacheManager = cacheManager;

            _commentRepository = bookRepository;
        }
Example #52
0
 public LoginUserQueryHandler(IUserRepository userRepository, ITokenHelper tokenHelper, IMediator mediator, ICacheManager cacheManager)
 {
     _userRepository = userRepository;
     _tokenHelper    = tokenHelper;
     _mediator       = mediator;
     _cacheManager   = cacheManager;
 }
 public static Object GetAttributeInfo(ICacheManager cache, string pluginName)
 {
     return(cache.GetData(pluginName + "@" + GetCacheKey()));
 }
Example #54
0
 public PropertyDictionaryItemService(Func <ICatalogRepository> repositoryFactory, ICacheManager <object> cacheManager)
 {
     _repositoryFactory = repositoryFactory;
     _cacheManager      = cacheManager;
 }
Example #55
0
        public static IList <ProductSpecificationModel> PrepareProductSpecificationModel(this Controller controller,
                                                                                         IWorkContext workContext,
                                                                                         ISpecificationAttributeService specificationAttributeService,
                                                                                         ICacheManager cacheManager,
                                                                                         Product product)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }

            string cacheKey = string.Format(ModelCacheEventConsumer.PRODUCT_SPECS_MODEL_KEY, product.Id, workContext.WorkingLanguage.Id);

            return(cacheManager.Get(cacheKey, () =>
                                    specificationAttributeService.GetProductSpecificationAttributes(product.Id, 0, null, true)
                                    .Select(psa =>
            {
                var m = new ProductSpecificationModel
                {
                    SpecificationAttributeId = psa.SpecificationAttributeOption.SpecificationAttributeId,
                    SpecificationAttributeName = psa.SpecificationAttributeOption.SpecificationAttribute.GetLocalized(x => x.Name),
                    ColorSquaresRgb = psa.SpecificationAttributeOption.ColorSquaresRgb
                };

                switch (psa.AttributeType)
                {
                case SpecificationAttributeType.Option:
                    m.ValueRaw = HttpUtility.HtmlEncode(psa.SpecificationAttributeOption.GetLocalized(x => x.Name));
                    break;

                case SpecificationAttributeType.CustomText:
                    m.ValueRaw = HttpUtility.HtmlEncode(psa.CustomValue);
                    break;

                case SpecificationAttributeType.CustomHtmlText:
                    m.ValueRaw = psa.CustomValue;
                    break;

                case SpecificationAttributeType.Hyperlink:
                    m.ValueRaw = string.Format("<a href='{0}' target='_blank'>{0}</a>", psa.CustomValue);
                    break;

                default:
                    break;
                }
                return m;
            }).ToList()
                                    ));
        }
 public static void ClearAttributeData(ICacheManager cache, string pluginName)
 {
     cache.Remove(pluginName + "@" + GetCacheKey());
 }
 public StoreMappingService(ICacheManager cache, IStoreContext storeContext, SmartDbContext db)
 {
     _cache        = cache;
     _storeContext = storeContext;
     _db           = db;
 }
Example #58
0
        public static IEnumerable <ProductOverviewModel> PrepareProductOverviewModels(this Controller controller,
                                                                                      IWorkContext workContext,
                                                                                      IStoreContext storeContext,
                                                                                      ICategoryService categoryService,
                                                                                      IProductService productService,
                                                                                      ISpecificationAttributeService specificationAttributeService,
                                                                                      IPriceCalculationService priceCalculationService,
                                                                                      IPriceFormatter priceFormatter,
                                                                                      IPermissionService permissionService,
                                                                                      ILocalizationService localizationService,
                                                                                      ITaxService taxService,
                                                                                      ICurrencyService currencyService,
                                                                                      IPictureService pictureService,
                                                                                      IMeasureService measureService,
                                                                                      IWebHelper webHelper,
                                                                                      ICacheManager cacheManager,
                                                                                      CatalogSettings catalogSettings,
                                                                                      MediaSettings mediaSettings,
                                                                                      IEnumerable <Product> products,
                                                                                      bool preparePriceModel                 = true, bool preparePictureModel = true,
                                                                                      int?productThumbPictureSize            = null, bool prepareSpecificationAttributes = false,
                                                                                      bool forceRedirectionAfterAddingToCart = false)
        {
            if (products == null)
            {
                throw new ArgumentNullException("products");
            }

            var models = new List <ProductOverviewModel>();

            foreach (var product in products)
            {
                var model = new ProductOverviewModel
                {
                    Id               = product.Id,
                    Name             = product.GetLocalized(x => x.Name),
                    ShortDescription = product.GetLocalized(x => x.ShortDescription),
                    FullDescription  = product.GetLocalized(x => x.FullDescription),
                    SeName           = product.GetSeName(),
                    ProductType      = product.ProductType,
                    MarkAsNew        = product.MarkAsNew &&
                                       (!product.MarkAsNewStartDateTimeUtc.HasValue || product.MarkAsNewStartDateTimeUtc.Value < DateTime.UtcNow) &&
                                       (!product.MarkAsNewEndDateTimeUtc.HasValue || product.MarkAsNewEndDateTimeUtc.Value > DateTime.UtcNow)
                };
                //price
                if (preparePriceModel)
                {
                    #region Prepare product price

                    var priceModel = new ProductOverviewModel.ProductPriceModel
                    {
                        ForceRedirectionAfterAddingToCart = forceRedirectionAfterAddingToCart
                    };

                    switch (product.ProductType)
                    {
                    case ProductType.GroupedProduct:
                    {
                        #region Grouped product

                        var associatedProducts = productService.GetAssociatedProducts(product.Id, storeContext.CurrentStore.Id);

                        //add to cart button (ignore "DisableBuyButton" property for grouped products)
                        priceModel.DisableBuyButton = !permissionService.Authorize(StandardPermissionProvider.EnableShoppingCart) ||
                                                      !permissionService.Authorize(StandardPermissionProvider.DisplayPrices);

                        //add to wishlist button (ignore "DisableWishlistButton" property for grouped products)
                        priceModel.DisableWishlistButton = !permissionService.Authorize(StandardPermissionProvider.EnableWishlist) ||
                                                           !permissionService.Authorize(StandardPermissionProvider.DisplayPrices);

                        //compare products
                        priceModel.DisableAddToCompareListButton = !catalogSettings.CompareProductsEnabled;
                        switch (associatedProducts.Count)
                        {
                        case 0:
                        {
                            //no associated products
                        }
                        break;

                        default:
                        {
                            //we have at least one associated product
                            //compare products
                            priceModel.DisableAddToCompareListButton = !catalogSettings.CompareProductsEnabled;
                            //priceModel.AvailableForPreOrder = false;

                            if (permissionService.Authorize(StandardPermissionProvider.DisplayPrices))
                            {
                                //find a minimum possible price
                                decimal?minPossiblePrice = null;
                                Product minPriceProduct  = null;
                                foreach (var associatedProduct in associatedProducts)
                                {
                                    //` for the maximum quantity (in case if we have tier prices)
                                    var tmpPrice = priceCalculationService.GetFinalPrice(associatedProduct,
                                                                                         workContext.CurrentCustomer, decimal.Zero, true, int.MaxValue);
                                    if (!minPossiblePrice.HasValue || tmpPrice < minPossiblePrice.Value)
                                    {
                                        minPriceProduct  = associatedProduct;
                                        minPossiblePrice = tmpPrice;
                                    }
                                    if (minPriceProduct != null && !minPriceProduct.CustomerEntersPrice)
                                    {
                                        if (minPriceProduct.CallForPrice)
                                        {
                                            priceModel.OldPrice = null;
                                            priceModel.Price    = localizationService.GetResource("Products.CallForPrice");
                                        }
                                        else if (minPossiblePrice.HasValue)
                                        {
                                            //calculate prices
                                            decimal taxRate;
                                            decimal finalPriceBase = taxService.GetProductPrice(minPriceProduct, minPossiblePrice.Value, out taxRate);
                                            decimal finalPrice     = currencyService.ConvertFromPrimaryStoreCurrency(finalPriceBase, workContext.WorkingCurrency);
                                            priceModel.OldPrice   = null;
                                            priceModel.Price      = String.Format(localizationService.GetResource("Products.PriceRangeFrom"), priceFormatter.FormatPrice(finalPrice));
                                            priceModel.PriceValue = finalPrice;

                                            //PAngV baseprice (used in Germany)
                                            priceModel.BasePricePAngV = product.FormatBasePrice(finalPrice,
                                                                                                localizationService, measureService, currencyService, workContext, priceFormatter);
                                        }
                                        else
                                        {
                                            //Actually it's not possible (we presume that minimalPrice always has a value)
                                            //We never should get here
                                            Debug.WriteLine("Cannot calculate minPrice for product #{0}", product.Id);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                //hide prices
                                priceModel.OldPrice = null;
                                priceModel.Price    = null;
                            }
                        }
                        break;
                        }

                        #endregion
                    }
                    break;

                    case ProductType.SimpleProduct:
                    default:
                    {
                        #region Simple product

                        //add to cart button
                        priceModel.DisableBuyButton = product.DisableBuyButton ||
                                                      !permissionService.Authorize(StandardPermissionProvider.EnableShoppingCart) ||
                                                      !permissionService.Authorize(StandardPermissionProvider.DisplayPrices);

                        //add to wishlist button
                        priceModel.DisableWishlistButton = product.DisableWishlistButton ||
                                                           !permissionService.Authorize(StandardPermissionProvider.EnableWishlist) ||
                                                           !permissionService.Authorize(StandardPermissionProvider.DisplayPrices);
                        //compare products
                        priceModel.DisableAddToCompareListButton = !catalogSettings.CompareProductsEnabled;

                        //rental
                        priceModel.IsRental = product.IsRental;

                        //pre-order
                        if (product.AvailableForPreOrder)
                        {
                            priceModel.AvailableForPreOrder = !product.PreOrderAvailabilityStartDateTimeUtc.HasValue ||
                                                              product.PreOrderAvailabilityStartDateTimeUtc.Value >= DateTime.UtcNow;
                            priceModel.PreOrderAvailabilityStartDateTimeUtc = product.PreOrderAvailabilityStartDateTimeUtc;
                        }

                        //prices
                        if (permissionService.Authorize(StandardPermissionProvider.DisplayPrices))
                        {
                            if (!product.CustomerEntersPrice)
                            {
                                if (product.CallForPrice)
                                {
                                    //call for price
                                    priceModel.OldPrice = null;
                                    priceModel.Price    = localizationService.GetResource("Products.CallForPrice");
                                }
                                else
                                {
                                    //prices

                                    //calculate for the maximum quantity (in case if we have tier prices)
                                    decimal minPossiblePrice = priceCalculationService.GetFinalPrice(product,
                                                                                                     workContext.CurrentCustomer, decimal.Zero, true, int.MaxValue);

                                    decimal taxRate;
                                    decimal oldPriceBase   = taxService.GetProductPrice(product, product.OldPrice, out taxRate);
                                    decimal finalPriceBase = taxService.GetProductPrice(product, minPossiblePrice, out taxRate);

                                    decimal oldPrice   = currencyService.ConvertFromPrimaryStoreCurrency(oldPriceBase, workContext.WorkingCurrency);
                                    decimal finalPrice = currencyService.ConvertFromPrimaryStoreCurrency(finalPriceBase, workContext.WorkingCurrency);

                                    //do we have tier prices configured?
                                    var tierPrices = new List <TierPrice>();
                                    if (product.HasTierPrices)
                                    {
                                        tierPrices.AddRange(product.TierPrices
                                                            .OrderBy(tp => tp.Quantity)
                                                            .ToList()
                                                            .FilterByStore(storeContext.CurrentStore.Id)
                                                            .FilterForCustomer(workContext.CurrentCustomer)
                                                            .RemoveDuplicatedQuantities());
                                    }
                                    //When there is just one tier (with  qty 1),
                                    //there are no actual savings in the list.
                                    bool displayFromMessage = tierPrices.Any() &&
                                                              !(tierPrices.Count == 1 && tierPrices[0].Quantity <= 1);
                                    if (displayFromMessage)
                                    {
                                        priceModel.OldPrice   = null;
                                        priceModel.Price      = String.Format(localizationService.GetResource("Products.PriceRangeFrom"), priceFormatter.FormatPrice(finalPrice));
                                        priceModel.PriceValue = finalPrice;
                                    }
                                    else
                                    {
                                        if (finalPriceBase != oldPriceBase && oldPriceBase != decimal.Zero)
                                        {
                                            priceModel.OldPrice   = priceFormatter.FormatPrice(oldPrice);
                                            priceModel.Price      = priceFormatter.FormatPrice(finalPrice);
                                            priceModel.PriceValue = finalPrice;
                                        }
                                        if (product.IsRental)
                                        {
                                            //rental product
                                            priceModel.OldPrice = priceFormatter.FormatRentalProductPeriod(product, priceModel.OldPrice);
                                            priceModel.Price    = priceFormatter.FormatRentalProductPeriod(product, priceModel.Price);
                                        }

                                        //property for German market
                                        //we display tax/shipping info only with "shipping enabled" for this product
                                        //we also ensure this it's not free shipping
                                        priceModel.DisplayTaxShippingInfo = catalogSettings.DisplayTaxShippingInfoProductBoxes &&
                                                                            product.IsShipEnabled &&
                                                                            !product.IsFreeShipping;


                                        //PAngV baseprice (used in Germany)
                                        priceModel.BasePricePAngV = product.FormatBasePrice(finalPrice,
                                                                                            localizationService, measureService, currencyService, workContext, priceFormatter);
                                    }
                                }
                            }
                            else
                            {
                                //hide prices
                                priceModel.OldPrice = null;
                                priceModel.Price    = null;
                            }
                        }

                        #endregion
                    }
                    break;
                    }

                    model.ProductPrice = priceModel;

                    #endregion
                }

                //picture
                if (preparePictureModel)
                {
                    #region Prepare product picture

                    //If a size has been set in the view, we use it in priority
                    int pictureSize = productThumbPictureSize.HasValue ? productThumbPictureSize.Value : mediaSettings.ProductThumbPictureSize;
                    //prepare picture model
                    var defaultProductPictureCacheKey = string.Format(ModelCacheEventConsumer.PRODUCT_DEFAULTPICTURE_MODEL_KEY, product.Id, pictureSize, true, workContext.WorkingLanguage.Id, webHelper.IsCurrentConnectionSecured(), storeContext.CurrentStore.Id);
                    model.DefaultPictureModel = cacheManager.Get(defaultProductPictureCacheKey, () =>
                    {
                        // GetPicturesByProductId 找出product所有的图片,DisplayOrder排序, 软后选出第一个作为默认的图片
                        var picture      = pictureService.GetPicturesByProductId(product.Id, 1).FirstOrDefault();
                        var pictureModel = new PictureModel
                        {
                            ImageUrl         = pictureService.GetPictureUrl(picture, pictureSize),
                            FullSizeImageUrl = pictureService.GetPictureUrl(picture)
                        };
                        //"title" attribute
                        pictureModel.Title = (picture != null && !string.IsNullOrEmpty(picture.TitleAttribute)) ?
                                             picture.TitleAttribute :
                                             string.Format(localizationService.GetResource("Media.Product.ImageLinkTitleFormat"), model.Name);
                        //"alt" attribute
                        pictureModel.AlternateText = (picture != null && !string.IsNullOrEmpty(picture.AltAttribute)) ?
                                                     picture.AltAttribute :
                                                     string.Format(localizationService.GetResource("Media.Product.ImageAlternateTextFormat"), model.Name);

                        return(pictureModel);
                    });

                    #endregion
                }

                //specs
                if (prepareSpecificationAttributes)
                {
                    model.SpecificationAttributeModels = PrepareProductSpecificationModel(controller, workContext,
                                                                                          specificationAttributeService, cacheManager, product);
                }

                //reviews
                model.ReviewOverviewModel = controller.PrepareProductReviewOverviewModel(storeContext, catalogSettings, cacheManager, product);

                models.Add(model);
            }

            return(models);
        }
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="context">Object context</param>
 public XMBusinessDataDetailService(HozestERPObjectContext context)
 {
     this._context      = context;
     this._cacheManager = new HozestERPRequestCache();
 }
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="cacheManager">Cache manager</param>
 /// <param name="SettingBehnabRepository">Store pickup point repository</param>
 public FaraBotUserService(ICacheManager cacheManager,
                           IRepository <FaraBotUser> storePickupPointRepository)
 {
     this._cacheManager    = cacheManager;
     this._ModelRepository = storePickupPointRepository;
 }