public async Task <CommentInformation> DeleteComment(CommentInformation info, bool both) { // HTTP 요청에 딜레이를 주어 서버 오류 방지 int delay = 50; GallogCommentDeleteParameter delParams = null; try { delParams = await this.GetDeleteCommentInfoAsync(info.DeleteUrl); } catch (Exception e) { info.IsGalleryDeleted = false; info.IsGallogDeleted = false; info.DeleteMessage = e.Message; return(info); } info.GalleryDeleteParameter = new GalleryCommentDeleteParameter() { GalleryId = delParams.GalleryId, ArticleId = delParams.ArticleId, CommentId = delParams.CommentId }; info.GallogDeleteParameter = delParams; await Task.Delay(delay); return(await DeleteComment(info, true, both)); }
internal static async Task <List <T> > GetItemListAsync <T>(string html) { if (typeof(T) != typeof(ArticleInformation) && typeof(T) != typeof(CommentInformation)) { throw new NotSupportedException(); } return(await Task.Run(async() => { HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(html); List <T> itemList = new List <T>(); if (typeof(T) == typeof(ArticleInformation)) { foreach (HtmlNode node in doc.DocumentNode.SelectNodes("//img[@src='http://wstatic.dcinside.com/gallery/skin/gallog/icon_01.gif']")) { if (node.Attributes["onClick"] != null) { string title = node.ParentNode.PreviousSibling.PreviousSibling.PreviousSibling.PreviousSibling.InnerText; title = HttpUtility.HtmlDecode(title).Trim(); string url = await GetAbsoulteURL(node.Attributes["onClick"].Value); string date = node.ParentNode.InnerText; object nItem = new ArticleInformation(title, date, url); itemList.Add((T)nItem); } } } else if (typeof(T) == typeof(CommentInformation)) { foreach (HtmlNode node in doc.DocumentNode.SelectNodes("//table[@bgcolor='#F2F2F5']/tr")) { if (node.Descendants("td").Count() == 6) { string name = node.SelectSingleNode("./td[1]").InnerText; name = HttpUtility.HtmlDecode(name).Trim(); string content = HttpUtility.HtmlDecode(node.SelectSingleNode("./td[3]").InnerText); string date = node.SelectSingleNode("./td[5]").InnerText; string url = await GetAbsoulteURL(node.SelectSingleNode("./td[6]/span").Attributes["onClick"].Value); object nItem = new CommentInformation(name, content, date, url); itemList.Add((T)nItem); } } } return itemList; })); }
public async Task <CommentInformation> DeleteComment(CommentInformation info, bool actualDelete, bool both) { // HTTP 요청에 딜레이를 주어 서버 오류 방지 int delay = 50; DeleteResult res1 = null; try { res1 = await PostDeleteGalleryCommentAsync(info.GalleryDeleteParameter); } catch (Exception ex) { info.IsGalleryDeleted = false; info.IsGallogDeleted = false; info.DeleteMessage = "갤러리의 리플을 지우는데 실패하였습니다 - [" + ex.Message + "]"; return(info); } if (!res1.Success && res1.ErrorMessage != "이미 삭제된 리플입니다.") { info.IsGalleryDeleted = false; info.IsGallogDeleted = false; info.DeleteMessage = "갤러리의 리플을 지우는데 실패하였습니다 - [" + res1.ErrorMessage + "]"; return(info); } if (both) { await Task.Delay(delay); DeleteResult res2 = null; try { res2 = await PostDeleteGallogCommentAsync(info.GallogDeleteParameter, delay); } catch (Exception ex) { info.IsGalleryDeleted = true; info.IsGallogDeleted = false; info.DeleteMessage = "갤로그의 리플을 지우는데 실패하였습니다 - [" + ex.Message + "]"; return(info); } if (!res2.Success) { info.IsGalleryDeleted = true; info.IsGallogDeleted = false; info.DeleteMessage = "갤로그의 리플을 지우는데 실패하였습니다 - [" + res2.ErrorMessage + "]"; return(info); } } info.IsGalleryDeleted = true; info.IsGallogDeleted = true; info.DeleteMessage = ""; return(info); }