Exemple #1
0
        public static int SheifTopic(ref string errText, ref List<TCG.ResourcesService.Resources> topics, TCG.SheifService.SheifSourceInfo sourceinfo, string topicurl)
        {
            topics = new List<TCG.ResourcesService.Resources>();

            TCG.ResourcesService.Resources topicinfo = new TCG.ResourcesService.Resources();
            int rtn = SheifHandlers.SheifTopic(ref errText, ref topicinfo, sourceinfo, topicurl);
            if (rtn < 0)
            {
                return -1;
            }

            topics.Add(topicinfo);

            //分页文章
            //string tempurl = Regex.Replace(topicurl, sourceinfo.TopicPagerOld, sourceinfo.TopicPagerTemp, RegexOptions.Singleline);

            //for (int i = 0; i < 20; i++)
            //{
            //    string tempurlex = string.Format(tempurl, i);

            //    TCG.ResourcesService.Resources topicinfo1 = new TCG.ResourcesService.Resources();

            //    int rtn1 = SheifHandlers.SheifTopic(ref errText, ref topicinfo1, sourceinfo, tempurlex);

            //    if (topicinfo.vcContent != topicinfo1.vcContent && !string.IsNullOrEmpty(topicinfo1.vcContent))
            //    {
            //        topics.Add(topicinfo1);
            //    }
            //}

            return 1;
        }
        private void btDebugTopicInfo_Click(object sender, EventArgs e)
        {
            this.SheifSourceInfoInit();
            if (this.thdrTestRes.Rows.Count == 0) return;

            DataGridViewRow row = this.thdrTestRes.Rows[0];
            TCG.ResourcesService.Resources topic = new TCG.ResourcesService.Resources();

            string errText = string.Empty;
            string Url = topics[0].SheifUrl;

            int rtn = SheifHandlers.SheifTopic(ref errText, ref topic, this.sheifourceinfo, Url);
            if (rtn < 0)
            {
                return;
            }

            this.sr_title.Text = topic.vcTitle;
            this.sr_content.DocumentText = topic.vcContent;
        }
Exemple #3
0
        public static int SheifTopicList(ref string errText, ref List<TCG.ResourcesService.Resources> topics, TCG.SheifService.SheifSourceInfo sheifourceinfo,
            int startpage, int endpage)
        {
            topics = new List<TCG.ResourcesService.Resources>();
            if (string.IsNullOrEmpty(sheifourceinfo.CharSet))
            {
                sheifourceinfo.CharSet = "gb2312";
            }

            if (startpage > endpage)
            {
                return -1;
            }

            for (int i = startpage; i < endpage + 1; i++)
            {
                string ListPageHtml = HttpWebHandlers.GetHtml(string.Format(sheifourceinfo.SourceUrl, i.ToString()), Encoding.GetEncoding(sheifourceinfo.CharSet)).Replace("\r\n","").Replace("\n","").Replace("\t","");

                if (sheifourceinfo.IsRss)
                {
                    XmlDocument document = null;
                    try
                    {
                        document = new XmlDocument();
                        document.LoadXml(ListPageHtml);
                    }
                    catch { }

                    if (document != null)
                    {
                        XmlNodeList mylist = document.GetElementsByTagName("item");
                        if (mylist != null)
                        {
                            foreach (XmlElement node in mylist)
                            {
                                TCG.ResourcesService.Resources res = new TCG.ResourcesService.Resources();
                                res.vcTitle = node.SelectSingleNode("title").InnerText;
                                res.SheifUrl = node.SelectSingleNode("link").InnerText;
                                res.dAddDate = objectHandlers.ToTime(node.SelectSingleNode("pubDate").InnerText);
                                topics.Add(res);

                            }
                        }
                    }
                }
                else
                {
                    Match item = Regex.Match(ListPageHtml, sheifourceinfo.ListAreaRole, RegexOptions.IgnoreCase | RegexOptions.Multiline);
                    if (item.Success)
                    {
                        MatchCollection matchs = Regex.Matches(item.Value, sheifourceinfo.TopicListRole, RegexOptions.IgnoreCase | RegexOptions.Multiline);
                        if (matchs.Count > 0)
                        {
                            foreach (Match m in matchs)
                            {
                                TCG.ResourcesService.Resources res1 = new TCG.ResourcesService.Resources();

                                int rtn = SheifTopicDataInt(ref errText, ref res1, m, sheifourceinfo.TopicListDataRole);
                                if (!string.IsNullOrEmpty(res1.SheifUrl))
                                {
                                    res1.SheifUrl = UrlCheck(res1.SheifUrl, sheifourceinfo);
                                    topics.Add(res1);
                                }
                            }
                        }
                        else
                        {
                            return -2;
                        }
                    }
                    else
                    {
                        return -1;
                    }
                }

            }
            return 1;
        }
