Example #1
0
        private string Request <T>(T request, string path) where T : GmGamingRequestBase
        {
            using (GamMatrixClient gmClient = new GamMatrixClient())
            {
                request.SessionId = gmClient.GetApiParameters(request.DomainId, false).SessionID;
            }

            JObject jObj = JObject.FromObject(request);

            return(Post(jObj.ToString(), path));
        }
        private LiveCasinoTableLimit ParseLimit()
        {
            LiveCasinoTableLimit limit = new LiveCasinoTableLimit();

            limit.BaseCurrency = Request.Form["baseCurrency"];

            decimal amount;

            if (decimal.TryParse(Request.Form["baseCurrencyMinAmount"], out amount))
            {
                limit.BaseLimit.MinAmount = amount;
            }
            if (decimal.TryParse(Request.Form["baseCurrencyMaxAmount"], out amount))
            {
                limit.BaseLimit.MaxAmount = amount;
            }

            CurrencyData[] currencies = GamMatrixClient.GetSupportedCurrencies();
            foreach (CurrencyData currency in currencies)
            {
                LimitAmount limitAmount = new LimitAmount();
                string      key         = string.Format("minAmount_{0}", currency.ISO4217_Alpha);
                if (decimal.TryParse(Request.Form[key], out amount))
                {
                    limitAmount.MinAmount = amount;
                }

                key = string.Format("maxAmount_{0}", currency.ISO4217_Alpha);
                if (decimal.TryParse(Request.Form[key], out amount))
                {
                    limitAmount.MaxAmount = amount;
                }

                limit.CurrencyLimits[currency.ISO4217_Alpha] = limitAmount;
            }

            LiveCasinoTableLimitType t;

            if (Enum.TryParse <LiveCasinoTableLimitType>(Request.Form["limitType"], out t))
            {
                limit.Type = t;
            }

            if (limit.Type == LiveCasinoTableLimitType.SameForAllCurrency ||
                limit.Type == LiveCasinoTableLimitType.AutoConvertBasingOnCurrencyRate)
            {
                if (limit.BaseLimit.MinAmount >= limit.BaseLimit.MaxAmount)
                {
                    limit.Type = LiveCasinoTableLimitType.None;
                }
            }

            return(limit);
        }
Example #3
0
        private Dictionary <string, LimitAmount> GetCurrencyLimitAmount(ceLiveCasinoTableBaseEx table)
        {
            Dictionary <string, LimitAmount> dic = new Dictionary <string, LimitAmount>(StringComparer.InvariantCultureIgnoreCase);

            CurrencyData [] currencies = GamMatrixClient.GetSupportedCurrencies();
            if (table.Limit.Type == LiveCasinoTableLimitType.AutoConvertBasingOnCurrencyRate)
            {
                foreach (CurrencyData currency in currencies)
                {
                    dic[currency.ISO4217_Alpha] = new LimitAmount()
                    {
                        MinAmount = GamMatrixClient.TransformCurrency(table.Limit.BaseCurrency, currency.ISO4217_Alpha, table.Limit.BaseLimit.MinAmount),
                        MaxAmount = GamMatrixClient.TransformCurrency(table.Limit.BaseCurrency, currency.ISO4217_Alpha, table.Limit.BaseLimit.MaxAmount),
                    };
                }
            }
            else if (table.Limit.Type == LiveCasinoTableLimitType.SameForAllCurrency)
            {
                foreach (CurrencyData currency in currencies)
                {
                    dic[currency.ISO4217_Alpha] = new LimitAmount()
                    {
                        MinAmount = table.Limit.BaseLimit.MinAmount,
                        MaxAmount = table.Limit.BaseLimit.MaxAmount,
                    };
                }
            }
            else if (table.Limit.Type == LiveCasinoTableLimitType.SpecificForEachCurrency)
            {
                foreach (var limit in table.Limit.CurrencyLimits)
                {
                    if (limit.Value.MaxAmount == 0.00M)
                    {
                        continue;
                    }

                    dic[limit.Key] = new LimitAmount()
                    {
                        MinAmount = limit.Value.MinAmount,
                        MaxAmount = limit.Value.MaxAmount,
                    };
                }
            }

            return(dic);
        }
Example #4
0
        private static ulong ParseXProLiveCasinoGameList(ceDomainConfigEx domain)
        {
            try
            {
                using (GamMatrixClient client = new GamMatrixClient())
                {
                    XProGamingAPIRequest request = new XProGamingAPIRequest()
                    {
                        GetGamesListWithLimits           = true,
                        GetGamesListWithLimitsGameType   = (int)XProGaming.GameType.AllGames,
                        GetGamesListWithLimitsOnlineOnly = 0,
                        //GetGamesListWithLimitsUserName = "******"
                    };
                    request = client.SingleRequest <XProGamingAPIRequest>(domain.DomainID, request);

                    if (string.IsNullOrWhiteSpace(request.GetGamesListWithLimitsResponse))
                    {
                        return(0L);
                    }

                    string xml = request.GetGamesListWithLimitsResponse;
                    XProGaming.Game.ParseXml(domain.DomainID, xml);

                    return(CRC64.ComputeAsAsciiString(xml));
                }
            }
            catch (GmException gex)
            {
                if (gex.ReplyResponse.ErrorCode == "SYS_1008")
                {
                    return(0L);
                }
                Logger.Exception(gex);
            }
            catch (Exception ex)
            {
                Logger.Exception(ex);
            }
            return(0L);
        }
Example #5
0
        private static List <VivoActiveTable> GetRawActiveTables(long domainID, long operatorID, string gameName, string currency)
        {
            List <VivoActiveTable> list = new List <VivoActiveTable>();

            using (GamMatrixClient client = new GamMatrixClient())
            {
                VivoGetActiveTablesRequest request = new VivoGetActiveTablesRequest()
                {
                    GameName        = gameName,
                    OperatorID      = operatorID,
                    PlayerCurrency  = currency,
                    ContextDomainID = domainID,
                };
                request = client.SingleRequest <VivoGetActiveTablesRequest>(domainID, request);
                if (request != null)
                {
                    list = request.ActiveTables;
                }
            }

            return(list);
        }
