internal void SaveMail(List <TableMailInfoWrap> mailList, int saveCount) { try { foreach (var mailInfo in mailList) { if (!mailInfo.Modified) { continue; } TableMailInfo dataMail = mailInfo.ToProto(); List <int> itemIds = new List <int>(); List <int> itemNums = new List <int>(); foreach (var item in mailInfo.m_Items) { itemIds.Add(item.m_ItemId); itemNums.Add(item.m_ItemNum); } dataMail.ItemIds = Converter.IntList2String(itemIds); dataMail.ItemNumbers = Converter.IntList2String(itemNums); Msg_LD_Save msg = new Msg_LD_Save(); msg.MsgId = (int)DataEnum.TableMailInfo; msg.PrimaryKeys.Add(dataMail.Guid.ToString()); msg.Data = DbDataSerializer.Encode(dataMail); DispatchAction(SaveInternal, msg); } } catch (Exception e) { LogSys.Log(LOG_TYPE.ERROR, "DataCache Save ERROR:{0}, Stacktrace:{1}", e.Message, e.StackTrace); } }
private void InitGuidData() { if (m_GuidInitStatus == DataInitStatus.Unload) { if (UserServerConfig.DataStoreAvailable == true) { m_GuidInitStatus = DataInitStatus.Loading; Msg_LD_Load msg = new Msg_LD_Load(); msg.MsgId = (int)DataEnum.TableGuid; GameFrameworkMessage.Msg_LD_SingleLoadRequest slr = new GameFrameworkMessage.Msg_LD_SingleLoadRequest(); slr.MsgId = (int)GameFrameworkData.DataEnum.TableGuid; slr.LoadType = GameFrameworkMessage.Msg_LD_SingleLoadRequest.LoadTypeEnum.LoadAll; slr.Keys.Clear(); msg.LoadRequests.Add(slr); RequestLoad(msg, ((ret) => { if (ret.ErrorNo == Msg_DL_LoadResult.ErrorNoEnum.Success) { List <GuidInfo> guidList = new List <GuidInfo>(); foreach (var singlerow in ret.Results) { object _msg; if (DbDataSerializer.Decode(singlerow.Data, DataEnum2Type.Query(slr.MsgId), out _msg)) { TableGuid dataGuid = _msg as TableGuid; if (null != dataGuid) { GuidInfo guidinfo = new GuidInfo(); guidinfo.GuidType = dataGuid.GuidType; guidinfo.NextGuid = (long)dataGuid.GuidValue; guidList.Add(guidinfo); } } } UserServer.Instance.GlobalProcessThread.InitGuidData(guidList); m_GuidInitStatus = DataInitStatus.Done; LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Green, "Load DataCache global data success. Table:TableGuid"); } else if (ret.ErrorNo == Msg_DL_LoadResult.ErrorNoEnum.NotFound) { //暂时初始化为空列表 List <GuidInfo> guidList = new List <GuidInfo>(); UserServer.Instance.GlobalProcessThread.InitGuidData(guidList); m_GuidInitStatus = DataInitStatus.Done; LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Green, "Load DataCache global data success. Table:TableGuid (empty)"); } else { m_GuidInitStatus = DataInitStatus.Unload; LogSys.Log(LOG_TYPE.ERROR, ConsoleColor.Red, "Load DataCache global data failed. Table: {0}", "TableGuid"); } } )); } else { m_GuidInitStatus = DataInitStatus.Done; LogSys.Log(LOG_TYPE.INFO, "init guid done!"); } } }
//-------------------------------------------------------------------------------------------------------------------------- // 供外部直接调用的方法,实际执行线程是调用线程。 //-------------------------------------------------------------------------------------------------------------------------- internal void DSPSaveCreateUser(AccountInfo ai, string nickname, ulong userGuid) { try { TableAccount dataAccount = new TableAccount(); dataAccount.AccountId = ai.AccountId; //dataAccount.IsBanned = ai.IsBanned; //dataAccount.UserGuid = ai.UserGuid; Msg_LD_Save msg = new Msg_LD_Save(); msg.MsgId = (int)DataEnum.TableAccount; msg.PrimaryKeys.Add(dataAccount.AccountId); msg.Data = DbDataSerializer.Encode(dataAccount); DispatchAction(DSSaveInternal, msg); TableNicknameInfo dataNickname = new TableNicknameInfo(); dataNickname.Nickname = nickname; dataNickname.UserGuid = userGuid; Msg_LD_Save msgNickname = new Msg_LD_Save(); msgNickname.MsgId = (int)DataEnum.TableNicknameInfo; msgNickname.PrimaryKeys.Add(dataNickname.Nickname); msgNickname.Data = DbDataSerializer.Encode(dataNickname); DispatchAction(DSSaveInternal, msgNickname); } catch (Exception e) { LogSys.Log(LOG_TYPE.ERROR, "DataCache Save ERROR. Msg:DSP_CreateUser, Key:{0}, Error:{1},\nStacktrace:{2}", ai.AccountId, e.Message, e.StackTrace); } }
private void InitGlobalData() { if (m_GlobalInitStatus == DataInitStatus.Unload) { if (m_DataStoreAvailable) { m_GlobalInitStatus = DataInitStatus.Loading; Msg_LD_Load msg = new Msg_LD_Load(); msg.MsgId = (int)DataEnum.TableGlobalData; GameFrameworkMessage.Msg_LD_SingleLoadRequest slr = new GameFrameworkMessage.Msg_LD_SingleLoadRequest(); slr.MsgId = (int)GameFrameworkData.DataEnum.TableGlobalData; slr.LoadType = GameFrameworkMessage.Msg_LD_SingleLoadRequest.LoadTypeEnum.LoadAll; slr.Keys.Clear(); msg.LoadRequests.Add(slr); RequestLoad(msg, ((ret) => { if (ret.ErrorNo == Msg_DL_LoadResult.ErrorNoEnum.Success) { List <TableGlobalData> datas = new List <TableGlobalData>(); foreach (var singlerow in ret.Results) { object _msg; if (DbDataSerializer.Decode(singlerow.Data, DataEnum2Type.Query(slr.MsgId), out _msg)) { TableGlobalData data = _msg as TableGlobalData; if (null != data) { datas.Add(data); } } } GlobalData.Instance.Init(datas); m_GlobalInitStatus = DataInitStatus.Done; LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Green, "Load DataCache global data success. Table:TableGlobalData"); } else if (ret.ErrorNo == Msg_DL_LoadResult.ErrorNoEnum.NotFound) { GlobalData.Instance.Clear(); m_GlobalInitStatus = DataInitStatus.Done; LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Green, "Load DataCache global data success. Table:TableGlobalData (empty)"); } else { m_GlobalInitStatus = DataInitStatus.Unload; LogSys.Log(LOG_TYPE.ERROR, ConsoleColor.Red, "Load DataCache global data failed. Table: {0}", "TableGlobalData"); } } )); } else { List <TableNicknameInfo> nicknameList = new List <TableNicknameInfo>(); UserServer.Instance.UserProcessScheduler.InitNicknameData(nicknameList); m_GlobalInitStatus = DataInitStatus.Done; LogSys.Log(LOG_TYPE.INFO, "load GlobalData done!"); } } }
internal void GMLoadUser(string gmAccount, ulong userGuid, LobbyGmMessageDefine jsonMsgId, int nodeHandle) { string key = userGuid.ToString(); Msg_LD_Load msg = new Msg_LD_Load(); msg.MsgId = (int)DataEnum.TableUserInfo; msg.PrimaryKeys.Add(key); Msg_LD_SingleLoadRequest reqUser = new Msg_LD_SingleLoadRequest(); reqUser.MsgId = (int)DataEnum.TableUserInfo; reqUser.LoadType = Msg_LD_SingleLoadRequest.LoadTypeEnum.LoadSingle; reqUser.Keys.Add(key); msg.LoadRequests.Add(reqUser); RequestLoad(msg, (ret) => { JsonMessage resultMsg = new JsonMessage(jsonMsgId, gmAccount); GameFrameworkMessage.Msg_LC_GmQueryUser protoData = new GameFrameworkMessage.Msg_LC_GmQueryUser(); protoData.m_Result = GameFrameworkMessage.GmResultEnum.Failed; protoData.m_Info = null; KeyString primaryKey = KeyString.Wrap(ret.PrimaryKeys); if (Msg_DL_LoadResult.ErrorNoEnum.Success == ret.ErrorNo) { LogSys.Log(LOG_TYPE.INFO, "DataCache Load Success: Msg:{0}, Key:{1}", "GmUser", primaryKey); TableUserInfo dataUser = null; foreach (var result in ret.Results) { object _msg; if (DbDataSerializer.Decode(result.Data, DataEnum2Type.Query(result.MsgId), out _msg)) { DataEnum msgEnum = (DataEnum)result.MsgId; switch (msgEnum) { case DataEnum.TableUserInfo: dataUser = _msg as TableUserInfo; break; default: LogSys.Log(LOG_TYPE.ERROR, ConsoleColor.Red, "Decode user data ERROR. Wrong message id. UserGuid:{0}, WrongId:{1}", userGuid, msgEnum); break; } } } protoData.m_Result = GameFrameworkMessage.GmResultEnum.Success; protoData.m_Info = CreateGmUserInfo(dataUser); } else if (Msg_DL_LoadResult.ErrorNoEnum.NotFound == ret.ErrorNo) { LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Yellow, "DataCache Load NotFound: Msg:{0}, Key:{1}", "GmUser", primaryKey); } else { LogSys.Log(LOG_TYPE.ERROR, "DataCache Load Failed: Msg:{0}, Key:{1}, ERROR:{2}", "GmUser", primaryKey, ret.ErrorInfo); } resultMsg.m_ProtoData = protoData; JsonGmMessageDispatcher.SendNodeMessage(nodeHandle, resultMsg); }); }
internal int SaveGlobalData(TableGlobalData data) { try { Msg_LD_Save msg = new Msg_LD_Save(); msg.MsgId = (int)DataEnum.TableGlobalData; msg.PrimaryKeys.Add(data.Key); msg.ForeignKeys.Clear(); msg.Data = DbDataSerializer.Encode(data); RequestSave(msg); return(0); } catch (Exception e) { LogSys.Log(LOG_TYPE.ERROR, "DataCache Save ERROR:{0}, Stacktrace:{1}", e.Message, e.StackTrace); return(0); } }
internal void SaveGuid(string guidType, ulong guidValue) { try { TableGuid dataGuid = new TableGuid(); dataGuid.GuidType = guidType; dataGuid.GuidValue = guidValue; Msg_LD_Save msg = new Msg_LD_Save(); msg.MsgId = (int)DataEnum.TableGuid; msg.PrimaryKeys.Add(dataGuid.GuidType); msg.Data = DbDataSerializer.Encode(dataGuid); DispatchAction(SaveInternal, msg); } catch (Exception e) { LogSys.Log(LOG_TYPE.ERROR, "DataCache Save ERROR:{0}, Stacktrace:{1}", e.Message, e.StackTrace); } }
internal int DSGSaveNickname(TableNicknameInfo nick) { try { Msg_LD_Save msg = new Msg_LD_Save(); msg.MsgId = (int)DataEnum.TableNicknameInfo; msg.PrimaryKeys.Add(nick.Nickname); msg.ForeignKeys.Clear(); msg.Data = DbDataSerializer.Encode(nick); RequestSave(msg); return(0); } catch (Exception e) { LogSys.Log(LOG_TYPE.ERROR, "DataCache Save ERROR:{0}, Stacktrace:{1}", e.Message, e.StackTrace); return(0); } }
internal void SaveGuid(List <GuidInfo> guidList, int saveCount) { try { foreach (var guidinfo in guidList) { TableGuid dataGuid = new TableGuid(); dataGuid.GuidType = guidinfo.GuidType; dataGuid.GuidValue = (ulong)guidinfo.NextGuid; Msg_LD_Save msg = new Msg_LD_Save(); msg.MsgId = (int)DataEnum.TableGuid; msg.PrimaryKeys.Add(dataGuid.GuidType); msg.Data = DbDataSerializer.Encode(dataGuid); DispatchAction(SaveInternal, msg); } } catch (Exception e) { LogSys.Log(LOG_TYPE.ERROR, "DataCache Save ERROR:{0}, Stacktrace:{1}", e.Message, e.StackTrace); } }
internal void DSPSaveUser(UserInfo ui, int saveCount) { try { ulong userGuid = ui.Guid; string key = userGuid.ToString(); if (ui.Modified) { Msg_LD_Save msg = new Msg_LD_Save(); msg.MsgId = (int)DataEnum.TableUserInfo; msg.PrimaryKeys.AddRange(ui.PrimaryKeys); msg.ForeignKeys.AddRange(ui.ForeignKeys); msg.Data = DbDataSerializer.Encode(ui.ToProto()); DispatchAction(DSSaveInternal, msg); ui.Modified = false; } ui.CurrentUserSaveCount = saveCount; } catch (Exception e) { LogSys.Log(LOG_TYPE.ERROR, "DataCache Save ERROR. Msg:DSP_User, Key:{0}, SaveCount:{1}, Error:{2},\nStacktrace:{3}", ui.Guid, saveCount, e.Message, e.StackTrace); } }
private void InitNicknameData() { if (m_NicknameInitStatus == DataInitStatus.Unload) { if (m_DataStoreAvailable) { m_NicknameInitStatus = DataInitStatus.Loading; Msg_LD_Load msg = new Msg_LD_Load(); msg.MsgId = (int)DataEnum.TableNicknameInfo; GameFrameworkMessage.Msg_LD_SingleLoadRequest slr = new GameFrameworkMessage.Msg_LD_SingleLoadRequest(); slr.MsgId = (int)GameFrameworkData.DataEnum.TableNicknameInfo; slr.LoadType = GameFrameworkMessage.Msg_LD_SingleLoadRequest.LoadTypeEnum.LoadAll; slr.Keys.Clear(); msg.LoadRequests.Add(slr); RequestLoad(msg, ((ret) => { if (ret.ErrorNo == Msg_DL_LoadResult.ErrorNoEnum.Success) { List <TableNicknameInfo> nickList = new List <TableNicknameInfo>(); foreach (var singlerow in ret.Results) { object _msg; if (DbDataSerializer.Decode(singlerow.Data, DataEnum2Type.Query(slr.MsgId), out _msg)) { TableNicknameInfo dataNickname = _msg as TableNicknameInfo; if (null != dataNickname) { nickList.Add(dataNickname); } } } UserServer.Instance.UserProcessScheduler.InitNicknameData(nickList); m_NicknameInitStatus = DataInitStatus.Done; LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Green, "Load DataCache global data success. Table:TableNickname"); } else if (ret.ErrorNo == Msg_DL_LoadResult.ErrorNoEnum.NotFound) { //暂时初始化为固定列表 List <string> nicks = new List <string> { "整容的柠檬", "温柔的椰枣", "霸气的研究生", "爱斗嘴的贵妇", "顽皮的姐姐", "爱唱歌的女汉子", "小心的木星人", "爱画画的贵妇", "妖娆的小灰灰", "可爱的菠菜", "呆萌的小老鼠", "卖大米的包子", "搞怪的火星人", "可气的数据线", "妖娆的无花果", "非主流的闪电", "没头发的伙计", "大眼睛的王老五", "没头发的夜莺", "傻萌的大象", "高调的小豆豆", "甜蜜的小瓶子", "爱网购的男神", "坚强的海龟", "手残的石榴", "坚强的公主", "爱刷屏的二锅头", "搞笑的香蕉", "妩媚的大雁", "不穿鞋的雪姨", "抑郁的海鸥", "爱网购的螺丝钉", "没牙的燕子", "爱装酷的毛毛虫", "爱哭的风扇", "纯纯的棉花糖", "温柔的母老虎", "积极的巧克力", "红果果的话梅", "安静的糍粑", "大眼睛的橘子", "顽皮的土豆", "搞笑的数据线", "不加糖的大雁", "高贵的大象", "爱刷屏的彩虹糖", "可气的螺丝钉", "爱网购的吃货", "不加糖的桑葚", "吃不饱的熊孩子", "高贵的蜡笔", "尊贵的大象", "不吐皮的少爷", "开心的椰奶", "悲愤的梨子", "高调的大叔", "狂热的天鹅", "搞笑的雪莲", "温柔的变色龙", "装失忆的斑竹", "爱装酷的壁虎", "残酷的古琴", "爱画画的大象", "冷酷的榛子", "苦恼的鸵鸟", "搞怪的喜羊羊", "欢喜的柿子", "爱唱歌的粉丝", "不说话的画笔", "爱斗嘴的红毛丹", "安静的鲸鱼", "非主流的小灰灰", "爱装酷的红太狼", "打酱油的灰太狼", "装失忆的汉堡包", "抑郁的熊孩子", "欢喜的海鸥", "温柔的榛子", "悲伤的壁虎", "悲愤的猫咪", "脑残的桑葚", "欢喜的空心菜", "爱斗嘴的牛蛙", "孤独的布丁", "大眼睛的水星人", "没牙的河马", "高调的粉丝", "坚强的大叔", "残酷的鲸鱼", "火星来的大妈", "着急的菠菜", "可气的玻璃杯", "孤独的大叔", "打酱油的蝴蝶", "积极的蚂蚁", "尊贵的珍珠", "不吐皮的少女", "爱踢球的砖家", "清纯的雪姨", "威武的大雁", "爱哭的数据线", "吃骨头的王老五", "低调的蝴蝶", "会弹琴的糯米", "吹口哨的金桔", "悲愤的杨梅", "搞笑的美眉", "听话的圣斗士", "着急的空心菜", "呆萌的袋鼠", "爱笑的胡桃", "胖嘟嘟的小豆豆", "呆萌的柑橘", "听话的喵妹", "不死的桃子", "爱笑的红毛丹", "火星来的椰枣", "悲愤的鸵鸟", "大眼睛的花生", "爱笑的蹄子", "高兴的雪莲", "爱睡觉的MM豆", "抑郁的土星人", "丑萌的蹄子", "爱哭的少爷", "甜美的男神", "不加糖的博士生", "爱斗嘴的男神", "脑残的玻璃杯", "闪瞎眼的蝴蝶", "爱笑的母老虎", "古怪的槟榔", "搞笑的土豆", "厚脸皮的大象", "尊贵的小媳妇", "英俊的珍珠", "非主流的桑葚", "傻萌的羚羊", "吃不饱的蜗牛", "伤心的小灰灰", "大眼睛的金星人", "爱装酷的灰太狼", "卖大米的鹦鹉", "冷艳的夜莺", "酷到爆的贵公子", "妖娆的田鼠", "青春的猴子", "残酷的米老鼠", "高大上的蚂蚁", "爱斗嘴的梯子", "古怪的画眉", "羞涩的女老板", "捣蛋的龙虾", "高兴的大熊", "虚荣的香瓜", "高调的鸭梨", "温柔的龙珠", "不加糖的小清新", "积极的柠檬", "爱斗嘴的信天翁", "压抑的椰奶", "狂热的杨梅", "纯纯的少爷", "厚脸皮的大学生", "搞笑的女博士", "甜蜜的龙眼", "清纯的骑士", "坚强的扇贝", "不加糖的河马", "高兴的母老虎", "威武的土星人", "爱画画的金龟子", "爱哭的贝勒爷", "没牙的汪星人", "残暴的彩虹", "高贵的毛毛虫", "可怜的土豪", "轻蔑的八哥", "傻萌的橘子", "妩媚的大叔", "甜蜜的樱桃", "低调的蛇皮果", "英俊的猫咪", "呆萌的石榴", "残暴的西红柿", "不穿鞋的便当", "装失忆的橄榄", "积极的凤梨", "没头发的椰奶", "开心的土豪", "小心的白狐", "残酷的橘子", "打酱油的小蓝瓶", "冷酷的画笔", "正义的伙计", "闪瞎眼的北极星", "爱哭的表情帝", "搞怪的姐姐", "冷艳的薯条", "听话的苹果" }; List <TableNicknameInfo> nickList = new List <TableNicknameInfo>(); foreach (string nick in nicks) { TableNicknameInfo info = new TableNicknameInfo(); info.Nickname = nick; info.UserGuid = 0; nickList.Add(info); } UserServer.Instance.UserProcessScheduler.InitNicknameData(nickList); m_NicknameInitStatus = DataInitStatus.Done; LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Green, "Load DataCache global data success. Table:TableNickname (empty)"); } else { m_NicknameInitStatus = DataInitStatus.Unload; LogSys.Log(LOG_TYPE.ERROR, ConsoleColor.Red, "Load DataCache global data failed. Table: {0}", "TableNickname"); } } )); } else { List <TableNicknameInfo> nicknameList = new List <TableNicknameInfo>(); UserServer.Instance.UserProcessScheduler.InitNicknameData(nicknameList); m_NicknameInitStatus = DataInitStatus.Done; LogSys.Log(LOG_TYPE.INFO, "load NickName done!"); } } }
private void InitMailData() { if (m_MailInitStatus == DataInitStatus.Unload) { if (UserServerConfig.DataStoreAvailable == true) { m_MailInitStatus = DataInitStatus.Loading; Msg_LD_Load msg = new Msg_LD_Load(); msg.MsgId = (int)DataEnum.TableMailInfo; GameFrameworkMessage.Msg_LD_SingleLoadRequest slr = new GameFrameworkMessage.Msg_LD_SingleLoadRequest(); slr.MsgId = (int)GameFrameworkData.DataEnum.TableMailInfo; slr.LoadType = GameFrameworkMessage.Msg_LD_SingleLoadRequest.LoadTypeEnum.LoadAll; slr.Keys.Clear(); msg.LoadRequests.Add(slr); RequestLoad(msg, ((ret) => { if (ret.ErrorNo == Msg_DL_LoadResult.ErrorNoEnum.Success) { List <TableMailInfoWrap> mailList = new List <TableMailInfoWrap>(); foreach (var singlerow in ret.Results) { object _msg; if (DbDataSerializer.Decode(singlerow.Data, DataEnum2Type.Query(slr.MsgId), out _msg)) { TableMailInfo dataMail = _msg as TableMailInfo; if (null != dataMail) { TableMailInfoWrap mailInfo = new TableMailInfoWrap(); mailInfo.FromProto(dataMail); List <int> itemIds = Converter.ConvertNumericList <int>(dataMail.ItemIds); List <int> itemNums = Converter.ConvertNumericList <int>(dataMail.ItemNumbers); for (int i = 0; i < itemIds.Count && i < itemNums.Count; ++i) { var item = new MailItem(); item.m_ItemId = itemIds[i]; item.m_ItemNum = itemNums[i]; mailInfo.m_Items.Add(item); } mailList.Add(mailInfo); } } } UserServer.Instance.GlobalProcessThread.InitMailData(mailList); m_MailInitStatus = DataInitStatus.Done; LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Green, "Load DataCache global data success. Table:TableMailInfo"); } else if (ret.ErrorNo == Msg_DL_LoadResult.ErrorNoEnum.NotFound) { //暂时初始化为空列表 List <TableMailInfoWrap> mailList = new List <TableMailInfoWrap>(); UserServer.Instance.GlobalProcessThread.InitMailData(mailList); m_MailInitStatus = DataInitStatus.Done; LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Green, "Load DataCache global data success. Table:TableMailInfo (empty)"); } else { m_MailInitStatus = DataInitStatus.Unload; LogSys.Log(LOG_TYPE.ERROR, ConsoleColor.Red, "Load DataCache global data failed. Table: {0}", "TableMailInfo"); } } )); } else { m_MailInitStatus = DataInitStatus.Done; LogSys.Log(LOG_TYPE.INFO, "init mail done!"); } } }
// internal void GMLoadAccount(string gmAccount, string accountId, int nodeHandle) { Msg_LD_Load msg = new Msg_LD_Load(); msg.MsgId = (int)DataEnum.TableAccount; msg.PrimaryKeys.Add(accountId); Msg_LD_SingleLoadRequest reqAccount = new Msg_LD_SingleLoadRequest(); reqAccount.MsgId = (int)DataEnum.TableAccount; reqAccount.LoadType = Msg_LD_SingleLoadRequest.LoadTypeEnum.LoadSingle; reqAccount.Keys.Add(accountId); msg.LoadRequests.Add(reqAccount); RequestLoad(msg, (ret) => { JsonMessage resultMsg = new JsonMessage(LobbyGmMessageDefine.Msg_CL_GmQueryAccount, gmAccount); GameFrameworkMessage.Msg_LC_GmQueryAccount protoData = new GameFrameworkMessage.Msg_LC_GmQueryAccount(); protoData.m_Result = GameFrameworkMessage.GmResultEnum.Failed; protoData.m_QueryAccount = accountId; protoData.m_AccountState = GameFrameworkMessage.GmStateEnum.Offline; resultMsg.m_ProtoData = protoData; KeyString primaryKey = KeyString.Wrap(ret.PrimaryKeys); if (Msg_DL_LoadResult.ErrorNoEnum.Success == ret.ErrorNo) { LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Green, "DataCache Load Success: Msg:{0}, Key:{1}", "GmAccount", primaryKey); TableAccount dataAccount = null; foreach (var result in ret.Results) { object _msg; if (DbDataSerializer.Decode(result.Data, DataEnum2Type.Query(result.MsgId), out _msg)) { DataEnum msgEnum = (DataEnum)result.MsgId; switch (msgEnum) { case DataEnum.TableAccount: dataAccount = _msg as TableAccount; break; default: LogSys.Log(LOG_TYPE.ERROR, ConsoleColor.Red, "Decode account data ERROR. Wrong message id. Account:{0}, WrongId:{1}", result.PrimaryKeys[0], msgEnum); break; } } } protoData.m_Result = GameFrameworkMessage.GmResultEnum.Success; protoData.m_QueryAccount = dataAccount.AccountId; protoData.m_AccountState = GameFrameworkMessage.GmStateEnum.Online; if (dataAccount.IsBanned) { protoData.m_AccountState = GameFrameworkMessage.GmStateEnum.Banned; } } else if (Msg_DL_LoadResult.ErrorNoEnum.NotFound == ret.ErrorNo) { LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Yellow, "DataCache Load NotFound: Msg:{0}, Key:{1}", "GmAccount", primaryKey); } else { LogSys.Log(LOG_TYPE.ERROR, ConsoleColor.Red, "DataCache Load Failed: Msg:{0}, Key:{1}, ERROR:{2}", "GmAccount", primaryKey, ret.ErrorInfo); } resultMsg.m_ProtoData = protoData; JsonGmMessageDispatcher.SendNodeMessage(nodeHandle, resultMsg); }); }
internal void SaveUser(UserInfo ui, int saveCount) { try { ulong userGuid = ui.Guid; string key = userGuid.ToString(); if (ui.Modified) { Msg_LD_Save msg = new Msg_LD_Save(); msg.MsgId = (int)DataEnum.TableUserInfo; msg.PrimaryKeys.AddRange(ui.PrimaryKeys); msg.ForeignKeys.AddRange(ui.ForeignKeys); msg.Data = DbDataSerializer.Encode(ui.ToProto()); DispatchAction(SaveInternal, msg); ui.Modified = false; } foreach (var pair in ui.MailStateInfo.WholeMailStates) { var mi = pair.Value; if (mi.Modified) { Msg_LD_Save msg = new Msg_LD_Save(); msg.MsgId = (int)DataEnum.TableMailStateInfo; msg.PrimaryKeys.AddRange(mi.PrimaryKeys); msg.ForeignKeys.AddRange(mi.ForeignKeys); msg.Data = DbDataSerializer.Encode(mi.ToProto()); DispatchAction(SaveInternal, msg); mi.Modified = false; } } foreach (var mi in ui.MailStateInfo.DeletedWholeMailStates) { if (mi.Deleted) { Msg_LD_Save msg = new Msg_LD_Save(); msg.MsgId = (int)DataEnum.TableMailStateInfo; msg.PrimaryKeys.AddRange(mi.PrimaryKeys); msg.ForeignKeys.AddRange(mi.ForeignKeys); msg.Data = null; DispatchAction(SaveInternal, msg); mi.Deleted = false; } } ui.MailStateInfo.DeletedWholeMailStates.Clear(); foreach (var mi in ui.MemberInfos) { if (mi.Modified) { Msg_LD_Save msg = new Msg_LD_Save(); msg.MsgId = (int)DataEnum.TableMemberInfo; msg.PrimaryKeys.AddRange(mi.PrimaryKeys); msg.ForeignKeys.AddRange(mi.ForeignKeys); msg.Data = DbDataSerializer.Encode(mi.ToProto()); DispatchAction(SaveInternal, msg); mi.Modified = false; } } foreach (var mi in ui.DeletedMemberInfos) { if (mi.Deleted) { Msg_LD_Save msg = new Msg_LD_Save(); msg.MsgId = (int)DataEnum.TableMemberInfo; msg.PrimaryKeys.AddRange(mi.PrimaryKeys); msg.ForeignKeys.AddRange(mi.ForeignKeys); msg.Data = null; DispatchAction(SaveInternal, msg); mi.Deleted = false; } } ui.DeletedMemberInfos.Clear(); foreach (var ii in ui.ItemBag.ItemInfos) { if (ii.Modified) { Msg_LD_Save msg = new Msg_LD_Save(); msg.MsgId = (int)DataEnum.TableItemInfo; msg.PrimaryKeys.AddRange(ii.PrimaryKeys); msg.ForeignKeys.AddRange(ii.ForeignKeys); msg.Data = DbDataSerializer.Encode(ii.ToProto()); DispatchAction(SaveInternal, msg); ii.Modified = false; } } foreach (var ii in ui.ItemBag.DeletedItemInfos) { if (ii.Deleted) { Msg_LD_Save msg = new Msg_LD_Save(); msg.MsgId = (int)DataEnum.TableItemInfo; msg.PrimaryKeys.AddRange(ii.PrimaryKeys); msg.ForeignKeys.AddRange(ii.ForeignKeys); msg.Data = null; DispatchAction(SaveInternal, msg); ii.Deleted = false; } } ui.ItemBag.DeletedItemInfos.Clear(); foreach (var fi in ui.FriendInfos) { if (fi.Modified) { Msg_LD_Save msg = new Msg_LD_Save(); msg.MsgId = (int)DataEnum.TableFriendInfo; msg.PrimaryKeys.AddRange(fi.PrimaryKeys); msg.ForeignKeys.AddRange(fi.ForeignKeys); msg.Data = DbDataSerializer.Encode(fi.ToProto()); DispatchAction(SaveInternal, msg); fi.Modified = false; } } foreach (var fi in ui.DeletedFriendInfos) { if (fi.Deleted) { Msg_LD_Save msg = new Msg_LD_Save(); msg.MsgId = (int)DataEnum.TableFriendInfo; msg.PrimaryKeys.AddRange(fi.PrimaryKeys); msg.ForeignKeys.AddRange(fi.ForeignKeys); msg.Data = DbDataSerializer.Encode(fi.ToProto()); DispatchAction(SaveInternal, msg); fi.Deleted = false; } } ui.DeletedFriendInfos.Clear(); ui.CurrentUserSaveCount = saveCount; } catch (Exception e) { LogSys.Log(LOG_TYPE.ERROR, "DataCache Save ERROR. Msg:SaveUser, Key:{0}, SaveCount:{1}, Error:{2},\nStacktrace:{3}", ui.Guid, saveCount, e.Message, e.StackTrace); } }