Exemple #4
0
        private void SheifRes(TCG.SheifService.SheifSourceInfo sourc, TCG.SheifConfig.SheifCategorieConfig scc)
        {
            string errText = string.Empty;
            List<TCG.ResourcesService.Resources> res = new List<TCG.ResourcesService.Resources>();
            int rtn = SheifHandlers.SheifTopicList(ref errText, ref res, sourc, 1, 1);
            if (res != null && res.Count > 0)
            {
                for (int i = 0; i < res.Count; i++)
                {
                    Thread.Sleep(7000);
                    TCG.ResourcesService.Resources resinfo = new TCG.ResourcesService.Resources();
                    resinfo.SheifUrl = res[i].SheifUrl;
                    resinfo.cChecked = "N";
                    resinfo.cCreated = "N";
                    resinfo.vcAuthor = "网络";
                    resinfo.vcEditor = "三云鬼";

                    TCG.ResourcesService.Categories cate = new TCG.ResourcesService.Categories();
                    cate.Id = scc.LocalCategorieId;
                    resinfo.Categorie = cate;
                    rtn = SheifHandlers.SheifTopic(ref errText, ref resinfo, sourc, res[i].SheifUrl);

                    if (!string.IsNullOrEmpty(resinfo.vcTitle))
                    {
                        resinfo.vcKeyWord = resinfo.vcTitle;
                        resinfo.vcShortContent = objectHandlers.Left(objectHandlers.NoHTML(resinfo.vcContent), 200);
                        resinfo.vcContent = objectHandlers.NoDiv(resinfo.vcContent);

                        rtn = resourcesService.CreateResources(resinfo);
                        if (rtn == 1)
                        {
                            this.Invoke((MethodInvoker)delegate
                            {
                                this.dataGridView1.Rows.Add(resinfo.vcTitle, resinfo.SheifUrl, resinfo.dAddDate.ToString());
                            });

                            if (this.WindowState == FormWindowState.Minimized)
                            {
                                string text3 = "成功抓取:" + resinfo.vcTitle + "\r\n" + resinfo.SheifUrl;
                                this.notifyIcon1.ShowBalloonTip(200, "资源抓取通知", text3, ToolTipIcon.Error);
                            }
                        }
                    }

                }
            }
        }
Exemple #5
0
 /// <remarks/>
 public void CreateResourcesAsync(Resources inf) {
     this.CreateResourcesAsync(inf, null);
 }
Exemple #6
0
 public int CreateResources(Resources inf) {
     object[] results = this.Invoke("CreateResources", new object[] {
                 inf});
     return ((int)(results[0]));
 }
Exemple #7
0
 /// <remarks/>
 public void CreateResourcesAsync(Resources inf, object userState) {
     if ((this.CreateResourcesOperationCompleted == null)) {
         this.CreateResourcesOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreateResourcesOperationCompleted);
     }
     this.InvokeAsync("CreateResources", new object[] {
                 inf}, this.CreateResourcesOperationCompleted, userState);
 }