Exemple #1
0
        public static async Task SendEditPostAsync(CancellationTokenSource cts, string title, string content, List <string> fileNameList, List <string> fileRemoveList, int postId, int threadId)
        {
            title   = CommonService.MyHtmlEncodeForSend(title);
            content = CommonService.ReplaceFaceLabel(content);
            content = CommonService.MyHtmlEncodeForSend(content);

            var postData = new List <KeyValuePair <string, object> >();

            postData.Add(new KeyValuePair <string, object>("formhash", AccountService.FormHash));
            postData.Add(new KeyValuePair <string, object>("subject", title));
            postData.Add(new KeyValuePair <string, object>("message", $"{content.Trim()}{MessageTail}"));
            postData.Add(new KeyValuePair <string, object>("wysiwyg", "1"));
            postData.Add(new KeyValuePair <string, object>("usesig", "1"));
            postData.Add(new KeyValuePair <string, object>("tid", threadId));
            postData.Add(new KeyValuePair <string, object>("pid", postId));
            postData.Add(new KeyValuePair <string, object>("iconid", "0"));

            // 添加附件
            foreach (var fileId in fileNameList)
            {
                postData.Add(new KeyValuePair <string, object>(string.Format("attachnew[{0}][description]", fileId), string.Empty));
            }

            // 删除附件
            foreach (var fileId in fileRemoveList)
            {
                postData.Add(new KeyValuePair <string, object>("attachdel[]", fileId));
            }

            string url = string.Format("http://www.hi-pda.com/forum/post.php?action=edit&extra=&editsubmit=yes&mod=", threadId);
            await _httpClient.PostAsync(url, postData, cts);
        }
Exemple #2
0
        public static async Task <bool> SendPostReplyAsync(CancellationTokenSource cts, string noticeauthor, string noticetrimstr, string noticeauthormsg, string content, List <string> fileNameList, int threadId)
        {
            content = CommonService.ReplaceFaceLabel(content);
            content = CommonService.MyHtmlEncodeForSend(content);

            var postData = new List <KeyValuePair <string, object> >();

            postData.Add(new KeyValuePair <string, object>("formhash", AccountService.FormHash));
            postData.Add(new KeyValuePair <string, object>("wysiwyg", "1"));
            postData.Add(new KeyValuePair <string, object>("usesig", "1"));
            postData.Add(new KeyValuePair <string, object>("noticeauthor", "0"));
            postData.Add(new KeyValuePair <string, object>("noticetrimstr", "0"));
            postData.Add(new KeyValuePair <string, object>("noticeauthormsg", "0"));
            postData.Add(new KeyValuePair <string, object>("subject", string.Empty));
            postData.Add(new KeyValuePair <string, object>("message", $"{noticetrimstr}{content.Trim()}{MessageTail}"));

            // 图片信息
            foreach (var fileName in fileNameList)
            {
                postData.Add(new KeyValuePair <string, object>(string.Format("attachnew[{0}][description]", fileName), string.Empty));
            }

            string url           = string.Format("http://www.hi-pda.com/forum/post.php?action=reply&tid={0}&replysubmit=yes&inajax=1", threadId);
            string resultContent = await _httpClient.PostAsync(url, postData, cts);

            return(resultContent.Contains("您的回复已经发布"));
        }
Exemple #3
0
        public static async Task <bool> SendNewThreadAsync(CancellationTokenSource cts, string title, string content, List <string> fileNameList, int forumId)
        {
            title   = CommonService.MyHtmlEncodeForSend(title);
            content = CommonService.ReplaceFaceLabel(content);
            content = CommonService.MyHtmlEncodeForSend(content);

            var postData = new List <KeyValuePair <string, object> >();

            postData.Add(new KeyValuePair <string, object>("formhash", AccountService.FormHash));
            postData.Add(new KeyValuePair <string, object>("wysiwyg", "1"));
            postData.Add(new KeyValuePair <string, object>("usesig", "1"));
            postData.Add(new KeyValuePair <string, object>("iconid", "0"));
            postData.Add(new KeyValuePair <string, object>("subject", title));
            postData.Add(new KeyValuePair <string, object>("message", $"{content.Trim()}{MessageTail}"));
            postData.Add(new KeyValuePair <string, object>("attention_add", "1"));

            // 图片信息
            foreach (var fileName in fileNameList)
            {
                postData.Add(new KeyValuePair <string, object>(string.Format("attachnew[{0}][description]", fileName), string.Empty));
            }

            string url           = string.Format("http://www.hi-pda.com/forum/post.php?action=newthread&fid={0}&extra=&topicsubmit=yes", forumId);
            string resultContent = await _httpClient.PostAsync(url, postData, cts);

            return(!resultContent.Contains("对不起,您两次发表间隔少于"));
        }
        public async Task <UserMessageItemModel> PostUserMessage(string message, int userId)
        {
            var postData = new List <KeyValuePair <string, object> >();

            postData.Add(new KeyValuePair <string, object>("formhash", AccountService.FormHash));
            postData.Add(new KeyValuePair <string, object>("handlekey", "pmreply"));
            postData.Add(new KeyValuePair <string, object>("lastdaterange", DateTime.Now.ToString("yyyy-MM-dd")));
            postData.Add(new KeyValuePair <string, object>("message", CommonService.ReplaceFaceLabel(message)));

            string url           = string.Format("http://www.hi-pda.com/forum/pm.php?action=send&uid={0}&pmsubmit=yes&_={1}", userId, DateTime.Now.Ticks.ToString("x"));
            var    cts           = new CancellationTokenSource();
            string resultContent = await _httpClient.PostAsync(url, postData, cts);

            if (resultContent.StartsWith(@"<?xml version=""1.0"" encoding=""gbk""?><root><![CDATA[<li id=""pm_") && resultContent.Contains(@"images/default/notice_newpm.gif"))
            {
                XmlDocument xdoc = new XmlDocument();
                xdoc.LoadXml(resultContent);
                string html = xdoc.ChildNodes[1].InnerText;

                HtmlDocument doc = new HtmlDocument();
                doc.LoadHtml(html);

                var htmlNode = doc.DocumentNode.ChildNodes[0];
                return(GetUserMessageItem(htmlNode));
            }
            else if (resultContent.StartsWith(@"<?xml version=""1.0"" encoding=""gbk""?><root><![CDATA[<li class=""pm_date"">") && resultContent.Contains(@"images/default/notice_newpm.gif"))
            {
                XmlDocument xdoc = new XmlDocument();
                xdoc.LoadXml(resultContent);
                string html = xdoc.ChildNodes[1].InnerText;

                HtmlDocument doc = new HtmlDocument();
                doc.LoadHtml(html);

                var htmlNode = doc.DocumentNode.ChildNodes[1];
                return(GetUserMessageItem(htmlNode));
            }

            return(null);
        }