private static ulong GetLiveCasinoTableStatusHash(ceDomainConfigEx domain) { StringBuilder sb = new StringBuilder(); List <ceLiveCasinoTableBaseEx> tables = LiveCasinoTableAccessor.GetDomainTables(domain.DomainID, null, true, true) .OrderBy(t => t.ID).ToList(); foreach (ceLiveCasinoTableBaseEx table in tables) { sb.AppendFormat("{0}-{1}\n", table.ID, table.IsOpen(domain.DomainID)); } return(CRC64.ComputeAsAsciiString(sb.ToString())); }
public static Dictionary <string, ceLiveCasinoTableBaseEx> GetLiveCasinoTableDictionary(long domainID) { string cacheKey = string.Format(GAME_CACHE_KEY_FORMAT, Constant.DomainLiveCasinoTableCachePrefix, domainID); Dictionary <string, ceLiveCasinoTableBaseEx> tables = HttpRuntime.Cache[cacheKey] as Dictionary <string, ceLiveCasinoTableBaseEx>; if (tables != null) { return(tables); } List <ceLiveCasinoTableBaseEx> allTables = LiveCasinoTableAccessor.GetDomainTables(domainID, null, true); tables = allTables.ToDictionary(t => t.ID.ToString(), t => t); CacheManager.AddCache(cacheKey, tables); return(tables); }
private StringBuilder GetLiveCasinoTableListXml(ceDomainConfigEx domain, List <ceCasinoGameBaseEx> games, bool includeMoreFields) { StringBuilder data = new StringBuilder(); data.AppendLine("<tableList>"); CasinoVendorAccessor cva = CasinoVendorAccessor.CreateInstance <CasinoVendorAccessor>(); Dictionary <VendorID, string> dic = cva.GetRestrictedTerritoriesDictionary(DomainManager.CurrentDomainID); List <ceLiveCasinoTableBaseEx> allTables = LiveCasinoTableAccessor.GetDomainTables(domain.DomainID, null, true, true); Dictionary <long, long> popularities = GetGamePopularity(domain); foreach (ceCasinoGameBaseEx game in games) { List <ceLiveCasinoTableBaseEx> tables = allTables.Where(t => t.CasinoGameBaseID == game.ID && t.Enabled).ToList(); if (tables.Count == 0) { continue; } long popularity = 0L; popularities.TryGetValue(game.ID, out popularity); string helperUrl = GetHelpUrl(domain, game); string restrictedTerritories; dic.TryGetValue(game.VendorID, out restrictedTerritories); foreach (ceLiveCasinoTableBaseEx table in tables) { string loaderUrl = string.Format(CultureInfo.InvariantCulture, "{0}/?tableID={1:D}" , GetLoaderUrl(domain, game.ID, game.Slug, game.VendorID) , table.ID ); data.AppendLine("\t<table>"); bool isOpen = table.IsOpen(domain.DomainID); if (!string.IsNullOrWhiteSpace(table.TableName)) { game.GameName = table.TableName; game.ShortName = table.TableName; } game.Thumbnail = table.Thumbnail; data.AppendFormat("\t\t<id>{0:D}</id>\n", table.ID); data.AppendFormat("\t\t<category>{0}</category>\n", table.Category.SafeHtmlEncode()); data.AppendFormat("\t\t<gameId>{0}</gameId>\n", game.ID); data.AppendFormat("\t\t<isOpen>{0}</isOpen>\n", isOpen ? "true" : "false"); data.AppendFormat("\t\t<vipTable>{0}</vipTable>\n", table.VIPTable ? "true" : "false"); data.AppendFormat("\t\t<newTable>{0}</newTable>\n", (table.NewTable && table.NewTableExpirationDate > DateTime.Now.Date) ? "true" : "false"); data.AppendFormat("\t\t<turkishTable>{0}</turkishTable>\n", table.TurkishTable ? "true" : "false"); data.AppendFormat("\t\t<betBehindAvailable>{0}</betBehindAvailable>\n", table.BetBehindAvailable ? "true" : "false"); data.AppendFormat("\t\t<excludeFromRandomLaunch>{0}</excludeFromRandomLaunch>\n", table.ExcludeFromRandomLaunch ? "true" : "false"); data.AppendFormat("\t\t<seatsUnlimited>{0}</seatsUnlimited>\n", table.SeatsUnlimited ? "true" : "false"); data.AppendFormat("\t\t<dealerGender>{0}</dealerGender>\n", table.DealerGender); data.AppendFormat("\t\t<dealerOrigin>{0}</dealerOrigin>\n", table.DealerOrigin); if (!string.IsNullOrWhiteSpace(table.OpenHoursTimeZone)) { data.Append("\t\t<openingTime>\n"); if (table.OpenHoursStart != table.OpenHoursEnd) { data.Append("\t\t\t<is24HoursOpen>false</is24HoursOpen>\n"); data.AppendFormat("\t\t\t<timeZone>{0}</timeZone>\n", table.OpenHoursTimeZone.SafeHtmlEncode()); data.AppendFormat("\t\t\t<startTime>{0:D2}:{1:D2}</startTime>\n", table.OpenHoursStart / 60, table.OpenHoursStart % 60); data.AppendFormat("\t\t\t<endTime>{0:D2}:{1:D2}</endTime>\n", table.OpenHoursEnd / 60, table.OpenHoursEnd % 60); } else { data.Append("\t\t\t<is24HoursOpen>true</is24HoursOpen>\n"); } data.Append("\t\t</openingTime>\n"); } if (table.Limit.Type != LiveCasinoTableLimitType.None) { Dictionary <string, LimitAmount> items = GetCurrencyLimitAmount(table); if (items.Count > 0) { data.Append("\t\t<limits>\n"); foreach (var item in items) { data.AppendFormat("\t\t\t<limit currency=\"{0}\">\n", item.Key.SafeHtmlEncode()); data.AppendFormat("\t\t\t\t<min>{0:0.##}</min>\n", item.Value.MinAmount); data.AppendFormat("\t\t\t\t<max>{0:0.##}</max>\n", item.Value.MaxAmount); data.Append("\t\t\t</limit>\n"); } data.Append("\t\t</limits>\n"); } } data.Append("\t\t<platforms>"); string[] platforms = (table.ClientCompatibility ?? string.Empty).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (platforms == null || platforms.Length == 0) { platforms = (game.ClientCompatibility ?? string.Empty).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); } foreach (string platform in platforms) { if (!string.IsNullOrWhiteSpace(platform)) { data.AppendFormat("<platform>{0}</platform>", platform.SafeHtmlEncode()); } } data.Append("</platforms>\n"); PopulateGameBasicProperties(data , domain , game , popularity , false , includeMoreFields , restrictedTerritories , loaderUrl , helperUrl ); data.AppendLine("\t</table>"); } } data.AppendLine("</tableList>"); return(data); }
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&gameID=3&operatorID=47&languageID={1}&loginToken={2}&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)); }