Exemplo n.º 1
0
        public static void ClassInit(XElement xe)
        {
            //__useUrlCache = xe.zXPathValueBool("UseUrlCache", false);
            __useUrlCache    = xe.zXPathValue("UseUrlCache").zTryParseAs(false);
            __cacheDirectory = xe.zXPathValue("CacheDirectory");

            //__useMongo = xe.zXPathValueBool("UseMongo", __useMongo);
            __useMongo              = xe.zXPathValue("UseMongo").zTryParseAs(__useMongo);
            __mongoServer           = xe.zXPathValue("MongoServer", __mongoServer);
            __mongoDatabase         = xe.zXPathValue("MongoDatabase");
            __mongoCollectionName   = xe.zXPathValue("MongoCollection");
            __mongoDocumentItemName = xe.zXPathValue("MongoDocumentItemName");

            //IDocumentStore_new<int, GoldenDdl_HeaderPage> documentStore = null;
            IDocumentStore_v3 <int, IEnumDataPages_v1 <int, IHeaderData_v1> > documentStore = null;

            if (__useMongo)
            {
                //documentStore = new MongoDocumentStore_new<int, GoldenDdl_HeaderPage>(__mongoServer, __mongoDatabase, __mongoCollectionName, __mongoDocumentItemName);
                MongoDocumentStore_v3 <int, IEnumDataPages_v1 <int, IHeaderData_v1> > mongoDocumentStore = new MongoDocumentStore_v3 <int, IEnumDataPages_v1 <int, IHeaderData_v1> >(__mongoServer, __mongoDatabase, __mongoCollectionName, __mongoDocumentItemName);
                mongoDocumentStore.DefaultSort = "{ 'download.id': 1 }";
                //mongoDocumentStore.GetDataKey = headerPage => headerPage.id;
                mongoDocumentStore.GetDataKey  = headerPage => headerPage.GetKey();
                mongoDocumentStore.Deserialize = document => (IEnumDataPages_v1 <int, IHeaderData_v1>)BsonSerializer.Deserialize <GoldenDdl_HeaderPage>(document);
                documentStore = mongoDocumentStore;
            }

            //__currentLoadHeaderPagesManager = new GoldenDdl_LoadHeaderPagesManager(new GoldenDdl_LoadHeaderPageFromWebManager(GetUrlCache()), documentStore);
            __currentLoadHeaderPagesManager = new GoldenDdl_LoadHeaderPagesManager(new GoldenDdl_LoadHeaderPageFromWebManager(GetUrlCache()), documentStore);
        }
Exemplo n.º 2
0
        //protected override GoldenDdl_HeaderPage GetDataFromWeb(LoadDataFromWeb loadDataFromWeb)
        protected override IEnumDataPages_v1 <int, IHeaderData_v1> GetDataFromWeb(LoadDataFromWeb_v3 loadDataFromWeb)
        {
            XXElement            xeSource = new XXElement(loadDataFromWeb.GetXmlDocument().Root);
            string               url      = loadDataFromWeb.request.Url;
            GoldenDdl_HeaderPage data     = new GoldenDdl_HeaderPage();

            data.sourceUrl       = url;
            data.loadFromWebDate = loadDataFromWeb.loadFromWebDate;
            data.id = GoldenDdl_LoadHeaderPagesManager.GetHeaderPageKey(url);

            data.urlNextPage = zurl.GetUrl(url, xeSource.XPathValue("//div[@class='basenavi']//span[@class='nnext']//a/@href"));
            IEnumerable <XXElement>     xeHeaders = xeSource.XPathElements("//div[@id='dle-content']//div[@class='base']");
            List <GoldenDdl_PostHeader> headers   = new List <GoldenDdl_PostHeader>();

            foreach (XXElement xeHeader in xeHeaders)
            {
                GoldenDdl_PostHeader header = new GoldenDdl_PostHeader();
                header.sourceUrl       = url;
                header.loadFromWebDate = loadDataFromWeb.loadFromWebDate;

                header.urlDetail = xeHeader.XPathValue(".//div[@class='bheading']//a/@href");

                //header.images = xeHeader.XPathImages(xeImg => new UrlImage(zurl.GetUrl(url, xeImg.zAttribValue("src")))).ToList();

                //XXElement xe = xeHeader.XPathElement(".//*[@class='shd']//a");
                //header.urlDetail = zurl.GetUrl(url, xe.XPathValue("@href"));
                //header.title = RapideDdl.ExtractTextValues(header.infos, xe.XPathValue(".//text()", RapideDdl.TrimFunc1));

                //xe = xeHeader.XPathElement(".//div[@class='shdinfo']");
                //header.postAuthor = xe.XPathValue(".//span[@class='arg']//a//text()");
                //// Aujourd'hui, 17:13
                //header.creationDate = RapideDdl.ParseDateTime(xe.XPathValue(".//span[@class='date']//text()"), loadDataFromWeb.loadFromWebDate);

                //xe = xeHeader.XPathElement(".//div[@class='maincont']");
                //header.images = xe.XPathImages(xeImg => new UrlImage(zurl.GetUrl(url, xeImg.zAttribValue("src")))).ToList();

                //RapideDdl.SetTextValues(header, xe.DescendantTextList());

                //xe = xeHeader.XPathElement(".//div[@class='morelink']//span[@class='arg']");
                //header.category = xe.DescendantTextList(".//a").Select(RapideDdl.TrimFunc1).Where(s => !s.StartsWith("Commentaires")).zToStringValues("/");

                headers.Add(header);
            }
            data.postHeaders = headers.ToArray();
            return((IEnumDataPages_v1 <int, IHeaderData_v1>)data);
        }