Example #6
0
        public static Dictionary <string, JackpotInfo> GetIGTJackpots(long domainID, string customUrl = null)
        {
            string filepath = Path.Combine(FileSystemUtility.GetWebSiteTempDirectory()
                                           , string.Format("IGTJackpotsFeeds.{0}.cache", domainID)
                                           );
            Dictionary <string, JackpotInfo> cached = HttpRuntime.Cache[filepath] as Dictionary <string, JackpotInfo>;

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

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

                    var domain = DomainManager.GetDomains().FirstOrDefault(d => d.DomainID == domainID);
                    if (domain == null && DomainManager.GetSysDomain().DomainID == domainID)
                    {
                        domain = DomainManager.GetSysDomain();
                    }

                    if (domain == null)
                    {
                        throw new Exception("domain can't be found");
                    }

                    string jackpotBaseURL = domain.GetCfg(IGT.JackpotBaseURL);
                    string url;
                    if (string.IsNullOrWhiteSpace(jackpotBaseURL))
                    {
                        url = customUrl ?? string.Format(IGT_URL, "0001");
                    }
                    else
                    {
                        url = customUrl ?? string.Format(jackpotBaseURL, "0001");
                    }

                    XDocument   xDoc    = XDocument.Load(url);
                    JackpotInfo jackpot = new JackpotInfo()
                    {
                        ID       = xDoc.Root.Element("jackpotid").Value,
                        Name     = xDoc.Root.Element("jackpotid").Value,
                        VendorID = VendorID.IGT,
                    };


                    // Only 1 IGT jackpot
                    Dictionary <string, CurrencyExchangeRateRec> currencies = GamMatrixClient.GetCurrencyRates(Constant.SystemDomainID);
                    string  currency = "EUR";
                    decimal amout    = decimal.Parse(xDoc.Root.Element("currentvalue").Value, CultureInfo.InvariantCulture);

                    foreach (string key in currencies.Keys)
                    {
                        jackpot.Amounts[key] = GamMatrixClient.TransformCurrency(currency, key, amout);
                    }

                    jackpots[jackpot.ID] = jackpot;

                    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);
        }
Example #7
0
        /// <summary>
        /// Returns the jackpots
        /// </summary>
        /// <returns></returns>
        public static Dictionary <string, JackpotInfo> GetMicrogamingJackpots(string customUrl = null)
        {
            string filepath = Path.Combine(FileSystemUtility.GetWebSiteTempDirectory(), "MicrogamingJackpotFeeds.cache");
            Dictionary <string, JackpotInfo> cached = HttpRuntime.Cache[filepath] as Dictionary <string, JackpotInfo>;

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

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

                    XDocument xDoc     = XDocument.Load(customUrl ?? MG_URL);
                    var       counters = xDoc.Root.Elements("Counter");
                    foreach (XElement counter in counters)
                    {
                        try
                        {
                            JackpotInfo jackpot = new JackpotInfo()
                            {
                                ID       = counter.Element("jackpotID").Value,
                                Name     = counter.Element("jackpotName").Value,
                                VendorID = VendorID.Microgaming,
                            };

                            // For Microgaming jackpors, the amount is always the same for all currencies
                            Dictionary <string, CurrencyExchangeRateRec> currencies = GamMatrixClient.GetCurrencyRates(Constant.SystemDomainID);
                            foreach (string key in currencies.Keys)
                            {
                                jackpot.Amounts[key] = decimal.Parse(counter.Element("jackpotCValue").Value, CultureInfo.InvariantCulture) / 100.00M;
                            }
                            jackpots[jackpot.ID] = jackpot;
                        }
                        catch
                        {
                        }
                    }
                    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);
        }
