public ActionResult RevertToDefaultTable(long id)
        {
            if (!DomainManager.AllowEdit())
            {
                throw new Exception("Data modified is not allowed");
            }
            try
            {
                if (DomainManager.CurrentDomainID != Constant.SystemDomainID)
                {
                    LiveCasinoTableAccessor lta   = LiveCasinoTableAccessor.CreateInstance <LiveCasinoTableAccessor>();
                    ceLiveCasinoTable       table = lta.GetTable(DomainManager.CurrentDomainID, id);
                    bool isExist = table != null;
                    SqlQuery <ceLiveCasinoTable> query2 = new SqlQuery <ceLiveCasinoTable>();
                    if (isExist)
                    {
                        query2.Delete(table);
                        return(this.Json(new { success = true }, JsonRequestBehavior.AllowGet));
                    }

                    return(this.Json(new { success = false, error = "Table not found!" }, JsonRequestBehavior.AllowGet));
                }

                return(this.Json(new { success = false }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                Logger.Exception(ex);
                return(this.Json(new { success = false, error = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 2
0
        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()));
        }
Exemplo n.º 3
0
    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);
    }
        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));
        }
Exemplo n.º 6
0
        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);
        }
        private bool InternalUpdateProperty(long id, AvailableEditTableProperty property, object value, bool updatingBase, PropertyEditType editType, bool setToDefault)
        {
            if (updatingBase && setToDefault)
            {
                return(false);
            }
            bool succeed = false;

            using (DbManager db = new DbManager())
            {
                db.BeginTransaction();
                try
                {
                    LiveCasinoTableAccessor          lcta      = LiveCasinoTableAccessor.CreateInstance <LiveCasinoTableAccessor>(db);
                    SqlQuery <ceLiveCasinoTableBase> query     = new SqlQuery <ceLiveCasinoTableBase>(db);
                    ceLiveCasinoTableBase            tableBase = null;
                    ceLiveCasinoTable tableDomain = null;

                    if (id > 0)
                    {
                        tableBase = query.SelectByKey(id);
                        if (tableBase != null)
                        {
                            string column                = string.Empty;
                            object defaultValue          = null;
                            bool   useBaseValueAsDefault = false;

                            if (!updatingBase)
                            {
                                tableDomain = lcta.GetTable(DomainManager.CurrentDomainID, id);
                            }

                            bool isExist = tableDomain != null;

                            #region Resolve and assignment property
                            bool tempBool;

                            column = property.ToString();

                            bool valueVerified = setToDefault;
                            bool changed       = true;
                            bool valueResolved = false;
                            switch (property)
                            {
                                #region bool properies
                            case AvailableEditTableProperty.OpVisible:
                            case AvailableEditTableProperty.Enabled:
                            case AvailableEditTableProperty.NewTable:
                            case AvailableEditTableProperty.TurkishTable:
                            case AvailableEditTableProperty.VIPTable:
                                useBaseValueAsDefault = true;
                                if (!setToDefault)
                                {
                                    if (bool.TryParse(value as string, out tempBool))
                                    {
                                        valueVerified = true;
                                        value         = tempBool;
                                    }
                                }
                                break;
                                #endregion bool properies

                            default:
                                column  = null;
                                changed = false;
                                break;
                            }

                            if (!valueResolved && !string.IsNullOrWhiteSpace(column))
                            {
                                value = ResolveValue(updatingBase, setToDefault, tableBase, tableDomain, column, value, defaultValue, useBaseValueAsDefault, out changed);
                            }
                            #endregion Resolve and assignment property

                            if (changed)
                            {
                                succeed = true;
                                if (updatingBase)
                                {
                                    LiveCasinoTableAccessor.UpdateTableBaseProperty(column, value, tableBase.ID);
                                }
                                else
                                {
                                    SqlQuery <ceCasinoGame> query2 = new SqlQuery <ceCasinoGame>(db);
                                    if (isExist)
                                    {
                                        LiveCasinoTableAccessor.UpdateTableProperty(column, value, tableDomain.ID);
                                    }
                                    else
                                    {
                                        LiveCasinoTableAccessor.InsertNewTableWithSpecificProperty(DomainManager.CurrentDomainID
                                                                                                   , tableBase.ID
                                                                                                   , CurrentUserSession.SessionID
                                                                                                   , CurrentUserSession.UserID
                                                                                                   , column
                                                                                                   , value
                                                                                                   , tableBase.Enabled
                                                                                                   , tableBase.OpVisible
                                                                                                   );
                                    }
                                }
                            }
                        }
                    }

                    db.CommitTransaction();

                    return(succeed);
                }
                catch (Exception ex)
                {
                    Logger.Exception(ex);
                    db.RollbackTransaction();
                }
            }
            return(false);
        }
        public ActionResult TableList(long domainID
                                      , VendorID[] filteredVendorIDs
                                      , string filteredTableName
                                      , string filteredGameID
                                      , string filteredSlug
                                      , string filteredClientType
                                      , string[] filteredCategories
                                      , string filteredTableType
                                      , string filteredOpeningHour
                                      , int?pageIndex
                                      , int pageSize
                                      )
        {
            if (!pageIndex.HasValue)
            {
                pageIndex = 1;
            }

            Dictionary <string, object> parameters = new Dictionary <string, object>();

            int totalCount = 0;
            List <ceLiveCasinoTableBaseEx> tables = LiveCasinoTableAccessor.SearchTables(pageIndex.Value, pageSize
                                                                                         , domainID
                                                                                         , filteredVendorIDs
                                                                                         , out totalCount
                                                                                         , false
                                                                                         , !CurrentUserSession.IsSystemUser
                                                                                         , filteredGameID
                                                                                         , filteredSlug
                                                                                         , filteredTableName
                                                                                         , filteredClientType
                                                                                         , filteredCategories
                                                                                         , filteredTableType
                                                                                         , filteredOpeningHour
                                                                                         );

            int totalPageCount = (int)Math.Ceiling(totalCount / (1.0f * pageSize));

            if (pageIndex.Value > totalPageCount)
            {
                pageIndex = totalPageCount;
            }

            this.ViewData["filteredVendorIDs"]  = filteredVendorIDs;
            this.ViewData["filteredGameID"]     = filteredGameID;
            this.ViewData["filteredSlug"]       = filteredSlug;
            this.ViewData["filteredTableName"]  = filteredTableName;
            this.ViewData["filteredClientType"] = filteredClientType;

            this.ViewData["pageIndex"]    = pageIndex.Value;
            this.ViewData["pageSize"]     = pageSize;
            this.ViewData["pageCount"]    = totalPageCount;
            this.ViewData["totalRecords"] = totalCount; //games.Count;

            int _temp = pageSize * pageIndex.Value;

            if (_temp > totalCount)
            {
                _temp = totalCount;
            }
            this.ViewData["currentRecords"] = _temp;

            return(View("TableList", tables));
        }
        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 JsonResult EnableTables(long[] tableIDs, bool enable)
        {
            if (!DomainManager.AllowEdit())
            {
                throw new Exception("Data modified is not allowed");
            }
            try
            {
                if (!CurrentUserSession.IsSystemUser)
                {
                    throw new CeException("You are not allowed to perform this operation.");
                }

                SqlQuery <ceLiveCasinoTableBase> query1 = new SqlQuery <ceLiveCasinoTableBase>();
                SqlQuery <ceLiveCasinoTable>     query2 = new SqlQuery <ceLiveCasinoTable>();
                LiveCasinoTableAccessor          lta    = LiveCasinoTableAccessor.CreateInstance <LiveCasinoTableAccessor>();
                foreach (long tableID in tableIDs)
                {
                    if (CurrentUserSession.IsSystemUser && DomainManager.CurrentDomainID == Constant.SystemDomainID)
                    {
                        ceLiveCasinoTableBase baseTable = query1.SelectByKey(tableID);
                        baseTable.Enabled = enable;
                        query1.Update(baseTable);
                    }
                    else
                    {
                        ceLiveCasinoTable table = lta.GetTable(DomainManager.CurrentDomainID, tableID);
                        if (table == null)
                        {
                            table = new ceLiveCasinoTable()
                            {
                                DomainID = DomainManager.CurrentDomainID, LiveCasinoTableBaseID = tableID
                            };
                            table.Ins           = DateTime.Now;
                            table.SessionUserID = CurrentUserSession.UserID;
                            table.SessionID     = CurrentUserSession.UserSessionID;
                            table.Enabled       = enable;

                            table.ClientCompatibility = null;
                            table.TableName           = null;
                            table.ShortName           = null;
                            table.Category            = null;
                            table.Thumbnail           = null;
                            table.Logo            = null;
                            table.BackgroundImage = null;
                            table.ExtraParameter1 = null;
                            table.ExtraParameter2 = null;
                            table.ExtraParameter3 = null;
                            table.ExtraParameter4 = null;
                            table.LaunchParams    = null;
                            table.LimitationXml   = null;
                            query2.Insert(table);
                        }
                        else
                        {
                            if (string.IsNullOrWhiteSpace(table.ClientCompatibility))
                            {
                                table.ClientCompatibility = null;
                            }
                            if (string.IsNullOrWhiteSpace(table.TableName))
                            {
                                table.TableName = null;
                            }
                            if (string.IsNullOrWhiteSpace(table.ShortName))
                            {
                                table.ShortName = null;
                            }
                            if (string.IsNullOrWhiteSpace(table.Category))
                            {
                                table.Category = null;
                            }
                            if (string.IsNullOrWhiteSpace(table.Thumbnail))
                            {
                                table.Thumbnail = null;
                            }
                            if (string.IsNullOrWhiteSpace(table.Logo))
                            {
                                table.Logo = null;
                            }
                            if (string.IsNullOrWhiteSpace(table.BackgroundImage))
                            {
                                table.BackgroundImage = null;
                            }
                            if (string.IsNullOrWhiteSpace(table.ExtraParameter1))
                            {
                                table.ExtraParameter1 = null;
                            }
                            if (string.IsNullOrWhiteSpace(table.ExtraParameter2))
                            {
                                table.ExtraParameter2 = null;
                            }
                            if (string.IsNullOrWhiteSpace(table.ExtraParameter3))
                            {
                                table.ExtraParameter3 = null;
                            }
                            if (string.IsNullOrWhiteSpace(table.ExtraParameter4))
                            {
                                table.ExtraParameter4 = null;
                            }
                            if (string.IsNullOrWhiteSpace(table.LaunchParams))
                            {
                                table.LaunchParams = null;
                            }
                            if (string.IsNullOrWhiteSpace(table.LimitationXml))
                            {
                                table.LimitationXml = null;
                            }

                            table.Enabled = enable;
                            query2.Update(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));
            }
        }
Exemplo n.º 11
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));
        }