Advertisement
kiraventom

Untitled

May 4th, 2020
1,170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.66 KB | None | 0 0
  1. private async Task<bool> StartPosting(IProgress<DateTime> dateTimePr)
  2.         {
  3. // получаем сервер для загрузки
  4.             var uploadServerInfo = Api.Photo.GetWallUploadServer(GroupId);
  5. // для всех имеющихся дат в расписании
  6.             for (int i = 0; i < DateTimes.Length; ++i)
  7.             {
  8. //берём соответствующий путь к картинке, параметры редактирования и дату\время
  9.                 string pathToPicture = PathsToPictures[i];
  10.                 var picEditParams = PictureEditParams[i];
  11.                 DateTime dateTime = DateTimes[i];
  12.  
  13. // подгружаем в память картинку
  14.                 Bitmap picture = new Bitmap(pathToPicture);
  15. //применяем к ней изменения
  16.                 picture = PictureEdit.PictureEditParams.Edit(picture, picEditParams);
  17. //переводим в байт-массив
  18.                 byte[] pictureBytes = ToByteArray(picture);
  19.  
  20. //грузим на сервер вк
  21.                     var response = await UploadImage(uploadServerInfo.UploadUrl, pictureBytes);
  22. //получаем экземпляр загруженного wallPhoto от вк
  23.                     var wallPhoto = Api.Photo.SaveWallPhoto(response, null, (ulong)GroupId);
  24.  
  25. //постим
  26.                     Api.Wall.Post(new VkNet.Model.RequestParams.WallPostParams
  27.                     {
  28.                         OwnerId = - GroupId,
  29.                         FromGroup = true,
  30.                         PublishDate = dateTime,
  31.                         Attachments = wallPhoto
  32.                     });
  33.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement