示例#1
0
        public void Save(cmSite site, SiteAccessRule rule, bool logChanges = true)
        {
            string         filePath = HostingEnvironment.MapPath(string.Format("~/Views/{0}/.config/SiteAccessRule", site.DistinctName));
            SiteAccessRule cached   = HttpRuntime.Cache[filePath] as SiteAccessRule;

            string relativePath = "/.config/site_access_rule.setting";
            string name         = "Access Control";

            cached = rule;
            HttpRuntime.Cache.Insert(filePath
                                     , cached
                                     , new CacheDependencyEx(new string[] { filePath }, false)
                                     , Cache.NoAbsoluteExpiration
                                     , Cache.NoSlidingExpiration
                                     , CacheItemPriority.NotRemovable
                                     , null
                                     );

            if (logChanges)
            {
                Revisions.BackupIfNotExists(site, filePath, relativePath, name);
            }

            ObjectHelper.BinarySerialize <SiteAccessRule>(rule, filePath);

            if (logChanges)
            {
                Revisions.Backup(site, filePath, relativePath, name);
            }
        }
示例#2
0
 public static void Save(List <int> domainIDs)
 {
     if (domainIDs != null)
     {
         ObjectHelper.BinarySerialize <List <int> >(domainIDs, _FilePath);
     }
 }
示例#3
0
        public static void Save(cmSite site, Dictionary <string, string> hostMapping)
        {
            string filePath = HostingEnvironment.MapPath(string.Format("~/Views/{0}/.config/SiteHostMapping", site.DistinctName));

            string relativePath = "/.config/site_host_mapping.setting";
            string name         = "Host Mapping";

            Revisions.BackupIfNotExists(site, filePath, relativePath, name);

            ObjectHelper.BinarySerialize <Dictionary <string, string> >(hostMapping, filePath);

            Revisions.Backup(site, filePath, relativePath, name);
        }
        public void Save(cmSite site, SiteRestrictDomainRule rule)
        {
            string filePath = HostingEnvironment.MapPath(string.Format("~/Views/{0}/.config/SiteDomainRule", site.DistinctName));

            string relativePath = "/.config/site_domain_access_rule.setting";
            string name         = "Domain Access Control";

            Revisions.BackupIfNotExists(site, filePath, relativePath, name);

            ObjectHelper.BinarySerialize <SiteRestrictDomainRule>(rule, filePath);

            Revisions.Backup(site, filePath, relativePath, name);
        }
示例#5
0
        public void Load(byte [] buffer)
        {
            using (MemoryStream ms = new MemoryStream(buffer))
            {
                BinaryFormatter bf = new BinaryFormatter();
                Dictionary <string, RouteExtraInfo> routeExtraInfos = (Dictionary <string, RouteExtraInfo>)bf.Deserialize(ms);

                if (routeExtraInfos == null)
                {
                    throw new Exception("Invalid Object");
                }

                Load(routeExtraInfos);

                ObjectHelper.BinarySerialize <Dictionary <string, RouteExtraInfo> >(routeExtraInfos, GetCacheFilePath());
            }
        }
示例#6
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);
        }
示例#7
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);
        }
示例#8
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);
        }
示例#9
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);
        }
示例#10
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);
        }
示例#11
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);
        }
