コード例 #1
0
 private ceDomainConfig EnsureDomainConfigExists()
 {
     SqlQuery<ceDomainConfig> query = new SqlQuery<ceDomainConfig>();
     ceDomainConfig config = query.SelectByKey(DomainManager.CurrentDomainID);
     if (config == null)
     {
         var domains = DomainManager.GetDomains();
         var domain = domains.First(d => d.DomainID == DomainManager.CurrentDomainID);
         config = new ceDomainConfig()
         {
             ID = DomainManager.CurrentDomainID,
             DomainID = DomainManager.CurrentDomainID,
             ApiUsername = Regex.Replace( domain.Name, @"[^a-zA-Z0-9]", "_", RegexOptions.Compiled),
             ApiWhitelistIP = "",
             TopWinnersDaysBack = 30,
             TopWinnersMaxRecords = 50,
             TopWinnersMinAmount = 10.00M,
             TopWinnersExcludeOtherOperators = false,
             ScalableThumbnailWidth = 376,
             ScalableThumbnailHeight = 250,
             GameLoaderDomain = string.Empty,
             GameResourceDomain = string.Empty,
             Ins = DateTime.Now,
         };
         query.Insert(config);
     }
     return config;
 }
コード例 #2
0
        public bool Delete(ceDomainConfig domain, long id, List <string> languages, out string error)
        {
            error = null;
            //var path = string.Format("/casino/games/{0}.game-information", id.ToString(CultureInfo.InvariantCulture));
            string path = string.Format("{0}/{1}.{2}", METADATA_PATH, id.ToString(CultureInfo.InvariantCulture), _metadataItemName);

            using (var sw = new StringWriter())
                using (var writer = new JsonTextWriter(sw))
                {
                    writer.WriteStartArray();
                    foreach (var language in languages)
                    {
                        writer.WriteValue(language);
                    }
                    writer.WriteEndArray();

                    var ret = MetadataClient.DeleteTranslation(domain, path, sw.ToString());
                    if (ret == "success")
                    {
                        return(true);
                    }

                    error = ret;
                    return(false);
                }
        }
コード例 #3
0
        public JsonResult SavePlayerCasinoConfigurationDefaultSetting(
            int lastPlayedGamesMaxRecords
            , bool lastPlayedGamesIsDuplicated
            , int lastPlayedGamesLastDayNum 
            ,
            int mostPlayedGamesLastDayNum
            , int mostPlayedGamesMinRoundCounts ,
            bool playerBiggestWinGamesIsDuplicated
            , int playerBiggestWinGamesLastDayNum
            , decimal playerBiggestWinGamesMinWinEURAmounts 
            )
        {
            if (!DomainManager.AllowEdit())
            {
                throw new Exception("Data modified is not allowed");
            }
            SqlQuery<ceDomainConfig> query = new SqlQuery<ceDomainConfig>();

            ceDomainConfig config = EnsureDomainConfigExists();
            config.LastPlayedGamesMaxRecords = lastPlayedGamesMaxRecords;
            config.LastPlayedGamesIsDuplicated = lastPlayedGamesIsDuplicated;
            config.LastPlayedGamesLastDayNum = lastPlayedGamesLastDayNum; 
            config.MostPlayedGamesLastDayNum = mostPlayedGamesLastDayNum;
            config.MostPlayedGamesMinRoundCounts = mostPlayedGamesMinRoundCounts;
            config.PlayerBiggestWinGamesIsDuplicated = playerBiggestWinGamesIsDuplicated;
            config.PlayerBiggestWinGamesLastDayNum = playerBiggestWinGamesLastDayNum;
            config.PlayerBiggestWinGamesMinWinEURAmounts = playerBiggestWinGamesMinWinEURAmounts;
            query.Update(config);

            CacheManager.ClearCache(Constant.DomainCacheKey);
            return this.Json(new { @success = true });
        }
コード例 #4
0
        public bool Update(ceDomainConfig domain, long id, Dictionary <string, string> translations, out string error)
        {
            error = null;
            //var path = string.Format("/casino/games/{0}.game-information", id.ToString(CultureInfo.InvariantCulture));
            string path = string.Format("{0}/{1}.{2}", METADATA_PATH, id.ToString(CultureInfo.InvariantCulture), _metadataItemName);

            using (var sw = new StringWriter())
                using (var writer = new JsonTextWriter(sw))
                {
                    writer.WriteStartObject();
                    foreach (var translation in translations)
                    {
                        writer.WritePropertyName(translation.Key);
                        writer.WriteValue(translation.Value);
                    }
                    writer.WriteEndObject();

                    var ret = MetadataClient.UpdateTranslation(domain, path, sw.ToString());
                    if (ret == "success")
                    {
                        return(true);
                    }

                    error = ret;
                    return(false);
                }
        }
コード例 #5
0
ファイル: MetadataClient.cs プロジェクト: tuanagps/Project1
        public static string GetDumpedTranslation(ceDomainConfig domain, string lang)
        {
            string url = string.Format(DUMP_TRANSLATION_URL
                                       , domain.MetadataUrl.DefaultIfNullOrWhiteSpace(DEFAULT_URL)
                                       , domain.TemplateID
                                       , lang
                                       );

            return(Download(url));
        }
