Exemple #1
0
        private void originalResponse(RequestPacket packet)
        {
            MyLog.Log(this, nameof(originalResponse) + packet.Url + "...");
            var data = packet.DataInString;

            HtmlAgilityPack.HtmlDocument doc = null;

            if (!string.IsNullOrEmpty(data))
            {
                MyLog.Log(this, "Loading HTML data" + "...");
                doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(data);
                MyLog.Log(this, "Loading HTML data" + "...Done");
            }

            var currentWebsite = Config.GetWebsite(packet.WebsiteKey);

            var overviewType = packet.OverviewType;

            if (overviewType == OverviewType.Null)
            {
                //Artical
                Artical artical = null;
                MyLog.Log(this, "Reading artical" + "...");
                if (doc != null)
                {
                    artical = currentWebsite.ReadArtical(packet.Tag as ArticalOverview, doc);
                }
                else
                {
                    artical = currentWebsite.ReadArticalExtrnal(packet.Tag as ArticalOverview, packet.ExtrnalLink);
                }
                MyLog.Log(this, "Reading artical" + "...Done");

                MyLog.Log(this, "Making callback on artical" + "...");

                packet.AnalisisModuleResponseUiArtical
                .ArticalProcessedCallback
                    (packet.Uid, packet.Url, artical);
                MyLog.Log(this, "Making callback on artical" + "...Done");
            }
            else
            {
                string nextPage = string.Empty;

                switch (overviewType)
                {
                case OverviewType.Null:
                    break;

                case OverviewType.UNKNOWN:
                    break;

                case OverviewType.IndexPage:
                    MyLog.Log(this, "Reading index page data" + "...");
                    var iData = currentWebsite.ReadIndexPage(packet.Url, doc, out nextPage);
                    MyLog.Log(this, "Reading index page data" + "...Done");

                    MyLog.Log(this, "Making index page callback" + "...");
                    packet.AnalisisModuleResponseUiArticalOverview
                    .ArticalOverviewProcessedCallback
                        (packet.Uid, packet.Url, iData, overviewType, nextPage);
                    MyLog.Log(this, "Making index page callback" + "...Done");
                    break;

                case OverviewType.Author:
                    MyLog.Log(this, "Reading author page data" + "...");
                    var aData = currentWebsite.ReadAuthor(packet.Tag as Author, doc, out nextPage);
                    MyLog.Log(this, "Reading author page data" + "...Done");
                    MyLog.Log(this, "Making author page callback" + "...");
                    packet.AnalisisModuleResponseUiArticalOverview
                    .ArticalOverviewProcessedCallback
                        (packet.Uid, packet.Url, aData, overviewType, nextPage);
                    MyLog.Log(this, "Making author page callback" + "...Done");
                    break;

                case OverviewType.Category:
                    MyLog.Log(this, "Reading category page data" + "...");
                    var cData = currentWebsite.ReadCategory(packet.Tag as Category, doc, out nextPage);
                    MyLog.Log(this, "Reading category page data" + "...Done");
                    MyLog.Log(this, "Making category page callback" + "...");
                    packet.AnalisisModuleResponseUiArticalOverview
                    .ArticalOverviewProcessedCallback
                        (packet.Uid, packet.Url, cData, overviewType, nextPage);
                    MyLog.Log(this, "Making category page callback" + "...Done");
                    break;

                default:
                    break;
                }
                if (nextPage != null && nextPage != string.Empty)
                {
                    //TODO: Think how to hold the next page info
                }
            }
            MyLog.Log(this, nameof(originalResponse) + packet.Url + "...Done");
        }
Exemple #2
0
 public void RequestProcessingError(RequestPacket requestPacket)
 {
     throw new NotImplementedException();
 }
Exemple #3
0
 public void RequestProcessedCallback(RequestPacket requestPacket)
 {
     pendingResponse.Enqueue(requestPacket);
 }
Exemple #4
0
 public void CancleRequest(RequestPacket requestPacket)
 {
     cancleRequest.Enqueue(requestPacket);
 }