Exemplo n.º 1
0
        private void GetDataByCacheKey(IInvocation invocation, IRedisCacheService redisCacheService, ParameterInfo[] parameters, ServiceCacheAttribute svcCacheAttribute, string cacheKey)
        {
            int retryTimes = 0;

            if (redisCacheService.Contains(cacheKey))
            {
                GetDataByCacheKey(invocation, redisCacheService, parameters, cacheKey);
                retryTimes = 0;
            }
            else
            {
Label_RETRY:
                var isLock = CheckCacheKeyLock(invocation, redisCacheService, parameters, svcCacheAttribute, cacheKey);
                if (isLock)
                {
                    while (retryTimes <= 3)
                    {
                        Thread.Sleep(500);
                        retryTimes++;
                        goto Label_RETRY;
                    }
                    var cacheKeyLocked = string.Format("{0}:LOCK", cacheKey);
                    redisCacheService.Remove(cacheKeyLocked);
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Performs constructor injection for repository interfaces used in this service.
 /// </summary>
 /// <param name="userManager"></param>
 /// <param name="signInManager"></param>
 /// <param name="tokenManagement"></param>
 /// <param name="httpClient"></param>
 /// <param name="contextRepository"></param>
 /// <param name="userRepository"></param>
 /// <param name="httpContextAccessor"></param>
 /// <param name="milvaMailSender"></param>
 /// <param name="sharedLocalizer"></param>
 /// <param name="milvaLogger"></param>
 /// <param name="redisCacheService"></param>
 public AccountService(UserManager <AppUser> userManager,
                       SignInManager <AppUser> signInManager,
                       ITokenManagement tokenManagement,
                       HttpClient httpClient,
                       IContextRepository <EducationAppDbContext> contextRepository,
                       IBaseRepository <AppUser, Guid, EducationAppDbContext> userRepository,
                       IHttpContextAccessor httpContextAccessor,
                       IMilvaMailSender milvaMailSender,
                       IStringLocalizer <SharedResource> sharedLocalizer,
                       IMilvaLogger milvaLogger,
                       IRedisCacheService redisCacheService) : base(userManager, signInManager, tokenManagement, contextRepository, sharedLocalizer, httpContextAccessor, true)
 {
     _userName            = httpContextAccessor.HttpContext.User.Identity.Name;
     _redisCacheService   = redisCacheService;
     _milvaLogger         = milvaLogger;
     _milvaMailSender     = milvaMailSender;
     _userRepository      = userRepository;
     _userManager         = userManager;
     _signInManager       = signInManager;
     _httpClient          = httpClient;
     _contextRepository   = contextRepository;
     _httpContextAccessor = httpContextAccessor;
     _localizer           = sharedLocalizer;
     _tokenManagement     = tokenManagement;
     _loginProvider       = tokenManagement.LoginProvider;
     _tokenName           = tokenManagement.TokenName;
 }
Exemplo n.º 3
0
 public ConsultantParser(IHtmlParser htmlParser, IRedisCacheService cache, IDatesRangeService rangeService, string calendarSourceFormat)
 {
     _htmlParser           = htmlParser;
     _cache                = cache;
     _rangeService         = rangeService;
     _calendarSourceFormat = calendarSourceFormat;
 }
Exemplo n.º 4
0
 public BlogController(IPostService postService, ITaxonomyService taxonomyService, IRedisCacheService redisCacheService)
 {
     _postService       = postService;
     _taxonomyService   = taxonomyService;
     _redisCacheService = redisCacheService;
     recordsPerPage     = 1;
 }
Exemplo n.º 5
0
 public ConversationService(IDialogflowService dialogflowService, IConsultantParser consultantParser, IRedisCacheService cache, IMapper mapper)
 {
     _dialogflowService = dialogflowService;
     _consultantParser  = consultantParser;
     _cache             = cache;
     _mapper            = mapper;
 }
Exemplo n.º 6
0
        public AccountController(IUsyUserRepository userRepository, IRedisCacheService redisCache, ICacheService memoryCache)
        {
            _userRepository = userRepository;

            _redisCache  = redisCache;
            _memoryCache = memoryCache;
        }
Exemplo n.º 7
0
        //private readonly IFilesService _filesService;
        //private readonly IConfiguration _configuration;
        //private readonly IHelper _helper;

        public CityManager(ICityRepository cityRepository, IMapper mapper, IRedisCacheService redisCacheService, BaseResponse <object> response)
        {
            _response          = response;
            _redisCacheService = redisCacheService;
            _mapper            = mapper;
            _cityRepository    = cityRepository;
        }
Exemplo n.º 8
0
 public BaseController(IOptions <ApiServer> option, IRedisCacheService redisCache, ICacheService memoryCache)
 {
     ApiServerAddr = option.Value.Addr;
     AppId         = option.Value.AppId;
     AppKey        = option.Value.AppKey;
     _redisCache   = redisCache;
     _memoryCache  = memoryCache;
 }
Exemplo n.º 9
0
 public SberService(
     IConversationService conversationService,
     IMapper mapper,
     IRedisCacheService cache) : base(conversationService, mapper)
 {
     _mapper = mapper;
     _cache  = cache;
 }
Exemplo n.º 10
0
 public MqttClientService(ILogger logger, IRedisCacheService redisCacheService, IManagedMqttClientOptions options)
 {
     this.options           = options;
     this.logger            = logger;
     this.redisCacheService = redisCacheService;
     mqttClient             = new MqttFactory().CreateManagedMqttClient();
     ConfigureMqttClient();
 }
Exemplo n.º 11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="queryBus"></param>
 /// <param name="commandBus"></param>
 /// <param name="redisCacheService"></param>
 /// <param name="storage"></param>
 public DemoController(IQueryBus queryBus, ICommandBus commandBus, IRedisCacheService redisCacheService, IStorage storage, IUriService uriService)
 {
     _uriService        = uriService;
     _queryBus          = queryBus;
     _commandBus        = commandBus;
     _redisCacheService = redisCacheService;
     _storage           = storage;
 }
Exemplo n.º 12
0
 public HomeController(IUsyAppRepository appRepository, IRedisCacheService redisCache, ICacheService memoryCache, IHostingEnvironment env)
 {
     log            = LogManager.GetLogger(Startup.log4netRepository.Name, typeof(HomeController));
     _appRepository = appRepository;
     _redisCache    = redisCache;
     _memoryCache   = memoryCache;
     _env           = env;
 }
Exemplo n.º 13
0
 public LoginService(IEncryptionService encryptionService, IRepository <DB.Entities.Users> userRepository, IUserService userService, IRedisCacheService redisCacheService, ICoreContext coreContext)
 {
     _encryptionService = encryptionService;
     _userRepository    = userRepository;
     _userService       = userService;
     _redisCacheService = redisCacheService;
     _coreContext       = coreContext;
 }
Exemplo n.º 14
0
 public DbSyncService(
     IRedisCacheService redisCacheService,
     ITemperatureHumidityRepository temperatureHumidityRepository,
     IMotionDetectionRepository motionDetectionRepository)
 {
     this.redisCacheService             = redisCacheService;
     this.motionDetectionRepository     = motionDetectionRepository;
     this.temperatureHumidityRepository = temperatureHumidityRepository;
 }
Exemplo n.º 15
0
 public LoginFilter(IRedisCacheService redisCacheService, IEncryptionService encryptionService,
                    IUserService userService, ICoreContext coreContext, IWorkContext workContext)
 {
     _redisCacheService = redisCacheService;
     _encryptionService = encryptionService;
     _coreContext       = coreContext;
     _userService       = userService;
     _workContext       = workContext;
 }
Exemplo n.º 16
0
        public ManageController(IUsyUserRepository userRepository, IRedisCacheService redisCache, ICacheService memoryCache, IUsyMenuRepository menuRepository)
        {
            _userRepository = userRepository;

            _redisCache  = redisCache;
            _memoryCache = memoryCache;

            _menuRepository = menuRepository;
        }
Exemplo n.º 17
0
 public Service(IUnitOfWork unitOfWork
                , IMapper mapper
                , IRedisCacheService redisCache
                , IHttpContextAccessor httpContextAccessor)
 {
     this.unitOfWork          = unitOfWork;
     this.mapper              = mapper;
     this.redisCache          = redisCache;
     this.httpContextAccessor = httpContextAccessor;
 }
Exemplo n.º 18
0
 public CartItemsController(
     DiscountGrpcService discountGrpcService,
     ICartItemsService cartItemsService,
     IRedisCacheService cacheService,
     IMapper mapper)
 {
     _discountGrpcService = discountGrpcService;
     _cartItemsService    = cartItemsService;
     _cacheService        = cacheService;
     _mapper = mapper;
 }
Exemplo n.º 19
0
        public GetProductsHandler(IConfiguration config, IRedisCacheService cacheService)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            _cacheService = cacheService ?? throw new ArgumentNullException(nameof(cacheService));
            _dbConnection = new Lazy <IDbConnection>(() =>
                                                     new SqlConnection(config.GetConnectionString("sqlserver")));
        }
Exemplo n.º 20
0
 public RoleService(IUnitOfWork unitOfWork
                    , IMapper mapper
                    , IRedisCacheService redisCache
                    , IHttpContextAccessor httpContextAccessor)
     : base(unitOfWork, mapper, redisCache, httpContextAccessor)
 {
     userRoleRepo       = unitOfWork.Repository <UserRole>();
     roleRepo           = unitOfWork.Repository <Role>();
     rolePermissionRepo = unitOfWork.Repository <RolePermission>();
     userRepo           = unitOfWork.Repository <User>();
 }
Exemplo n.º 21
0
 public LoginFilter(IRedisCacheService redisCacheService, IEncryption encryption,
                    IUserService userService, ICoreContext coreContext, IWorkContext workContext, IRoleService roleService, IStringLocalizer <VbtController> localizer)
 {
     _redisCacheService = redisCacheService;
     _encryption        = encryption;
     _coreContext       = coreContext;
     _userService       = userService;
     _workContext       = workContext;
     _roleService       = roleService;
     _localizer         = localizer;
 }
Exemplo n.º 22
0
        public EmployeesService(IRepository <DB.Entities.Employees> employeesRepository, IMapper mapper, IRedisCacheService redisCacheManager, IRepository <DB.Entities.Territories> territoriesRepository,
                                IRepository <DB.Entities.EmployeeTerritories> employeeTerritoriesRepository,
                                IRepository <DB.Entities.Region> regionRepository)
        {
            _employeesRepository           = employeesRepository;
            _territoriesRepository         = territoriesRepository;
            _employeeTerritoriesRepository = employeeTerritoriesRepository;
            _regionRepository = regionRepository;

            _mapper            = mapper;
            _redisCacheManager = redisCacheManager;
        }
Exemplo n.º 23
0
        private void GetDataByCacheKey(IInvocation invocation, IRedisCacheService redisCacheService, ParameterInfo[] parameters, string cacheKey)
        {
            invocation.ReturnValue = redisCacheService.GetNullableData(cacheKey, invocation.Method.ReturnType);

            for (int i = 0; i < parameters.Length; i++)
            {
                if (parameters[i].ParameterType.IsByRef)
                {
                    object argVal = redisCacheService.GetData(cacheKey + parameters[i].Name, parameters[i].ParameterType.GetElementType());
                    invocation.SetArgumentValue(i, argVal);
                }
            }
        }
Exemplo n.º 24
0
 private bool CheckCacheKey(IInvocation invocation, IRedisCacheService redisCacheService, ParameterInfo[] parameters, ServiceCacheAttribute svcCacheAttribute, string cacheKey)
 {
     if (redisCacheService.Contains(cacheKey))
     {
         GetDataByCacheKey(invocation, redisCacheService, parameters, cacheKey);
         return(false);
     }
     else
     {
         CheckCacheKeyLock(invocation, redisCacheService, parameters, svcCacheAttribute, cacheKey);
         return(true);
     }
 }
Exemplo n.º 25
0
        public void Clear(IRedisCacheService cacheService)
        {
            cacheService.ClearServiceCache();
            List <string> toRemove = new List <string>();

            foreach (DictionaryEntry cacheItem in HttpRuntime.Cache)
            {
                toRemove.Add(cacheItem.Key.ToString());
            }
            foreach (string key in toRemove)
            {
                HttpRuntime.Cache.Remove(key);
            }
        }
Exemplo n.º 26
0
        public EmployeesService(IRepository <DB.Entities.Employees> employeesRepository, IMapper mapper, IRedisCacheService redisCacheManager, IRepository <DB.Entities.Territories> territoriesRepository,
                                IRepository <DB.Entities.EmployeeTerritories> employeeTerritoriesRepository,
                                IRepository <DB.Entities.Region> regionRepository, VbtContext context, IRepository <DB.Entities.CategorySalesFor1997> categoryViewRepository)
        {
            _employeesRepository           = employeesRepository;
            _territoriesRepository         = territoriesRepository;
            _employeeTerritoriesRepository = employeeTerritoriesRepository;
            _regionRepository = regionRepository;

            _categoryViewRepository = categoryViewRepository;
            _mapper            = mapper;
            _redisCacheManager = redisCacheManager;
            _context           = context;
        }
Exemplo n.º 27
0
        private void AddCacheKey(IInvocation invocation, IRedisCacheService redisCacheService, ParameterInfo[] parameters, ServiceCacheAttribute svcCacheAttribute, string cacheKey)
        {
            invocation.Proceed();

            redisCacheService.AddNullableData(cacheKey, invocation.ReturnValue, svcCacheAttribute.TimeoutSecs);

            for (int i = 0; i < parameters.Length; i++)
            {
                if (parameters[i].ParameterType.IsByRef && invocation.Arguments[i] != null)
                {
                    redisCacheService.Add(cacheKey + parameters[i].Name, invocation.Arguments[i], svcCacheAttribute.TimeoutSecs);
                }
            }
        }
Exemplo n.º 28
0
        public LuisService(IOptions <LuisSettings> options,
                           ILUISAuthoringClient luisAuthoringClient,
                           ILUISRuntimeClient luisRuntimeClient,
                           IRedisCacheService redisCache,
                           HttpClient httpClient,
                           ILogger <LuisService> logger)
        {
            _redisCache   = redisCache;
            _luisSettings = options?.Value ?? throw new ArgumentNullException(nameof(options));
            _logger       = logger;
            _httpClient   = httpClient;

            _luisRuntimeClient   = luisRuntimeClient;
            _luisAuthoringClient = luisAuthoringClient;
        }
Exemplo n.º 29
0
 public AnswerService(MoMoDbContext context,
                      IRedisCacheService cache,
                      IHttpContextAccessor httpContextAccessor,
                      IUnknownService issueService,
                      HttpClient httpClient,
                      KnowledgeMapContext mapContext,
                      ILogger <AnswerService> logger)
 {
     _httpContextAccessor = httpContextAccessor;
     _issueService        = issueService;
     _cache      = cache;
     _context    = context;
     _httpClient = httpClient;
     _logger     = logger;
     _mapContext = mapContext;
 }
Exemplo n.º 30
0
 public ProductService(
     IRepository <Product> productRepository,
     IRepository <ExchangeType> exchangeTypeRepository,
     IMapper mapper,
     DevnotContext devnotContext,
     IRedisCacheService redisCacheManager,
     IRabbitMQService rabbitMQService
     )
 {
     _productRepository      = productRepository;
     _exchangeTypeRepository = exchangeTypeRepository;
     _mapper            = mapper;
     _devnotContext     = devnotContext;
     _redisCacheManager = redisCacheManager;
     _rabbitMQService   = rabbitMQService;
 }