public static TCPProcessCmdResults ProcessGetRegressActiveMinTime(DBManager dbMgr, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket) { tcpOutPacket = null; string cmdData = null; try { cmdData = new UTF8Encoding().GetString(data, 0, count); } catch (Exception) { LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID), null, true); tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767); return(TCPProcessCmdResults.RESULT_DATA); } try { string[] fields = cmdData.Split(new char[] { ':' }); if (fields.Length != 2) { LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}", (TCPGameServerCmds)nID, fields.Length, cmdData), null, true); tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767); return(TCPProcessCmdResults.RESULT_DATA); } int RoleID = Convert.ToInt32(fields[0]); string UserID = fields[1]; DBRoleInfo dbRoleInfo = dbMgr.GetDBRoleInfo(ref RoleID); if (null == dbRoleInfo) { LogManager.WriteLog(LogTypes.Error, string.Format("发起请求的角色不存在,CMD={0}, RoleID={1}", (TCPGameServerCmds)nID, RoleID), null, true); tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767); return(TCPProcessCmdResults.RESULT_DATA); } if (!dbRoleInfo.UserID.Equals(UserID)) { LogManager.WriteLog(LogTypes.Error, string.Format("请求的UserID出错,CMD={0}, UserID={1}", (TCPGameServerCmds)nID, UserID), null, true); tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767); return(TCPProcessCmdResults.RESULT_DATA); } string OutUserID; string Regtime; if (!DBQuery.GetMinRegtime(dbMgr, UserID, out OutUserID, out Regtime)) { LogManager.WriteLog(LogTypes.Error, string.Format("获取最早注册时间出错,CMD={0}, RoleID={1}", (TCPGameServerCmds)nID, RoleID), null, true); tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767); return(TCPProcessCmdResults.RESULT_DATA); } cmdData = string.Format("{0}:{1}", OutUserID, Regtime.Replace(":", "$")); tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, cmdData, nID); return(TCPProcessCmdResults.RESULT_DATA); } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "", false, false); } tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767); return(TCPProcessCmdResults.RESULT_DATA); }
public RegressActiveOpcode ProcessGetRegressAcitveFile(GameClient client, out string ToClientRegtime, out int ToClientID, out int ToClientLevel, out int CurrDay, out int ActiveMoney) { ToClientRegtime = ""; ToClientID = 0; ToClientLevel = 0; CurrDay = 0; ActiveMoney = 0; string UserID = client.strUserID; RegressActiveOpcode result; if (UserID == null || UserID.Equals("") || !UserID.Equals(client.strUserID)) { result = RegressActiveOpcode.RegressActiveUserInfoErr; } else { RegressActiveOpen iflAct = HuodongCachingMgr.GetRegressActiveOpen(); string Regtime; if (iflAct == null || !iflAct.InActivityTime()) { result = RegressActiveOpcode.RegressActiveOpenErr; } else if (!iflAct.CanGiveAward()) { result = RegressActiveOpcode.RegressActiveNotIn; } else if (!UserRegressActiveManager.GetRegressMinRegtime(client, out Regtime) || Regtime == null || Regtime.Equals("")) { result = RegressActiveOpcode.RegressActiveGetRegTime; } else { int ConfID; int Level = iflAct.GetUserActiveFile(Regtime, out ConfID); if (0 == Level) { result = RegressActiveOpcode.RegressActiveGetFile; } else { ToClientRegtime = Regtime.Replace(":", "$"); ToClientID = ConfID; ToClientLevel = Level; DateTime nowDateTime = TimeUtil.NowDateTime(); int Day = Global.GetOffsetDay(nowDateTime) - Global.GetOffsetDay(DateTime.Parse(iflAct.FromDate)); CurrDay = Day + 1; string ZeroTime = "2011-11-11 00$00$00"; string GetInfoStr = string.Format("{0}:{1}:{2}", client.ClientData.RoleID, ZeroTime, iflAct.FromDate.Replace(':', '$')); string[] dbResult; if (TCPProcessCmdResults.RESULT_FAILED == Global.RequestToDBServer(Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, 14136, GetInfoStr, out dbResult, 0)) { result = RegressActiveOpcode.RegressActiveGetFile; } else if (dbResult == null || dbResult.Length != 2 || Convert.ToInt32(dbResult[0]) != client.ClientData.RoleID) { result = RegressActiveOpcode.RegressActiveGetFile; } else { int Money = Convert.ToInt32(dbResult[1]); if (Money < 0) { Money = 0; } ActiveMoney = Money; result = RegressActiveOpcode.RegressActiveSucc; } } } } return(result); }