示例#12
0
        public static Dictionary <string, XProGaming.Game> ParseXml(long domainID, string inputXml)
        {
            Dictionary <string, XProGaming.Game> dic = new Dictionary <string, XProGaming.Game>(StringComparer.InvariantCultureIgnoreCase);

            XElement   root = XElement.Parse(inputXml);
            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)
            {
                XProGaming.Game gameToAdd = new XProGaming.Game()
                {
                    GameID         = game.Element(ns + "gameID").Value,
                    GameType       = (XProGaming.GameType) int.Parse(game.Element(ns + "gameType").Value, CultureInfo.InvariantCulture),
                    GameName       = game.Element(ns + "gameName").Value,
                    ConnectionUrl  = game.Element(ns + "connectionUrl").Value,
                    WindowParams   = game.Element(ns + "winParams").Value,
                    OpenHour       = game.Element(ns + "openHour").Value,
                    CloseHour      = game.Element(ns + "closeHour").Value,
                    DealerName     = game.Element(ns + "dealerName").Value,
                    DealerImageUrl = game.Element(ns + "dealerImageUrl").Value,
                    IsOpen         = string.Equals(game.Element(ns + "isOpen").Value, "1", StringComparison.InvariantCultureIgnoreCase),
                };

                IEnumerable <XElement> limitSets = game.Element(ns + "limitSetList").Elements(ns + "limitSet");
                foreach (XElement limitSet in limitSets)
                {
                    XProGaming.LimitSet limitSetToAdd = new XProGaming.LimitSet();

                    decimal temp;
                    limitSetToAdd.ID = limitSet.Element(ns + "limitSetID").Value;
                    if (limitSet.Element(ns + "minBet") != null && decimal.TryParse(limitSet.Element(ns + "minBet").Value, NumberStyles.Number | NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out temp))
                    {
                        limitSetToAdd.MinBet = temp;
                    }
                    if (limitSet.Element(ns + "maxBet") != null && decimal.TryParse(limitSet.Element(ns + "maxBet").Value, NumberStyles.Number | NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out temp))
                    {
                        limitSetToAdd.MaxBet = temp;
                    }
                    if (limitSet.Element(ns + "minInsideBet") != null && decimal.TryParse(limitSet.Element(ns + "minInsideBet").Value, NumberStyles.Number | NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out temp))
                    {
                        limitSetToAdd.MinInsideBet = temp;
                    }
                    if (limitSet.Element(ns + "maxInsideBet") != null && decimal.TryParse(limitSet.Element(ns + "maxInsideBet").Value, NumberStyles.Number | NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out temp))
                    {
                        limitSetToAdd.MaxInsideBet = temp;
                    }
                    if (limitSet.Element(ns + "minOutsideBet") != null && decimal.TryParse(limitSet.Element(ns + "minOutsideBet").Value, NumberStyles.Number | NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out temp))
                    {
                        limitSetToAdd.MinOutsideBet = temp;
                    }
                    if (limitSet.Element(ns + "maxOutsideBet") != null && decimal.TryParse(limitSet.Element(ns + "maxOutsideBet").Value, NumberStyles.Number | NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out temp))
                    {
                        limitSetToAdd.MaxOutsideBet = temp;
                    }
                    if (limitSet.Element(ns + "minPlayerBet") != null && decimal.TryParse(limitSet.Element(ns + "minPlayerBet").Value, NumberStyles.Number | NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out temp))
                    {
                        limitSetToAdd.MinPlayerBet = temp;
                    }
                    if (limitSet.Element(ns + "maxPlayerBet") != null && decimal.TryParse(limitSet.Element(ns + "maxPlayerBet").Value, NumberStyles.Number | NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out temp))
                    {
                        limitSetToAdd.MaxPlayerBet = temp;
                    }

                    gameToAdd.LimitSets.Add(limitSetToAdd);
                }


                dic[gameToAdd.GameID] = gameToAdd;
            }

            string cacheFile = Path.Combine(FileSystemUtility.GetWebSiteTempDirectory()
                                            , string.Format(CultureInfo.InvariantCulture, CACHE_FILE_FORMAT, domainID)
                                            );

            ObjectHelper.BinarySerialize <Dictionary <string, XProGaming.Game> >(dic, cacheFile);
            HttpRuntime.Cache[cacheFile] = dic;
            return(dic);
        }
示例#13
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);
        }
示例#14
0
        public void LoadConfigration()
        {
            try
            {
                Logger.Information("SiteRouteInfo", "{0} LoadConfigration start", this.Domain.DistinctName);
                ContentTree tree = ContentTree.GetByDistinctName(this.Domain.DistinctName, this.Domain.TemplateDomainDistinctName, false);
                if (tree != null)
                {
                    RouteCollection routeCollection = new RouteCollection();
                    Dictionary <string, RouteExtraInfo> routeExtraInfos = new Dictionary <string, RouteExtraInfo>(StringComparer.InvariantCultureIgnoreCase);

                    Type[] types = ControllerEx.GetControllerAssembly().GetTypes();

                    foreach (KeyValuePair <string, ContentNode> item in tree.AllNodes)
                    {
                        ContentNode node = item.Value;
                        if (node.NodeType == ContentNode.ContentNodeType.Page)
                        {
                            PageNode pageNode = new PageNode(node);

                            if (string.IsNullOrWhiteSpace(pageNode.Controller))
                            {
                                continue;
                            }

                            // Get the controller class
                            Type controllerType = types.FirstOrDefault(t => t.FullName == pageNode.Controller);

                            if (controllerType == null)
                            {
                                Logger.Error("CMS", "Error, can't find the type [{0}].", pageNode.Controller);
                                continue;
                            }
                            else
                            {
                                object[] attributes = controllerType.GetCustomAttributes(typeof(ControllerExtraInfoAttribute), false);
                                ControllerExtraInfoAttribute attribute = null;
                                if (attributes.Length > 0)
                                {
                                    attribute = attributes[0] as ControllerExtraInfoAttribute;
                                }
                                else
                                {
                                    attribute = new ControllerExtraInfoAttribute()
                                    {
                                        DefaultAction = "Index"
                                    }
                                };

                                string url = pageNode.ContentNode.RelativePath;
                                if (!url.StartsWith("/"))
                                {
                                    url = "/" + url;
                                }
                                url = url.TrimEnd('/');

                                RouteExtraInfo extraInfo = new RouteExtraInfo();
                                extraInfo.RouteName = pageNode.RouteName;
                                extraInfo.RouteUrl  = string.Format("{0}/{{action}}/{1}", url.TrimStart('/').TrimEnd('/'), attribute.ParameterUrl);
                                Route route = routeCollection.MapRoute(extraInfo.RouteName, extraInfo.RouteUrl);
                                extraInfo.Action = attribute.DefaultAction.DefaultIfNullOrEmpty("Index");
                                route.Defaults.Add("action", extraInfo.Action);
                                extraInfo.Controller = Regex.Replace(controllerType.Name, "(Controller)$", string.Empty, RegexOptions.IgnoreCase | RegexOptions.ECMAScript | RegexOptions.CultureInvariant | RegexOptions.Compiled);
                                route.Defaults.Add("controller", extraInfo.Controller);

                                if (!string.IsNullOrEmpty(attribute.ParameterUrl))
                                {
                                    string[] parameters = attribute.ParameterUrl.Split('/');
                                    foreach (string parameter in parameters)
                                    {
                                        string p = parameter.TrimStart('{').TrimEnd('}');
                                        extraInfo.Parameters.Add(p);
                                        route.Defaults.Add(p, UrlParameter.Optional);
                                    }
                                }
                                extraInfo.Url                 = url;
                                extraInfo.ControllerType      = controllerType;
                                route.DataTokens["RouteName"] = extraInfo.RouteName;

                                routeExtraInfos[extraInfo.RouteName] = extraInfo;
                            } // if_else
                        }     // if
                    }         // foreach

                    this.RouteExtraInfos = routeExtraInfos;
                    this.RouteCollection = routeCollection;

                    ObjectHelper.BinarySerialize <Dictionary <string, RouteExtraInfo> >(routeExtraInfos, GetCacheFilePath());
                }// if

                Logger.Information("SiteRouteInfo", "{0} LoadConfigration completed", this.Domain.DistinctName);
            }
            catch (Exception ex)
            {
                Logger.Exception(ex);
            }
        }// LoadConfigration
