public void GetGroupInfo(long groupId, Action <BackendResult <GroupData, ResultCode> > callback) { VKRequestsDispatcher.DispatchRequestToVK <GroupData>("execute.getGroupInfo", new Dictionary <string, string>() { { "groupId", groupId.ToString() }, { "func_v", "2" } }, callback, (Func <string, GroupData>)(jsonStr => { jsonStr = VKRequestsDispatcher.FixArrayToObject(jsonStr, "counters"); jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "photos", true); jsonStr = VKRequestsDispatcher.FixArrayToObject(jsonStr, "mediaSectionsSettings"); GroupData response = JsonConvert.DeserializeObject <VKRequestsDispatcher.GenericRoot <GroupData> >(jsonStr).response; GroupMembershipType groupMembershipType = GroupMembershipType.NotAMember; try { groupMembershipType = (GroupMembershipType)response.group.member_status; if (groupMembershipType == GroupMembershipType.InvitationRejected) { groupMembershipType = GroupMembershipType.NotAMember; } } catch { if (response.membership.member == 1) { groupMembershipType = GroupMembershipType.Member; } if (response.membership.invitation == 1) { groupMembershipType = GroupMembershipType.InvitationReceived; } if (response.membership.request == 1) { groupMembershipType = GroupMembershipType.RequestSent; } } response.group.MembershipType = groupMembershipType; if (Enum.IsDefined(typeof(ProfileMainSectionType), response.group.main_section)) { response.group.MainSection = (ProfileMainSectionType)response.group.main_section; } this.AddCachedGroup(response.group); return(response); }), false, true, new CancellationToken?(), null); }
public void GetGroupInfo(long groupId, Action <BackendResult <Group, ResultCode> > callback) {/* * VKRequestsDispatcher.DispatchRequestToVK<GroupData>("execute.getGroupInfo", new Dictionary<string, string>() * { * { * "groupId", * groupId.ToString() * }, * { * "func_v", * "2" * } * }, callback, (Func<string, GroupData>) (jsonStr => * { * jsonStr = VKRequestsDispatcher.FixArrayToObject(jsonStr, "counters"); * jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "photos", true); * jsonStr = VKRequestsDispatcher.FixArrayToObject(jsonStr, "mediaSectionsSettings"); * GroupData response = JsonConvert.DeserializeObject<VKRequestsDispatcher.GenericRoot<GroupData>>(jsonStr).response; * GroupMembershipType groupMembershipType = GroupMembershipType.NotAMember; * try * { * groupMembershipType = (GroupMembershipType) response.group.member_status; * if (groupMembershipType == GroupMembershipType.InvitationRejected) * groupMembershipType = GroupMembershipType.NotAMember; * } * catch * { * if (response.membership.member == 1) * groupMembershipType = GroupMembershipType.Member; * if (response.membership.invitation == 1) * groupMembershipType = GroupMembershipType.InvitationReceived; * if (response.membership.request == 1) * groupMembershipType = GroupMembershipType.RequestSent; * } * response.group.MembershipType = groupMembershipType; * if (Enum.IsDefined(typeof (ProfileMainSectionType), response.group.main_section)) * response.group.MainSection = (ProfileMainSectionType) response.group.main_section; * this.AddCachedGroup(response.group); * return response; * }), false, true, new CancellationToken?(), null);*/ Dictionary <string, string> parameters = new Dictionary <string, string>(); /* * if (uid > 0) { * param("user_id", uid); * param("func_v", 2); * } else { * param("group_id", -uid); * param("func_v", 5); * param("good_count", goodsCount); * } * this.uid = uid; * param("photo_count", photoCount); * param("gift_count", giftCount); * param(ServerKeys.PHOTO_SIZES, 1); * param("skip_hidden", 1); */ parameters["group_id"] = groupId.ToString(); parameters["func_v"] = "5"; parameters["good_count"] = "15"; parameters["photo_count"] = "25"; parameters["gift_count"] = "25"; parameters["photo_sizes"] = "1"; parameters["skip_hidden"] = "1"; VKRequestsDispatcher.DispatchRequestToVK <Group>("execute.getFullGroupNewNew", parameters, callback, (Func <string, Group>)(jsonStr => { jsonStr = VKRequestsDispatcher.FixArrayToObject(jsonStr, "counters"); jsonStr = VKRequestsDispatcher.FixArrayToObject(jsonStr, "photos"); //jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "photos", true); jsonStr = VKRequestsDispatcher.FixArrayToObject(jsonStr, "mediaSectionsSettings"); //"status":{"text":"На пути достижения цели..."} System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex(".+(\"status\":{\"text\":\"(.*?)\"})"); System.Text.RegularExpressions.Match m = r.Match(jsonStr); string str1 = m.Groups[1].Value; string str2 = m.Groups[2].Value; jsonStr = jsonStr.Replace(str1, "\"status\":\"" + str2 + "\""); jsonStr = VKRequestsDispatcher.FixArrayToObject(jsonStr, "goods"); Group response = JsonConvert.DeserializeObject <VKRequestsDispatcher.GenericRoot <Group> >(jsonStr).response; GroupMembershipType groupMembershipType = (GroupMembershipType)response.member_status; if (groupMembershipType == GroupMembershipType.InvitationRejected) { groupMembershipType = GroupMembershipType.NotAMember; } response.MembershipType = groupMembershipType; if (Enum.IsDefined(typeof(ProfileMainSectionType), response.main_section)) { response.MainSection = (ProfileMainSectionType)response.main_section; } this.AddCachedGroup(response /*.group*/); return(response); }), false, true, new CancellationToken?(), null); }