Exemplo n.º 1
0
        public ReadOnlyCollection <PhotoAlbum> GetAlbums(out int count, PhotoGetAlbumsParams @params)
        {
            var response = _vk.Call("photos.getAlbums", @params);

            count = response["count"];
            return(response["items"].ToReadOnlyCollectionOf <PhotoAlbum>(x => x));
        }
Exemplo n.º 2
0
        public ReadOnlyCollection <PhotoAlbum> GetAlbums(out int count, PhotoGetAlbumsParams @params)
        {
            var response = GetAlbums(@params);

            count = Convert.ToInt32(response.TotalCount);

            return(response.ToReadOnlyCollection());
        }
Exemplo n.º 3
0
        private void GetAlbumInfoById(long?albumId)
        {
            PhotoGetAlbumsParams requestParams = new PhotoGetAlbumsParams()
            {
                AlbumIds = new long[] { (long)albumId }
            };

            foreach (PhotoAlbum album in API.Photo.GetAlbums(requestParams))
            {
                PrintAlbumToConsole(album);
            }
        }
Exemplo n.º 4
0
        public List <PhotoAlbum> GetAlbums(long ownerId)
        {
            var alb = new List <PhotoAlbum>();

            using (var api = _apiFactory.CreateVkApi())
            {
                var p = new PhotoGetAlbumsParams()
                {
                    OwnerId    = ownerId,
                    NeedSystem = true,
                };
                var albums = api.Photo.GetAlbums(p);
                alb.AddRange(albums.ToList());
            }
            return(alb);
        }
Exemplo n.º 5
0
 /// <inheritdoc />
 public async Task <VkCollection <PhotoAlbum> > GetAlbumsAsync(PhotoGetAlbumsParams @params,
                                                               bool skipAuthorization = false)
 {
     return(await TypeHelper.TryInvokeMethodAsync(() => _vk.Photo.GetAlbums(@params, skipAuthorization)));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Возвращает список альбомов пользователя или сообщества.
 /// </summary>
 /// <param name="params">Параметры запроса.</param>
 /// <param name="skipAuthorization">Если <c>true</c>, то пропустить авторизацию</param>
 /// <returns>
 /// Возвращает список объектов <see cref="PhotoAlbum" />
 /// </returns>
 /// <remarks>
 /// Страница документации ВКонтакте <seealso cref="http://vk.com/dev/photos.getAlbums" />.
 /// </remarks>
 public VkCollection<PhotoAlbum> GetAlbums(PhotoGetAlbumsParams @params, bool skipAuthorization = false)
 {
     return _vk.Call("photos.getAlbums", @params, skipAuthorization).ToVkCollectionOf<PhotoAlbum>(x => x);
 }
Exemplo n.º 7
0
 private void btnSrch_Click(object sender, EventArgs e)
 {
     //onClick search button
     if (vk.IsAuthorized)
     {
         int cnt    = 0;
         var groups = vk.Groups.Search(new GroupsSearchParams {
             Query = txtSrch.Text, Count = 100
         });
         foreach (var group in groups)
         {
             var  getted  = vk.Groups.GetById(null, group.Id.ToString(), GroupsFields.CanPost | GroupsFields.CanSeelAllPosts | GroupsFields.MembersCount).FirstOrDefault();
             bool canPost = getted.CanPost;
             bool pblcGrp = getted.CanSeelAllPosts;
             bool valid;
             if (getted.MembersCount > membersCnt.Value)
             {
                 valid = true;
             }
             else
             {
                 valid = false;
             }
             if (canPost && pblcGrp && valid)
             {
                 dataGridView1.Rows.Add();
                 dataGridView1.Rows[cnt].Cells[0].Value = group.Name;
                 dataGridView1.Rows[cnt].Cells[1].Value = canPost;
                 dataGridView1.Rows[cnt].Cells[2].Value = group.Id;
                 try
                 {
                     PhotoGetAlbumsParams pgap = new PhotoGetAlbumsParams
                     {
                         OwnerId = 0 - group.Id,
                     };
                     var albums = vk.Photo.GetAlbums(pgap);
                     int albCnt = 0;
                     foreach (var album in albums)
                     {
                         DataGridViewTextBoxColumn secondColumn = new DataGridViewTextBoxColumn();
                         secondColumn.HeaderText = "Name " + albCnt;
                         secondColumn.Name       = albCnt.ToString();
                         if (dataGridView1.ColumnCount <= albCnt + 3)
                         {
                             dataGridView1.Columns.Add(secondColumn);
                         }
                         dataGridView1.Rows[cnt].Cells[albCnt + 3].Value = album.Id;
                         albCnt++;
                     }
                 }
                 catch
                 {
                     Debugger.Log(1, "Exception", "Exception");
                 }
                 finally {
                     cnt++;
                 }
             }
         }
     }
 }
Exemplo n.º 8
0
        private void impBtn_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            string fileName = openFileDialog1.FileName;

            string[] arrstr = File.ReadAllLines(fileName);
            int      mCnt   = 0;

            if (vk.IsAuthorized)
            {
                foreach (string id in arrstr)
                {
                    var  getted  = vk.Groups.GetById(null, id, GroupsFields.CanPost | GroupsFields.CanSeelAllPosts | GroupsFields.MembersCount).FirstOrDefault();
                    bool canPost = getted.CanPost;
                    bool pblcGrp = getted.CanSeelAllPosts;
                    bool valid;
                    valid = (getted.MembersCount > membersCnt.Value);

                    if (valid && canPost && pblcGrp)
                    {
                        dataGridView1.Rows.Add();
                        dataGridView1.Rows[mCnt].Cells[0].Value = getted.Name;
                        dataGridView1.Rows[mCnt].Cells[1].Value = canPost;
                        dataGridView1.Rows[mCnt].Cells[2].Value = getted.Id;
                        try
                        {
                            PhotoGetAlbumsParams pgap = new PhotoGetAlbumsParams
                            {
                                OwnerId = 0 - getted.Id,
                            };
                            var albums = vk.Photo.GetAlbums(pgap);
                            int albCnt = 0;
                            foreach (var album in albums)
                            {
                                DataGridViewTextBoxColumn secondColumn = new DataGridViewTextBoxColumn();
                                secondColumn.HeaderText = "Name " + albCnt;
                                secondColumn.Name       = albCnt.ToString();
                                if (dataGridView1.ColumnCount <= albCnt + 3)
                                {
                                    dataGridView1.Columns.Add(secondColumn);
                                }
                                dataGridView1.Rows[mCnt].Cells[albCnt + 3].Value = album.Id;
                                albCnt++;
                            }
                        }
                        catch
                        {
                            Debugger.Log(1, "Exception", "Exception");
                        }
                        finally
                        {
                            mCnt++;
                        }
                    }
                }
            }
        }
Exemplo n.º 9
0
 /// <inheritdoc />
 public Task <VkCollection <PhotoAlbum> > GetAlbumsAsync(PhotoGetAlbumsParams @params, bool skipAuthorization = false)
 {
     return(TypeHelper.TryInvokeMethodAsync(func: () =>
                                            GetAlbums(@params: @params, skipAuthorization: skipAuthorization)));
 }