コード例 #6
0
ファイル: MetadataClient.cs プロジェクト: tuanagps/Project1
        public static string GetPendingWithdrawalCfg(ceDomainConfig domain)
        {
            string url = string.Format(GET_METADATA_URL
                                       , domain.MetadataUrl.DefaultIfNullOrWhiteSpace(DEFAULT_URL)
                                       , domain.TemplateID
                                       , WebUtility.UrlEncode("/config/pending-withdrawal")
                                       );

            return(Download(url));
        }
コード例 #7
0
ファイル: MetadataClient.cs プロジェクト: tuanagps/Project1
        public static string GetExternalAuthCfg(ceDomainConfig domain)
        {
            string url = string.Format(GET_METADATA_URL
                                       , domain.MetadataUrl.DefaultIfNullOrWhiteSpace(DEFAULT_URL)
                                       , domain.TemplateID
                                       , WebUtility.UrlEncode("/config/external-authentication")
                                       );

            return(Download(url));
        }
コード例 #8
0
ファイル: MetadataClient.cs プロジェクト: tuanagps/Project1
        public static string GetBonuses(ceDomainConfig domain, GamMatrixAPI.VendorID vendor)
        {
            string url = string.Format(GET_METADATA_URL
                                       , domain.MetadataUrl.DefaultIfNullOrWhiteSpace(DEFAULT_URL)
                                       , domain.TemplateID
                                       , WebUtility.UrlEncode(string.Format("/config/gaming-accounts/{0}/bonus/*", vendor.ToString()))
                                       );

            return(Download(url));
        }
コード例 #9
0
ファイル: MetadataClient.cs プロジェクト: tuanagps/Project1
        public static string GetRegions(ceDomainConfig domain, string country)
        {
            string url = string.Format(GET_METADATA_URL
                                       , domain.MetadataUrl.DefaultIfNullOrWhiteSpace(DEFAULT_URL)
                                       , domain.TemplateID
                                       , WebUtility.UrlEncode(string.Format("/config/countries/{0}/*", country))
                                       );

            return(Download(url));
        }
コード例 #10
0
ファイル: MetadataClient.cs プロジェクト: tuanagps/Project1
        public static string GetTranslation(ceDomainConfig domain, string path)
        {
            string url = string.Format(GET_TRANSLATION_URL
                                       , domain.MetadataUrl.DefaultIfNullOrWhiteSpace(DEFAULT_URL)
                                       , domain.TemplateID
                                       , WebUtility.UrlEncode(path)
                                       );

            return(Download(url));
        }
コード例 #11
0
ファイル: MetadataClient.cs プロジェクト: tuanagps/Project1
        public static string DeleteTranslation(ceDomainConfig domain, string path, string translation)
        {
            string url = string.Format(DELETE_TRANSLATION_URL
                                       , domain.MetadataUrl.DefaultIfNullOrWhiteSpace(DEFAULT_URL)
                                       , domain.TemplateID
                                       , WebUtility.UrlEncode(path)
                                       );

            return(Upload(url, translation));
        }
コード例 #12
0
ファイル: MetadataClient.cs プロジェクト: tuanagps/Project1
        public static string GetCurrencies(ceDomainConfig domain)
        {
            string url = string.Format(GET_METADATA_URL
                                       , domain.MetadataUrl.DefaultIfNullOrWhiteSpace(DEFAULT_URL)
                                       , domain.TemplateID
                                       , WebUtility.UrlEncode("/config/currencies/*")
                                       );

            return(Download(url));
        }
コード例 #13
0
ファイル: MetadataClient.cs プロジェクト: tuanagps/Project1
        public static string GetPaymentMethodsInCategory(ceDomainConfig domain, string catetory)
        {
            string url = string.Format(GET_METADATA_URL
                                       , domain.MetadataUrl.DefaultIfNullOrWhiteSpace(DEFAULT_URL)
                                       , domain.TemplateID
                                       , WebUtility.UrlEncode(string.Format("/config/payment-method-categories/{0}/*", catetory))
                                       );

            return(Download(url));
        }
