Beispiel #1
0
        public static bool initConfig()
        {
            string   fileName = Global.GameResPath("Config/TenAward.xml");
            XElement xml      = CheckHelper.LoadXml(fileName, true);
            bool     result;

            if (null == xml)
            {
                result = false;
            }
            else
            {
                try
                {
                    TenManager._tenAwardDic.Clear();
                    IEnumerable <XElement> xmlItems = xml.Elements();
                    foreach (XElement xmlItem in xmlItems)
                    {
                        if (xmlItem != null)
                        {
                            TenAwardData config = new TenAwardData();
                            config.AwardID     = Convert.ToInt32(Global.GetSafeAttributeLong(xmlItem, "ID"));
                            config.AwardName   = Global.GetSafeAttributeStr(xmlItem, "Name");
                            config.DbKey       = Global.GetSafeAttributeStr(xmlItem, "DbKey");
                            config.DayMaxNum   = Convert.ToInt32(Global.GetSafeAttributeLong(xmlItem, "DayMaxNum"));
                            config.OnlyNum     = Convert.ToInt32(Global.GetSafeAttributeLong(xmlItem, "OnlyNum"));
                            config.MailUser    = GLang.GetLang(112, new object[0]);
                            config.MailTitle   = Global.GetSafeAttributeStr(xmlItem, "MailTitle");
                            config.MailContent = Global.GetSafeAttributeStr(xmlItem, "MailContent");
                            string beginTime = Global.GetDefAttributeStr(xmlItem, "BeginDate", "");
                            string endTime   = Global.GetDefAttributeStr(xmlItem, "EndDate", "");
                            string roleLevel = Global.GetDefAttributeStr(xmlItem, "Level", "0,1");
                            if (string.IsNullOrEmpty(beginTime))
                            {
                                config.BeginTime = DateTime.MinValue;
                            }
                            else
                            {
                                config.BeginTime = DateTime.Parse(beginTime);
                            }
                            if (string.IsNullOrEmpty(endTime))
                            {
                                config.EndTime = DateTime.MaxValue;
                            }
                            else
                            {
                                config.EndTime = DateTime.Parse(endTime);
                            }
                            string[] arrLevel = roleLevel.Split(new char[]
                            {
                                ','
                            });
                            config.RoleLevel = int.Parse(arrLevel[0]) * 100 + int.Parse(arrLevel[1]);
                            string awards = Global.GetSafeAttributeStr(xmlItem, "AwardGoods");
                            if (!string.IsNullOrEmpty(awards))
                            {
                                string[] awardsArr = awards.Split(new char[]
                                {
                                    '|'
                                });
                                config.AwardGoods = GoodsHelper.ParseGoodsDataList(awardsArr, fileName);
                            }
                            TenManager._tenAwardDic.Add(config.AwardID, config);
                        }
                    }
                    TenManager.initDb();
                }
                catch (Exception)
                {
                    LogManager.WriteLog(LogTypes.Error, "加载Config/TenAward.xml时文件出现异常!!!", null, true);
                    Process.GetCurrentProcess().Kill();
                    return(false);
                }
                result = true;
            }
            return(result);
        }
Beispiel #2
0
 public bool initialize()
 {
     return(TenManager.initConfig());
 }