Exemplo n.º 1
0
    public static ceDomainConfigEx GetSysDomain()
    {
        ceDomainConfigEx domain = HttpRuntime.Cache[Constant.SysDomainCacheKey] as ceDomainConfigEx;

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

        lock (typeof(DomainManager))
        {
            domain = HttpRuntime.Cache[Constant.SysDomainCacheKey] as ceDomainConfigEx;
            if (domain != null)
            {
                return(domain);
            }

            DomainConfigAccessor dca = DomainConfigAccessor.CreateInstance <DomainConfigAccessor>();
            domain = dca.GetSys();

            CacheManager.AddCache(Constant.SysDomainCacheKey, domain);
        }

        return(domain);
    }
Exemplo n.º 2
0
        public static Dictionary <ConfigAttribute, ceDomainConfigItem> DirectReadAll(long domainID, Type type)
        {
            DomainConfigAccessor dca = DomainConfigAccessor.CreateInstance <DomainConfigAccessor>();
            Dictionary <string, ceDomainConfigItem> items = dca.GetConfigurationItemsByDomainID(domainID);

            Dictionary <ConfigAttribute, ceDomainConfigItem> dic = new Dictionary <ConfigAttribute, ceDomainConfigItem>();

            FieldInfo [] fields = type.GetFields(BindingFlags.Public | BindingFlags.Static);
            foreach (FieldInfo field in fields)
            {
                object [] attributes = field.GetCustomAttributes(typeof(ConfigAttribute), false);
                if (attributes.Length == 0)
                {
                    continue;
                }

                ConfigAttribute attr = attributes[0] as ConfigAttribute;
                if (attr == null)
                {
                    continue;
                }

                if (field.FieldType != typeof(string))
                {
                    continue;
                }

                string itemName = field.GetValue(null) as string;
                if (itemName == null)
                {
                    continue;
                }

                ceDomainConfigItem item = null;
                if (!items.TryGetValue(itemName, out item) || item == null)
                {
                    item = new ceDomainConfigItem()
                    {
                        ItemName = itemName,
                    };

                    if (!string.Equals(ConfigurationManager.AppSettings["ProductionMode"], "off", StringComparison.InvariantCultureIgnoreCase))
                    {
                        item.ItemValue = attr.ProductionDefaultValue;
                    }
                    else
                    {
                        item.ItemValue = attr.StagingDefaultValue;
                    }
                }

                dic[attr] = item;
            }

            return(dic);
        }
Exemplo n.º 3
0
 //
 // GET: /Configuration/
 public ActionResult Index()
 {
     if (DomainManager.CurrentDomainID > 0)
     {
         DomainConfigAccessor dca = DomainConfigAccessor.CreateInstance<DomainConfigAccessor>();
         ceDomainConfigEx domain = dca.GetByDomainID(DomainManager.CurrentDomainID);
         return View(domain);
     }
     return View();
 }
Exemplo n.º 4
0
        private Dictionary <string, ceDomainConfigItem> GetCfgCache(long domainID)
        {
            string cacheKey = string.Format("{0}{1}", CACHE_KEY_PREFIX, this.DomainID);
            Dictionary <string, ceDomainConfigItem> items = HttpRuntime.Cache[cacheKey] as Dictionary <string, ceDomainConfigItem>;

            if (items == null)
            {
                DomainConfigAccessor dca = DomainConfigAccessor.CreateInstance <DomainConfigAccessor>();
                items = dca.GetConfigurationItemsByDomainID(domainID);
                CacheManager.AddCache(cacheKey, items);
            }
            return(items);
        }
Exemplo n.º 5
0
        public JsonResult SaveDomainConfig(string typeName)
        {
            if (!DomainManager.AllowEdit())
            {
                throw new Exception("Data modified is not allowed");
            }
            Type type = null;
            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                type = assembly.GetType(typeName);
                if (type != null)
                    break;
            }
            if (type == null)
                throw new CeException("Can not find type [{0}]", typeName);
            DomainConfigAccessor dca = DomainConfigAccessor.CreateInstance<DomainConfigAccessor>();
            FieldInfo[] fields = type.GetFields(BindingFlags.Public | BindingFlags.Static);
            foreach (FieldInfo field in fields)
            {
                ConfigAttribute attr = field.GetCustomAttribute<ConfigAttribute>();
                if (attr == null)
                    continue;

                string itemName = field.GetValue(null) as string;
                string itemValue = Request.Form[itemName];
                string countrySpecificCfg = null;
                if (itemValue == null)
                    continue;

                if (attr.AllowCountrySpecificValue)
                {
                    countrySpecificCfg = Request.Form[string.Format("{0}_CountrySpecificCfg", itemName)];
                }

                dca.SetConfigurationItemValue(DomainManager.CurrentDomainID, itemName, itemValue, countrySpecificCfg);
            }
            ceDomainConfigEx.ClearCfgCache(DomainManager.CurrentDomainID);
            return this.Json(new { @success = true });
        }