コード例 #14
0
ファイル: Translation.cs プロジェクト: tuanagps/Project1
        internal static Dictionary <ulong, string> Get(ceDomainConfig domain, string lang, bool reloadCache = false)
        {
            string cacheFile = MetadataFileCache.GetPathWithRegion <Translation>(domain.DomainID.ToString(CultureInfo.InvariantCulture), lang);

            if (reloadCache)
            {
                DelayUpdateCache <Dictionary <ulong, string> > .SetExpired(cacheFile);
            }

            Func <Dictionary <ulong, string> > func = () =>
            {
                Dictionary <ulong, string> dic = new Dictionary <ulong, string>();

                // {"6883073332696432216":"Immediately","8464306736891375262":"Visa Credit Card","11378931541622277876":"Free","15079650489870782597":""}
                string json = MetadataClient.GetDumpedTranslation(domain, lang);
                using (StringReader sr = new StringReader(json))
                    using (JsonTextReader reader = new JsonTextReader(sr))
                    {
                        if (!reader.Read() || reader.TokenType != JsonToken.StartObject)
                        {
                            throw new Exception("Unknown format from metadata");
                        }

                        while (reader.Read())
                        {
                            if (reader.TokenType == JsonToken.PropertyName && reader.ValueType == typeof(string))
                            {
                                ulong hash;
                                if (!ulong.TryParse(reader.Value as string, out hash))
                                {
                                    throw new Exception("Unknown format from metadata");
                                }
                                if (!reader.Read() || reader.TokenType != JsonToken.String)
                                {
                                    throw new Exception("Unknown format from metadata");
                                }

                                dic[hash] = reader.Value as string;
                            }
                        }
                    }

                return(dic);
            };

            Dictionary <ulong, string> cache = null;
            bool ret = DelayUpdateCache <Dictionary <ulong, string> > .TryGetValue(cacheFile, out cache, func, 3600);

            if (ret)
            {
                return(cache);
            }

            return(func());
        }
コード例 #15
0
        public JsonResult SaveVendors(VendorID[] enabledVendors
            , VendorID[] liveCasinoVendors
            , string cashierUrl
            , string lobbyUrl
            , string accountHistoryUrl
            , string mobileCashierUrl
            , string mobileLobbyUrl
            , string mobileAccountHistoryUrl
            , string domainDefaultCurrencyCode
            , string googleAnalyticsAccount
            , string gameLoaderDomain
            , string gameResourceDomain
            , short newStatusCasinoGameExpirationDays
            , short newStatusLiveCasinoGameExpirationDays
            )
        {
            if (!DomainManager.AllowEdit())
            {
                throw new Exception("Data modified is not allowed");
            }
            CasinoVendorAccessor.SetEnabledVendors(DomainManager.CurrentDomainID
                , Constant.SystemDomainID
                , enabledVendors
                , liveCasinoVendors
                );

            if (enabledVendors != null && enabledVendors.Length > 0)
            {
                SqlQuery<ceDomainConfig> query = new SqlQuery<ceDomainConfig>();

                ceDomainConfig config = EnsureDomainConfigExists();

                config.MobileCashierUrl = mobileCashierUrl;
                config.MobileLobbyUrl = mobileLobbyUrl;
                config.MobileAccountHistoryUrl = mobileAccountHistoryUrl;
                config.CashierUrl = cashierUrl;
                config.LobbyUrl = lobbyUrl;
                config.AccountHistoryUrl = accountHistoryUrl;
                config.DomainDefaultCurrencyCode = domainDefaultCurrencyCode;
                config.GoogleAnalyticsAccount = googleAnalyticsAccount;
                config.GameLoaderDomain = gameLoaderDomain;
                config.GameResourceDomain = gameResourceDomain;
                config.NewStatusCasinoGameExpirationDays = newStatusCasinoGameExpirationDays;
                config.NewStatusLiveCasinoGameExpirationDays = newStatusLiveCasinoGameExpirationDays;

                query.Update(config);
            }

            //CacheManager.ClearCache(Constant.GameListCachePrefix);
            //CacheManager.ClearCache(Constant.JackpotListCachePrefix);
            //CacheManager.ClearCache(Constant.VendorListCachePrefix);
            //CacheManager.ClearCache(Constant.DomainCacheKey);
            return this.Json(new { @success = true });
        }
コード例 #16
0
        public static string GetGameInformation(ceDomainConfig domain, long id, string lang)
        {
            Dictionary <long, CasinoGame> casinoGames = GetAll(domain);
            CasinoGame casinoGame;

            if (casinoGames.TryGetValue(id, out casinoGame))
            {
                return(casinoGame.GetGameInformation(lang));
            }

            return(null);
        }
コード例 #17
0
        public JsonResult SaveWcfApiCredentials(string wcfApiUsername, string wcfApiPassword)
        {
            if (!DomainManager.AllowEdit())
            {
                throw new Exception("Data modified is not allowed");
            }
            SqlQuery<ceDomainConfig> query = new SqlQuery<ceDomainConfig>();

            ceDomainConfig config = EnsureDomainConfigExists();
            config.WcfApiUsername = wcfApiUsername;
            config.WcfApiPassword = wcfApiPassword;
            query.Update(config);

            CacheManager.ClearCache(Constant.DomainCacheKey);
            return this.Json(new { @success = true });
        }
コード例 #18
0
        public JsonResult SaveRecommendationConfig(string recommendationExcludeGames
            ,int recommendationMaxPlayerRecords
            , int recommendationMaxGameRecords)
        {
            if (!DomainManager.AllowEdit())
            {
                throw new Exception("Data modified is not allowed");
            }
            SqlQuery<ceDomainConfig> query = new SqlQuery<ceDomainConfig>();

            ceDomainConfig config = EnsureDomainConfigExists();
            config.RecommendationExcludeGames = recommendationExcludeGames;
            config.RecommendationMaxPlayerRecords = recommendationMaxPlayerRecords;
            config.RecommendationMaxGameRecords = recommendationMaxGameRecords;
            query.Update(config);

            CE.BackendThread.ScalableThumbnailProcessor.Begin();
            CacheManager.ClearCache(Constant.DomainCacheKey);
            return this.Json(new { @success = true });
        }
