Exemplo n.º 1
0
        /// <summary>
        /// Получает и устанавливает коментарии к посту
        /// </summary>
        /// <param name="abstractJObject">Пост на стене</param>
        private void GetComent(VKAbstractJObject abstractJObject)
        {
            if (abstractJObject.comments.count != 0)
            {
                string GetCommentURL = string.Concat
                                       (
                    "https://api.vk.com/method/wall.getComments?access_token=", (File.ReadAllLines("UserInf.txt"))[0],
                    "&owner_id=", abstractJObject.owner_id,
                    "&v=5.52&count=1&sort=desc&post_id=", abstractJObject.id
                                       );

                List <Comment> comments = new List <Comment>();

                using (WebClient wc = new WebClient())
                {
                    string JsonComment = wc.DownloadString(GetCommentURL);
                    JsonComment = @"{" + Substring.GetSubstringStartIncluded(JsonComment, @"""items", "}}") + @"}";
                    Thread.Sleep(300);
                    if (abstractJObject.id == 127605)
                    {
                    }
                    comments = Converter <Comment> .JsonToList(JsonComment, "items");
                }
                byte[] price  = Encoding.Default.GetBytes(comments[0].ToString());
                string coment = Encoding.UTF8.GetString(price);
                abstractJObject.comment = coment; // Black Magic
            }
        }
Exemplo n.º 2
0
        private string GetPrice()
        {
            startPrice = Substring.GetSubstringNoIncluded(text, @"Стартовая цена:", "\nМинимальный шаг:");

            if (this.comments.count == 0)
            {
                return(string.Concat(startPrice, @" / 0"));
            }

            string GetCommentURL = string.Concat
                                   (
                "https://api.vk.com/method/wall.getComments?access_token=", access_token[0],
                "&owner_id=", owner_id,
                "&v=5.52&count=1&sort=desc&post_id=", id
                                   );

            List <Comment> comments = new List <Comment>();

            using (WebClient wc = new WebClient())
            {
                string JsonComment = wc.DownloadString(GetCommentURL);
                JsonComment = @"{" + Substring.GetSubstringStartIncluded(JsonComment, @"""items", "}}") + @"}";
                Thread.Sleep(300);
                comments = Converter <Comment> .JsonToList(JsonComment, "items");
            }
            if (comments == null)
            {
                return(string.Empty);
            }
            price = comments[0]?.ToString();
            price = Encoding.UTF8.GetString(Encoding.Default.GetBytes(price)); // Black Magic
            price = Substring.GetSubstringNoIncluded(price, "(", " рублей)");
            return(string.Concat(startPrice, " / ", price));
        }
Exemplo n.º 3
0
 /// <summary>
 /// Собирает в читаемый, прграммой, вид строку
 /// </summary>
 /// <param name="JSON">JSON строка</param>
 /// <returns></returns>
 private string ConvertTopDeckTextToJson(string JSON)
 {
     JSON = Substring.GetSubstringStartIncluded(JSON, @"""items", "}}");
     JSON = @"{" + JSON + @"}";
     return(JSON);
 }