using System; using System.Collections.Generic; using Sog; using ProtoCSStruct; using Sog.Crypto; using System.Text; using MySql.Data.MySqlClient; namespace DB { public static class AccountOP { public static void OnSelectAccountInfo(uint remoteAppID, StructPacket packet, DBOperator dbOperator) { ref SSGmQueryUserAccountInfoReq req = ref packet.GetMessage(); SSGmQueryUserAccountInfoRes res = new SSGmQueryUserAccountInfoRes { Id = req.Id }; res.ReqType = req.ReqType; if(req.ReqType == 0) { var accountType = req.AccountType; var accountID = req.Account.GetString(); tbAccount accountRecord = dbOperator.QueryAccount(accountType, accountID); if (accountRecord != null) { res.AccountId.SetString(accountRecord.AccountID); res.CreateDeviceId.SetString(accountRecord.CreateDeviceID); res.CreateIpAddr = (uint)accountRecord.CreateIpAddr; res.CreateTime = (ulong)accountRecord.CreateTime; res.Gender = accountRecord.Gender; res.Nick.SetString(accountRecord.Nick); res.LastLoginRealm = accountRecord.LastLoginRealm; res.Grade = accountRecord.Grade; DBAccountExData ext = new DBAccountExData(); if (accountRecord.exData.Length != 0) { StructMessageParseUtils.ParseFrom(ref ext, accountRecord.exData); } res.ExData = ext; var realmuid_linklist = dbOperator.QueryAccountUid(req.AccountType, accountID, 0); if (realmuid_linklist != null) { foreach (var link in realmuid_linklist) { var temp = new RoleSimpleInfo(); temp.Icon.SetString(link.icon); temp.Level = (uint)link.level; temp.Nick.SetString(link.nick); temp.Realm = (uint)link.realmId; temp.Uid = (uint)link.uid; if (res.RoleList.Count < res.RoleList.GetMaxCount()) { res.RoleList.Add(temp); } else { TraceLog.Error("AccountOp.OnSelectAccountInfo error, GmQueryUserAccountinfoRes no space"); } } } } } // 先这样写,表示通过uid查询 if (req.ReqType == 1) { int uid = 0; try { uid = Convert.ToInt32(req.Account.GetString()); } catch (Exception) { TraceLog.Error("AccountOp.OnSelectAccountInfo error, uid convert errod"); } var link = dbOperator.QueryAccountUidbyUid(uid, 0); if (link != null) { res.Nick.SetString(link.nick); res.AccountId.SetString(link.accountId); var temp = new RoleSimpleInfo(); temp.Icon.SetString(link.icon); temp.Level = (uint)link.level; temp.Nick.SetString(link.nick); temp.Realm = (uint)link.realmId; temp.Uid = (uint)link.uid; if (res.RoleList.Count < res.RoleList.GetMaxCount()) { res.RoleList.Add(temp); } tbAccount accountRecord = dbOperator.QueryAccount(link.accountType, link.accountId); if (accountRecord != null) { DBAccountExData ext = new DBAccountExData(); if (accountRecord.exData.Length != 0) { StructMessageParseUtils.ParseFrom(ref ext, accountRecord.exData); res.Channel = ext.Channel; res.ChannelId = ext.ChannelId; } } } } DBServerUtils.GetPacketSender().SendToServerByID(remoteAppID, (int)SSGameMsgID.GmQueryUserAccountinfoRes, ref res, packet.ObjectID, packet.ServerID); } public static void SSSendGift(uint remoteAppID, StructPacket packet, DBOperator dbOperator) { ref SSSendGift req = ref packet.GetMessage(); List list = dbOperator.QueryAccountUid(req.AccountType, req.AccountId.GetString(), 0); long lastLoginTime = 0;long lastUid = 0; if (list != null) { for (int i = 0; i < list.Count; i++) { var r = list[i]; if (r.lastLoginTime > lastLoginTime) { lastLoginTime = r.lastLoginTime; lastUid = r.uid; } } } else { TraceLog.Trace("AccountOp.SSSendGift error, no uid found account={0}", req.AccountId.GetString()); return; } req.Uid = lastUid; req.Queryed = 1; DBServerUtils.GetPacketSender().SendToServerByID(remoteAppID, (int)SSMsgID.SendGifts, ref req, packet.ObjectID); } } }