public static bool InitializeClient(AutoCSer.Net.TcpInternalServer.ServerSocketSender socket, KuaFuClientContext clientInfo) { bool isLogin = false; try { if (clientInfo.ServerId != 0) { bool bFirstInit = false; int ret = ClientAgentManager.Instance().InitializeClient(clientInfo, out bFirstInit); if (ret > 0) { isLogin = true; socket.ClientObject = ClientAgentManager.Instance().GetCurrentClientAgent(clientInfo.ServerId); if (clientInfo.MapClientCountDict != null && clientInfo.MapClientCountDict.Count > 0) { KuaFuServerManager.UpdateKuaFuLineData(clientInfo.ServerId, clientInfo.MapClientCountDict); ClientAgentManager.Instance().SetMainlinePayload(clientInfo.ServerId, clientInfo.MapClientCountDict.Values.ToList <int>().Sum()); } } } else { LogManager.WriteLog(LogTypes.Error, string.Format("InitializeClient时GameType错误,禁止连接.ServerId:{0},GameType:{1}", clientInfo.ServerId, clientInfo.GameType), null, true); } } catch (Exception ex) { LogManager.WriteExceptionUseCache(string.Format("InitializeClient服务器ID重复,禁止连接.ServerId:{0},ClientId:{1},info:{2}", clientInfo.ServerId, clientInfo.ClientId, clientInfo.Token)); } return(isLogin); }
private static bool Load_DuiHuanShangCheng(out List <DuiHuanShangChengConfig> _DuiHuanShangChengCgfList) { _DuiHuanShangChengCgfList = new List <DuiHuanShangChengConfig>(); try { XElement xml = ConfigHelper.Load(KuaFuServerManager.GetResourcePath("Config/DuiHuanShangCheng.xml", KuaFuServerManager.ResourcePathTypes.GameRes)); if (null == xml) { LogManager.WriteLog(LogTypes.Fatal, string.Format("读取 {0} null == xml", "Config/DuiHuanShangCheng.xml"), null, true); return(false); } IEnumerable <XElement> xmlItems = xml.Elements(); foreach (XElement xmlItem in xmlItems) { DuiHuanShangChengConfig myData = new DuiHuanShangChengConfig(); myData.ID = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "ID", 0L); myData.DaiBiJiaGe = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "DaiBiJiaGe", 0L); myData.MeiRiShangXianDan = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "MeiRiShangXianDan", 0L); myData.Name = ConfigHelper.GetElementAttributeValue(xmlItem, "Name", ""); myData.WuPinID = ConfigHelper.GetElementAttributeValue(xmlItem, "WuPinID", ""); _DuiHuanShangChengCgfList.Add(myData); } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Fatal, string.Format("{0}解析出现异常, {1}", "Config/DuiHuanShangCheng.xml", ex.Message), null, true); return(false); } return(true); }
public static void LoadSyncData(DateTime now, bool rebuild = false) { lock (EscapeBattle_K.Mutex) { List <KFEscapeRankInfo> rankList = new List <KFEscapeRankInfo>(); List <KFEscapeRankInfo> SeasonRankList = new List <KFEscapeRankInfo>(); if (KuaFuServerManager.IsGongNengOpened(115) && EscapeBattleConsts.CheckOpenState(now)) { int weekStartDay = TimeUtil.GetWeekStartDayIdNow(); int offsetDay = TimeUtil.GetOffsetDayNow(); int startDay = EscapeBattle_K.Persistence.GetAsyncInt(14, weekStartDay); startDay = MathEx.Pack(offsetDay, startDay, EscapeBattleConsts.DaysPerSeason); int lastStartDay = startDay - EscapeBattleConsts.DaysPerSeason; DateTime minFightTime = TimeUtil.GetRealDate(startDay); if (EscapeBattle_K.Persistence.BuildEscapeRankList(startDay, minFightTime)) { } EscapeBattle_K.SyncData.Season = startDay; if (offsetDay == startDay) { EscapeBattle_K.Persistence.SetAsyncInt(14, EscapeBattle_K.SyncData.Season); } rankList = EscapeBattle_K.Persistence.LoadEscapeRankData(startDay); SeasonRankList = EscapeBattle_K.Persistence.LoadEscapeRankData(lastStartDay); } EscapeBattle_K.SyncData.RankList = rankList; EscapeBattle_K.SyncData.SeasonRankList = SeasonRankList; EscapeBattle_K.SyncData.RankModTime = now; } }
public static bool InitConfig() { TianTi5v5Service.RankData.MaxPaiMingRank = 201; try { string fileName = "Config/TeamDuanWeiAward.xml"; string fullPathFileName = KuaFuServerManager.GetResourcePath(fileName, KuaFuServerManager.ResourcePathTypes.GameRes); XElement xml = ConfigHelper.Load(fullPathFileName); IEnumerable <XElement> nodes = xml.Elements(); foreach (XElement node in nodes) { int StarRank = (int)ConfigHelper.GetElementAttributeValueLong(node, "StarRank", 201L); TianTi5v5Service.RankData.MaxPaiMingRank = Math.Max(TianTi5v5Service.RankData.MaxPaiMingRank, StarRank); } } catch (Exception ex) { LogManager.WriteException(ex.ToString()); } Dictionary <int, TianTi5v5ZhanDuiData> dict = new Dictionary <int, TianTi5v5ZhanDuiData>(); lock (TianTi5v5Service.Mutex) { TianTi5v5Service.LoadZhanDuiRankData(TianTi5v5Service.RankData, TimeUtil.NowDateTime()); if (!TianTi5v5Service.Persistence.LoadZhanDuiData(dict)) { return(false); } TianTi5v5Service.ZhanDuiDict = dict; } TianTi5v5Service.pTianTiPiPeiCfg = new List <TianTi5v5Service.PiPeiCfg> { new TianTi5v5Service.PiPeiCfg { ID = 0, MinTime = 0, MaxTime = 5 }, new TianTi5v5Service.PiPeiCfg { ID = 1, MinTime = 5, MaxTime = 10 }, new TianTi5v5Service.PiPeiCfg { ID = 3, MinTime = 10, MaxTime = 15 }, new TianTi5v5Service.PiPeiCfg { ID = 25, MinTime = 15, MaxTime = 60 } }; return(true); }
private int ComputeCurrentSeasonID(DateTime now, int CurrentSeasonID) { int result; if (!this.CheckOpenState(now)) { result = 0; } else if (!KuaFuServerManager.IsGongNengOpened(114)) { result = 0; } else { lock (this.MutexConfig) { DateTime OpenTime = ZorkBattleUtils.GetSeasonDateTm(CurrentSeasonID); if (OpenTime == DateTime.MinValue) { TimeSpan start = TimeSpan.MaxValue; foreach (ZorkBattleSceneInfo item in this.SceneDataDict.Values) { for (int i = 0; i < item.TimePoints.Count - 1; i += 2) { TimeSpan startTm = item.TimePoints[i]; if (startTm.Days == 0) { startTm += new TimeSpan(7, 0, 0, 0); } if (startTm < start) { start = startTm; } } } start -= new TimeSpan(1, 0, 0, 0); int spanday = TimeUtil.NowDateTime().DayOfWeek - DayOfWeek.Monday; spanday = ((spanday >= 0) ? (-spanday) : (-(7 + spanday))); TimeSpan nowfromMonday = new TimeSpan(Math.Abs(spanday), now.Hour, now.Minute, now.Second); if (nowfromMonday < start) { OpenTime = TimeUtil.NowDateTime().AddDays((double)spanday); } else { OpenTime = TimeUtil.NowDateTime().AddDays((double)(spanday + 7)); } } else if ((now - OpenTime).Days >= this.SeasonWeeks * 7) { int spanday = TimeUtil.NowDateTime().DayOfWeek - DayOfWeek.Monday; spanday = ((spanday >= 0) ? (-spanday) : (-(7 + spanday))); OpenTime = TimeUtil.NowDateTime().AddDays((double)spanday); } result = ZorkBattleUtils.MakeSeason(OpenTime); } } return(result); }
private int GetCurrentRoundByTime(DateTime now, int CurrentSeasonID) { int result; if (!this.CheckOpenState(now)) { result = 0; } else if (!KuaFuServerManager.IsGongNengOpened(114)) { result = 0; } else { lock (this.MutexConfig) { ZorkBattleSceneInfo sceneConfig = this.SceneDataDict.Values.FirstOrDefault <ZorkBattleSceneInfo>(); if (null == sceneConfig) { result = 0; } else { DateTime curSeasonTime = ZorkBattleUtils.GetSeasonDateTm(CurrentSeasonID); if (now < curSeasonTime) { result = 1; } else { TimeSpan fromMonday = new TimeSpan((int)now.DayOfWeek, now.Hour, now.Minute, now.Second); if (fromMonday.Days == 0) { fromMonday += new TimeSpan(7, 0, 0, 0); } int weekRound = 0; for (int i = 0; i < sceneConfig.TimePoints.Count - 1; i += 2) { TimeSpan myTmp = sceneConfig.TimePoints[i + 1]; if (myTmp.Days == 0) { myTmp += new TimeSpan(7, 0, 0, 0); } if (fromMonday > myTmp) { weekRound++; } } int week = (now - curSeasonTime).Days % (7 * this.SeasonWeeks) / 7; int round = week * sceneConfig.TimePoints.Count / 2 + weekRound + 1; result = Math.Min(round, sceneConfig.SeasonFightRound + 1); } } } } return(result); }
public static void UpdateKuaFuMapClientCount(AutoCSer.Net.TcpInternalServer.ServerSocketSender socket, int serverId, Dictionary <int, int> mapClientCountDict) { ClientAgent agent = socket.ClientObject as ClientAgent; if (mapClientCountDict != null && mapClientCountDict.Count > 0) { KuaFuServerManager.UpdateKuaFuLineData(agent.ClientInfo.ServerId, mapClientCountDict); ClientAgentManager.Instance().SetMainlinePayload(agent.ClientInfo.ServerId, mapClientCountDict.Values.ToList <int>().Sum()); } }
public static void CalZorkBattleRankTeamJiFen(List <KFZorkRankInfo> rankList) { lock (TianTi5v5Service.Mutex) { List <TianTi5v5ZhanDuiData> zhanduiList = TianTi5v5Service.ZhanDuiDict.Values.ToList <TianTi5v5ZhanDuiData>(); if (zhanduiList.Count != 0) { zhanduiList.RemoveAll((TianTi5v5ZhanDuiData x) => x.ZorkJiFen == 0); zhanduiList.Sort(delegate(TianTi5v5ZhanDuiData left, TianTi5v5ZhanDuiData right) { int result; if (left.ZorkJiFen > right.ZorkJiFen) { result = -1; } else if (left.ZorkJiFen < right.ZorkJiFen) { result = 1; } else if (left.ZorkLastFightTime > right.ZorkLastFightTime) { result = 1; } else if (left.ZorkLastFightTime < right.ZorkLastFightTime) { result = -1; } else if (left.ZhanDuiID > right.ZhanDuiID) { result = -1; } else if (left.ZhanDuiID < right.ZhanDuiID) { result = 1; } else { result = 0; } return(result); }); zhanduiList = zhanduiList.GetRange(0, Math.Min(30, zhanduiList.Count)); foreach (TianTi5v5ZhanDuiData item in zhanduiList) { KFZorkRankInfo rankinfo = new KFZorkRankInfo { Key = item.ZhanDuiID, Value = item.ZorkJiFen, StrParam1 = KuaFuServerManager.FormatName(item.ZoneID, item.ZhanDuiName) }; rankList.Add(rankinfo); } } } }
public static int ZhengBaRequestEnter(int zhanDuiID, out int gameId, out int kuaFuServerID, out string[] ips, out int[] ports) { gameId = 0; kuaFuServerID = 0; ips = null; ports = null; lock (ZhanDuiZhengBa_K.Mutex) { if (ZhanDuiZhengBa_K.StateMachine.GetCurrState() != 5) { if (!Consts.TestMode || ZhanDuiZhengBa_K.StateMachine.GetCurrState() != 6) { return(-2001); } } ZhanDuiZhengBa_K.JoinRolePkData roleData = ZhanDuiZhengBa_K.TodayJoinRoleDatas.Find((ZhanDuiZhengBa_K.JoinRolePkData _r) => _r.ZhanDuiID == zhanDuiID); if (roleData == null || roleData.CurrGameID == 0) { return(-4006); } ZhanDuiZhengBaPkLogData logData = null; ZhanDuiZhengBa_K.ThisLoopPkLogs.TryGetValue(roleData.CurrGameID, out logData); if (roleData == null || logData == null) { return(-4006); } if (!roleData.WaitReqEnter) { return(-2001); } gameId = roleData.CurrGameID; kuaFuServerID = roleData.ToServerID; } KuaFuServerInfo serverInfo = KuaFuServerManager.GetKuaFuServerInfo(kuaFuServerID); int result; if (null != serverInfo) { ips = new string[] { serverInfo.Ip }; ports = new int[] { serverInfo.Port }; result = 0; } else { result = -11001; } return(result); }
private void UpdateTopZhanDuiInfo() { this.TopZhanDuiName = ""; if (this.TopZhanDui > 0) { TianTi5v5ZhanDuiData zhanduiData = TianTi5v5Service.GetZhanDuiData(this.TopZhanDui); if (null != zhanduiData) { this.TopZhanDuiName = KuaFuServerManager.FormatName(zhanduiData.ZoneID, zhanduiData.ZhanDuiName); } } }
private void MS_Init_Update(DateTime now, int param) { if (this.CheckOpenState(now)) { if (KuaFuServerManager.IsGongNengOpened(114)) { ZorkBattleSceneInfo matchConfig = this.SceneDataDict.Values.FirstOrDefault <ZorkBattleSceneInfo>(); Zork5v5StateMachine.StateType GameState = Zork5v5StateMachine.StateType.Init; for (int i = 0; i < matchConfig.TimePoints.Count - 1; i += 2) { if (now.DayOfWeek == (DayOfWeek)matchConfig.TimePoints[i].Days) { int RoundSeconds = matchConfig.BattleSignSecs + matchConfig.PrepareSecs + matchConfig.FightingSecs + matchConfig.ClearRolesSecs; int MatchPerRound = (int)(matchConfig.SecondsOfDay[i + 1] - matchConfig.SecondsOfDay[i]) / RoundSeconds; for (int matchloop = 0; matchloop < MatchPerRound; matchloop++) { int signSeconds = (int)matchConfig.SecondsOfDay[i] + RoundSeconds * matchloop; int startSeconds = signSeconds + matchConfig.BattleSignSecs; int endSeconds = startSeconds + RoundSeconds - matchConfig.BattleSignSecs; if (now.TimeOfDay.TotalSeconds >= (double)signSeconds && now.TimeOfDay.TotalSeconds < (double)startSeconds) { GameState = Zork5v5StateMachine.StateType.SignUp; } else if (now.TimeOfDay.TotalSeconds >= (double)startSeconds && now.TimeOfDay.TotalSeconds < (double)endSeconds) { GameState = Zork5v5StateMachine.StateType.GameStart; } } } } if (this.CurrentSeasonID > 0) { if (this.CurrentSeasonID != this.ComputeCurrentSeasonID(now, this.CurrentSeasonID)) { GameState = Zork5v5StateMachine.StateType.RankAnalyse; } } else { this.CurrentSeasonID = this.ComputeCurrentSeasonID(now, this.CurrentSeasonID); this.Persistence.SaveZorkSeasonID(this.CurrentSeasonID); this.CurrentRound = this.GetCurrentRoundByTime(now, this.CurrentSeasonID); } if (GameState != Zork5v5StateMachine.StateType.Init) { this.StateMachine.SetCurrState(GameState, now, param); LogManager.WriteLog(LogTypes.Analysis, string.Format("Zork::MS_Init_Update To:{0} SeasonID:{1} Round:{2}", GameState, this.CurrentSeasonID, this.CurrentRound), null, true); } } } }
public int SignUp_ZorkBattle(int zhanduiID, int serverID) { int result = 0; try { lock (this.Mutex) { DateTime now = TimeUtil.NowDateTime(); if (!this.CheckOpenState(now)) { result = -11004; return(result); } if (this.StateMachine.GetCurrState() != Zork5v5StateMachine.StateType.SignUp && this.StateMachine.GetCurrState() != Zork5v5StateMachine.StateType.RankAnalyse) { result = -2001; return(result); } TianTi5v5ZhanDuiData zhanduiData = TianTi5v5Service.GetZhanDuiData(zhanduiID); if (null == zhanduiData) { result = -5; return(result); } if (this.PiPeiDict.ContainsKey(zhanduiID)) { result = -5; return(result); } KF5v5PiPeiTeam pipeiTeam = new KF5v5PiPeiTeam { TeamID = zhanduiID, ServerID = serverID, GroupIndex = this.CalDuanWeiByJiFen(zhanduiData.ZorkJiFen), ZhanDouLi = zhanduiData.ZhanDouLi, ZorkJiFen = zhanduiData.ZorkJiFen, ZhanDuiName = KuaFuServerManager.FormatName(zhanduiData.ZoneID, zhanduiData.ZhanDuiName) }; this.PiPeiDict[zhanduiID] = pipeiTeam; LogManager.WriteLog(LogTypes.Analysis, string.Format("Zork::比赛报名 SeasonID:{0} Round:{1} ZhanDuiID:{2}", this.CurrentSeasonID, this.CurrentRound, zhanduiID), null, true); } return(result); } catch (Exception ex) { result = -11; LogManager.WriteLog(LogTypes.Error, "Zork5v5Service.SignUp_ZorkBattle failed!", ex, true); } return(result); }
public static bool InitConfig() { lock (ZhanDuiZhengBa_K.Mutex) { ZhanDuiZhengBa_K.Initialize = false; bool bOk = ZhanDuiZhengBa_K._Config.Load(KuaFuServerManager.GetResourcePath("Config\\TeamMatch.xml", KuaFuServerManager.ResourcePathTypes.GameRes), KuaFuServerManager.GetResourcePath("Config\\TeamMatchBirthPoint.xml", KuaFuServerManager.ResourcePathTypes.GameRes)); ZhanDuiZhengBaConsts.MinZhanDuiNum = (Global.TestMode ? 0 : 4); if (!bOk) { LogManager.WriteLog(LogTypes.Error, "ZhanDuiZhengBa_K.InitConfig failed!", null, true); } ZhanDuiZhengBa_K.Initialize = bOk; } return(true); }
public void LoadConfig() { try { List <StatisticsControl> MyIPControlList = new List <StatisticsControl>(); string file = "Config\\IPStaristicsConfig.xml"; XElement xml = ConfigHelper.Load(KuaFuServerManager.GetResourcePath(file, KuaFuServerManager.ResourcePathTypes.GameRes)); if (null != xml) { foreach (XElement xmlItem in xml.Elements()) { MyIPControlList.Add(new StatisticsControl { ID = Convert.ToInt32(xmlItem.Attribute("ID").Value.ToString()), ParamType = Convert.ToInt32(xmlItem.Attribute("ParamType").Value.ToString()), ParamLimit = Convert.ToInt32(xmlItem.Attribute("ParamLimit").Value.ToString()), ComParamType = Convert.ToInt32(xmlItem.Attribute("ComParamType").Value.ToString()), ComParamLimit = Convert.ToDouble(xmlItem.Attribute("ComParamLimit").Value.ToString()), OperaType = Convert.ToInt32(xmlItem.Attribute("OperaType").Value.ToString()), OperaParam = Convert.ToInt32(xmlItem.Attribute("OperaParam").Value.ToString()) }); } file = "Config\\IPPassList.xml"; xml = ConfigHelper.Load(KuaFuServerManager.GetResourcePath(file, KuaFuServerManager.ResourcePathTypes.GameRes)); if (null != xml) { List <IPPassList> NewIPPassList = new List <IPPassList>(); IEnumerable <XElement> xmlItems = xml.Elements(); foreach (XElement xmlItem in xmlItems) { IPPassList value = new IPPassList(); value.ID = Convert.ToInt32(xmlItem.Attribute("ID").Value.ToString()); string MinIP = xmlItem.Attribute("MinIP").Value.ToString(); value.MinIP = IpHelper.IpToInt(MinIP); string MaxIP = xmlItem.Attribute("MaxIP").Value.ToString(); value.MaxIP = IpHelper.IpToInt(MaxIP); NewIPPassList.Add(value); } this._IPControlList = MyIPControlList; this._IPPassList = NewIPPassList; } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Error, "IPStaristicsConfig.InitConfig failed!", ex, true); } }
public static int ZhengBaRequestEnter(int zhanDuiID, out int gameId, out int kuaFuServerID, out string[] ips, out int[] ports) { gameId = 0; kuaFuServerID = 0; ips = null; ports = null; lock (EscapeBattle_K.Mutex) { EscapeBattle_K.JoinPkData roleData; if (!EscapeBattle_K.JoinDict.TryGetValue(zhanDuiID, out roleData) || roleData.CurrGameID == 0) { return(-4006); } EscapeBattlePkLogData logData = null; if (!EscapeBattle_K.ThisLoopPkLogs.TryGetValue(roleData.CurrGameID, out logData)) { return(-4006); } if (logData.State >= 3) { return(-2008); } gameId = roleData.CurrGameID; kuaFuServerID = roleData.ToServerID; } KuaFuServerInfo serverInfo = KuaFuServerManager.GetKuaFuServerInfo(kuaFuServerID); int result; if (null != serverInfo) { ips = new string[] { serverInfo.Ip }; ports = new int[] { serverInfo.Port }; result = 0; } else { result = -11001; } return(result); }
private void AssginKfFuben(KuaFu5v5FuBenData fubenData) { int toServerId = 0; int gameId = 0; gameId = TianTiPersistence.Instance.GetNextGameId(); int roleNum = fubenData.ZhanDuiDict.Count * 5; if (ClientAgentManager.Instance().AssginKfFuben(this.GameType, (long)gameId, roleNum, out toServerId)) { fubenData.ServerId = toServerId; fubenData.GameId = gameId; fubenData.GameType = (int)this.GameType; fubenData.LoginInfo = KuaFuServerManager.GetKuaFuLoginInfo(0, toServerId); this.FuBenDataDict[gameId] = fubenData; foreach (int zhanDuiID in fubenData.ZhanDuiDict.Keys) { this.ZhanDuiIDVsGameIDDict[zhanDuiID] = gameId; KF5v5PiPeiTeam kuaFuRoleDataTemp; if (this.PiPeiDict.TryGetValue(zhanDuiID, out kuaFuRoleDataTemp)) { kuaFuRoleDataTemp.GameId = fubenData.GameId; } } string zhanduiIdArray = string.Join <int>("|", fubenData.ZhanDuiDict.Keys.ToArray <int>()); LogManager.WriteLog(LogTypes.Analysis, string.Format("Zork::分组 SeasonID:{0} gameId:{1} zhanduiId:{2} Round:{3}", new object[] { this.CurrentSeasonID, gameId, zhanduiIdArray, this.CurrentRound }), null, true); } else { string zhanduiIdArray = string.Join <int>("|", fubenData.ZhanDuiDict.Keys.ToArray <int>()); LogManager.WriteLog(LogTypes.Analysis, string.Format("Zork::分配游戏服务器失败 SeasonID:{0} gameId:{1} zhanduiId:{2} Round:{3}", new object[] { this.CurrentSeasonID, gameId, zhanduiIdArray, this.CurrentRound }), null, true); } }
public static bool InitConfig() { lock (EscapeBattle_K.Mutex) { EscapeBattle_K.Initialize = false; bool bOk = EscapeBattle_K._Config.Load(KuaFuServerManager.GetResourcePath("Config\\EscapeActivityRules.xml", KuaFuServerManager.ResourcePathTypes.GameRes)); EscapeBattleMatchConfig config = EscapeBattle_K._Config.MatchConfigList[0]; EscapeBattleConsts.MinZhanDuiNumPerGame = config.MatchTeamNum; EscapeBattleConsts.MinRoleNumPerGame = config.EnterBattleNum; EscapeBattleConsts.BattleSignSecs = config.BattleSignSecs; DateTime.TryParse(KuaFuServerManager.systemParamsList.GetParamValueByName("EscapeStartTime"), out EscapeBattleConsts.EscapeStartTime); if (!bOk) { LogManager.WriteLog(LogTypes.Error, "EscapeBattle_K.InitConfig failed!", null, true); } EscapeBattle_K.Initialize = bOk; } return(true); }
private static void ZhanDuiChangeState(EscapeBattle_K.JoinPkData pkData, int state) { int zhanDuiState = 0; if (state >= 5) { pkData.InGame = false; zhanDuiState = 0; } pkData.State = zhanDuiState; int sid = KuaFuServerManager.GetServerIDFromZoneID(pkData.ZoneId); ClientAgentManager.Instance().SendMsg(sid, KFCallMsg.New <int[]>(KuaFuEventTypes.EscapeBattle_GameState, new int[] { pkData.ZhanDuiID, pkData.CurrGameID, zhanDuiState })); }
public static void ReloadCmdHandler(object obj) { try { string[] args = obj as string[]; if (args.Length == 1 && args[0] == "reload") { KuaFuServerManager.LoadConfig(); } else { TianTiService.Instance.ExecCommand(args); } } catch { } Console.WriteLine("重新加载配置成功!"); }
public static int ZhengBaKuaFuLogin(AutoCSer.Net.TcpInternalServer.ServerSocketSender socket, int zhanDuiID, int gameId, int srcServerID, out ZhanDuiZhengBaFuBenData copyData) { copyData = null; lock (ZhanDuiZhengBa_K.Mutex) { ZhanDuiZhengBa_K.JoinRolePkData roleData = ZhanDuiZhengBa_K.TodayJoinRoleDatas.Find((ZhanDuiZhengBa_K.JoinRolePkData _r) => _r.ZhanDuiID == zhanDuiID && _r.CurrGameID == gameId); ZhanDuiZhengBaPkLogData logData = null; ZhanDuiZhengBa_K.ThisLoopPkLogs.TryGetValue(gameId, out logData); if (roleData == null || logData == null) { return(-12); } if (!roleData.WaitReqEnter) { return(-12); } copyData = roleData.CopyData; } KuaFuServerInfo serverInfo = KuaFuServerManager.GetKuaFuServerInfo(srcServerID); int result; if (null != serverInfo) { copyData.IPs = new string[] { serverInfo.DbIp, serverInfo.DbIp }; copyData.Ports = new int[] { serverInfo.DbPort, serverInfo.LogDbPort }; result = 0; } else { result = -11000; } return(result); }
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); }
public static int ZhengBaKuaFuLogin(AutoCSer.Net.TcpInternalServer.ServerSocketSender socket, int zhanDuiID, int gameId, int srcServerID, out EscapeBattleFuBenData copyData) { copyData = null; lock (EscapeBattle_K.Mutex) { EscapeBattle_K.JoinPkData roleData; if (!EscapeBattle_K.JoinDict.TryGetValue(zhanDuiID, out roleData) || roleData.CurrGameID == 0) { return(-4006); } EscapeBattlePkLogData logData = null; if (!EscapeBattle_K.ThisLoopPkLogs.TryGetValue(roleData.CurrGameID, out logData)) { return(-4006); } copyData = roleData.CopyData; } KuaFuServerInfo serverInfo = KuaFuServerManager.GetKuaFuServerInfo(srcServerID); int result; if (null != serverInfo) { copyData.IPs = new string[] { serverInfo.DbIp, serverInfo.DbIp }; copyData.Ports = new int[] { serverInfo.DbPort, serverInfo.LogDbPort }; result = 0; } else { result = -11000; } return(result); }
public void LoadParamsList() { string fileName = string.Format("Config/SystemParams.xml", new object[0]); XElement xml = XElement.Load(KuaFuServerManager.GetResourcePath(fileName, KuaFuServerManager.ResourcePathTypes.GameRes)); if (null == xml) { throw new Exception(string.Format("加载系统配置参数配置文件:{0}, 失败。没有找到相关XML配置文件!", fileName)); } IEnumerable <XElement> paramNodes = xml.Elements("Params").Elements <XElement>(); if (null != paramNodes) { Dictionary <string, string> paramsDict = new Dictionary <string, string>(); foreach (XElement xmlNode in paramNodes) { string paramName = ConfigHelper.GetElementAttributeValue(xmlNode, "Name", ""); string paramValue = ConfigHelper.GetElementAttributeValue(xmlNode, "Value", ""); paramsDict[paramName] = paramValue; } this._ParamsDict = paramsDict; } }
public static void ConsoleInputThread(object obj) { for (;;) { try { Program.ShowCmdHelp(); string cmd = Console.ReadLine(); if (null != cmd) { Program.CmdDict.ExcuteCmd(cmd); } if (Program.NeedExitServer) { KuaFuServerManager.OnStopServer(); break; } } catch (Exception ex) { LogManager.WriteException(ex.ToString()); } } }
public void InitConfig() { try { lock (this.MutexConfig) { DateTime.TryParse(KuaFuServerManager.systemParamsList.GetParamValueByName("ZorkStartTime"), out this.ZorkStartTime); this.SceneDataDict.Clear(); string fileName = "Config/ZorkActivityRules.xml"; string fullPathFileName = KuaFuServerManager.GetResourcePath(fileName, KuaFuServerManager.ResourcePathTypes.GameRes); XElement xml = ConfigHelper.Load(fullPathFileName); IEnumerable <XElement> xmlItems = xml.Elements(); foreach (XElement node in xmlItems) { ZorkBattleSceneInfo sceneItem = new ZorkBattleSceneInfo(); int id = (int)ConfigHelper.GetElementAttributeValueLong(node, "ID", 0L); int mapCode = (int)ConfigHelper.GetElementAttributeValueLong(node, "MapCode", 0L); sceneItem.Id = id; sceneItem.MapCode = mapCode; sceneItem.MaxEnterNum = (int)ConfigHelper.GetElementAttributeValueLong(node, "MaxEnterNum", 0L); sceneItem.PrepareSecs = (int)ConfigHelper.GetElementAttributeValueLong(node, "PrepareSecs", 0L); sceneItem.FightingSecs = (int)ConfigHelper.GetElementAttributeValueLong(node, "FightingSecs", 0L); sceneItem.ClearRolesSecs = (int)ConfigHelper.GetElementAttributeValueLong(node, "ClearRolesSecs", 0L); sceneItem.BattleSignSecs = (int)ConfigHelper.GetElementAttributeValueLong(node, "BattleSignSecs", 0L); sceneItem.SeasonFightRound = (int)ConfigHelper.GetElementAttributeValueLong(node, "SeasonFightDay", 0L); string[] fields = node.Attribute("TimePoints").Value.Split(new char[] { ',', '-', '|' }); for (int i = 0; i < fields.Length; i += 3) { TimeSpan dayPart = new TimeSpan(Convert.ToInt32(fields[i]), 0, 0, 0); TimeSpan time = DateTime.Parse(fields[i + 1]).TimeOfDay.Add(dayPart); TimeSpan time2 = DateTime.Parse(fields[i + 2]).TimeOfDay.Add(dayPart); sceneItem.TimePoints.Add(time); sceneItem.TimePoints.Add(time2); } for (int i = 0; i < sceneItem.TimePoints.Count; i++) { TimeSpan ts = new TimeSpan(sceneItem.TimePoints[i].Hours, sceneItem.TimePoints[i].Minutes, sceneItem.TimePoints[i].Seconds); sceneItem.SecondsOfDay.Add(ts.TotalSeconds); } for (int i = 0; i < sceneItem.TimePoints.Count; i++) { TimeSpan ts = new TimeSpan(sceneItem.TimePoints[i].Hours, sceneItem.TimePoints[i].Minutes, sceneItem.TimePoints[i].Seconds); sceneItem.SecondsOfDay.Add(ts.TotalSeconds); } this.SceneDataDict[id] = sceneItem; this.SeasonWeeks = Math.Max(this.SeasonWeeks, (int)Math.Ceiling((double)sceneItem.SeasonFightRound / (double)(sceneItem.TimePoints.Count / 2))); } this.ZorkLevelRangeList.Clear(); fileName = "Config/ZorkDanAward.xml"; fullPathFileName = KuaFuServerManager.GetResourcePath(fileName, KuaFuServerManager.ResourcePathTypes.GameRes); xml = ConfigHelper.Load(fullPathFileName); xmlItems = xml.Elements(); foreach (XElement node in xmlItems) { ZorkBattleAwardConfig item = new ZorkBattleAwardConfig(); item.ID = (int)ConfigHelper.GetElementAttributeValueLong(node, "ID", 0L); item.RankValue = (int)ConfigHelper.GetElementAttributeValueLong(node, "RankValue", 0L); item.WinRankValue = (int)ConfigHelper.GetElementAttributeValueLong(node, "WinRankValue", 0L); item.LoseRankValue = (int)ConfigHelper.GetElementAttributeValueLong(node, "LoseRankValue", 0L); this.ZorkLevelRangeList.Add(item); this.ZorkLevelRangeList.Sort(delegate(ZorkBattleAwardConfig left, ZorkBattleAwardConfig righit) { int result; if (left.ID > righit.ID) { result = -1; } else if (left.ID > righit.ID) { result = 1; } else { result = 0; } return(result); }); } } } catch (Exception ex) { LogManager.WriteExceptionUseCache(ex.ToString()); } }
private static void InitCmdDict() { Program.CmdDict.AddCmdHandler("exit", new ParameterizedThreadStart(Program.ExitCmdHandler)); Program.CmdDict.AddCmdHandler("reload", new ParameterizedThreadStart(Program.ReloadCmdHandler)); Program.CmdDict.AddCmdHandler("clear", new ParameterizedThreadStart(Program.ClearCmdHandler)); Program.CmdDict.AddCmdHandler("load", new ParameterizedThreadStart(Program.ReloadCmdHandler)); Program.CmdDict.AddCmdHandler("tcpinfo", new ParameterizedThreadStart(CmdMonitor.ShowServerTCPInfo)); Program.CmdDict.AddCmdHandler("opt", delegate(object x) { Program.OptCmdProc(x); }); Program.CmdDict.AddCmdHelp("组队天梯,排行刷新", new string[] { "tianti5v5", "paihang" }); Program.CmdDict.AddCmdHelp("组队天梯,排行刷新,重建月度排行", new string[] { "tianti5v5", "paihang", "month" }); Program.CmdDict.AddCmdHandler("tianti5v5", delegate(object x) { string[] cmdFields = x as string[]; if (cmdFields.Length >= 2 && cmdFields[1] == "paihang") { TianTi5v5Service.UpdateZhanDuiRankData(TimeUtil.NowDateTime(), cmdFields.Length >= 3 && cmdFields[2] == "month"); Console.Write("组队天梯,排行刷新"); } else { Console.Write("组队天梯,未知命令!"); } }); Program.CmdDict.AddCmdHelp("组队天梯,排行重建,会先重建组队竞技月排行", new string[] { "zhanduizhengba", "load" }); Program.CmdDict.AddCmdHelp("战队争霸,排行刷新", new string[] { "zhanduizhengba", "reload" }); Program.CmdDict.AddCmdHandler("zhanduizhengba", delegate(object x) { string[] cmdFields = x as string[]; if (cmdFields.Length >= 2 && cmdFields[1] == "load") { TianTi5v5Service.PaiHangCopy(TimeUtil.NowDateTime()); ZhanDuiZhengBa_K.LoadSyncData(TimeUtil.NowDateTime(), false); Console.Write("战队争霸,排行重建"); } else if (cmdFields.Length >= 2 && cmdFields[1] == "reload") { ZhanDuiZhengBa_K.LoadSyncData(TimeUtil.NowDateTime(), cmdFields[1] == "reload"); Console.Write("战队争霸,排行刷新"); } else { Console.Write("战队争霸,未知命令!"); } }); Program.CmdDict.AddCmdHandler("serverlist", delegate(object x) { KuaFuServerManager.UpdateServerListAge(); }); Program.CmdDict.AddCmdHandler("flushcity", delegate(object x) { YongZheZhanChangPersistence.Instance.LangHunLingYuBroadcastServerIdHashSet.Clear(); }); Program.CmdDict.AddCmdHandler("testmode", delegate(object x) { Global.TestMode = !Global.TestMode; if (Global.TestMode) { Consts.TianTiRoleCountTotal = 1; } else { Consts.TianTiRoleCountTotal = 2; } Console.WriteLine("测试模式状态:{0}", Global.TestMode); }); Program.CmdDict.AddCmdHandler("-maxteamcopy", delegate(object x) { try { string[] cmdFields = x as string[]; int copyId = Convert.ToInt32(cmdFields[1]); int num = Convert.ToInt32(cmdFields[2]); ConstData.MaxCopyTeamMemberNumDict[copyId] = num; string msg = string.Format("设置组队副本{0}人数上线为{1}", copyId, num); Console.WriteLine(msg); } catch (Exception ex) { LogManager.WriteException(ex.ToString()); } }); Program.CmdDict.AddCmdHandler("-help", delegate(object x) { try { string[] args = x as string[]; if (args != null && args.Length > 0) { args = args.Skip(1).ToArray <string>(); } Program.CmdDict.ShowHelp(args); } catch (Exception ex) { LogManager.WriteException(ex.ToString()); } }); }
private static void Main(string[] args) { try { string exeFile = Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName; string version = Program.GetVersionDateTime(); Console.Title = string.Format("跨服中心服务器@{0}@{1}", version, exeFile); File.WriteAllText("Pid.txt", Process.GetCurrentProcess().Id.ToString()); FileStream fs = File.Open("Pid.txt", FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read); } catch (Exception ex) { LogManager.WriteLog(LogTypes.Fatal, "本程序已经启动了一个进程,按任意键退出!", ex, true); return; } if (args.Contains("-gmsettime")) { KuaFuServerManager.EnableGMSetAllServerTime = true; } if (args.Contains("-testmode")) { Global.TestMode = true; Consts.TestMode = true; } if (args.Contains("-waitdebug")) { Console.WriteLine("等待调试器连接,按任意键继续!"); do { Thread.Sleep(100); }while (!Console.KeyAvailable); Console.ReadKey(); } Program.HideCloseBtn(); Program.SetConsoleCtrlHandler(Program.newDelegate, true); if (Console.WindowWidth < 88) { Console.BufferWidth = 88; Console.WindowWidth = 88; } Console.WriteLine("跨服中心服务器启动!"); LogManager.WriteLog(LogTypes.Info, "跨服中心服务器启动!", null, true); if (!KuaFuServerManager.CheckConfig()) { Console.WriteLine("服务器无法启动!"); Thread.Sleep(300000); } else { RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off; KuaFuServerManager.StartServerConfigThread(); if (!KuaFuServerManager.LoadConfig()) { Console.WriteLine("服务器无法启动!"); Thread.Sleep(300000); } else { KuaFuServerManager.InitServer(); Program.StartServices(); Program.InitCmdDict(); KuaFuServerManager.OnStartServer(); new Thread(new ParameterizedThreadStart(Program.ConsoleInputThread)) { IsBackground = true }.Start(); while (!KuaFuServerManager.WaitStop(0)) { Thread.Sleep(1000); } } } }
public static bool AssignGameFuben(KF5v5PiPeiTeam kuaFuRoleData, RangeKey range, DateTime now) { int roleCount = 0; DateTime stateEndTime = now.AddSeconds((double)TianTi5v5Service.EnterGameSecs); List <KuaFuFuBenRoleData> updateRoleDataList = new List <KuaFuFuBenRoleData>(); KuaFu5v5FuBenData KuaFu5v5FuBenData = new KuaFu5v5FuBenData(); int side = 0; int removeZhanDuiIDFromPiPeiList = 0; KF5v5PiPeiTeam team = kuaFuRoleData; if (Consts.TianTiRoleCountTotal > 1) { foreach (Tuple <KF5v5PiPeiTeam, int, int, int> z in TianTi5v5Service.ProcessPiPeiList) { if (z.Item2 >= range.Left && z.Item2 <= range.Right) { if (kuaFuRoleData.GroupIndex >= z.Item3 && kuaFuRoleData.GroupIndex <= z.Item4) { if (TianTi5v5Service.CanAddFuBenRole(kuaFuRoleData.TeamID, z.Item1.TeamID)) { removeZhanDuiIDFromPiPeiList = z.Item1.TeamID; team = z.Item1; if (KuaFu5v5FuBenData.AddZhanDui(team.TeamID, ref roleCount, ref side)) { TianTi5v5ZhanDuiData teamData; if (TianTi5v5Service.ZhanDuiDict.TryGetValue(team.TeamID, out teamData)) { foreach (TianTi5v5ZhanDuiRoleData role in teamData.teamerList) { KuaFuFuBenRoleData kuaFuFuBenRoleData = new KuaFuFuBenRoleData { ServerId = team.ServerID, RoleId = role.RoleID, Side = side }; KuaFu5v5FuBenData.AddKuaFuFuBenRoleData(kuaFuFuBenRoleData, team.TeamID); } } } } } } } if (removeZhanDuiIDFromPiPeiList == 0) { TianTi5v5Service.ProcessPiPeiList.Add(new Tuple <KF5v5PiPeiTeam, int, int, int>(kuaFuRoleData, kuaFuRoleData.GroupIndex, range.Left, range.Right)); return(true); } TianTi5v5Service.ProcessPiPeiList.RemoveAll((Tuple <KF5v5PiPeiTeam, int, int, int> x) => x.Item1.TeamID == removeZhanDuiIDFromPiPeiList); TianTi5v5Service.ProcessPiPeiList.RemoveAll((Tuple <KF5v5PiPeiTeam, int, int, int> x) => x.Item1.TeamID == kuaFuRoleData.TeamID); } team = kuaFuRoleData; if (KuaFu5v5FuBenData.AddZhanDui(team.TeamID, ref roleCount, ref side)) { TianTi5v5ZhanDuiData teamData; if (TianTi5v5Service.ZhanDuiDict.TryGetValue(team.TeamID, out teamData)) { foreach (TianTi5v5ZhanDuiRoleData role in teamData.teamerList) { KuaFuFuBenRoleData kuaFuFuBenRoleData = new KuaFuFuBenRoleData { ServerId = team.ServerID, RoleId = role.RoleID, Side = side }; KuaFu5v5FuBenData.AddKuaFuFuBenRoleData(kuaFuFuBenRoleData, team.TeamID); } } } try { int kfSrvId = 0; int gameId = TianTi5v5Service.Persistence.GetNextGameId(); bool createSuccess = ClientAgentManager.Instance().AssginKfFuben(TianTi5v5Service.GameType, (long)gameId, roleCount, out kfSrvId); if (createSuccess) { KuaFu5v5FuBenData.ServerId = kfSrvId; KuaFu5v5FuBenData.GameId = gameId; KuaFu5v5FuBenData.GameType = (int)TianTi5v5Service.GameType; KuaFu5v5FuBenData.EndTime = Global.NowTime.AddMinutes(8.0); KuaFu5v5FuBenData.LoginInfo = KuaFuServerManager.GetKuaFuLoginInfo(kuaFuRoleData.ServerID, kfSrvId); TianTi5v5Service.AddGameFuBen(KuaFu5v5FuBenData); TianTi5v5Service.Persistence.LogCreateTianTiFuBen(KuaFu5v5FuBenData.GameId, KuaFu5v5FuBenData.ServerId, 0, roleCount); foreach (int zhanDuiID in KuaFu5v5FuBenData.ZhanDuiDict.Keys) { KF5v5PiPeiTeam kuaFuRoleDataTemp; if (TianTi5v5Service.PiPeiDict.TryGetValue(zhanDuiID, out kuaFuRoleDataTemp)) { kuaFuRoleDataTemp.State = 3; kuaFuRoleDataTemp.StateEndTicks = stateEndTime.Ticks; kuaFuRoleDataTemp.GameId = KuaFu5v5FuBenData.GameId; } } KuaFu5v5FuBenData.State = GameFuBenState.Start; TianTi5v5Service.NotifyFuBenRoleEnterGame(KuaFu5v5FuBenData); TianTi5v5Service.AddRolePairFightCount(KuaFu5v5FuBenData); return(true); } return(false); } catch (Exception ex) { LogManager.WriteExceptionUseCache(ex.ToString()); } return(false); }
static void Main(string[] args) { try { FileStream fs = File.Open("Pid.txt", FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read); if (fs != null) { byte[] bytes = Encoding.UTF8.GetBytes(Process.GetCurrentProcess().Id.ToString()); fs.Write(bytes, 0, bytes.Length); fs.Flush(); } } catch (System.Exception ex) { Console.WriteLine("本程序已经启动了一个进程,按任意键退出!"); Console.ReadKey(); return; } //Console.TreatControlCAsInput = true; #region 控制台关闭控制 HideCloseBtn(); SetConsoleCtrlHandler(newDelegate, true); if (Console.WindowWidth < 88) { Console.BufferWidth = 88; Console.WindowWidth = 88; } #endregion 控制台关闭控制 Console.WriteLine("跨服中心服务器启动!"); LogManager.WriteLog(LogTypes.Info, "跨服中心服务器启动!"); SetWindowMin(); //new MoRiJudgeService(); if (!KuaFuServerManager.CheckConfig()) { Console.WriteLine("服务器无法启动!"); } if (!KuaFuServerManager.LoadConfig()) { Console.ReadLine(); return; } KuaFuServerManager.StartServerConfigThread(); RemotingConfiguration.Configure(Process.GetCurrentProcess().MainModule.FileName + ".config", false); InitCmdDict(); //YongZheZhanChangService s = new YongZheZhanChangService(); do { try { ShowCmdHelp(); string cmd = Console.ReadLine(); if (null != cmd) { CmdDict.ExcuteCmd(cmd); } //判断是否需要退出 if (NeedExitServer) { KuaFuServerManager.OnStopServer(); Console.WriteLine("Press any key to Stop!"); Console.ReadKey(); break; } } catch (System.Exception ex) { LogManager.WriteException(ex.ToString()); } } while (true); }
private static bool LoadCaiShuZi(out List <CaiShuZiConfig> _CaiShuZiCfgList) { _CaiShuZiCfgList = new List <CaiShuZiConfig>(); try { XElement xml = ConfigHelper.Load(KuaFuServerManager.GetResourcePath("Config/CaiShuZi.xml", KuaFuServerManager.ResourcePathTypes.GameRes)); if (null == xml) { LogManager.WriteLog(LogTypes.Fatal, string.Format("读取 {0} null == xml", "Config/CaiShuZi.xml"), null, true); return(false); } IEnumerable <XElement> xmlItems = xml.Elements(); foreach (XElement xmlItem in xmlItems) { CaiShuZiConfig myData = new CaiShuZiConfig(); myData.ID = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "ID", 0L); myData.XiaoHaoDaiBi = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "XiaoHaoDaiBi", 0L); myData.ChuFaBiZhong = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "ChuFaBiZhong", 0L); myData.BuChongTiaoJian = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "BuChongTiaoJian", 0L); myData.XiTongChouCheng = ConfigHelper.GetElementAttributeValueDouble(xmlItem, "XiTongChouCheng", 0.0); myData.ShangChengKaiGuan = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "ShangChengKaiGuan", 0L); myData.AnNiuList = new List <CaiShuZiAnNiu>(); foreach (string item in ConfigHelper.GetElementAttributeValue(xmlItem, "ZhongJiangFanLi", "").Split(new char[] { '|' })) { string[] temp = item.Split(new char[] { ',' }); if (temp.Length < 2) { LogManager.WriteLog(LogTypes.Fatal, string.Format("{0}解析出现 AnNiuName err, myData.ID={1}", "Config/CaiShuZi.xml", myData.ID), null, true); } else { CaiShuZiAnNiu d = new CaiShuZiAnNiu(); d.NO = Convert.ToInt32(temp[0]); d.Percent = Convert.ToDouble(temp[1]); myData.AnNiuList.Add(d); if (d.NO != myData.AnNiuList.Count) { LogManager.WriteLog(LogTypes.Fatal, string.Format("{0}解析出现 d.NO != myData.AnNiuList.Count myData.ID={1}", "Config/CaiShuZi.xml", myData.ID), null, true); } } } if (myData.AnNiuList.Count < 3) { LogManager.WriteLog(LogTypes.Fatal, string.Format("{0}解析出现 myData.AnNiuList.Count < 3 err, myData.ID={1}", "Config/CaiShuZi.xml", myData.ID), null, true); } else { myData.KaiQiShiJian = ConfigHelper.GetElementAttributeValue(xmlItem, "KaiQiShiJian", ""); DateTime.Parse(myData.KaiQiShiJian); myData.JieShuShiJian = ConfigHelper.GetElementAttributeValue(xmlItem, "JieShuShiJian", ""); DateTime.Parse(myData.JieShuShiJian); myData.KaiJiangShiJian = ConfigHelper.GetElementAttributeValue(xmlItem, "KaiJiangShiJian", ""); DateTime.Parse(myData.KaiJiangShiJian); _CaiShuZiCfgList.Add(myData); } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Fatal, string.Format("{0}解析出现异常, {1}", "Config/CaiShuZi.xml", ex.Message), null, true); return(false); } return(true); }