Example #8
0
        public static Dictionary <string, JackpotInfo> GetPlaynGOJackpots(long domainID, string customUrl = null)
        {
            string filepath = Path.Combine(FileSystemUtility.GetWebSiteTempDirectory()
                                           , string.Format("PlaynGOJackpotsFeeds.{0}.cache", domainID)
                                           );
            Dictionary <string, JackpotInfo> cached = HttpRuntime.Cache[filepath] as Dictionary <string, JackpotInfo>;

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

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

                    DomainConfigAccessor dca    = DomainConfigAccessor.CreateInstance <DomainConfigAccessor>();
                    ceDomainConfigEx     config = dca.GetByDomainID(domainID);

                    if (config != null)
                    {
                        url = customUrl ?? string.Format(PlaynGO_URL, config.GetCfg(PlaynGO.PID).DefaultIfNullOrEmpty("71"));
                        PlaynGOJackpot[] objects = null;

                        HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
                        request.Timeout = 50000;
                        using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                            using (Stream stream = response.GetResponseStream())
                                using (StreamReader sr = new StreamReader(stream))
                                {
                                    string json = sr.ReadToEnd();
                                    JavaScriptSerializer jss = new JavaScriptSerializer();
                                    objects = jss.Deserialize <PlaynGOJackpot[]>(json);
                                }


                        if (objects != null)
                        {
                            foreach (PlaynGOJackpot obj in objects)
                            {
                                JackpotInfo jackpot = new JackpotInfo()
                                {
                                    ID       = obj.JackpotId.ToString(),
                                    Name     = obj.Description,
                                    VendorID = VendorID.PlaynGO,
                                };

                                // Only 1 IGT jackpot
                                Dictionary <string, CurrencyExchangeRateRec> currencies = GamMatrixClient.GetCurrencyRates(Constant.SystemDomainID);
                                string  currency = obj.Currency;
                                decimal amout    = obj.BaseAmount;

                                foreach (string key in currencies.Keys)
                                {
                                    jackpot.Amounts[key] = GamMatrixClient.TransformCurrency(currency, key, amout);
                                }

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

                    if (jackpots.Count > 0 && string.IsNullOrEmpty(customUrl))
                    {
                        ObjectHelper.BinarySerialize <Dictionary <string, JackpotInfo> >(jackpots, filepath);
                    }
                    return(jackpots);
                }
                catch (Exception ex)
                {
                    Logger.Exception(ex, string.Format(@" PlaynGO - Jackpots URL : {0}", url));
                    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);
        }
Example #9
0
        /// <summary>
        /// Get CTXM jackpots
        /// </summary>
        /// <returns></returns>
        public static Dictionary <string, JackpotInfo> GetCTXMJackpots(long domainID)
        {
            string filepath = Path.Combine(FileSystemUtility.GetWebSiteTempDirectory()
                                           , string.Format("CTXMJackpotsFeeds.{0}.cache", domainID)
                                           );
            Dictionary <string, JackpotInfo> cached = HttpRuntime.Cache[filepath] as Dictionary <string, JackpotInfo>;

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

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

                    using (GamMatrixClient client = new GamMatrixClient())
                    {
                        //CTXMAPIRequest request = new CTXMAPIRequest()
                        //{
                        //    GetJackpotList = true,
                        //    GetJackpotListCurrency = "EUR",
                        //    GetJackpotListLanguage = "en",
                        //};
                        //request = client.SingleRequest<CTXMAPIRequest>(domainID, request);

                        //foreach (GamMatrixAPI.JackpotType j in request.GetJackpotListResponse.jackpotsField)
                        //{
                        //    JackpotInfo jackpot = new JackpotInfo()
                        //    {
                        //        ID = j.campaignIdField,
                        //        Name = j.campaignNameField,
                        //        VendorID = VendorID.CTXM,
                        //    };

                        //    // For CTXM jackpots, the amount is always converted from the primary currency
                        //    Dictionary<string, CurrencyExchangeRateRec> currencies = GamMatrixClient.GetCurrencyRates(Constant.SystemDomainID);
                        //    string currency = j.currencyField;
                        //    decimal amout = j.jackpotAmountField.Value;

                        //    foreach (string key in currencies.Keys)
                        //    {
                        //        jackpot.Amounts[key] = GamMatrixClient.TransformCurrency(currency, key, amout);
                        //    }
                        //    jackpots[jackpot.ID] = jackpot;
                        //}
                    }

                    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);
        }
Example #10
0
        /// <summary>
        /// Get NetEnt Jackpots
        /// </summary>
        /// <returns></returns>
        public static Dictionary <string, JackpotInfo> GetNetEntJackpots(long domainID)
        {
            string filepath = Path.Combine(FileSystemUtility.GetWebSiteTempDirectory()
                                           , "NetEntJackpotFeeds.cache"
                                           );
            Dictionary <string, JackpotInfo> cached = HttpRuntime.Cache[filepath] as Dictionary <string, JackpotInfo>;

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

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

                    using (GamMatrixClient client = new GamMatrixClient())
                    {
                        NetEntAPIRequest request = new NetEntAPIRequest()
                        {
                            GetIndividualJackpotInfo         = true,
                            GetIndividualJackpotInfoCurrency = "EUR",
                        };
                        request = client.SingleRequest <NetEntAPIRequest>(domainID, request);

                        foreach (GamMatrixAPI.Jackpot j in request.GetIndividualJackpotInfoResponse)
                        {
                            if (!j.currentJackpotValueField.amountField.HasValue)
                            {
                                continue;
                            }

                            JackpotInfo jackpot = new JackpotInfo()
                            {
                                ID       = j.jackpotNameField,
                                Name     = j.jackpotNameField,
                                VendorID = VendorID.Neteller,
                            };
                            // For NetEnt jackpots, the amount is always converted from the primary currency
                            Dictionary <string, CurrencyExchangeRateRec> currencies = GamMatrixClient.GetCurrencyRates(Constant.SystemDomainID);
                            string  currency = j.currentJackpotValueField.amountCurrencyISOCodeField;
                            decimal amout    = j.currentJackpotValueField.amountField.Value;

                            foreach (string key in currencies.Keys)
                            {
                                jackpot.Amounts[key] = GamMatrixClient.TransformCurrency(currency, key, amout);
                            }

                            jackpots[jackpot.ID] = jackpot;
                        }
                    }

                    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);
        }