コード例 #19
0
        public JsonResult SaveScalableThumbnailSetting(bool enableScalableThumbnail
            , int scalableThumbnailWidth
            , int scalableThumbnailHeight
            )
        {
            if (!DomainManager.AllowEdit())
            {
                throw new Exception("Data modified is not allowed");
            }
            SqlQuery<ceDomainConfig> query = new SqlQuery<ceDomainConfig>();

            ceDomainConfig config = EnsureDomainConfigExists();
            config.EnableScalableThumbnail = enableScalableThumbnail;
            config.ScalableThumbnailWidth = scalableThumbnailWidth;
            config.ScalableThumbnailHeight = scalableThumbnailHeight;
            query.Update(config);

            CE.BackendThread.ScalableThumbnailProcessor.Begin();
            CacheManager.ClearCache(Constant.DomainCacheKey);
            return this.Json(new { @success = true });
        }
コード例 #20
0
        public JsonResult SaveRecentWinnersDefaultSetting(int recentWinnersMaxRecords
            , decimal recentWinnersMinAmount
            , bool recentWinnersExcludeOtherOperators
            , bool recentWinnersReturnDistinctUserOnly
            )
        {
            if (!DomainManager.AllowEdit())
            {
                throw new Exception("Data modified is not allowed");
            }
            SqlQuery<ceDomainConfig> query = new SqlQuery<ceDomainConfig>();

            ceDomainConfig config = EnsureDomainConfigExists();
            config.RecentWinnersExcludeOtherOperators = recentWinnersExcludeOtherOperators;
            config.RecentWinnersMaxRecords = recentWinnersMaxRecords;
            config.RecentWinnersMinAmount = recentWinnersMinAmount;
            config.RecentWinnersReturnDistinctUserOnly = recentWinnersReturnDistinctUserOnly;
            query.Update(config);

            CacheManager.ClearCache(Constant.DomainCacheKey);
            return this.Json(new { @success = true });
        }
コード例 #21
0
        public List <Translation> Get(ceDomainConfig domain, long id)
        {
            //var path = string.Format("/casino/games/{0}.game-information", id.ToString(CultureInfo.InvariantCulture));
            string path = string.Format("{0}/{1}.{2}", METADATA_PATH, id.ToString(CultureInfo.InvariantCulture), _metadataItemName);
            var    json = MetadataClient.GetTranslation(domain, path);

            var translations = new List <Translation>();

            using (var sr = new StringReader(json))
                using (var reader = new JsonTextReader(sr))
                {
                    if (!reader.Read() || reader.TokenType != JsonToken.StartArray)
                    {
                        throw new Exception("Unknown format from metadata");
                    }

                    while (reader.Read())
                    {
                        if (reader.TokenType == JsonToken.StartObject)
                        {
                            var translation = Read(reader);
                            if (translation != null)
                            {
                                translations.Add(translation);
                            }
                        }
                        else if (reader.TokenType == JsonToken.EndArray)
                        {
                            break;
                        }
                        else
                        {
                            throw new Exception("Unknown format from metadata");
                        }
                    }
                }
            return(translations);
        }
コード例 #22
0
        public JsonResult SaveTopWinnersDefaultSetting(int topWinnersDaysBack
            , int topWinnersMaxRecords
            , decimal topWinnersMinAmount
            , bool topWinnersExcludeOtherOperators
            )
        {
            if (!DomainManager.AllowEdit())
            {
                throw new Exception("Data modified is not allowed");
            }
            SqlQuery<ceDomainConfig> query = new SqlQuery<ceDomainConfig>();

            ceDomainConfig config = EnsureDomainConfigExists();
            config.TopWinnersDaysBack = topWinnersDaysBack;
            config.TopWinnersExcludeOtherOperators = topWinnersExcludeOtherOperators;
            config.TopWinnersMaxRecords = topWinnersMaxRecords;
            config.TopWinnersMinAmount = topWinnersMinAmount;
            query.Update(config);

            CacheManager.ClearCache(Constant.TopWinnersCachePrefix);
            CacheManager.ClearCache(Constant.DomainCacheKey);
            return this.Json(new { @success = true });
        }
コード例 #23
0
ファイル: Translation.cs プロジェクト: tuanagps/Project1
        public static string GetByHash(ceDomainConfig domain, string lang, ulong hash)
        {
            Dictionary <ulong, string> dic = Get(domain, lang);
            string value = string.Empty;

            if (dic.TryGetValue(hash, out value))
            {
                // get the dic for domain
                ConcurrentDictionary <ulong, int> domainDic = null;
                while (!_dic.TryGetValue(domain.TemplateID, out domainDic))
                {
                    _dic.TryAdd(domain.TemplateID, new ConcurrentDictionary <ulong, int>());
                }
                for (; ;)
                {
                    int count = 0;
                    while (!domainDic.TryGetValue(hash, out count))
                    {
                        domainDic.TryAdd(hash, 0);
                    }

                    if (domainDic.TryUpdate(hash, count + 1, count))
                    {
                        break;
                    }
                }
                if ((Interlocked.Increment(ref _count) % 100) == 0)
                {
                    _count = 0;
                    ConcurrentDictionary <int, ConcurrentDictionary <ulong, int> > currentDic = _dic;
                    _dic = new ConcurrentDictionary <int, ConcurrentDictionary <ulong, int> >();
                    UploadStatistic(currentDic);
                }
                return(value);
            }
            return(string.Empty);
        }
