void GetInternal()
        {
            var client = new WebLib.NetClient();
            var task   = client.Create <XmlDocument>(HttpMethod.Get, "https://blog.iccfish.com/feed/", "").Send();

            if (task == null || !task.IsSuccess || task.Result == null)
            {
                Success = false;
            }
            else
            {
                Success      = true;
                SystemNotice = new List <SystemNotice>();
                var nodes = task.Result.SelectNodes("//item");
                foreach (var node in nodes.Cast <XmlNode>())
                {
                    var no = new SystemNotice(node.SelectSingleNode("title").InnerText.Trim(),
                                              node.SelectSingleNode("link").InnerText.Trim(),
                                              node.SelectSingleNode("pubDate").InnerText.Trim().ToDateTimeNullable() ?? DateTime.Now,
                                              false,
                                              node.SelectSingleNode("description").InnerText.Trim()
                                              );
                    SystemNotice.Add(no);
                }
            }

            _operation.PostOperationCompleted(_ => OnDownloadComplete(), null);
        }
Ejemplo n.º 2
0
        void GetInternal()
        {
            var client = new WebLib.NetClient();
            //var task = client.Create<string>(HttpMethod.Get, "http://www.12306.cn/mormhweb/tlxw_tip.html").SendAsync();
            var task = client.Create <string>(HttpMethod.Get, "https://www.12306.cn/mormhweb/zxdt/index_zxdt.html").Send();

            if (task == null || !task.IsSuccess)
            {
                Success = false;
            }
            else
            {
                Success = true;
                var baseUri = new Uri("https://www.12306.cn/mormhweb/zxdt/");
                SystemNotice = System.Text.RegularExpressions.Regex.Matches(GetNewListHtml(task.Result), @"(class='red'>)?<a.*?href=['""](.*?)['""].*?title=['""](.*?)['""].*?\((\d{4}-\d{2}-\d{2})\)", RegexOptions.IgnoreCase | RegexOptions.Singleline)
                               .Cast <Match>().Where(s => s.Success).Select(s => new Entity.Web.SystemNotice(s.Groups[3].Value, new Uri(baseUri, s.Groups[2].Value).ToString(), DateTime.Parse(s.Groups[4].Value), !s.Groups[1].Value.IsNullOrEmpty())).ToList();
            }

            _operation.PostOperationCompleted(_ => OnDownloadComplete(), null);
        }
Ejemplo n.º 3
0
        public async Task <List <Entity.Web.SystemNotice> > LoadAsync()
        {
            var client = new WebLib.NetClient();
            var task   = client.Create <string>(HttpMethod.Get, "https://forum.iccfish.com/forum.php?mod=rss" + (Fid > 0 ? "&fid=" + Fid : ""), "");
            var result = await task.SendAsync();

            if (!task.IsValid())
            {
                return(null);
            }

            var ret = new List <SystemNotice>();

            await Task.Factory.StartNew(() =>
            {
                var doc = new XmlDocument();
                doc.LoadXml(result);

                var nodes = doc.SelectNodes("//item");
                foreach (var node in nodes.Cast <XmlNode>())
                {
                    var categoryName = node.SelectSingleNode("category").InnerText.Trim();

                    var no = new SystemNotice(node.SelectSingleNode("title").InnerText.Trim(),
                                              node.SelectSingleNode("link").InnerText.Trim(),
                                              node.SelectSingleNode("pubDate").InnerText.Trim().ToDateTimeNullable() ?? DateTime.Now,
                                              categoryName.IndexOf("新闻") > -1 || categoryName.IndexOf("公告") > -1,
                                              "作者:" + node.SelectSingleNode("author").InnerText.Trim() + "\n\n" +
                                              node.SelectSingleNode("description").InnerText.Trim()
                                              );
                    ret.Add(no);
                }
            });

            return(ret);
        }