Example #11
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
    public override void OnAuthorization(AuthorizationContext filterContext)
    {
        if (filterContext == null)
        {
            throw new ArgumentNullException("filterContext");
        }

        HttpRequestBase request   = filterContext.RequestContext.HttpContext.Request;
        string          sessionID = request.QueryString["session_id"];

        if (string.Equals(request.HttpMethod, "GET", StringComparison.OrdinalIgnoreCase) &&
            !filterContext.RequestContext.HttpContext.Request.IsAjaxRequest())
        {
            HttpCookie cookie = filterContext.RequestContext.HttpContext.Request.Cookies["gmcoresid"];
            if (!string.IsNullOrWhiteSpace(sessionID) ||
                (cookie != null && !string.IsNullOrEmpty(cookie.Value) && !CurrentUserSession.IsAuthenticated))
            {
                if (string.IsNullOrWhiteSpace(sessionID))
                {
                    sessionID = cookie.Value;
                }

                using (GamMatrixClient client = new GamMatrixClient())
                {
                    ReplyResponse replyResp = client.IsLoggedIn(new IsLoggedInRequest()
                    {
                        SESSION_ID = sessionID
                    });
                    IsLoggedInRequest resp = replyResp.Reply as IsLoggedInRequest;
                    if (replyResp.Success &&
                        resp != null &&
                        resp.IsLoggedIn &&
                        null != resp.UserProfile.RolesByName.FirstOrDefault(r => string.Equals(r, "Casino Engine Manager", StringComparison.InvariantCultureIgnoreCase)))
                    {
                        CurrentUserSession.IsAuthenticated = true;
                        CurrentUserSession.IsSuperUser     = resp.UserProfile.IsSuperUser;
                        CurrentUserSession.Roles           = resp.UserProfile.RolesByName.ToArray();
                        CurrentUserSession.UserDomainID    = resp.UserProfile.DomainID;
                        CurrentUserSession.UserID          = resp.UserProfile.UserRec.ID;

                        if (!string.IsNullOrWhiteSpace(request.QueryString["d_si"]))
                        {
                            bool showInactiveDomains = string.Equals(request.QueryString["d_si"], "1", StringComparison.InvariantCulture);
                            CurrentUserSession.ShowInactiveDomains = showInactiveDomains;
                        }

                        cookie          = new HttpCookie("gmcoresid", sessionID);
                        cookie.HttpOnly = true;
                        filterContext.RequestContext.HttpContext.Response.Cookies.Add(cookie);
                        filterContext.Result = new RedirectResult(FilterUrlQueryString(request).ToString());
                        return;
                    }
                    else
                    {
                        cookie          = new HttpCookie("gmcoresid", string.Empty);
                        cookie.HttpOnly = true;
                        filterContext.RequestContext.HttpContext.Response.Cookies.Add(cookie);
                    }
                }
            }
        }

        if (!CurrentUserSession.IsAuthenticated)
        {
            filterContext.Result = new ContentResult()
            {
                Content = @"Access Denied.", ContentType = "text/html"
            };
            return;
        }


        //
        long currentDomainID = 0;

        if (long.TryParse(filterContext.RouteData.Values["domainID"] as string, out currentDomainID) &&
            currentDomainID > 0 &&
            CurrentUserSession.UserDomainID == Constant.SystemDomainID)
        {
            DomainManager.CurrentDomainID = currentDomainID;
        }
        else
        {
            DomainManager.CurrentDomainID = CurrentUserSession.UserDomainID;
        }
    }
Example #13
0
        public ActionResult GetFrequentPlayerPoints(string apiUsername, string apiPassword, string _sid)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(apiUsername))
                {
                    return(WrapResponse(ResultCode.Error_InvalidParameter, "OperatorKey cannot be empty!"));
                }

                if (string.IsNullOrWhiteSpace(apiPassword))
                {
                    return(WrapResponse(ResultCode.Error_InvalidParameter, "API password cannot be empty!"));
                }

                if (string.IsNullOrWhiteSpace(_sid))
                {
                    return(WrapResponse(ResultCode.Error_InvalidParameter, "Session ID cannot be empty!"));
                }

                var domains = DomainManager.GetApiUsername_DomainDictionary();
                ceDomainConfigEx domain;
                if (!domains.TryGetValue(apiUsername.Trim(), out domain))
                {
                    return(WrapResponse(ResultCode.Error_InvalidParameter, "Invalid OperatorKey!"));
                }

                if (!string.Equals(domain.ApiPassword, apiPassword.MD5Hash(), StringComparison.InvariantCulture))
                {
                    return(WrapResponse(ResultCode.Error_InvalidParameter, "API password is incorrect!"));
                }

                if (!IsWhitelistedIPAddress(domain, Request.GetRealUserAddress()))
                {
                    return(WrapResponse(ResultCode.Error_BlockedIPAddress, string.Format("IP Address [{0}] is denied!", Request.GetRealUserAddress())));
                }

                SessionPayload sessionPayload = _agentClient.GetSessionByGuid(_sid);

                if (sessionPayload == null || sessionPayload.IsAuthenticated != true)
                {
                    return(WrapResponse(ResultCode.Error_InvalidSession, "Session ID is not available!"));
                }


                ////////////////////////////////////////////////////////////////////////
                using (GamMatrixClient client = new GamMatrixClient())
                {
                    CasinoFPPGetClaimDetailsRequest request = new CasinoFPPGetClaimDetailsRequest()
                    {
                        UserID = sessionPayload.UserID,
                    };

                    request = client.SingleRequest <CasinoFPPGetClaimDetailsRequest>(sessionPayload.DomainID, request);

                    StringBuilder data = new StringBuilder();
                    data.AppendLine("<getFrequentPlayerPoints>");

                    if (request != null && request.ClaimRec != null)
                    {
                        data.AppendFormat(CultureInfo.InvariantCulture, "\t<points>{0:f2}</points>\n", Math.Truncate(request.ClaimRec.Points * 100) / 100.00M);
                        data.AppendFormat(CultureInfo.InvariantCulture, "\t<convertionMinClaimPoints>{0:f0}</convertionMinClaimPoints>\n", request.ClaimRec.CfgConvertionMinClaimPoints);
                        data.AppendFormat(CultureInfo.InvariantCulture, "\t<convertionPoints>{0}</convertionPoints>\n", request.ClaimRec.CfgConvertionPoints);
                        data.AppendFormat(CultureInfo.InvariantCulture, "\t<convertionCurrency>{0}</convertionCurrency>\n", request.ClaimRec.CfgConvertionCurrency.SafeHtmlEncode());
                        data.AppendFormat(CultureInfo.InvariantCulture, "\t<convertionAmount>{0}</convertionAmount>\n", request.ClaimRec.CfgConvertionAmount);
                        data.AppendFormat(CultureInfo.InvariantCulture, "\t<convertionType>{0}</convertionType>\n", request.ClaimRec.CfgConvertionType);
                    }
                    data.AppendLine("</getFrequentPlayerPoints>");
                    return(WrapResponse(ResultCode.Success, null, data));
                }
            }
            catch (Exception ex)
            {
                Logger.Exception(ex);
                return(WrapResponse(ResultCode.Error_SystemFailure, ex.Message));
            }
        }
