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); }
public ActionResult TableEditorDialog(long domainID, long id) { ceLiveCasinoTableBaseEx table = LiveCasinoTableAccessor.GetDomainTable(DomainManager.CurrentDomainID, id); if (table == null) { throw new CeException("Table not found by ID [{0}]", id); } var domain = DomainManager.GetDomains().FirstOrDefault(d => d.DomainID == DomainManager.CurrentDomainID); if (domain == null && DomainManager.GetSysDomain().DomainID == DomainManager.CurrentDomainID) { domain = DomainManager.GetSysDomain(); } this.ViewData["newStatusLiveCasinoGameExpirationDays"] = domain.NewStatusLiveCasinoGameExpirationDays; return(this.View("TableEditorDialog", table)); }
public ActionResult RegisterTableDialog(long domainID, long?id) { ceLiveCasinoTableBaseEx table = null; if (id.HasValue && id.Value > 0) { table = LiveCasinoTableAccessor.GetDomainTable(DomainManager.CurrentDomainID, id.Value); } if (table == null) { table = new ceLiveCasinoTableBaseEx() { CasinoGameBaseID = 0L, DomainID = 1000L, } } ; return(this.View("RegisterTableDialog", table)); }
public ActionResult SaveTable(ceLiveCasinoTableBaseEx updatedTable , HttpPostedFileBase thumbnailFile ) { if (!DomainManager.AllowEdit()) { throw new Exception("Data modified is not allowed"); } try { string imageFileName; byte[] imageBuffer; if (ImageAsset.ParseImage(thumbnailFile, out imageFileName, out imageBuffer)) { imageFileName = ImageAsset.GetImageFtpFilePath(imageFileName); FTP.UploadFile(DomainManager.CurrentDomainID, imageFileName, imageBuffer); } SqlQuery <ceLiveCasinoTableBase> query = new SqlQuery <ceLiveCasinoTableBase>(); ceLiveCasinoTableBase baseTable = query.SelectByKey(updatedTable.ID); ceCasinoGameBaseEx game = CasinoGameAccessor.GetDomainGame(Constant.SystemDomainID, baseTable.CasinoGameBaseID); if (CurrentUserSession.IsSystemUser && DomainManager.CurrentDomainID == Constant.SystemDomainID) { baseTable.TableName = updatedTable.TableName; baseTable.Category = updatedTable.Category; baseTable.ExtraParameter1 = updatedTable.ExtraParameter1; baseTable.ExtraParameter2 = updatedTable.ExtraParameter2; baseTable.ExtraParameter3 = updatedTable.ExtraParameter3; baseTable.ExtraParameter4 = updatedTable.ExtraParameter4; baseTable.LaunchParams = updatedTable.LaunchParams; baseTable.OpenHoursStart = updatedTable.OpenHoursStart; baseTable.OpenHoursEnd = updatedTable.OpenHoursEnd; baseTable.OpenHoursTimeZone = updatedTable.OpenHoursTimeZone; baseTable.Limit = ParseLimit(); baseTable.VIPTable = updatedTable.VIPTable; baseTable.NewTable = updatedTable.NewTable; baseTable.NewTableExpirationDate = updatedTable.NewTable ? updatedTable.NewTableExpirationDate : DateTime.Now.AddDays(-1); baseTable.ExcludeFromRandomLaunch = updatedTable.ExcludeFromRandomLaunch; baseTable.TurkishTable = updatedTable.TurkishTable; baseTable.BetBehindAvailable = updatedTable.BetBehindAvailable; baseTable.SeatsUnlimited = updatedTable.SeatsUnlimited; baseTable.DealerGender = updatedTable.DealerGender; baseTable.DealerOrigin = updatedTable.DealerOrigin; baseTable.TableStudioUrl = updatedTable.TableStudioUrl; //if (game.VendorID == VendorID.EvolutionGaming) { baseTable.ClientCompatibility = updatedTable.ClientCompatibility; } if (!string.IsNullOrWhiteSpace(imageFileName)) { baseTable.Thumbnail = imageFileName; } query.Update(baseTable); //updating properties that are inherited from basetable and disabled for edit in child tables var propertiesValues = new Dictionary <string, object> { { "BetBehindAvailable", updatedTable.BetBehindAvailable }, { "SeatsUnlimited", updatedTable.SeatsUnlimited }, { "DealerGender", updatedTable.DealerGender }, { "DealerOrigin", updatedTable.DealerOrigin } }; LiveCasinoTableAccessor.UpdateChildTablesProperties(propertiesValues, baseTable.ID); } else if (DomainManager.CurrentDomainID != Constant.SystemDomainID) { LiveCasinoTableAccessor lta = LiveCasinoTableAccessor.CreateInstance <LiveCasinoTableAccessor>(); ceLiveCasinoTable table = lta.GetTable(DomainManager.CurrentDomainID, updatedTable.ID); bool isExist = table != null; bool isModified = false; if (!isExist) { table = new ceLiveCasinoTable() { DomainID = DomainManager.CurrentDomainID, LiveCasinoTableBaseID = updatedTable.ID }; table.Ins = DateTime.Now; table.SessionUserID = CurrentUserSession.UserID; table.SessionID = CurrentUserSession.UserSessionID; table.OpVisible = baseTable.OpVisible; table.ClientCompatibility = null; table.NewTableExpirationDate = baseTable.NewTableExpirationDate == DateTime.MinValue ? DateTime.Now.Date.AddDays(-1) : baseTable.NewTableExpirationDate; table.BetBehindAvailable = baseTable.BetBehindAvailable; table.SeatsUnlimited = baseTable.SeatsUnlimited; table.DealerGender = baseTable.DealerGender; table.DealerOrigin = baseTable.DealerOrigin; } table.ShortName = null; table.Logo = null; table.BackgroundImage = null; if (!string.IsNullOrWhiteSpace(updatedTable.ExtraParameter1) && !string.Equals(baseTable.ExtraParameter1, updatedTable.ExtraParameter1)) { isModified = true; table.ExtraParameter1 = updatedTable.ExtraParameter1; } else { table.ExtraParameter1 = null; } if (!string.IsNullOrWhiteSpace(updatedTable.ExtraParameter2) && !string.Equals(baseTable.ExtraParameter2, updatedTable.ExtraParameter2)) { isModified = true; table.ExtraParameter2 = updatedTable.ExtraParameter2; } else { table.ExtraParameter2 = null; } if (!string.IsNullOrWhiteSpace(updatedTable.ExtraParameter3) && !string.Equals(baseTable.ExtraParameter3, updatedTable.ExtraParameter3)) { isModified = true; table.ExtraParameter3 = updatedTable.ExtraParameter3; } else { table.ExtraParameter3 = null; } if (!string.IsNullOrWhiteSpace(updatedTable.ExtraParameter4) && !string.Equals(baseTable.ExtraParameter4, updatedTable.ExtraParameter4)) { isModified = true; table.ExtraParameter4 = updatedTable.ExtraParameter4; } else { table.ExtraParameter4 = null; } if (!string.IsNullOrEmpty(updatedTable.LaunchParams) && !string.Equals(baseTable.LaunchParams, updatedTable.LaunchParams)) { isModified = true; table.LaunchParams = updatedTable.LaunchParams; } else { table.LaunchParams = null; } if (!string.IsNullOrWhiteSpace(updatedTable.TableName) && !string.Equals(baseTable.TableName, updatedTable.TableName)) { isModified = true; table.TableName = updatedTable.TableName; } else { table.TableName = null; } if (!string.IsNullOrWhiteSpace(updatedTable.Category) && !string.Equals(baseTable.Category, updatedTable.Category)) { isModified = true; table.Category = updatedTable.Category; } else { table.Category = null; } if (!string.IsNullOrWhiteSpace(imageFileName) && !string.Equals(baseTable.Thumbnail, updatedTable.Thumbnail)) { isModified = true; table.Thumbnail = imageFileName; } else { table.Thumbnail = null; } //if (game.VendorID == VendorID.EvolutionGaming) { if (updatedTable.ClientCompatibility != null && !string.Equals(table.ClientCompatibility, updatedTable.ClientCompatibility)) { isModified = true; if (!string.Equals(baseTable.ClientCompatibility, updatedTable.ClientCompatibility)) { table.ClientCompatibility = updatedTable.ClientCompatibility; } else { table.ClientCompatibility = null; } } } string limitationXml = table.LimitationXml; LiveCasinoTableLimit limit = table.Limit; table.Limit = ParseLimit(); if (table.Limit.Equals(baseTable.Limit)) { table.LimitationXml = null; } if (!(string.IsNullOrWhiteSpace(table.LimitationXml) && string.IsNullOrWhiteSpace(limitationXml))) { if (table.LimitationXml == null) { isModified = true; } else if (!table.LimitationXml.Equals(limitationXml, StringComparison.InvariantCultureIgnoreCase)) { isModified = true; } } if (table.VIPTable != updatedTable.VIPTable) { table.VIPTable = updatedTable.VIPTable; isModified = true; } if (table.NewTable != updatedTable.NewTable || table.NewTableExpirationDate.CompareTo(updatedTable.NewTableExpirationDate) != 0) { table.NewTable = updatedTable.NewTable; table.NewTableExpirationDate = updatedTable.NewTable ? updatedTable.NewTableExpirationDate : DateTime.Now.AddDays(-1); isModified = true; } if (table.TurkishTable != updatedTable.TurkishTable) { table.TurkishTable = updatedTable.TurkishTable; isModified = true; } if (table.ExcludeFromRandomLaunch != updatedTable.ExcludeFromRandomLaunch) { table.ExcludeFromRandomLaunch = updatedTable.ExcludeFromRandomLaunch; isModified = true; } if (table.TableStudioUrl != updatedTable.TableStudioUrl) { table.TableStudioUrl = updatedTable.TableStudioUrl; isModified = true; } if (isModified) { SqlQuery <ceLiveCasinoTable> query2 = new SqlQuery <ceLiveCasinoTable>(); if (isExist) { query2.Update(table); } else { query2.Insert(table); } } } return(this.Json(new { success = true }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Logger.Exception(ex); return(this.Json(new { success = false, error = ex.Message }, JsonRequestBehavior.AllowGet)); } }
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)); }