示例#15
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
示例#16
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
示例#17
0
        private static bool InternalReloadSiteHostCache()
        {
            bool success = false;

            if (Monitor.TryEnter(s_UpdateSiteHostCacheLock))
            {
                try
                {
                    SiteAccessor  da       = DataAccessor.CreateInstance <SiteAccessor>();
                    string        filePath = HostingEnvironment.MapPath(ALL_SITES_CACHE_FILE);
                    List <cmSite> sites    = da.GetAll();
                    if (sites.Count > 0)
                    {
                        ObjectHelper.BinarySerialize <List <cmSite> >(sites, filePath);
                        HttpRuntime.Cache.Insert(ALL_SITES_CACHE_FILE
                                                 , sites
                                                 , new CacheDependency(filePath)
                                                 , Cache.NoAbsoluteExpiration
                                                 , Cache.NoSlidingExpiration
                                                 , CacheItemPriority.NotRemovable
                                                 , null
                                                 );
                    }

                    HostAccessor ha = DataAccessor.CreateInstance <HostAccessor>();
                    filePath = HostingEnvironment.MapPath(ALL_HOSTS_CACHE_FILE);

                    List <cmHost> hosts = ha.GetAll();
                    if (!string.IsNullOrWhiteSpace(ConfigurationManager.AppSettings["Init.Debug.Sites"]))
                    {
                        //only loads the sites specificed from web.config & template sites, to speed the loading for debug
                        hosts = hosts.Where(h => GetRootTemplateSites().Exists(s => s.ID == h.SiteID) || GetDebugSites().Contains(h.SiteID)).ToList();
                    }
                    if (hosts.Count > 0)
                    {
                        ObjectHelper.BinarySerialize <List <cmHost> >(hosts, filePath);
                        HttpRuntime.Cache.Insert(ALL_HOSTS_CACHE_FILE
                                                 , hosts
                                                 , new CacheDependency(filePath)
                                                 , Cache.NoAbsoluteExpiration
                                                 , Cache.NoSlidingExpiration
                                                 , CacheItemPriority.NotRemovable
                                                 , null
                                                 );
                    }


                    Dictionary <string, SiteAndHost> dictionary = new Dictionary <string, SiteAndHost>(StringComparer.InvariantCultureIgnoreCase);
                    foreach (cmHost host in hosts)
                    {
                        cmSite site = sites.FirstOrDefault(s => s.ID == host.SiteID);
                        if (site != null)
                        {
                            dictionary[host.HostName] = new SiteAndHost()
                            {
                                Site = site,
                                Host = host,
                            };
                        }
                    }
                    if (dictionary.Count > 0)
                    {
                        filePath = HostingEnvironment.MapPath(HOST_SITE_MAP_CACHE_FILE);
                        ObjectHelper.BinarySerialize <Dictionary <string, SiteAndHost> >(dictionary, filePath);
                        HttpRuntime.Cache.Insert(HOST_SITE_MAP_CACHE_FILE
                                                 , dictionary
                                                 , new CacheDependency(filePath)
                                                 , Cache.NoAbsoluteExpiration
                                                 , Cache.NoSlidingExpiration
                                                 , CacheItemPriority.NotRemovable
                                                 , null
                                                 );
                    }

                    success = true;
                }
                catch (Exception ex)
                {
                    Logger.Exception(ex);
                }
                finally
                {
                    Monitor.Exit(s_UpdateSiteHostCacheLock);
                }
            }

            return(success);
        }