public WalletService(UserSession userSession, IHttpClientFactory httpClientFactory, CachedSettings cachedSettings, IDatabaseManager databaseManager, ILogger <WalletService> logger) { this.userSession = userSession; this.httpClientFactory = httpClientFactory; this.databaseManager = databaseManager; this.logger = logger; if (cachedSettings.ConfigSettings.TryGetValue(URL_WALLETPROXY, out ConfigurationSetting so)) { proxyUrl = so.Value; } else { using (var db = databaseManager.GetReadOnlyDatabase()) { if (string.IsNullOrEmpty(proxyUrl)) { proxyUrl = db.ConfigurationSettings .Where(s => s.Name == URL_WALLETPROXY) .AsNoTracking() .FirstOrDefault().Value; } } } extraInfo = userSession.ExtraInfo ?? string.Empty; if (cachedSettings.OperatorsById.TryGetValue(userSession.User.OperatorId, out Operator op)) { enableEndGame = op.EnableEndGame; } }
private IDictionary <string, IList <CachedSettings> > GetAllSetingsCached() { string key = string.Format(SETTINGS_ALL_KEY); return(_cacheManager.Get(key, () => { var query = from setting in _settingRepository.AsNoTracking orderby setting.Name, setting.Id select setting; IDictionary <string, IList <CachedSettings> > allSettings = new Dictionary <string, IList <CachedSettings> >(); foreach (var setting in query) { CachedSettings cachedSettings = new CachedSettings() { Id = setting.Id, StoreId = setting.StoreId, Name = setting.Name.ToLowerInvariant(), Value = setting.Value }; if (!allSettings.ContainsKey(cachedSettings.Name)) { allSettings.Add(cachedSettings.Name, new List <CachedSettings>() { cachedSettings }); } else { allSettings[cachedSettings.Name].Add(cachedSettings); } } return allSettings; })); }
public TournamentService(IDatabaseManager databaseManager, CachedSettings cachedSettings, ILogger <TournamentService> logger) { this.databaseManager = databaseManager; this.cachedSettings = cachedSettings; this.logger = logger; }
public AuthenticationService(IDistributedCache cache, CachedSettings cachedSettings, IHttpClientFactory httpClientFactory, ILogger <AuthenticationService> logger) { this.cache = cache; this.cachedSettings = cachedSettings; this.httpClientFactory = httpClientFactory; this.logger = logger; }
public Dictionary <string, string> GatherSettings() { CachedSettings.Clear(); foreach (var settingMapper in SettingMappings) { CachedSettings.Add(settingMapper.Key, settingMapper.Value.Load()); } SettingChangeEmitters.ForEach(emitter => emitter(CachedSettings)); return(CachedSettings.ToDictionary(entry => entry.Key, entry => entry.Value)); }
public void UpdateSetting(string setting, string value) { if (!CachedSettings.ContainsKey(setting)) { CachedSettings.Add(setting, value); } else { CachedSettings[setting] = value; } }
public BonusGameRequestBuilder(IUserService userService, IGameService gameService, CachedSettings cachedSettings, IHttpContextAccessor httpContextAccessor, ILogger <BonusGameRequestBuilder> logger) { this.userService = userService; this.gameService = gameService; this.cachedSettings = cachedSettings; this.httpContextAccessor = httpContextAccessor; this.logger = logger; }
public static async Task <Result <RequestContext <T>, ErrorCode> > Build <T>( IUserService userService, IGameService gameService, CachedSettings cachedSettings, IHttpContextAccessor httpContextAccessor, string sessionKey, string gameKey) { var userSession = await userService.GetUserSession(sessionKey); if (userSession == null) { return(ErrorCode.SessionExpired); } var query = httpContextAccessor.HttpContext.Request.Query; if (!query.TryGetString("platform", out string platform)) { platform = "web"; } var requestContext = new RequestContext <T>(sessionKey, gameKey, GetPlatformType(platform)) { Query = query, UserSession = userSession, Currency = userSession.User.Currency }; if (!gameService.CheckAvailability(gameKey, userSession.User.OperatorId, out Game game)) { return(ErrorCode.InvalidGame); } requestContext.Game = game; if (!cachedSettings.OperatorsById.TryGetValue(userSession.User.OperatorId, out Operator op)) { return(ErrorCode.SessionExpired); } requestContext.Operator = op; var gameSettingKey = string.Format("{0}-{1}-{2}", op.GameSettingGroupId, game.Id, userSession.User.CurrencyId); if (!cachedSettings.GameSettings.TryGetValue(gameSettingKey, out GameSetting gameSetting)) { return(ErrorCode.MissingGameSetting); } requestContext.GameSetting = gameSetting; requestContext.UserGameKey = new UserGameKey(userSession.User.Id, game.Id); return(requestContext); }
public UserService(IDatabaseManager databaseManager, IDistributedCache cache, CachedSettings cachedSettings, IHttpClientFactory httpClientFactory, IAuthenticationService authenticationService, ILoggerFactory loggerFactory) { this.databaseManager = databaseManager; this.cache = cache; this.cachedSettings = cachedSettings; this.httpClientFactory = httpClientFactory; this.authenticationService = authenticationService; this.loggerFactory = loggerFactory; logger = loggerFactory.CreateLogger <UserService>(); }
public static IServiceCollection AddCachedSettings(this IServiceCollection services) { return(services.AddSingleton(serviceProvider => { using (var scope = serviceProvider.CreateScope()) { var monitoring = scope.ServiceProvider.GetRequiredService <IMonitoringService>(); var logger = scope.ServiceProvider .GetRequiredService <ILoggerFactory>() .CreateLogger <CachedSettings>(); var configuration = scope.ServiceProvider.GetRequiredService <IConfiguration>(); var caching = new CachedSettings(logger, configuration); monitoring.TrackDependency("CachedSettings", "Load", caching.Load); return caching; } })); }
public void InstallService(IServiceCollection services, IConfiguration configuration) { var CacheSettings = new CachedSettings(); configuration.GetSection(nameof(CachedSettings)).Bind(CacheSettings); services.AddSingleton(CacheSettings); if (!CacheSettings.Enabled) { return; } services.AddSingleton <IConnectionMultiplexer>(_ => ConnectionMultiplexer.Connect(CacheSettings.ConnectionString)); services.AddStackExchangeRedisCache(option => option.Configuration = CacheSettings.ConnectionString); services.AddSingleton <ICacheService, CacheService>(); }
public MembersRepository( IHttpContextAccessor httpContextAccessor, IDatabaseManager databaseManager, CachedSettings cachedSettings, GamePayoutEngine gamePayoutEngine, PaylineRepository paylineRepository, SymbolRepository symbolRepository, HistoryDecoderFactory historyDecoderFactory, GameInfoRepository gameInfoRepository) { this.httpContextAccessor = httpContextAccessor; this.databaseManager = databaseManager; this.cachedSettings = cachedSettings; this.gamePayoutEngine = gamePayoutEngine; this.paylineRepository = paylineRepository; this.symbolRepository = symbolRepository; this.gameInfoRepository = gameInfoRepository; this.historyDecoderFactory = historyDecoderFactory; }
public GameService(GameModuleCollection gameModules, IUserService userService, IBonusService bonusService, IPayoutService payoutService, IGameHistoryService gameHistoryService, IGameTransactionService transactionService, IDistributedCache cache, CachedSettings cachedSettings, IValidationStrategy validator, ILogger <GameService> logger) { this.gameModules = gameModules; this.userService = userService; this.bonusService = bonusService; this.payoutService = payoutService; this.gameHistoryService = gameHistoryService; this.transactionService = transactionService; this.cache = cache; this.cachedSettings = cachedSettings; this.validator = validator; this.logger = logger; }
public AdminController(CachedSettings cachedSettings, ILogger <AdminController> logger) { this.cachedSettings = cachedSettings; this.logger = logger; }
public Dictionary <string, string> GetSettings() { return(CachedSettings.ToDictionary(entry => entry.Key, entry => entry.Value)); }
public FiltersController(CachedSettings cachedSettings) { this.cachedSettings = cachedSettings; }