コード例 #24
0
        public JsonResult SavePopularitySetting(bool popularityExcludeOtherOperators
            , PopularityCalculationMethod popularityCalculationMethod
            , int popularityDaysBack
            , bool popularityNotByCountry
            , string popularityConfigurationByCountry
            )
        {
            if (!DomainManager.AllowEdit())
            {
                throw new Exception("Data modified is not allowed");
            }
            SqlQuery<ceDomainConfig> query = new SqlQuery<ceDomainConfig>();

            ceDomainConfig config = EnsureDomainConfigExists();
            config.PopularityExcludeOtherOperators = popularityExcludeOtherOperators;
            config.PopularityCalculationMethod = popularityCalculationMethod;
            config.PopularityDaysBack = popularityDaysBack;
            config.PopularityNotByCountry = popularityNotByCountry;
            config.PopularityConfigurationByCountry = popularityConfigurationByCountry;
            query.Update(config);

            CacheManager.ClearCache(Constant.DomainCacheKey);
            return this.Json(new { @success = true });
        }
コード例 #25
0
        public JsonResult SaveApiCredentials(string apiUsername
            , string apiPassword
            , string apiWhitelistIP
            , string gameListChangedNotificationUrl
            )
        {
            if (!DomainManager.AllowEdit())
            {
                throw new Exception("Data modified is not allowed");
            }
            SqlQuery<ceDomainConfig> query = new SqlQuery<ceDomainConfig>();

            ceDomainConfig config = EnsureDomainConfigExists();
            config.ApiUsername = apiUsername;
            if( !string.IsNullOrWhiteSpace(apiPassword) )
                config.ApiPassword = apiPassword.MD5Hash();
            config.ApiWhitelistIP = apiWhitelistIP;
            config.GameListChangedNotificationUrl = gameListChangedNotificationUrl;
            query.Update(config);

            CacheManager.ClearCache(Constant.DomainCacheKey);

            return this.Json(new { @success = true });
        }
コード例 #26
0
        public static Dictionary <string, JackpotInfo> GetBetSoftJackpots(ceDomainConfig domain, string customUrl = null)
        {
            string filepath = Path.Combine(FileSystemUtility.GetWebSiteTempDirectory()
                                           , domain == null ? "BetSoftJackpotsFeeds.cache" : string.Format("BetSoftJackpotsFeeds.{0}.cache", domain.GetCfg(BetSoft.BankID))
                                           );
            Dictionary <string, JackpotInfo> cached = HttpRuntime.Cache[filepath] as Dictionary <string, JackpotInfo>;

            if (cached != null && string.IsNullOrEmpty(customUrl))
            {
                return(cached);
            }

            string url = "http://lobby.everymatrix.betsoftgaming.com/jackpots/jackpots_218.xml";

            if (domain != null && domain.DomainID != Constant.SystemDomainID)
            {
                url = string.Format(CultureInfo.InvariantCulture, BetSoft_URL, domain.GetCfg(BetSoft.BankID));
            }
            else
            {
                url = ConfigurationManager.AppSettings["SystemJackpotListUrl"];
            }

            url = customUrl ?? url;

            Func <Dictionary <string, JackpotInfo> > func = () =>
            {
                try
                {
                    Dictionary <string, JackpotInfo> jackpots = new Dictionary <string, JackpotInfo>(StringComparer.InvariantCultureIgnoreCase);

                    XDocument xDoc = XDocument.Load(url);
                    IEnumerable <XElement> elements = xDoc.Root.Elements("jackpotGame");
                    foreach (XElement elem in elements)
                    {
                        string      id = elem.Element("gameId").Value;
                        JackpotInfo jackpot;
                        if (!jackpots.TryGetValue(id, out jackpot))
                        {
                            jackpot = new JackpotInfo()
                            {
                                ID       = elem.Element("gameId").Value,
                                Name     = elem.Element("gameName").Value,
                                VendorID = VendorID.BetSoft,
                            };
                        }


                        string  currency = elem.Element("currencyCode").Value;
                        decimal amout    = decimal.Parse(elem.Element("jackpotAmount").Value, CultureInfo.InvariantCulture);

                        jackpot.Amounts[currency] = amout;

                        jackpots[jackpot.ID] = jackpot;
                    }

                    Dictionary <string, CurrencyExchangeRateRec> currencies = GamMatrixClient.GetCurrencyRates(Constant.SystemDomainID);
                    foreach (JackpotInfo jackpotInfo in jackpots.Values)
                    {
                        if (jackpotInfo.Amounts.Count == 0)
                        {
                            continue;
                        }

                        decimal amount = 0.00M;
                        if (jackpotInfo.Amounts.ContainsKey("EUR"))
                        {
                            amount = jackpotInfo.Amounts["EUR"];
                        }
                        else
                        {
                            amount = jackpotInfo.Amounts.First().Value;
                        }

                        foreach (string key in currencies.Keys)
                        {
                            if (!jackpotInfo.Amounts.ContainsKey(key))
                            {
                                jackpotInfo.Amounts[key] = amount;
                            }
                        }
                    }


                    if (jackpots.Count > 0 && string.IsNullOrEmpty(customUrl))
                    {
                        ObjectHelper.BinarySerialize <Dictionary <string, JackpotInfo> >(jackpots, filepath);
                    }
                    return(jackpots);
                }
                catch (Exception ex)
                {
                    Logger.Exception(ex);
                    throw;
                }
            };

            if (!string.IsNullOrEmpty(customUrl))
            {
                cached = func();
            }
            else if (!DelayUpdateCache <Dictionary <string, JackpotInfo> > .TryGetValue(filepath, out cached, func, 120))
            {
                cached = ObjectHelper.BinaryDeserialize <Dictionary <string, JackpotInfo> >(filepath, new Dictionary <string, JackpotInfo>());
            }

            return(cached);
        }