Example #14
0
        public static Dictionary <string, NetEntAPI.LiveCasinoTable> ParseJson(long domainID, string urlFormat)
        {
            string cacheFile = Path.Combine(FileSystemUtility.GetWebSiteTempDirectory()
                                            , string.Format(CultureInfo.InvariantCulture, CACHE_FILE_FORMAT, CRC64.ComputeAsUtf8String(urlFormat))
                                            );

            Dictionary <string, NetEntAPI.LiveCasinoTable> dic = new Dictionary <string, NetEntAPI.LiveCasinoTable>(StringComparer.InvariantCultureIgnoreCase);

            // first get the EUR currency data
            string url = string.Format(CultureInfo.InvariantCulture, urlFormat, "EUR");

            RawNetEntLiveCasinoTable[] rawTables = RawNetEntLiveCasinoTable.Get(url);
            foreach (RawNetEntLiveCasinoTable rawTable in rawTables)
            {
                foreach (RawNetEntLiveCasinoGame rawGame in rawTable.Games)
                {
                    string key = string.Format(CultureInfo.InvariantCulture, "{0}|{1}", rawGame.GameID, rawTable.TableID);
                    dic[key] = new NetEntAPI.LiveCasinoTable()
                    {
                        GameID  = rawGame.GameID,
                        TableID = rawTable.TableID.ToString(),
                    };
                    dic[key].Limitation.Type = LiveCasinoTableLimitType.SpecificForEachCurrency;
                }
            }

            CurrencyData [] currencies = GamMatrixClient.GetSupportedCurrencies();
            foreach (CurrencyData currency in currencies)
            {
                url       = string.Format(CultureInfo.InvariantCulture, urlFormat, currency.ISO4217_Alpha);
                rawTables = RawNetEntLiveCasinoTable.Get(url);
                foreach (RawNetEntLiveCasinoTable rawTable in rawTables)
                {
                    foreach (RawNetEntLiveCasinoGame rawGame in rawTable.Games)
                    {
                        if ([email protected]("MINBET") || [email protected]("MAXBET"))
                        {
                            continue;
                        }

                        decimal minBet, maxBet;
                        if (!decimal.TryParse(rawGame.@params["MINBET"].ToString(), out minBet) ||
                            !decimal.TryParse(rawGame.@params["MAXBET"].ToString(), out maxBet) ||
                            minBet >= maxBet)
                        {
                            continue;
                        }
                        minBet /= 100.00M;
                        maxBet /= 100.00M;

                        string key = string.Format(CultureInfo.InvariantCulture, "{0}|{1}", rawGame.GameID, rawTable.TableID);
                        NetEntAPI.LiveCasinoTable table;
                        if (dic.TryGetValue(key, out table))
                        {
                            table.Limitation.CurrencyLimits[currency.ISO4217_Alpha] = new LimitAmount()
                            {
                                MinAmount = minBet,
                                MaxAmount = maxBet,
                            };
                        }
                    }
                }
            }
            if (dic.Keys.Count > 0)
            {
                ObjectHelper.BinarySerialize <Dictionary <string, NetEntAPI.LiveCasinoTable> >(dic, cacheFile);
                HttpRuntime.Cache[cacheFile] = dic;
            }
            return(dic);
        }
Example #15
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);
        }
