コード例 #1
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
コード例 #2
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
コード例 #3
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);
        }