示例#1
0
 private void InitConfig()
 {
     try
     {
         CaiDaXiaoConfig cfg = KFBoCaiConfigManager.GetCaiDaXiaoConfig();
         if (null != cfg)
         {
             this.Config                 = new CaiDaXiaoConfig();
             this.Config.ID              = cfg.ID;
             this.Config.HuoDongKaiQi    = cfg.HuoDongKaiQi;
             this.Config.HuoDongJieSu    = cfg.HuoDongJieSu;
             this.Config.MeiRiKaiQi      = cfg.MeiRiKaiQi;
             this.Config.MeiRiJieSu      = cfg.MeiRiJieSu;
             this.Config.ZhuShuShangXian = cfg.ZhuShuShangXian;
             this.OpenData.XiaoHaoDaiBi  = cfg.XiaoHaoDaiBi;
         }
         else
         {
             this.Config = null;
             LogManager.WriteLog(LogTypes.Error, "[ljl_caidaxiao_猜大小] KFBoCaiConfigManager.GetCaiShuZiConfig() == null", null, true);
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_caidaxiao_猜大小]{0}", ex.ToString()), null, true);
     }
 }
        public static CaiDaXiaoConfig GetCaiDaXiaoConfig()
        {
            CaiDaXiaoConfig cfg = null;

            try
            {
                lock (KFBoCaiConfigManager.CaiDaXiaoCfgList)
                {
                    int maxLen = KFBoCaiConfigManager.CaiDaXiaoCfgList.Count;
                    int index  = 0;
                    while (index < maxLen)
                    {
                        if (DateTime.Parse(KFBoCaiConfigManager.CaiDaXiaoCfgList[index].HuoDongJieSu) < TimeUtil.NowDateTime())
                        {
                            KFBoCaiConfigManager.CaiDaXiaoCfgList.RemoveAt(index);
                            maxLen = KFBoCaiConfigManager.CaiDaXiaoCfgList.Count;
                        }
                        else
                        {
                            if (cfg == null || DateTime.Parse(cfg.HuoDongKaiQi) > DateTime.Parse(KFBoCaiConfigManager.CaiDaXiaoCfgList[index].HuoDongKaiQi))
                            {
                                cfg = KFBoCaiConfigManager.CaiDaXiaoCfgList[index];
                            }
                            index++;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true);
            }
            return(cfg);
        }
 private static bool LoadCaiDaXiao(out List <CaiDaXiaoConfig> _CaiDaXiaoCfgList)
 {
     _CaiDaXiaoCfgList = new List <CaiDaXiaoConfig>();
     try
     {
         XElement xml = ConfigHelper.Load(KuaFuServerManager.GetResourcePath("Config/CaiDaXiao.xml", KuaFuServerManager.ResourcePathTypes.GameRes));
         if (null == xml)
         {
             LogManager.WriteLog(LogTypes.Fatal, string.Format("读取 {0} null == xml", "Config/CaiDaXiao.xml"), null, true);
             return(false);
         }
         IEnumerable <XElement> xmlItems = xml.Elements();
         foreach (XElement xmlItem in xmlItems)
         {
             if (null != xmlItem)
             {
                 CaiDaXiaoConfig myData = new CaiDaXiaoConfig();
                 myData.ID                = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "ID", 0L);
                 myData.XiaoHaoDaiBi      = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "XiaoHaoDaiBi", 0L);
                 myData.ShangChengKaiGuan = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "ShangChengKaiGuan", 0L);
                 myData.HuoDongKaiQi      = ConfigHelper.GetElementAttributeValue(xmlItem, "HuoDongKaiQi", "");
                 myData.ZhuShuShangXian   = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "ZhuShuShangXian", 0L);
                 DateTime.Parse(myData.HuoDongKaiQi);
                 myData.HuoDongJieSu = ConfigHelper.GetElementAttributeValue(xmlItem, "HuoDongJieSu", "");
                 DateTime.Parse(myData.HuoDongJieSu);
                 myData.MeiRiKaiQi = ConfigHelper.GetElementAttributeValue(xmlItem, "MeiRiKaiQi", "");
                 DateTime.Parse(myData.MeiRiKaiQi);
                 myData.MeiRiJieSu = ConfigHelper.GetElementAttributeValue(xmlItem, "MeiRiJieSu", "");
                 DateTime.Parse(myData.MeiRiJieSu);
                 _CaiDaXiaoCfgList.Add(myData);
             }
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Fatal, string.Format("{0}解析出现异常, {1}", "Config/CaiDaXiao.xml", ex.Message), null, true);
         return(false);
     }
     return(true);
 }