Example #16
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
        public ContentResult RawXml(string apiUsername, string vendor, string username)
        {
            if (string.IsNullOrWhiteSpace(apiUsername))
            {
                return(WrapResponse(ResultCode.Error_InvalidParameter, "Operator is NULL!"));
            }

            var domains = DomainManager.GetApiUsername_DomainDictionary();
            ceDomainConfigEx domain;

            if (!domains.TryGetValue(apiUsername.Trim(), out domain))
            {
                return(WrapResponse(ResultCode.Error_InvalidParameter, "Operator is invalid!"));
            }

            if (!IsWhitelistedIPAddress(domain, Request.GetRealUserAddress()))
            {
                return(WrapResponse(ResultCode.Error_BlockedIPAddress, string.Format("IP Address [{0}] is denied!", Request.GetRealUserAddress())));
            }

            try
            {
                if (string.Equals(vendor, "IGT", StringComparison.InvariantCultureIgnoreCase))
                {
                    using (GamMatrixClient client = new GamMatrixClient())
                    {
                        IGTAPIRequest request = new IGTAPIRequest()
                        {
                            GameListV2 = true,
                        };
                        request = client.SingleRequest <IGTAPIRequest>(domain.DomainID, request);

                        return(this.Content(request.GameListV2Response, "text/xml"));
                    }
                }
                else if (string.Equals(vendor, "IGTgames", StringComparison.InvariantCultureIgnoreCase))
                {
                    Dictionary <string, IGTIntegration.Game> games = GamMatrixClient.GetIGTGames(domain.DomainID);

                    StringBuilder output = new StringBuilder();
                    foreach (var game in games)
                    {
                        output.AppendFormat("{0} {1}\n", game.Key, game.Value.Title);
                    }
                    return(this.Content(output.ToString(), "text/plain"));
                }
                else if (string.Equals(vendor, "GTgameInfo", StringComparison.InvariantCultureIgnoreCase))
                {
                    GreenTubeAPIRequest request = new GreenTubeAPIRequest()
                    {
                        ArticlesGetRequest = new GreentubeArticlesGetRequest()
                        {
                            LanguageCode = "EN"
                        }
                    };
                    using (GamMatrixClient client = new GamMatrixClient())
                    {
                        request = client.SingleRequest <GreenTubeAPIRequest>(domain.DomainID, request);
                        DataContractSerializer dcs = new DataContractSerializer(request.ArticlesGetResponse.GetType());

                        using (MemoryStream ms = new MemoryStream())
                        {
                            dcs.WriteObject(ms, request.ArticlesGetResponse);
                            byte[] buffer = ms.ToArray();
                            return(this.Content(Encoding.UTF8.GetString(buffer, 0, buffer.Length)
                                                , "text/xml"
                                                ));
                        }
                    }
                }
                else if (string.Equals(vendor, "XPRO", StringComparison.InvariantCultureIgnoreCase))
                {
                    XProGamingAPIRequest request = new XProGamingAPIRequest()
                    {
                        GetGamesListWithLimits           = true,
                        GetGamesListWithLimitsGameType   = (int)XProGaming.GameType.AllGames,
                        GetGamesListWithLimitsOnlineOnly = 0,
                        GetGamesListWithLimitsUserName   = username,
                        GetUserCurrency         = true,
                        GetUserCurrencyUserName = username,
                    };
                    using (GamMatrixClient client = new GamMatrixClient())
                    {
                        request = client.SingleRequest <XProGamingAPIRequest>(domain.DomainID, request);

                        StringBuilder output = new StringBuilder();
                        output.AppendFormat("XProGamingAPIRequest.GetUserCurrencyResponse = [{0}]"
                                            , request.GetUserCurrencyResponse
                                            );
                        output.AppendLine();
                        output.AppendLine();
                        output.Append("XProGamingAPIRequest.GetGamesListWithLimitsResponse = \n");


                        using (StringWriter sw = new StringWriter())
                        {
                            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                            doc.LoadXml(request.GetGamesListWithLimitsResponse);
                            doc.Save(sw);
                            output.Append(sw.ToString());
                        }

                        return(this.Content(output.ToString(), "text/plain"));
                    }
                }
                //else if (string.Equals(vendor, "BALLY", StringComparison.InvariantCultureIgnoreCase))
                //{
                //    BallyGetGamesListRequest request = new BallyGetGamesListRequest();
                //    using (GamMatrixClient client = new GamMatrixClient())
                //    {
                //        request = client.SingleRequest<BallyGetGamesListRequest>(domain.DomainID, request);

                //        DataContractSerializer formatter = new DataContractSerializer(request.Games.GetType());
                //        using (MemoryStream ms = new MemoryStream())
                //        {
                //            formatter.WriteObject(ms, request.Games);
                //            string xml = Encoding.UTF8.GetString(ms.ToArray());
                //            return this.Content(xml, "text/plain");
                //        }
                //    }
                //}
                //else if (string.Equals(vendor, "ISoftBet", StringComparison.InvariantCultureIgnoreCase))
                //{
                //    List<ISoftBetIntegration.Game> list = ISoftBetIntegration.GameMgt.LoadRawGameFeedsForSpecialLanguage(domain,"en").Values.ToList();
                //    DataContractSerializer formatter = new DataContractSerializer(typeof(List<ISoftBetIntegration.Game>));
                //    using (MemoryStream ms = new MemoryStream())
                //    {
                //        formatter.WriteObject(ms, list);
                //        string xml = Encoding.UTF8.GetString(ms.ToArray());
                //        return this.Content(xml, "text/xml");
                //    }
                //}
                else if (string.Equals(vendor, "Vivo", StringComparison.InvariantCultureIgnoreCase))
                {
                    Dictionary <string, string> dicGameName = new Dictionary <string, string>();
                    dicGameName.Add("Baccarat", "Baccarat");
                    dicGameName.Add("Roulette", "Roulette");
                    dicGameName.Add("Blackjack", "Blackjack");


                    long operatorID = 0;
                    long.TryParse(domain.GetCfg(CE.DomainConfig.Vivo.OperatorID), out operatorID);
                    string vivoWebServiceUrl = domain.GetCfg(CE.DomainConfig.Vivo.VivoWebServiceUrl);
                    List <VivoActiveTable> vivoTables;
                    Type           t          = typeof(VivoActiveTable);
                    PropertyInfo[] properties = t.GetProperties();

                    StringBuilder xml = new StringBuilder();
                    xml.AppendLine(@"<?xml version=""1.0"" encoding=""ISO-8859-1""?>");
                    xml.AppendLine(@"<root>");
                    foreach (string key in dicGameName.Keys)
                    {
                        vivoTables = VivoAPI.LiveCasinoTable.GetActiveTables(vivoWebServiceUrl, domain.DomainID, operatorID, dicGameName[key], "EUR");
                        if (vivoTables != null)
                        {
                            xml.AppendLine(string.Format("<{0}>", key));
                            foreach (VivoActiveTable table in vivoTables)
                            {
                                xml.AppendLine(string.Format("<table-{0}>", table.TableID));
                                foreach (PropertyInfo p in properties)
                                {
                                    xml.AppendLine(string.Format("<{0}>{1}</{0}>", p.Name, p.GetValue(table).ToString()));
                                }
                                xml.AppendLine(string.Format("</table-{0}>", table.TableID));
                            }
                            xml.AppendLine(string.Format("</{0}>", key));
                        }
                    }
                    xml.AppendLine(@"</root>");
                    return(this.Content(xml.ToString(), "text/xml"));
                }
                else if (string.Equals(vendor, "RecentWinners", StringComparison.InvariantCultureIgnoreCase))
                {
                    string sql = DwAccessor.GetCasinoGameRecentWinnersInternalSql(domain, false);
                    return(this.Content(sql, "text/plain"));
                }
                else if (string.Equals(vendor, "GreenTube", StringComparison.InvariantCultureIgnoreCase))
                {
                    using (GamMatrixClient client = new GamMatrixClient())
                    {
                        GreenTubeAPIRequest request = new GreenTubeAPIRequest()
                        {
                            ArticlesGetRequest = new GreentubeArticlesGetRequest()
                            {
                                LanguageCode = "EN"
                            }
                        };
                        request = client.SingleRequest <GreenTubeAPIRequest>(domain.DomainID, request);

                        DataContractSerializer formatter = new DataContractSerializer(request.ArticlesGetResponse.GetType());
                        using (MemoryStream ms = new MemoryStream())
                        {
                            formatter.WriteObject(ms, request.ArticlesGetResponse);
                            string xml = Encoding.UTF8.GetString(ms.ToArray());
                            return(this.Content(xml, "text/xml"));
                        }
                    }
                }
                else
                {
                    throw new NotSupportedException();
                }
            }
            catch (Exception ex)
            {
                return(this.Content(ex.Message));
            }
        }