Exemplo n.º 6
0
    public static List <DomainVendorConfig> GetDomainVendors()
    {
        List <DomainVendorConfig> domainVendors = HttpRuntime.Cache[Constant.DomainVendorCacheKey] as List <DomainVendorConfig>;

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

        lock (typeof(DomainManager))
        {
            domainVendors = HttpRuntime.Cache[Constant.DomainVendorCacheKey] as List <DomainVendorConfig>;
            if (domainVendors != null)
            {
                return(domainVendors);
            }

            DomainConfigAccessor dca = DomainConfigAccessor.CreateInstance <DomainConfigAccessor>();
            domainVendors = dca.GetEnabledVendorsForAllOperators(Constant.SystemDomainID);

            CacheManager.AddCache(Constant.DomainVendorCacheKey, domainVendors);
        }
        return(domainVendors);
    }
Exemplo n.º 7
0
    public static List <ceDomainConfigEx> GetDomains()
    {
        List <ceDomainConfigEx> domains = HttpRuntime.Cache[Constant.DomainCacheKey] as List <ceDomainConfigEx>;

        if (domains != null)
        {
            return(ObjectHelper.DeepClone(domains));
        }

        lock (typeof(DomainManager))
        {
            domains = HttpRuntime.Cache[Constant.DomainCacheKey] as List <ceDomainConfigEx>;
            if (domains != null)
            {
                return(domains);
            }

            DomainConfigAccessor dca = DomainConfigAccessor.CreateInstance <DomainConfigAccessor>();
            domains = dca.GetAll(ActiveStatus.Active);

            CacheManager.AddCache(Constant.DomainCacheKey, domains);
        }
        return(domains);
    }
Exemplo n.º 8
0
        public static Dictionary <string, JackpotInfo> GetPlaynGOJackpots(long domainID, string customUrl = null)
        {
            string filepath = Path.Combine(FileSystemUtility.GetWebSiteTempDirectory()
                                           , string.Format("PlaynGOJackpotsFeeds.{0}.cache", domainID)
                                           );
            Dictionary <string, JackpotInfo> cached = HttpRuntime.Cache[filepath] as Dictionary <string, JackpotInfo>;

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

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

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

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

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


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

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

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

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

                    if (jackpots.Count > 0 && string.IsNullOrEmpty(customUrl))
                    {
                        ObjectHelper.BinarySerialize <Dictionary <string, JackpotInfo> >(jackpots, filepath);
                    }
                    return(jackpots);
                }
                catch (Exception ex)
                {
                    Logger.Exception(ex, string.Format(@" PlaynGO - Jackpots URL : {0}", url));
                    throw;
                }
            };

            if (!string.IsNullOrEmpty(customUrl))
            {
                cached = func();
            }
            else if (!DelayUpdateCache <Dictionary <string, JackpotInfo> > .TryGetValue(filepath, out cached, func, 120))
            {
                cached = ObjectHelper.BinaryDeserialize <Dictionary <string, JackpotInfo> >(filepath, new Dictionary <string, JackpotInfo>());
            }

            return(cached);
        }
Exemplo n.º 9
0
        public JsonResult LoadCustomJackpots(VendorID vendorId, string url)
        {
            VendorID[] filteredVendorIDs = { vendorId };

            Dictionary <string, JackpotInfo> customJackpots = null;
            var  query    = new SqlQuery <ceCasinoJackpotBase>();
            long domainID = DomainManager.CurrentDomainID;

            var jackpots = CasinoJackpotAccessor.SearchJackpots(domainID, filteredVendorIDs);

            switch (vendorId)
            {
            case VendorID.Microgaming:
                customJackpots = JackpotFeeds.GetMicrogamingJackpots(url);

                break;

            case VendorID.PlaynGO:
                customJackpots = JackpotFeeds.GetPlaynGOJackpots(Constant.SystemDomainID, url);

                break;

            case VendorID.IGT:
                customJackpots = JackpotFeeds.GetIGTJackpots(Constant.SystemDomainID, url);

                break;

            case VendorID.BetSoft:
                var dca    = DomainConfigAccessor.CreateInstance <DomainConfigAccessor>();
                var config = dca.GetByDomainID(Constant.SystemDomainID);

                customJackpots = JackpotFeeds.GetBetSoftJackpots(config, url);

                break;
            }

            var data = new List <SelectListItem>();

            if (customJackpots != null)
            {
                var customVendorForCurrentUrlConfigs = jackpots.Where(x => !string.IsNullOrEmpty(x.CustomVendorConfig))
                                                       .SelectMany(x => JsonConvert.DeserializeObject <List <CustomVendorJackpotConfig> >(x.CustomVendorConfig))
                                                       .Where(x => x.Url == url).ToList();

                //j => !jackpots.Exists(jSaved => jSaved.MappedJackpotID == j.Value.ID
                //&& (this.Model == null || this.Model.MappedJackpotID != jSaved.MappedJackpotID)

                data = customJackpots.Where(x => !customVendorForCurrentUrlConfigs.Exists(cc => cc.MappedJackpotID == x.Value.ID))
                       .Select(j => new SelectListItem
                {
                    Text     = string.Format("{0} ( £ {1:N0} )", j.Value.Name, j.Value.Amounts["GBP"]),
                    Value    = j.Key,
                    Selected = false     //this.Model != null && string.Equals(j.Key, this.Model.MappedJackpotID, StringComparison.OrdinalIgnoreCase)
                })
                       .OrderBy(j => j.Text)
                       .ToList();
            }

            return(this.Json(new
            {
                @success = true,
                Data = data
            }));
        }