Beispiel #1
0
        }// GetSheriffJackpots

        #endregion


        #region OMI
        private static OMIJackpot QueryOMIJackpot(string currency, string jackpotID, string operatorID)
        {
            string requestContent = string.Format(CultureInfo.InvariantCulture
                                                  , "{{\"@requestType\":\".GetJackpotInfoRequest\", \"currencyCode\" : \"{0}\", \"jackpotId\" : \"{1}\", \"operatorId\" : \"{2}\"}}"
                                                  , currency.SafeJavascriptStringEncode()
                                                  , jackpotID.SafeJavascriptStringEncode()
                                                  , operatorID.SafeJavascriptStringEncode()
                                                  );

            string         url     = ConfigurationManager.AppSettings["DefaultOMIJackpotJsonUrl"];
            HttpWebRequest request = HttpWebRequest.Create(url) as HttpWebRequest;

            request.Method      = "POST";
            request.ContentType = "application/json";
            request.KeepAlive   = false;
            using (Stream stream = request.GetRequestStream())
            {
                byte[] buffer = Encoding.UTF8.GetBytes(requestContent);
                stream.Write(buffer, 0, buffer.Length);
            }

            string json;

            try
            {
                HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                using (Stream stream = response.GetResponseStream())
                {
                    using (StreamReader sr = new StreamReader(stream))
                    {
                        json = sr.ReadToEnd();
                    }
                }
                response.Close();

                // {"@responseType":".GetJackpotInfoResponse","responseMsg":null,"responseMsgDetails":null,"dbg":null,"responseCode":0,"apiVersion":1,"currentValue":0.01409393942356109700,"currencyCode":"AUD","currencySymbol":"AUD","lastWagerTransactionId":null,"lastWonTS":null,"lastWonValue":null}
                JavaScriptSerializer jss        = new JavaScriptSerializer();
                OMIJackpot           omiJackpot = jss.Deserialize <OMIJackpot>(json);
                if (omiJackpot.responseCode != 0 || string.IsNullOrEmpty(omiJackpot.currencyCode))
                {
                    throw new Exception(json);
                }
                return(omiJackpot);
            }
            catch {}

            return(null);
        }
Beispiel #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