using System.Collections.Generic; using Sog; using LitJson; using SimpleHttpServer; using ProtoCSStruct; using System.Reflection; namespace Operation { [MenuMapping(refc = typeof(PlayerInfoOp))] public class SelectCus { //收到回包时调用这个 public static void OnResMsg(uint id, JsonData jsondata, HttpResponse rsp, HttpRequest request, HttpQueryParams query, ref SSGmQueryUserRoletInfoRes res) { jsondata["code"] = 0; jsondata["totalPayMoneyUSD"] = res.RoleData.PayData.TotalPayMoneyUSD; rsp.IsWaitFor = false; return; } private static void GetResData(Dictionary man, FieldInfo[] fieldInfos, object res) { //dynamic obj =new ExpandoObject(); foreach (var Fd in fieldInfos) { if (Fd.Name.StartsWith("Repeated") || Fd.Name == "FixedElementField") { continue; } if (Fd.FieldType.IsArray) { continue; } //基础类型直接写入值 if (Fd.FieldType.IsPrimitive) { if (!man.ContainsKey(Fd.Name)) { man.Add(Fd.Name, Fd.GetValue(res)); } } else { // ProtoCSStruct.RepeatedDBIDValue_32 +< Buffer > e__FixedBuffer.FixedElementField var vla = res.GetType().GetField(Fd.Name).GetValue(res); //字符类型获取字符写入 if (Fd.FieldType == typeof(FixedStructString32) || Fd.FieldType == typeof(FixedStructString16)) { man.Add(Fd.Name, Fd.FieldType.GetMethod("GetString").Invoke(vla, null)); } //自定义结构继续递归 else { var sss = new Dictionary(); GetResData(sss, Fd.FieldType.GetFields(), vla); man.Add(Fd.Name, sss); } } } } [RequestMapping("关卡信息",PermissionCode.USER_ROLE,true)] public static int OnSelectCusHttpReq(string httpApiCmd, JsonData jsonData, HttpResponse rsp, HttpRequest request, HttpQueryParams query, uint httpContextId) { TraceLog.Trace("SelectCus.OnSelectCusHttpReq Url{0},param count {1}, httpContextId {2}", request.Url, query.Count, httpContextId); int uid = query.GetValue("uid").Toint32(0); SSGmQueryUserRoleInfoReq req = new SSGmQueryUserRoleInfoReq(); req.Id = httpContextId; req.Uid = (uint)uid; req.AccountType = 0; OperationServerUtils.SendToWorld((int)SSGameMsgID.GmQueryUserRoleReq, ref req, uid, 0, ""); rsp.IsWaitFor = true; return 0; } } }