protected override async void Run(Session session, C2G_QueryUserMessage message, Action <G2C_QueryUserMessage> reply) { G2C_QueryUserMessage response = new G2C_QueryUserMessage(); response.IsSuccess = false; try { DBProxyComponent dBProxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); var acounts = await dBProxyComponent.Query <UserMessage>("{ '_id': " + message.UserMessageID + "}"); if (acounts.Count > 0) { UserMessage user = acounts[0] as UserMessage; response.MessageInfo = RepeatedFieldAndListChangeTool.ListToRepeatedField(user._Message); response.ByAccountID = user._ByInvAccountID; response.AccountID = user._InvAccountID; response.SendDate = user._SendDate; response.IsSuccess = true; response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "好友消息获取成功"; } reply(response); } catch (Exception e) { response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "好友列表获取或创建失败,服务器维护中。"; ReplyError(response, e, reply); } }
protected override async void Run(Session session, C2G_QueryChatRoom message, Action <G2C_QueryChatRoom> reply) { G2C_QueryChatRoom response = new G2C_QueryChatRoom(); response.IsSuccess = false; try { DBProxyComponent dBProxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); var acountsC = await dBProxyComponent.Query <ChatRoom>("{'_id' : '" + message.ChatRoomID + "'}"); if (acountsC.Count > 0) { ChatRoom chatRoom = acountsC[0] as ChatRoom; if (chatRoom._State == 2) { var acounts = await dBProxyComponent.Query <RelationInfo>("{'_id' : '" + message.Acount + "'}"); RelationInfo info = acounts[0] as RelationInfo; info._ChatRoomList.Remove(message.ChatRoomID); response.IsSuccess = true; response.Message = "聊天室已删除退出聊天室成功"; await dBProxyComponent.Save(info); } else { response.GroupType = chatRoom._GroupType; response.CreateDate = chatRoom._CreateDate; response.ManagePassword = chatRoom._ManagePassword; response.PublicBorad = chatRoom._PublicBorad; response.Name = chatRoom._Name; response.UserList = RepeatedFieldAndListChangeTool.ListToRepeatedField(chatRoom._UserList); response.DateMessageIDList = RepeatedFieldAndListChangeTool.ListToRepeatedField(chatRoom._DateMessageIDList); response.IsSuccess = true; response.Message = "聊天室获取成功"; } } else { response.IsSuccess = false; response.Message = "聊天室数据库异常"; Log.Debug(MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "聊天室数据库异常"); } reply(response); } catch (Exception e) { response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "聊天室获取失败,服务器维护中。"; ReplyError(response, e, reply); } }
protected override async void Run(Session session, C2G_QueryUserProductInfo message, Action <G2C_QueryUserProductInfo> reply) { G2C_QueryUserProductInfo response = new G2C_QueryUserProductInfo(); UserProductInfo UserProductInfo = null; try { DBProxyComponent dBProxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); var acounts = await dBProxyComponent.Query <UserProductInfo>("{ '_AccountID': " + message.AccountID + "}"); if (acounts.Count <= 0) { UserProductInfo Info = ComponentFactory.Create <UserProductInfo>(); Info._AccountID = message.AccountID; Info._InfoID = message.InfoID; Info._ProductList = new List <int>(); Info._UserPoint = 0; response.ProductList = RepeatedFieldAndListChangeTool.ListToRepeatedField(Info._ProductList); response.UserPoint = Info._UserPoint; await dBProxyComponent.Save(Info); await dBProxyComponent.SaveLog(Info); } else { UserProductInfo = acounts[0] as UserProductInfo; response.ProductList = RepeatedFieldAndListChangeTool.ListToRepeatedField(UserProductInfo._ProductList); response.UserPoint = UserProductInfo._UserPoint; await dBProxyComponent.Save(UserProductInfo); await dBProxyComponent.SaveLog(UserProductInfo); } reply(response); } catch (Exception e) { response.Message = "数据库异常"; ReplyError(response, e, reply); } }
protected override async void Run(Session session, C2G_QueryUserProductRecord message, Action <G2C_QueryUserProductRecord> reply) { G2C_QueryUserProductRecord response = new G2C_QueryUserProductRecord(); UserProductRecord UserProductRecord = null; try { DBProxyComponent dBProxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); var acounts = await dBProxyComponent.Query <UserProductRecord>("{ '_AccountID': " + message.AccountID + "}"); if (acounts.Count > 0) { for (int i = 0; i < acounts.Count; i++) { UserProductRecord = acounts[i] as UserProductRecord; ProductRecord record = new ProductRecord(); record.AccountID = UserProductRecord._AccountID; record.InfoID = UserProductRecord._InfoID; record.ProductID = UserProductRecord._ProductID; record.Level = UserProductRecord._Level; record.StartDate = UserProductRecord._StartDate; record.EndDate = UserProductRecord._EndDate; record.RightCodeList = RepeatedFieldAndListChangeTool.ListToRepeatedField(UserProductRecord._RightCodeList); record.BuyType = UserProductRecord._BuyType; record.Price = UserProductRecord._Price; response.Userlist.Add(record); } } await dBProxyComponent.Save(UserProductRecord); await dBProxyComponent.SaveLog(UserProductRecord); reply(response); } catch (Exception e) { response.Message = "数据库异常"; ReplyError(response, e, reply); } }
protected override async void Run(Session session, C2G_QueryUserAdress message, Action <G2C_QueryUserAdress> reply) { G2C_QueryUserAdress response = new G2C_QueryUserAdress(); UserAdress userAdress = null; try { DBProxyComponent dBProxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); var acounts = await dBProxyComponent.Query <UserAdress>("{ '_AccountID': " + message.AccountID + "}"); if (acounts.Count <= 0) { UserAdress Info = ComponentFactory.Create <UserAdress>(); Info._AccountID = message.AccountID; Info._InfoID = message.InfoID; Info._AdressList = new List <string>(); response.AdressList = RepeatedFieldAndListChangeTool.ListToRepeatedField(Info._AdressList); await dBProxyComponent.Save(Info); await dBProxyComponent.SaveLog(Info); } else { userAdress = acounts[0] as UserAdress; response.AdressList = RepeatedFieldAndListChangeTool.ListToRepeatedField(userAdress._AdressList); await dBProxyComponent.Save(userAdress); await dBProxyComponent.SaveLog(userAdress); } reply(response); } catch (Exception e) { response.Message = "数据库异常"; ReplyError(response, e, reply); } }
/// <summary> /// 添加用户产品记录 /// </summary> async void AddUserProductRecord() { try { G2C_AddUserProductRecord AccountInfo = (G2C_AddUserProductRecord)await SessionComponent.Instance.Session.Call(new C2G_AddUserProductRecord() { AccountID = AccountID, InfoID = InfoID, ProductID = ProductID, Level = Level, StartDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), EndDate = EndDate, RightCodeList = RepeatedFieldAndListChangeTool.ListToRepeatedField(RightCodeList), BuyType = BuyType, Price = Price, }); } catch (Exception e) { Debug.Log("UserProductInfoComponent AddUserProductRecord" + e.Message); } }
protected override async void Run(Session session, C2G_FriendApplyCount message, Action <G2C_FriendApplyCount> reply) { G2C_FriendApplyCount response = new G2C_FriendApplyCount(); response.IsSuccess = false; List <long> Idlist = new List <long>(); try { DBProxyComponent dBProxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); var acounts = await dBProxyComponent.Query <RequestInfo>("{'_InvAccountID' : '" + message.Account + "','_ByInvAccountID' : '" + message.Account + "'}"); if (acounts.Count > 0) { foreach (RequestInfo item in acounts) { Idlist.Add(item.Id); } response.RequestInfoidlist = RepeatedFieldAndListChangeTool.ListToRepeatedField(Idlist); response.IsSuccess = true; response.Message = "获取好友申请id列表成功"; } else { response.IsSuccess = false; response.Message = "好友列表数据库异常"; Log.Debug(MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "好友列表数据库异常"); } reply(response); } catch (Exception e) { response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "好友列表获取或创建失败,服务器维护中。"; ReplyError(response, e, reply); } }
/// <summary> /// 添加交易订单信息 /// </summary> async void DealOrder() { try { G2C_AddDealOrder AccountInfo = (G2C_AddDealOrder)await SessionComponent.Instance.Session.Call(new C2G_AddDealOrder() { InvAccountID = AccountID, ByInvAccountID = ByInvAccountID, ProductID = ProductID, InvItemList = RepeatedFieldAndListChangeTool.ListToRepeatedField(InvItemList), InvProductPoint = InvProductPoint, InvProductDiamond = InvProductDiamond, ByInvItemList = RepeatedFieldAndListChangeTool.ListToRepeatedField(ByInvItemList), ByInvProductPoint = ByInvProductPoint, ByInvProductDiamond = ByInvProductDiamond, MessageList = RepeatedFieldAndListChangeTool.ListToRepeatedField(MessageList), CreateDate = CreateDate, DealDate = DealDate, InvIP = InvIP, ByInvIP = ByInvIP, State = State, }); if (AccountInfo.IsOk) { Debug.Log("DealOrderComponent DealOrder" + "添加交易订单信息成功"); } else { Debug.Log("DealOrderComponent DealOrder" + "添加交易订单信息失败"); } } catch (Exception e) { Debug.Log("DealOrderComponent DealOrder" + e.Message); } }
/// <summary> /// 修改主账户数据 /// </summary> async void UpdateMainAccount() { try { G2C_UpdateDealOrder g2C_UpdateMainAccount = (G2C_UpdateDealOrder)await SessionComponent.Instance.Session.Call(new C2G_UpdateDealOrder() { ByInvAccountID = ByInvAccountID, ProductID = ProductID, InvItemList = RepeatedFieldAndListChangeTool.ListToRepeatedField(InvItemList), InvProductPoint = InvProductPoint, InvProductDiamond = InvProductDiamond, ByInvItemList = RepeatedFieldAndListChangeTool.ListToRepeatedField(ByInvItemList), ByInvProductPoint = ByInvProductPoint, ByInvProductDiamond = ByInvProductDiamond, MessageList = RepeatedFieldAndListChangeTool.ListToRepeatedField(MessageList), CreateDate = CreateDate, DealDate = DealDate, InvIP = InvIP, ByInvIP = ByInvIP, State = State, }); if (g2C_UpdateMainAccount.IsOk) { Debug.Log("DealOrderComponent UpdateMainAccount" + "交易订单修改成功"); } else { Debug.Log("DealOrderComponent UpdateMainAccount" + "交易订单修改失败"); } } catch (Exception e) { Debug.Log("DealOrderComponent UpdateMainAccount" + e.Message); } }
protected override async void Run(Session session, C2G_QueryWalletData message, Action <G2C_QueryWalletData> reply) { G2C_QueryWalletData response = new G2C_QueryWalletData(); response.IsSuccess = false; try { DBProxyComponent dBProxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); var acounts = await dBProxyComponent.Query <WalletData>("{ '_AccountID': " + message.AccountID + "}"); if (acounts.Count > 0) { WalletData user = acounts[0] as WalletData; response.PayPassword = user._PayPassword; response.CreateDate = user._CreateDate; response.Diamond = user._Diamond; response.Point = user._Point; response.WalletType = user._WalletType; response.OffList = RepeatedFieldAndListChangeTool.ListToRepeatedField(user._OffList); response.State = user._State; response.WalletTipList = RepeatedFieldAndListChangeTool.ListToRepeatedField(user._WalletTipList); response.IsSuccess = true; response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "钱包数据获取成功"; } reply(response); } catch (Exception e) { response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "钱包数据获取失败,服务器维护中。"; ReplyError(response, e, reply); } }
protected override async void Run(Session session, C2G_FriendList message, Action <G2C_FriendList> reply) { G2C_FriendList response = new G2C_FriendList(); response.IsSuccess = false; try { DBProxyComponent dBProxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); var acounts = await dBProxyComponent.Query <RelationInfo>("{'_Account' : '" + message.Account + "'}"); if (message.Type == 1) { if (acounts.Count < 1) { RelationInfo relationInfo = ComponentFactory.Create <RelationInfo>(); relationInfo._InfoID = message.InfoID; relationInfo._AccountID = message.Account; relationInfo._BlackIDList = new List <long>(); relationInfo._ChatRoomList = new List <long>(); relationInfo._FriendIDList = new List <long>(); relationInfo._GroupList = new List <long>(); await dBProxyComponent.Save(relationInfo); response.IsSuccess = true; response.Message = "好友列表创建成功"; Log.Debug(MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "好友列表创建成功"); } } else if (message.Type == 2) { if (acounts.Count > 0) { RelationInfo item = acounts[0] as RelationInfo; response.BlackIDList = RepeatedFieldAndListChangeTool.ListToRepeatedField(item._BlackIDList); response.ChatRoomList = RepeatedFieldAndListChangeTool.ListToRepeatedField(item._ChatRoomList); response.FriendIDList = RepeatedFieldAndListChangeTool.ListToRepeatedField(item._FriendIDList); response.GroupList = RepeatedFieldAndListChangeTool.ListToRepeatedField(item._GroupList); response.IsSuccess = true; response.Message = "好友列表获取成功"; } else { response.IsSuccess = false; response.Message = "好友列表数据库异常"; Log.Debug(MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "好友列表数据库异常"); } } reply(response); } catch (Exception e) { response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "好友列表获取或创建失败,服务器维护中。"; ReplyError(response, e, reply); } }
protected override async void Run(Session session, C2G_AddressManager message, Action <G2C_AddressManager> reply) { G2C_AddressManager response = new G2C_AddressManager(); try { Log.Debug("地址管理"); DBProxyComponent dBProxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); //读取数据表 if (message.DoState == 1) { var acounts = await dBProxyComponent.Query <UserAdress>("{'_AccountID' : " + message.AccountID + "}"); if (acounts.Count == 1) { foreach (UserAdress item in acounts) { response.InfoID = item._InfoID; response.AdressList = RepeatedFieldAndListChangeTool.ListToRepeatedField(item._AdressList); } response.IsSuccess = true; response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "拿取数据成功"; } else if (acounts.Count == 0) { response.IsSuccess = false; response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "无数据"; } else { response.IsSuccess = false; response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "地址数据错误"; } } //操作数据表 else if (message.DoState == 2) { Log.Debug("操作数据表"); var acounts = await dBProxyComponent.Query <UserAdress>("{'_AccountID' : " + message.AccountID + "}"); //修改 if (acounts.Count == 1) { foreach (UserAdress item in acounts) { if (message.AddressType == 1) { item._AdressList.Insert(0, message.DetailsAddress); await dBProxyComponent.Save(item); response.IsSuccess = true; response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "修改地址成功"; } if (message.AddressType == 2) { item._AdressList.Remove(message.DetailsAddress); await dBProxyComponent.Save(item); response.IsSuccess = true; response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "修改地址成功"; } } } //保存数据表 else if (acounts.Count == 0) { UserAdress adressData = ComponentFactory.Create <UserAdress>(); adressData._AccountID = message.AccountID; adressData._InfoID = adressData.Id; adressData._AdressList = new List <string>(); await dBProxyComponent.Save(adressData); Log.Debug(MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "添加地址成功"); response.IsSuccess = true; response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "添加地址成功"; } else { response.IsSuccess = false; response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "地址数据错误"; } } reply(response); } catch (Exception e) { response.IsSuccess = false; response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "数据库异常"; ReplyError(response, e, reply); } }