Ejemplo n.º 1
0
        public void GetProfileInfo(long userId, Action <BackendResult <UserData, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();
            string index1 = "userId";
            string str1   = userId.ToString();

            parameters[index1] = str1;
            string index2 = "func_v";
            string str2   = "3";

            parameters[index2] = str2;
            VKRequestsDispatcher.DispatchRequestToVK <UserData>("execute.getProfileInfo", parameters, callback, (Func <string, UserData>)(jsonStr =>
            {
                jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "relatives", false);
                jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "wallData", true);
                jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "Groups", false);
                jsonStr = VKRequestsDispatcher.FixArrayToObject(jsonStr, "personal");
                jsonStr = VKRequestsDispatcher.FixArrayToObject(jsonStr, "occupation");
                jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "photos", true);
                jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "subscriptions", true);
                jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "gifts", true);
                int resultCount;
                jsonStr = VKRequestsDispatcher.GetArrayCountAndRemove(jsonStr, "wall", out resultCount);
                VKRequestsDispatcher.GenericRoot <UserData> genericRoot = JsonConvert.DeserializeObject <VKRequestsDispatcher.GenericRoot <UserData> >(jsonStr);
                if (genericRoot.response.user.counters.docs == 0)
                {
                    genericRoot.response.user.counters.docs = genericRoot.response.docsCount;
                }
                return(genericRoot.response);
            }), false, true, new CancellationToken?(), null);
        }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
        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);
        }