コード例 #27
0
        /// <summary>
        /// Get all the casino games for a specific vendor
        /// </summary>
        /// <param name="domain"></param>
        /// <param name="reloadCache"></param>
        /// <returns></returns>
        public static Dictionary <long, CasinoGame> GetAll(ceDomainConfig domain, bool reloadCache = false)
        {
            string cacheFile = MetadataFileCache.GetPath <CasinoGame>(domain.DomainID.ToString(CultureInfo.InvariantCulture));

            if (reloadCache)
            {
                DelayUpdateCache <Dictionary <long, CasinoGame> > .SetExpired(cacheFile);
            }

            Func <Dictionary <long, CasinoGame> > func = () =>
            {
                var dic = new Dictionary <long, CasinoGame>();

                try
                {
                    // {"8101":{"game-information":"12027250142368842869"},"8102":{"game-information":"5380242421959168179"}}
                    string json = MetadataClient.GetCasinoGames(domain);
                    using (StringReader sr = new StringReader(json))
                        using (JsonTextReader reader = new JsonTextReader(sr))
                        {
                            if (!reader.Read() || reader.TokenType != JsonToken.StartObject)
                            {
                                throw new Exception("Unknown format from metadata");
                            }

                            CasinoGame casinoGame = null;
                            while (reader.Read())
                            {
                                if (casinoGame == null)
                                {
                                    if (reader.TokenType == JsonToken.PropertyName)
                                    {
                                        casinoGame = new CasinoGame()
                                        {
                                            Domain = domain
                                        };
                                        dic[ConvertHelper.ToInt64(reader.Value)] = casinoGame;

                                        if (!reader.Read() || reader.TokenType != JsonToken.StartObject)
                                        {
                                            throw new Exception("Unknown format from metadata");
                                        }
                                    }
                                    else if (reader.TokenType == JsonToken.EndObject)
                                    {
                                        break;
                                    }
                                    else
                                    {
                                        throw new Exception("Unknown format from metadata");
                                    }
                                }
                                else
                                {
                                    if (reader.TokenType == JsonToken.EndObject)
                                    {
                                        casinoGame = null;
                                    }
                                    else if (reader.TokenType == JsonToken.PropertyName)
                                    {
                                        string propertyName = reader.Value.ToString().ToLowerInvariant();
                                        reader.Read();
                                        switch (propertyName)
                                        {
                                        case "game-information":
                                            casinoGame.GameInformationHash = ConvertHelper.ToUInt64(reader.Value);
                                            break;


                                        default:
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        throw new Exception("Unknown format from metadata");
                                    }
                                }
                            }
                        }
                }
                catch
                {
                }

                return(dic);
            };

            Dictionary <long, CasinoGame> cache = null;
            bool ret = DelayUpdateCache <Dictionary <long, CasinoGame> > .TryGetValue(cacheFile, out cache, func, 36000);

            if (ret)
            {
                return(cache);
            }

            return(func());
        }
コード例 #28
0
        public static Dictionary <string, JackpotInfo> GetSheriffJackpots(ceDomainConfig domain)
        {
            string filepath = Path.Combine(FileSystemUtility.GetWebSiteTempDirectory()
                                           , domain == null ? "SheriffJackpotsFeeds.cache" : string.Format("SheriffJackpotsFeeds.{0}.cache", domain.GetCfg(Sheriff.JackpotJsonURL).GetHashCode())
                                           );
            Dictionary <string, JackpotInfo> cached = HttpRuntime.Cache[filepath] as Dictionary <string, JackpotInfo>;

            if (cached != null)
            {
                return(cached);
            }

            // http://jetbull.nl1.gamingclient.com/jackpot/retrieve/{0}
            string urlFormat = null;

            if (domain != null)
            {
                urlFormat = domain.GetCfg(Sheriff.JackpotJsonURL);
            }
            if (string.IsNullOrWhiteSpace(urlFormat))
            {
                urlFormat = ConfigurationManager.AppSettings["DefaultSheriffJackpotJsonUrl"];
            }

            Func <Dictionary <string, JackpotInfo> > func = () =>
            {
                try
                {
                    Dictionary <string, JackpotInfo> jackpots = new Dictionary <string, JackpotInfo>(StringComparer.InvariantCultureIgnoreCase);

                    //List<ceCasinoGameBaseEx> games = CasinoGameAccessor.GetDomainGames(domain == null ? Constant.SystemDomainID : domain.DomainID)
                    //    .Where(g => g.VendorID == VendorID.Sheriff)
                    //    .ToList();

                    List <ceCasinoGameBaseEx> games = CacheManager.GetGameList(domain == null ? Constant.SystemDomainID : domain.DomainID, false, false)
                                                      .Where(g => g.VendorID == VendorID.Sheriff)
                                                      .ToList();


                    using (WebClient client = new WebClient())
                    {
                        JavaScriptSerializer jss = new JavaScriptSerializer();
                        Dictionary <string, CurrencyExchangeRateRec> currencies = GamMatrixClient.GetCurrencyRates(Constant.SystemDomainID);

                        foreach (ceCasinoGameBaseEx game in games)
                        {
                            string url  = string.Format(CultureInfo.InvariantCulture, urlFormat, HttpUtility.UrlEncode(game.GameCode));
                            string json = client.DownloadString(url);
                            if (!string.IsNullOrWhiteSpace(json))
                            {
                                try
                                {
                                    Dictionary <string, SheriffJackpot> j = jss.Deserialize <Dictionary <string, SheriffJackpot> >(json);
                                    if (j.Count > 0)
                                    {
                                        JackpotInfo jackpot = new JackpotInfo();
                                        jackpot.ID       = game.GameCode;
                                        jackpot.Name     = game.GameName;
                                        jackpot.VendorID = VendorID.Sheriff;

                                        // For Sheriff jackpors, the amount is always the same for all currencies
                                        foreach (string key in currencies.Keys)
                                        {
                                            SheriffJackpot sj = j.First().Value;
                                            if (sj.totalAmount.HasValue)
                                            {
                                                jackpot.Amounts[key] = sj.totalAmount.Value / 100.00M;
                                            }
                                            else
                                            {
                                                jackpot.Amounts[key] = sj.amount / 100.00M;
                                            }
                                        }
                                        jackpots[jackpot.ID] = jackpot;
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Logger.Exception(ex, string.Format(@" Sheriff - Jackpots URL : {0}", url));
                                }
                            }
                        }
                    }


                    if (jackpots.Count > 0)
                    {
                        ObjectHelper.BinarySerialize <Dictionary <string, JackpotInfo> >(jackpots, filepath);
                    }
                    return(jackpots);
                }
                catch (Exception ex)
                {
                    Logger.Exception(ex);
                    throw;
                }
            };

            if (!DelayUpdateCache <Dictionary <string, JackpotInfo> > .TryGetValue(filepath, out cached, func, 120))
            {
                cached = ObjectHelper.BinaryDeserialize <Dictionary <string, JackpotInfo> >(filepath, new Dictionary <string, JackpotInfo>());
            }

            return(cached);
        }// GetSheriffJackpots
コード例 #29
0
        public static Dictionary <string, JackpotInfo> GetOMIJackpots(ceDomainConfig domain)
        {
            string omiOperatorID = ConfigurationManager.AppSettings["DefaultOMIOperatorID"];

            if (domain != null && !string.IsNullOrEmpty(domain.GetCfg(OMI.OperatorID)))
            {
                omiOperatorID = domain.GetCfg(OMI.OperatorID);
            }

            string filepath = Path.Combine(FileSystemUtility.GetWebSiteTempDirectory()
                                           , string.Format(CultureInfo.InvariantCulture, "OMIJackpotsFeeds.{0}.cache", omiOperatorID)
                                           );
            Dictionary <string, JackpotInfo> cached = HttpRuntime.Cache[filepath] as Dictionary <string, JackpotInfo>;

            if (cached != null)
            {
                return(cached);
            }

            // https://vegasinstallation.com/gserver/api/game/slot


            Func <Dictionary <string, JackpotInfo> > func = () =>
            {
                try
                {
                    string   str = "ARS,AUD,BRL,BGN,CAD,CHF,CNY,CZK,DKK,EUR,GBP,GEL,HKD,HUF,HRK,IDR,ISK,JPY,LTL,LVL,MXN,MYR,NGN,NOK,NZD,PLN,RON,RUB,SEK,SGD,THB,TRY,TWD,UAH,USD,VEF,ZAR";
                    string[] omiSupportCurrencies = str.ToUpperInvariant().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                    Dictionary <string, CurrencyExchangeRateRec> currencies = GamMatrixClient.GetCurrencyRates(Constant.SystemDomainID);
                    Dictionary <string, JackpotInfo>             jackpots   = new Dictionary <string, JackpotInfo>(StringComparer.InvariantCultureIgnoreCase);

                    // hard-coded jackpotId:
                    //  The jackpot id. For Jungle Fruits:"201", For Benny The Panda: "202" for maxi, "203" for mini
                    string[] jackpotIDs = new string[] { "201", "202", "203" };
                    string   strFailed  = "";
                    foreach (string jackpotID in jackpotIDs)
                    {
                        OMIJackpot omiJackpot = QueryOMIJackpot("EUR", jackpotID, omiOperatorID);

                        JackpotInfo jackpot;
                        jackpot = new JackpotInfo()
                        {
                            ID       = jackpotID,
                            Name     = jackpotID,
                            VendorID = VendorID.OMI,
                        };
                        jackpot.Amounts[omiJackpot.currencyCode] = omiJackpot.currentValue;


                        foreach (string key in currencies.Keys)
                        {
                            if (key.ToUpperInvariant() == "EUR" || !omiSupportCurrencies.Contains(key.ToUpperInvariant()))
                            {
                                continue;
                            }
                            omiJackpot = QueryOMIJackpot(key, jackpotID, omiOperatorID);
                            if (omiJackpot != null)
                            {
                                jackpot.Amounts[omiJackpot.currencyCode] = omiJackpot.currentValue;
                            }
                            else
                            {
                                strFailed += string.Format("jackpotID: {0}, currency: {1} /n", jackpotID, key);
                            }
                        }

                        jackpots[jackpot.ID] = jackpot;
                    }// foreach

                    if (!string.IsNullOrWhiteSpace(strFailed))
                    {
                        Logger.Information("OMI jackpots /n" + strFailed);
                    }
                    if (jackpots.Count > 0)
                    {
                        ObjectHelper.BinarySerialize <Dictionary <string, JackpotInfo> >(jackpots, filepath);
                    }
                    return(jackpots);
                }
                catch (Exception ex)
                {
                    Logger.Exception(ex, string.Format(" OMI - omiOperatorID : {0}", omiOperatorID));
                    throw;
                }
            };// Func

            if (!DelayUpdateCache <Dictionary <string, JackpotInfo> > .TryGetValue(filepath, out cached, func, 300))
            {
                cached = ObjectHelper.BinaryDeserialize <Dictionary <string, JackpotInfo> >(filepath, new Dictionary <string, JackpotInfo>());
            }

            return(cached);
        }// GetOMIJackpots
コード例 #30
0
        /// <summary>
        /// Get All the languages for the current domain
        /// </summary>
        /// <param name="domain"></param>
        /// <param name="reloadCache"></param>
        /// <returns></returns>
        public static Language[] GetAll(ceDomainConfig domain, bool reloadCache = false)
        {
            string cacheFile = MetadataFileCache.GetPath <Language>(domain.DomainID.ToString(CultureInfo.InvariantCulture));

            if (reloadCache)
            {
                DelayUpdateCache <Dictionary <string, Language> > .SetExpired(cacheFile);
            }

            Func <Language[]> func = () =>
            {
                List <Language> list = new List <Language>();

                // {"ar":{"name":"\u0627\u0644\u0639\u0631\u0628\u064A\u0629"},"cs":{"name":"\u010Ce\u0161tina"},"en":{"name":"English"}}
                string json = MetadataClient.GetLanguages(domain);
                using (StringReader sr = new StringReader(json))
                    using (JsonTextReader reader = new JsonTextReader(sr))
                    {
                        if (!reader.Read() || reader.TokenType != JsonToken.StartObject)
                        {
                            throw new Exception("Unknown format from metadata");
                        }

                        Language lang = null;
                        while (reader.Read())
                        {
                            if (lang == null)
                            {
                                if (reader.TokenType == JsonToken.PropertyName && reader.ValueType == typeof(string))
                                {
                                    lang = new Language()
                                    {
                                        RFC1766 = reader.Value as string
                                    };
                                    if (!reader.Read() || reader.TokenType != JsonToken.StartObject)
                                    {
                                        throw new Exception("Unknown format from metadata");
                                    }
                                }
                                else if (reader.TokenType == JsonToken.EndObject)
                                {
                                    break;
                                }
                                else
                                {
                                    throw new Exception("Unknown format from metadata");
                                }
                            }
                            else
                            {
                                if (reader.TokenType == JsonToken.EndObject)
                                {
                                    list.Add(lang);
                                    lang = null;
                                }
                                else if (reader.TokenType == JsonToken.PropertyName)
                                {
                                    if (reader.ValueType == typeof(string) &&
                                        reader.Value as string == "name")
                                    {
                                        if (!reader.Read() || reader.TokenType != JsonToken.String)
                                        {
                                            throw new Exception("Unknown format from metadata");
                                        }
                                        lang.DisplayName = reader.Value as string;
                                    }
                                }
                                else
                                {
                                    throw new Exception("Unknown format from metadata");
                                }
                            }
                        }
                    }

                return(list.ToArray());
            };

            Language[] cache = null;
            bool       ret   = DelayUpdateCache <Language[]> .TryGetValue(cacheFile, out cache, func, 36000);

            if (ret)
            {
                return(cache);
            }

            return(func());
        }