Example #18
0
        private StringBuilder GetGreenTubeGameInfo(ceCasinoGameBaseEx game, string lang)
        {
            if (string.IsNullOrWhiteSpace(lang))
            {
                lang = "EN";
            }

            string cacheKey = string.Format("XmlFeedsController.GetGreenTubeGameInfo.{0}.{1}"
                                            , DomainManager.CurrentDomainID
                                            , lang
                                            );

            Dictionary <string, List <Topic> > dic = HttpRuntime.Cache[cacheKey] as Dictionary <string, List <Topic> >;

            if (dic == null)
            {
                using (GamMatrixClient client = new GamMatrixClient())
                {
                    GreenTubeAPIRequest request = new GreenTubeAPIRequest()
                    {
                        ArticlesGetRequest = new GreentubeArticlesGetRequest()
                        {
                            LanguageCode = lang.ToUpperInvariant()
                        }
                    };
                    request = client.SingleRequest <GreenTubeAPIRequest>(DomainManager.CurrentDomainID, request);
                    if (request.ArticlesGetResponse.ErrorCode < 0)
                    {
                        throw new Exception(request.ArticlesGetResponse.Message.Description);
                    }

                    if (request.ArticlesGetResponse.Topic != null &&
                        request.ArticlesGetResponse.Topic.Count > 0)
                    {
                        dic = new Dictionary <string, List <Topic> >(StringComparer.InvariantCultureIgnoreCase);
                        foreach (Topic topic in request.ArticlesGetResponse.Topic)
                        {
                            List <Topic> topics = null;
                            if (!dic.TryGetValue(topic.GameId.ToString(), out topics))
                            {
                                topics = new List <Topic>();
                                dic[topic.GameId.ToString()] = topics;
                            }

                            topics.Add(topic);
                        }
                        HttpRuntime.Cache.Insert(cacheKey, dic, null, DateTime.Now.AddMinutes(20), Cache.NoSlidingExpiration);
                    }
                }
            }

            List <Topic> found = null;

            if (dic != null &&
                dic.TryGetValue(game.GameID, out found))
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("<topics>");

                foreach (Topic t in found)
                {
                    sb.Append("<topic>");

                    sb.AppendFormat(CultureInfo.InvariantCulture, "<id>{0}</id>", t.Id);
                    sb.AppendFormat(CultureInfo.InvariantCulture, "<description>{0}</description>", t.Description.SafeHtmlEncode());

                    {
                        sb.Append("<articles>");
                        foreach (Article article in t.ArticleList)
                        {
                            sb.AppendFormat(CultureInfo.InvariantCulture, "<id>{0}</id>", article.Id);
                            sb.AppendFormat(CultureInfo.InvariantCulture, "<title>{0}</title>", article.Title.SafeHtmlEncode());
                            sb.AppendFormat(CultureInfo.InvariantCulture, "<content>{0}</content>", article.Content.SafeHtmlEncode());
                        }
                        sb.Append("</articles>");
                    }

                    sb.Append("</topic>");
                }

                sb.Append("</topics>");
                return(sb);
            }

            // if the translation is not found, try to search in English
            if (!string.Equals(lang, "en", StringComparison.InvariantCultureIgnoreCase))
            {
                return(GetGreenTubeGameInfo(game, "en"));
            }

            return(null);
        }
Example #19
0
        public ContentResult GetLiveCasinoTableStatus(string apiUsername, string callback)
        {
            if (string.IsNullOrWhiteSpace(apiUsername))
            {
                return(WrapResponse(ResultCode.Error_InvalidParameter, "Operator is NULL!"));
            }

            var domains = DomainManager.GetApiUsername_DomainDictionary();
            ceDomainConfigEx domain;

            if (!domains.TryGetValue(apiUsername.Trim(), out domain))
            {
                return(WrapResponse(ResultCode.Error_InvalidParameter, "Operator is invalid!"));
            }

            Dictionary <string, LiveCasinoSeat> seats = new Dictionary <string, LiveCasinoSeat>();

            DomainManager.CurrentDomainID = domain.DomainID;
            string cacheKey = string.Format("RestfulApiController.GetLiveCasinoTableStatus.LiveCasinoDic.{0}", domain.DomainID);

            List <ceLiveCasinoTableBaseEx> tables = null;
            {
                tables = HttpRuntime.Cache[cacheKey] as List <ceLiveCasinoTableBaseEx>;
                if (tables == null)
                {
                    tables = LiveCasinoTableAccessor.GetDomainTables(domain.DomainID, null, true, true);
                    HttpRuntime.Cache.Insert(cacheKey, tables, null, DateTime.Now.AddMinutes(5), TimeSpan.Zero);
                }
            }


            List <ceLiveCasinoTableBaseEx> xproTables = tables.Where(t => t.VendorID == VendorID.XProGaming).ToList();

            if (xproTables.Count > 0)
            {
                XProGamingAPIRequest request = new XProGamingAPIRequest()
                {
                    GetGamesListWithLimits           = true,
                    GetGamesListWithLimitsGameType   = (int)XProGaming.GameType.AllGames,
                    GetGamesListWithLimitsOnlineOnly = 0,
                    GetGamesListWithLimitsCurrency   = "EUR",
                    //GetGamesListWithLimitsUserName = "******",
                };
                using (GamMatrixClient client = new GamMatrixClient())
                {
                    request = client.SingleRequest <XProGamingAPIRequest>(domain.DomainID, request);
                }

                /*
                 * <response xmlns="apiGamesLimitsListData" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                 * <gamesList>
                 * <game>
                 * <limitSetList>
                 * <limitSet>
                 * <limitSetID>1</limitSetID>
                 * <minBet>0.00</minBet>
                 * <maxBet>800.00</maxBet>
                 * </limitSet>
                 * <limitSet>
                 * <limitSetID>45</limitSetID>
                 * <minBet>1.00</minBet>
                 * <maxBet>5.00</maxBet>
                 * </limitSet>
                 * </limitSetList>
                 * <gameID>3</gameID>
                 * <gameType>1</gameType>
                 * <gameName>Dragon Roulette LCPP</gameName>
                 * <dealerName>Dealer</dealerName>
                 * <dealerImageUrl>http://lcpp.xprogaming.com/LiveGames/Games/dealers/1.jpg</dealerImageUrl>
                 * <isOpen>1</isOpen>
                 * <connectionUrl>https://lcpp.xprogaming.com/LiveGames/GeneralGame.aspx?audienceType=1&amp;gameID=3&amp;operatorID=47&amp;languageID={1}&amp;loginToken={2}&amp;securityCode={3}</connectionUrl>
                 * <winParams>'width=955,height=690,menubar=no, scrollbars=no,toolbar=no,status=no,location=no,directories=no,resizable=yes,left=' + (screen.width - 955) / 2 + ',top=20'</winParams>
                 * <openHour>00:00</openHour>
                 * <closeHour>23:59</closeHour>
                 * <PlayersNumber xsi:nil="true" />
                 * <PlayersNumberInGame xsi:nil="true" />
                 * </game>
                 * <errorCode>0</errorCode>
                 * <description />
                 * </response>
                 */

                XElement   root = XElement.Parse(request.GetGamesListWithLimitsResponse);
                XNamespace ns   = root.GetDefaultNamespace();
                if (root.Element(ns + "errorCode").Value != "0")
                {
                    throw new Exception(root.Element(ns + "description").Value);
                }

                IEnumerable <XElement> games = root.Element(ns + "gamesList").Elements(ns + "game");
                foreach (XElement game in games)
                {
                    string   gameID = game.Element(ns + "gameID").Value;
                    XElement playersNumberElement       = game.Element(ns + "PlayersNumber");
                    XElement playersNumberInGameElement = game.Element(ns + "PlayersNumberInGame");
                    if (playersNumberElement == null ||
                        playersNumberInGameElement == null ||
                        playersNumberElement.Value == null ||
                        playersNumberInGameElement.Value == null)
                    {
                        continue;
                    }

                    int seatTaken = 0, totalSeats = 0;
                    if (!int.TryParse(playersNumberElement.Value, out totalSeats) ||
                        !int.TryParse(playersNumberInGameElement.Value, out seatTaken))
                    {
                        continue;
                    }

                    foreach (ceLiveCasinoTableBaseEx xproTable in xproTables.Where(t => t.GameID == gameID))
                    {
                        seats.Add(xproTable.ID.ToString()
                                  , new LiveCasinoSeat()
                        {
                            TakenSeats = seatTaken, TotalSeats = totalSeats
                        }
                                  );
                    }
                }
            }


            List <ceLiveCasinoTableBaseEx> netentTables = tables.Where(t => t.VendorID == VendorID.NetEnt).ToList();

            if (netentTables.Count > 0)
            {
                string url = domain.GetCfg(CE.DomainConfig.NetEnt.LiveCasinoQueryOpenTablesApiURL);
                url = string.Format(url, "EUR");
                HttpWebRequest request = HttpWebRequest.Create(url) as HttpWebRequest;
                request.Accept      = "application/json";
                request.ContentType = "application/json";
                request.Method      = "POST";

                HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                using (Stream s = response.GetResponseStream())
                {
                    using (StreamReader sr = new StreamReader(s))
                    {
                        string json = sr.ReadToEnd();
                        JavaScriptSerializer jss = new JavaScriptSerializer();
                        NetEntAPI.RawNetEntLiveCasinoTable[] rawTables = jss.Deserialize <NetEntAPI.RawNetEntLiveCasinoTable[]>(json);

                        foreach (var rawTable in rawTables)
                        {
                            if (rawTable.Games.Length == 0 ||
                                rawTable.Slots.Length == 0)
                            {
                                continue;
                            }

                            string gameID = rawTable.Games[0].GameID;
                            ceLiveCasinoTableBaseEx netentTable = netentTables.FirstOrDefault(t => t.GameID == gameID);
                            if (netentTable == null)
                            {
                                continue;
                            }

                            int seatTaken  = rawTable.Slots.Count(slot => slot.Available == false);
                            int totalSeats = rawTable.Slots.Length;

                            seats.Add(netentTable.ID.ToString()
                                      , new LiveCasinoSeat()
                            {
                                TakenSeats = seatTaken, TotalSeats = totalSeats
                            }
                                      );
                        }
                    }
                }
            }

            DataContractJsonSerializer serializer = new DataContractJsonSerializer(seats.GetType()
                                                                                   , new DataContractJsonSerializerSettings()
            {
                UseSimpleDictionaryFormat = true
            }
                                                                                   );

            string jsonp;

            using (MemoryStream ms = new MemoryStream())
            {
                serializer.WriteObject(ms, seats);
                string json = Encoding.UTF8.GetString(ms.ToArray());

                jsonp = string.Format("{0}({1})", callback, json);
            }


            return(this.Content(jsonp));
        }