Пример #1
0
        protected virtual void CreateHeaderWebDataPageManager(XElement xe)
        {
            _headerWebDataPageManager = new WebDataPageManager <THeaderData>();

            _headerWebDataPageManager.WebLoadDataManager = new WebLoadDataManager <IEnumDataPages <THeaderData> >();
            UrlCache urlCache = UrlCache.Create(xe);

            if (urlCache != null)
            {
                urlCache.GetUrlSubDirectory = GetHeaderPageCacheUrlSubDirectory;
                _headerWebDataPageManager.WebLoadDataManager.UrlCache = urlCache;
            }

            _headerWebDataPageManager.WebLoadDataManager.InitLoadFromWeb          = InitLoadFromWeb;
            _headerWebDataPageManager.WebLoadDataManager.GetHttpRequestParameters = GetHttpRequestParameters;
            _headerWebDataPageManager.WebLoadDataManager.GetData = GetHeaderPageData;
            _headerWebDataPageManager.GetKeyFromHttpRequest      = GetHeaderKey;

            _headerWebDataPageManager.DocumentStore = MongoDocumentStore <IEnumDataPages <THeaderData> > .Create(xe);

            if (_headerWebDataPageManager.DocumentStore != null)
            {
                _headerWebDataPageManager.DocumentStore.NominalType = _headerPageNominalType;
            }

            _headerWebDataPageManager.GetHttpRequestPageFunction = GetHttpRequestPage;
        }
Пример #2
0
        private static WebDataManager_v1 <string, OnisepInstitution_Detail> CreateWebDataManager(XElement xe)
        {
            WebDataManager_v1 <string, OnisepInstitution_Detail> detailWebDataManager = new WebDataManager_v1 <string, OnisepInstitution_Detail>();

            detailWebDataManager.WebLoadDataManager = new WebLoadDataManager <OnisepInstitution_Detail>();

            UrlCache urlCache = UrlCache.Create(xe);

            if (urlCache != null)
            {
                //urlCache.GetUrlSubDirectoryFunction = httpRequest => (GetKey(httpRequest) / 1000 * 1000).ToString();
                urlCache.GetUrlSubDirectory = httpRequest => GetGroup(httpRequest);
                detailWebDataManager.WebLoadDataManager.UrlCache = urlCache;
            }

            //detailWebDataManager.WebLoadDataManager.InitLoadFromWeb = EbookdzLogin.InitLoadFromWeb;
            detailWebDataManager.WebLoadDataManager.GetHttpRequestParameters = OnisepInstitution.GetHttpRequestParameters;
            detailWebDataManager.WebLoadDataManager.GetData = GetData;
            detailWebDataManager.GetKeyFromHttpRequest      = GetKey;
            //detailWebDataManager.LoadImages = DownloadPrint.LoadImages;

            //documentStore.GetDataKey = headerPage => headerPage.GetKey();
            //documentStore.Deserialize = document => (IEnumDataPages_new<int, IHeaderData_new>)BsonSerializer.Deserialize<Handeco_HeaderPage>(document);
            detailWebDataManager.DocumentStore = MongoDocumentStore_v4 <string, OnisepInstitution_Detail> .Create(xe);

            return(detailWebDataManager);
        }
Пример #3
0
        private static Ebookdz_MainForumManager_v1 CreateMainForumManager(XElement xe)
        {
            //WebDataPageManager<int, Ebookdz_ForumPage, Ebookdz_Forum> forumWebDataPageManager = new WebDataPageManager<int, Ebookdz_ForumPage, Ebookdz_Forum>();
            Ebookdz_MainForumManager_v1 mainForumManager = new Ebookdz_MainForumManager_v1();

            mainForumManager.WebLoadDataManager = new WebLoadDataManager <Ebookdz_ForumPage_v1>();
            //
            //if (xe.zXPathValueBool("UseUrlCache", false))
            if (xe.zXPathValue("UseUrlCache").zTryParseAs(false))
            {
                UrlCache urlCache = new UrlCache(xe.zXPathValue("CacheDirectory"));
                urlCache.UrlFileNameType = zurl.GetUrlFileNameType(xe.zXPathValue("CacheUrlFileNameType"));
                //urlCache.GetUrlSubDirectoryFunction = httpRequest => (GetPostDetailKey(httpRequest) / 1000 * 1000).ToString();
                mainForumManager.WebLoadDataManager.UrlCache = urlCache;
            }
            mainForumManager.WebLoadDataManager.InitLoadFromWeb          = EbookdzLogin_v1.InitLoadFromWeb;
            mainForumManager.WebLoadDataManager.GetHttpRequestParameters = EbookdzLogin_v1.GetHttpRequestParameters;
            mainForumManager.WebLoadDataManager.GetData = GetData;
            //detailWebDataManager.GetKeyFromHttpRequest = GetPostDetailKey;
            //detailWebDataManager.LoadImages = DownloadPrint.LoadImages; // IPost

            //if (xe.zXPathValueBool("UseMongo", false))
            if (xe.zXPathValue("UseMongo").zTryParseAs(false))
            {
                MongoDocumentStore_v4 <int, Ebookdz_ForumPage_v1> documentStore = new MongoDocumentStore_v4 <int, Ebookdz_ForumPage_v1>(xe.zXPathValue("MongoServer"), xe.zXPathValue("MongoDatabase"), xe.zXPathValue("MongoCollection"), xe.zXPathValue("MongoDocumentItemName"));
                //documentStore.DefaultSort = "{ 'download.id': 1 }";
                documentStore.DefaultSort = xe.zXPathValue("MongoDefaultSort");
                //documentStore.GetDataKey = headerPage => headerPage.GetKey();
                //documentStore.Deserialize = document => (IEnumDataPages_new<int, IHeaderData_new>)BsonSerializer.Deserialize<Ebookdz_HeaderPage>(document);
                mainForumManager.DocumentStore = documentStore;
            }
            mainForumManager.GetHttpRequestPage = _GetHttpRequestPage;
            return(mainForumManager);
        }
Пример #4
0
        private static WebDataManager_v1 <int, TelechargerMagazine_PostDetail_v1> CreateWebDataManager(XElement xe)
        {
            WebDataManager_v1 <int, TelechargerMagazine_PostDetail_v1> detailWebDataManager = new WebDataManager_v1 <int, TelechargerMagazine_PostDetail_v1>();

            detailWebDataManager.WebLoadDataManager = new WebLoadDataManager <TelechargerMagazine_PostDetail_v1>();

            UrlCache urlCache = UrlCache.Create(xe);

            if (urlCache != null)
            {
                urlCache.GetUrlSubDirectoryFunction = httpRequest => (GetPostDetailKey(httpRequest) / 1000 * 1000).ToString();
                detailWebDataManager.WebLoadDataManager.UrlCache = urlCache;
            }

            //detailWebDataManager.WebLoadDataManager.InitLoadFromWeb = EbookdzLogin.InitLoadFromWeb;
            detailWebDataManager.WebLoadDataManager.GetHttpRequestParameters = TelechargerMagazine_v1.GetHttpRequestParameters;
            detailWebDataManager.WebLoadDataManager.GetData = GetData;
            detailWebDataManager.GetKeyFromHttpRequest      = GetPostDetailKey;
            detailWebDataManager.LoadImages = DownloadPrint_v1.LoadImages;

            //documentStore.GetDataKey = headerPage => headerPage.GetKey();
            //documentStore.Deserialize = document => (IEnumDataPages_new<int, IHeaderData_new>)BsonSerializer.Deserialize<Vosbooks_HeaderPage>(document);
            __detailMongoDocumentStore = MongoDocumentStore_v4 <int, TelechargerMagazine_PostDetail_v1> .Create(xe);

            detailWebDataManager.DocumentStore = __detailMongoDocumentStore;

            return(detailWebDataManager);
        }
Пример #5
0
        //private static Ebookdz_MainForumManager_v2 CreateMainForumManager(XElement xe)
        private static WebDataPageManager <IHeaderData> CreateMainForumManager(XElement xe)
        {
            //Ebookdz_MainForumManager_v2 mainForumManager = new Ebookdz_MainForumManager_v2();
            WebDataPageManager <IHeaderData> webDataPageManager = new WebDataPageManager <IHeaderData>();

            //mainForumManager.WebLoadDataManager = new WebLoadDataManager<Ebookdz_ForumPage>();
            //if (xe.zXPathValue("UseUrlCache").zTryParseAs(false))
            //{
            //    UrlCache urlCache = new UrlCache(xe.zXPathValue("CacheDirectory"));
            //    urlCache.UrlFileNameType = zurl.GetUrlFileNameType(xe.zXPathValue("CacheUrlFileNameType"));
            //    mainForumManager.WebLoadDataManager.UrlCache = urlCache;
            //}
            webDataPageManager.WebLoadDataManager                          = new WebLoadDataManager <IEnumDataPages <IHeaderData> >();
            webDataPageManager.WebLoadDataManager.UrlCache                 = UrlCache.Create(xe);
            webDataPageManager.WebLoadDataManager.InitLoadFromWeb          = EbookdzLogin_v2.InitLoadFromWeb;
            webDataPageManager.WebLoadDataManager.GetHttpRequestParameters = EbookdzLogin_v2.GetHttpRequestParameters;
            webDataPageManager.WebLoadDataManager.GetData                  = GetData;

            //if (xe.zXPathValue("UseMongo").zTryParseAs(false))
            //{
            //    MongoDocumentStore<int, Ebookdz_ForumPage> documentStore = new MongoDocumentStore<int, Ebookdz_ForumPage>(xe.zXPathValue("MongoServer"), xe.zXPathValue("MongoDatabase"), xe.zXPathValue("MongoCollection"), xe.zXPathValue("MongoDocumentItemName"));
            //    documentStore.DefaultSort = xe.zXPathValue("MongoDefaultSort");
            //    webDataPageManager.DocumentStore = documentStore;
            //}
            webDataPageManager.DocumentStore = MongoDocumentStore <IEnumDataPages <IHeaderData> > .Create(xe);

            if (webDataPageManager.DocumentStore != null)
            {
                webDataPageManager.DocumentStore.NominalType = typeof(Ebookdz_ForumPage_v2);
            }

            webDataPageManager.GetHttpRequestPageFunction = GetHttpRequestPage;
            return(webDataPageManager);
        }
Пример #6
0
        //private static WebDataManager<int, Ebookdz_PostDetail> CreateWebDataManager(XElement xe)
        private static WebDataManager <Ebookdz_PostDetail_v2> CreateWebDataManager(XElement xe)
        {
            //WebDataManager<int, Ebookdz_PostDetail> detailWebDataManager = new WebDataManager<int, Ebookdz_PostDetail>();
            WebDataManager <Ebookdz_PostDetail_v2> detailWebDataManager = new WebDataManager <Ebookdz_PostDetail_v2>();

            //detailWebDataManager.WebLoadDataManager = new WebLoadDataManager<Ebookdz_PostDetail>();
            detailWebDataManager.WebLoadDataManager = new WebLoadDataManager <Ebookdz_PostDetail_v2>();

            UrlCache urlCache = UrlCache.Create(xe);

            if (urlCache != null)
            {
                urlCache.GetUrlSubDirectoryFunction = httpRequest => (_GetPostDetailKey(httpRequest) / 1000 * 1000).ToString();
                detailWebDataManager.WebLoadDataManager.UrlCache = urlCache;
            }

            detailWebDataManager.WebLoadDataManager.InitLoadFromWeb          = EbookdzLogin_v2.InitLoadFromWeb;
            detailWebDataManager.WebLoadDataManager.GetHttpRequestParameters = EbookdzLogin_v2.GetHttpRequestParameters;
            detailWebDataManager.WebLoadDataManager.GetData = GetData;
            detailWebDataManager.GetKeyFromHttpRequest      = GetPostDetailKey;
            //detailWebDataManager.LoadImages = DownloadPrint.LoadImages; // IPost
            detailWebDataManager.LoadImages = data => { data.LoadImages(); };

            //detailWebDataManager.DocumentStore = MongoDocumentStore<int, Ebookdz_PostDetail>.Create(xe);
            detailWebDataManager.DocumentStore = MongoDocumentStore <Ebookdz_PostDetail_v2> .Create(xe);

            return(detailWebDataManager);
        }
Пример #7
0
        protected virtual void Create(XElement xe)
        {
            _webLoadDataManager = new WebLoadDataManager <IEnumDataPages <TData> >();
            UrlCache urlCache = UrlCache.Create(xe);

            if (urlCache != null)
            {
                urlCache.GetUrlSubDirectory  = GetCacheUrlSubDirectory;
                _webLoadDataManager.UrlCache = urlCache;
            }

            _webLoadDataManager.InitLoadFromWeb          = InitLoadFromWeb;
            _webLoadDataManager.GetHttpRequestParameters = GetHttpRequestParameters;
            _webLoadDataManager.GetData = GetDataPage;
            _getKeyFromHttpRequest      = GetKey;

            _documentStore = MongoDocumentStore <IEnumDataPages <TData> > .Create(xe);

            if (_documentStore != null)
            {
                _documentStore.NominalType = _dataPageNominalType;
            }

            _getHttpRequestPageFunction = GetHttpRequestPage;
        }
        //TDetailData Vosbooks_PostDetail_v2
        public WebDataManager <TDetailData> CreateDetailWebDataManager(XElement xe)
        {
            WebDataManager <TDetailData> detailWebDataManager = new WebDataManager <TDetailData>();

            detailWebDataManager.WebLoadDataManager = new WebLoadDataManager <TDetailData>();

            UrlCache urlCache = UrlCache.Create(xe);

            if (urlCache != null)
            {
                urlCache.GetUrlSubDirectoryFunction = _detailCacheGetUrlSubDirectory;
                detailWebDataManager.WebLoadDataManager.UrlCache = urlCache;
            }

            detailWebDataManager.WebLoadDataManager.InitLoadFromWeb          = _initLoadFromWeb;
            detailWebDataManager.WebLoadDataManager.GetHttpRequestParameters = _getHttpRequestParameters;
            detailWebDataManager.WebLoadDataManager.GetData = _getDetailData;
            detailWebDataManager.GetKeyFromHttpRequest      = _getDetailKeyFromHttpRequest;
            detailWebDataManager.LoadImages = _loadDetailImages;

            detailWebDataManager.DocumentStore = MongoDocumentStore <TDetailData> .Create(xe);

            _detailWebDataManager = detailWebDataManager;

            return(detailWebDataManager);
        }
Пример #9
0
        private static WebDataPageManager_v1 <int, Ebookdz_HeaderPage_v1, Ebookdz_PostHeader> CreateWebDataPageManager(XElement xe)
        {
            WebDataPageManager_v1 <int, Ebookdz_HeaderPage_v1, Ebookdz_PostHeader> headerWebDataPageManager = new WebDataPageManager_v1 <int, Ebookdz_HeaderPage_v1, Ebookdz_PostHeader>();

            headerWebDataPageManager.WebLoadDataManager = new WebLoadDataManager <Ebookdz_HeaderPage_v1>();

            //if (xe.zXPathValue("UseUrlCache").zTryParseAs(false))
            //{
            //    UrlCache urlCache = new UrlCache(xe.zXPathValue("CacheDirectory"));
            //    urlCache.UrlFileNameType = zurl.GetUrlFileNameType(xe.zXPathValue("CacheUrlFileNameType"));
            //    headerWebDataPageManager.WebLoadDataManager.UrlCache = urlCache;
            //}
            headerWebDataPageManager.WebLoadDataManager.UrlCache = UrlCache.Create(xe);

            headerWebDataPageManager.WebLoadDataManager.InitLoadFromWeb          = EbookdzLogin_v1.InitLoadFromWeb;
            headerWebDataPageManager.WebLoadDataManager.GetHttpRequestParameters = EbookdzLogin_v1.GetHttpRequestParameters;
            headerWebDataPageManager.WebLoadDataManager.GetData = GetData;
            //detailWebDataManager.GetKeyFromHttpRequest = GetPostDetailKey;
            //detailWebDataManager.LoadImages = DownloadPrint.LoadImages; // IPost

            //if (xe.zXPathValue("UseMongo").zTryParseAs(false))
            //{
            //    MongoDocumentStore<int, Ebookdz_HeaderPage> documentStore = new MongoDocumentStore<int, Ebookdz_HeaderPage>(xe.zXPathValue("MongoServer"), xe.zXPathValue("MongoDatabase"), xe.zXPathValue("MongoCollection"), xe.zXPathValue("MongoDocumentItemName"));
            //    documentStore.DefaultSort = xe.zXPathValue("MongoDefaultSort");
            //    headerWebDataPageManager.DocumentStore = documentStore;
            //}
            //documentStore.GetDataKey = headerPage => headerPage.GetKey();
            //documentStore.Deserialize = document => (IEnumDataPages_new<int, IHeaderData_new>)BsonSerializer.Deserialize<Ebookdz_HeaderPage>(document);
            headerWebDataPageManager.DocumentStore = MongoDocumentStore_v4 <int, Ebookdz_HeaderPage_v1> .Create(xe);

            headerWebDataPageManager.GetHttpRequestPage = GetHttpRequestPage;
            return(headerWebDataPageManager);
        }
Пример #10
0
        //protected bool _exportRequest = false;

        //public WebImageMongoCacheManager(string server, string database, string collectionName, string directory)
        //{
        //    _server = server;
        //    _database = database;
        //    _collectionName = collectionName;
        //    _urlCache = new UrlCache(directory);
        //    _urlCache.UrlFileNameType = UrlFileNameType.Host | UrlFileNameType.Path;
        //    _urlCache.GetUrlSubDirectoryFunction = httpRequest => zurl.GetDomain(httpRequest.Url);
        //}

        public WebImageMongoCacheManager(string server, string database, string collectionName, UrlCache urlCache)
        {
            _server         = server;
            _database       = database;
            _collectionName = collectionName;
            _urlCache       = urlCache;
        }
Пример #11
0
 protected void Create(XElement xe = null)
 {
     _urlCache = UrlCache.Create(xe);
     if (_urlCache != null)
     {
         //_urlCache.GetUrlSubDirectory = httpRequest => zurl.GetDomain(httpRequest.Url);
         _urlCache.GetUrlSubDirectory = GetUrlSubDirectory;
     }
 }
Пример #12
0
        public CDNProvider()
        {
            long cacheSize = StringUtil.ParseSizeString(Settings.GetSetting("SitecoreCDN.FileVersionCacheSize", "5MB"));

            _cache               = new UrlCache("CDNUrl", cacheSize);
            _excludeUrlCache     = new ExcludeIncludeCache("CDNExcludes", cacheSize);
            _includeUrlCache     = new ExcludeIncludeCache("CDNIncludes", cacheSize);
            _excludeRequestCache = new ExcludeIncludeCache("CDNRequestExcludes", cacheSize);
        }
Пример #13
0
 public HtmlNotInTocTransformer(string basePath, UrlCache manifestUrlCache, PdfOptions pdfOptions)
 {
     Guard.ArgumentNotNullOrEmpty(basePath, nameof(basePath));
     Guard.ArgumentNotNull(manifestUrlCache, nameof(manifestUrlCache));
     Guard.ArgumentNotNull(pdfOptions, nameof(pdfOptions));
     _basePath         = basePath;
     _manifestUrlCache = manifestUrlCache;
     _pdfOptions       = pdfOptions;
 }
Пример #14
0
        protected virtual void CreateDetailWebDataManager(XElement xe)
        {
            _detailDataManager         = new WebDataManager <TDetailData>();
            _detailDataManager.Version = xe.zXPathValue("Version").zTryParseAs(1);

            UrlCache urlCache = UrlCache.Create(xe);

            if (urlCache != null)
            {
                urlCache.GetUrlSubDirectory = GetDetailCacheUrlSubDirectory;
            }

            //if (_detailDataManager.Version <= 3)
            //{
            _detailDataManager.WebLoadDataManager                          = new WebLoadDataManager <TDetailData>();
            _detailDataManager.WebLoadDataManager.UrlCache                 = urlCache;
            _detailDataManager.WebLoadDataManager.InitLoadFromWeb          = InitLoadFromWeb;
            _detailDataManager.WebLoadDataManager.GetHttpRequestParameters = GetHttpRequestParameters;
            _detailDataManager.WebLoadDataManager.GetData                  = GetDetailData;
            //}
            //else
            //{
            //    _detailDataManager.WebLoadDataManager_v2 = new WebLoadDataManager_v2<TDetailData>();
            //    _detailDataManager.WebLoadDataManager_v2.TraceException = true;
            //    _detailDataManager.WebLoadDataManager_v2.UrlCache = urlCache;
            //    _detailDataManager.WebLoadDataManager_v2.InitLoadFromWeb = InitLoadFromWeb;
            //    _detailDataManager.WebLoadDataManager_v2.GetData = GetDetailData_v2;
            //    SetHttpRequestParameters(_detailDataManager.WebLoadDataManager_v2.RequestParameters);
            //}

            _detailDataManager.GetKeyFromHttpRequest = GetDetailKey;
            //_detailDataManager.LoadImages = LoadDetailImages;

            //if (_detailDataManager.Version < 3)
            //{
            _detailDataManager.DocumentStore = MongoDocumentStore <TDetailData> .Create(xe);

            //}
            //else
            //{
            //    _detailDataManager.DataStore = MongoDataStore.Create(xe);
            //    MongoDataSerializer<TDetailData> dataSerializer = new MongoDataSerializer<TDetailData>();
            //    dataSerializer.ItemName = xe.zXPathValue("MongoDocumentItemName");
            //    _detailDataManager.DataSerializer = dataSerializer;
            //}

            //UrlCache imageUrlCache = UrlCache.Create(xe.zXPathElement("Image"));
            //if (imageUrlCache != null)
            //{
            //    //imageUrlCache.GetUrlSubDirectory = GetDetailImageCacheUrlSubDirectory;
            //    //_detailDataManager.WebImageCacheManager = new WebImageCacheManager_v2(imageUrlCache);
            //    _detailDataManager.WebImageCacheManager = new WebImageCacheManager_v3(imageUrlCache);
            //    _detailDataManager.WebImageCacheManager.TraceException = true;
            //    _detailDataManager.GetImageSubDirectory = GetDetailImageCacheUrlSubDirectory;
            //}
        }
Пример #15
0
        public static UrlCache GetUrlCache()
        {
            UrlCache urlCache = null;

            if (__useUrlCache)
            {
                urlCache = new UrlCache(__cacheDirectory);
                urlCache.UrlFileNameType = __urlFileNameType;
            }
            return(urlCache);
        }
Пример #16
0
        private static void InitImage(XElement xe)
        {
            UrlCache urlCache = UrlCache.Create(xe);

            //if (xe.zXPathValue("UseUrlCache").zTryParseAs(false))
            if (urlCache != null)
            {
                // xe.zXPathValue("CacheDirectory")
                _imageCacheManager = new WebImageMongoCacheManager(xe.zXPathValue("MongoServer"), xe.zXPathValue("MongoDatabase"), xe.zXPathValue("MongoCollection"), urlCache);
            }
            _imageFilterMinHeight = xe.zXPathValue("ImageFilterMinHeight").zParseAs <int>();
        }
Пример #17
0
        public static UrlCache GetUrlCache()
        {
            UrlCache urlCache = null;

            if (__useUrlCache)
            {
                //urlCache = new UrlCache_new(__cacheDirectory, __urlFileNameType, (url, requestParameters) => (Ebookdz_LoadPostDetailFromWebManager.GetPostDetailKey(url) / 1000 * 1000).ToString());
                urlCache = new UrlCache(__cacheDirectory);
                urlCache.UrlFileNameType            = __urlFileNameType;
                urlCache.GetUrlSubDirectoryFunction = httpRequest => (Ebookdz_LoadPostDetailFromWebManager.GetPostDetailKey(httpRequest) / 1000 * 1000).ToString();
            }
            return(urlCache);
        }
Пример #18
0
        public static HttpManager_v5 CreateHttpManager(string cacheDirectory = null)
        {
            HttpManager_v5 httpManager = new HttpManager_v5();

            //httpManager.TraceException = true;
            if (cacheDirectory != null)
            {
                UrlCache urlCache = new UrlCache(cacheDirectory);
                urlCache.UrlFileNameType = UrlFileNameType.Host | UrlFileNameType.Path;
                urlCache.IndexedFile     = true;
                httpManager.SetCacheManager(urlCache);
            }
            return(httpManager);
        }
Пример #19
0
        private static void ClassInit(XElement xe)
        {
            bool     useUrlCache = xe.zXPathValue("UseUrlCache").zTryParseAs(false);
            UrlCache urlCache    = null;

            if (useUrlCache)
            {
                string cacheDirectory = xe.zXPathValue("CacheDirectory");
                urlCache = new UrlCache(cacheDirectory);
                urlCache.UrlFileNameType = UrlFileNameType.Path | UrlFileNameType.Query;
                //urlCache.GetUrlSubDirectoryFunction = httpRequest => (Ebookdz_LoadPostDetailFromWebManager.GetPostDetailKey(httpRequest) / 1000 * 1000).ToString();
            }
            __currentLoadForumFromWebManager = new Ebookdz_LoadForumFromWebManager(urlCache);
        }
Пример #20
0
        private static WebDataPageManager_v1 <int, TelechargerMagazine_HeaderPage_v1, TelechargerMagazine_PostHeader_v1> CreateWebDataPageManager(XElement xe)
        {
            WebDataPageManager_v1 <int, TelechargerMagazine_HeaderPage_v1, TelechargerMagazine_PostHeader_v1> headerWebDataPageManager = new WebDataPageManager_v1 <int, TelechargerMagazine_HeaderPage_v1, TelechargerMagazine_PostHeader_v1>();

            headerWebDataPageManager.WebLoadDataManager          = new WebLoadDataManager <TelechargerMagazine_HeaderPage_v1>();
            headerWebDataPageManager.WebLoadDataManager.UrlCache = UrlCache.Create(xe);

            //headerWebDataPageManager.WebLoadDataManager.InitLoadFromWeb = EbookdzLogin.InitLoadFromWeb;
            headerWebDataPageManager.WebLoadDataManager.GetHttpRequestParameters = TelechargerMagazine_v1.GetHttpRequestParameters;
            headerWebDataPageManager.WebLoadDataManager.GetData = GetData;
            headerWebDataPageManager.DocumentStore = MongoDocumentStore_v4 <int, TelechargerMagazine_HeaderPage_v1> .Create(xe);

            headerWebDataPageManager.GetHttpRequestPage = GetHttpRequestPage;
            return(headerWebDataPageManager);
        }
Пример #21
0
        public static HttpManager_v2 CreateHttpManager(string cacheDirectory = null)
        {
            //string directory = @"";
            HttpManager_v2 httpManager = new HttpManager_v2();

            if (cacheDirectory != null)
            {
                UrlCache urlCache = new UrlCache(cacheDirectory);
                urlCache.UrlFileNameType = UrlFileNameType.Host | UrlFileNameType.Path;
                urlCache.IndexedFile     = false;
                urlCache.SaveRequest     = true;
                httpManager.UrlCache     = urlCache;
            }
            return(httpManager);
        }
Пример #22
0
        public static OcrWebService CreateOcrWebService()
        {
            XmlConfig     config        = new XmlConfig(_configFile);
            OcrWebService ocrWebService = new OcrWebService(config.GetExplicit("UserName"), config.GetExplicit("LicenseCode"));

            //ocrWebService.UserName = config.GetExplicit("UserName");
            //ocrWebService.LicenseCode = config.GetExplicit("LicenseCode");
            if (_cacheDirectory != null)
            {
                UrlCache urlCache = new UrlCache(_cacheDirectory);
                urlCache.UrlFileNameType = UrlFileNameType.Host | UrlFileNameType.Path;
                urlCache.IndexedFile     = true;
                ocrWebService.HttpManager.SetCacheManager(urlCache);
            }
            return(ocrWebService);
        }
Пример #23
0
        private static WebDataPageManager_v1 <int, Handeco_HeaderPage, Handeco_Header> CreateWebDataPageManager(XElement xe)
        {
            WebDataPageManager_v1 <int, Handeco_HeaderPage, Handeco_Header> headerWebDataPageManager = new WebDataPageManager_v1 <int, Handeco_HeaderPage, Handeco_Header>();

            headerWebDataPageManager.WebLoadDataManager = new WebLoadDataManager <Handeco_HeaderPage>();

            headerWebDataPageManager.WebLoadDataManager.UrlCache = UrlCache.Create(xe);

            //headerWebDataPageManager.WebLoadDataManager.InitLoadFromWeb = EbookdzLogin.InitLoadFromWeb;
            headerWebDataPageManager.WebLoadDataManager.GetHttpRequestParameters = Handeco.GetHttpRequestParameters;
            headerWebDataPageManager.WebLoadDataManager.GetData = GetData;

            headerWebDataPageManager.DocumentStore = MongoDocumentStore_v4 <int, Handeco_HeaderPage> .Create(xe);

            headerWebDataPageManager.GetHttpRequestPage = GetHttpRequestPage;
            return(headerWebDataPageManager);
        }
        protected virtual void CreateHeaderWebDataPageManager(XElement xe)
        {
            _headerDataPageManager = new WebDataPageManager_v4 <THeaderData>();

            UrlCache urlCache = UrlCache.Create(xe);

            if (urlCache != null)
            {
                urlCache.GetUrlSubDirectory = GetHeaderPageCacheUrlSubDirectory;
            }
            //Trace.WriteLine($"WebHeaderDetailMongoManagerBase_v2<THeaderData, TDetailData>.CreateHeaderWebDataPageManager() : {(urlCache != null ? "urlCache created" : "no urlCache")}");

            _headerDataPageManager.WebLoadDataManager = new WebLoadDataManager_v2 <IEnumDataPages <THeaderData> >();
            _headerDataPageManager.WebLoadDataManager.TraceException  = true;
            _headerDataPageManager.WebLoadDataManager.UrlCache        = urlCache;
            _headerDataPageManager.WebLoadDataManager.InitLoadFromWeb = InitLoadFromWeb;
            _headerDataPageManager.WebLoadDataManager.GetData         = GetHeaderPageData;
            //_headerDataPageManager.WebLoadDataManager.GetHttpRequestParameters = GetHttpRequestParameters;
            SetHttpRequestParameters(_headerDataPageManager.WebLoadDataManager.RequestParameters);
            _headerDataPageManager.GetKeyFromHttpRequest = GetHeaderKey;

            //_headerDataPageManager.DocumentStore = MongoDocumentStore<IEnumDataPages<THeaderData>>.Create(xe);
            //if (_headerDataPageManager.DocumentStore != null)
            //    _headerDataPageManager.DocumentStore.NominalType = _headerPageNominalType;

            _headerDataPageManager.DataStore = MongoDataStore.Create(xe);
            MongoDataSerializer <IEnumDataPages <THeaderData> > dataSerializer = new MongoDataSerializer <IEnumDataPages <THeaderData> >();

            dataSerializer.ItemName               = xe.zXPathValue("MongoDocumentItemName");
            dataSerializer.NominalType            = _headerPageNominalType;
            _headerDataPageManager.DataSerializer = dataSerializer;

            UrlCache imageUrlCache = UrlCache.Create(xe.zXPathElement("Image"));

            _headerDataPageManager.WebLoadImageManager = new WebLoadImageManager_v2 <IEnumDataPages <THeaderData> >();
            if (imageUrlCache != null)
            {
                _headerDataPageManager.WebLoadImageManager.WebImageCacheManager = new WebImageCacheManager_v3(imageUrlCache);
                _headerDataPageManager.WebLoadImageManager.WebImageCacheManager.TraceException = true;
                //_headerDataPageManager.WebLoadImageManager.GetImageSubDirectory = GetHeaderImageCacheUrlSubDirectory;
                _headerDataPageManager.GetImageSubDirectory = GetHeaderImageCacheUrlSubDirectory;
            }

            _headerDataPageManager.GetHttpRequestPageFunction = GetHttpRequestPage;
        }
Пример #25
0
        private static WebDataPageManager <int, MagazinesGratuits_HeaderPage_v1, MagazinesGratuits_PostHeader_v1> CreateWebDataPageManager(XElement xe)
        {
            WebDataPageManager <int, MagazinesGratuits_HeaderPage_v1, MagazinesGratuits_PostHeader_v1> headerWebDataPageManager = new WebDataPageManager <int, MagazinesGratuits_HeaderPage_v1, MagazinesGratuits_PostHeader_v1>();

            headerWebDataPageManager.WebLoadDataManager          = new WebLoadDataManager <MagazinesGratuits_HeaderPage_v1>();
            headerWebDataPageManager.WebLoadDataManager.UrlCache = UrlCache.Create(xe);

            //headerWebDataPageManager.WebLoadDataManager.InitLoadFromWeb = EbookdzLogin.InitLoadFromWeb;
            headerWebDataPageManager.WebLoadDataManager.GetHttpRequestParameters = MagazinesGratuits.GetHttpRequestParameters;
            headerWebDataPageManager.WebLoadDataManager.GetData = GetData;
            //detailWebDataManager.GetKeyFromHttpRequest = GetPostDetailKey;
            //detailWebDataManager.LoadImages = DownloadPrint.LoadImages; // IPost

            headerWebDataPageManager.DocumentStore = MongoDocumentStore <int, MagazinesGratuits_HeaderPage_v1> .Create(xe);

            headerWebDataPageManager.GetHttpRequestPage = GetHttpRequestPage;
            return(headerWebDataPageManager);
        }
Пример #26
0
        public static WebImageMongoCacheManager Create(XElement xe = null)
        {
            //if (xe != null && xe.zXPathValue("UseUrlCache").zTryParseAs(false))
            //    return new WebImageMongoCacheManager(xe.zXPathValue("MongoServer"), xe.zXPathValue("MongoDatabase"), xe.zXPathValue("MongoCollection"), xe.zXPathValue("CacheDirectory"));
            //else
            //    return null;
            UrlCache urlCache = UrlCache.Create(xe);

            if (urlCache != null)
            {
                urlCache.GetUrlSubDirectory = httpRequest => zurl.GetDomain(httpRequest.Url);
                return(new WebImageMongoCacheManager(xe.zXPathExplicitValue("MongoServer"), xe.zXPathExplicitValue("MongoDatabase"), xe.zXPathExplicitValue("MongoCollection"), urlCache));
            }
            else
            {
                return(null);
            }
        }
Пример #27
0
        private static WebDataManager <MagazinesGratuits_PostDetail_v2> CreateWebDataManager(XElement xe)
        {
            WebDataManager <MagazinesGratuits_PostDetail_v2> detailWebDataManager = new WebDataManager <MagazinesGratuits_PostDetail_v2>();

            detailWebDataManager.WebLoadDataManager = new WebLoadDataManager <MagazinesGratuits_PostDetail_v2>();

            //if (xe.zXPathValue("UseUrlCache").zTryParseAs(false))
            //{
            //    UrlCache urlCache = new UrlCache(xe.zXPathValue("CacheDirectory"));
            //    urlCache.UrlFileNameType = zurl.GetUrlFileNameType(xe.zXPathValue("CacheUrlFileNameType"));
            //    urlCache.GetUrlSubDirectoryFunction = httpRequest => (GetPostDetailKey(httpRequest) / 1000 * 1000).ToString();
            //    detailWebDataManager.WebLoadDataManager.UrlCache = urlCache;
            //}
            UrlCache urlCache = UrlCache.Create(xe);

            if (urlCache != null)
            {
                urlCache.GetUrlSubDirectoryFunction = GetSubDirectoryKey;
                detailWebDataManager.WebLoadDataManager.UrlCache = urlCache;
            }

            //detailWebDataManager.WebLoadDataManager.InitLoadFromWeb = EbookdzLogin.InitLoadFromWeb;
            detailWebDataManager.WebLoadDataManager.GetHttpRequestParameters = MagazinesGratuits_v2.GetHttpRequestParameters;
            detailWebDataManager.WebLoadDataManager.GetData = GetData;
            detailWebDataManager.GetKeyFromHttpRequest      = GetPostDetailKey;
            //detailWebDataManager.LoadImages = DownloadPrint.LoadImages;
            detailWebDataManager.LoadImages = data => { data.LoadImages(); };

            //if (xe.zXPathValue("UseMongo").zTryParseAs(false))
            //{
            //    MongoDocumentStore<int, Vosbooks_PostDetail> documentStore = new MongoDocumentStore<int, Vosbooks_PostDetail>(xe.zXPathValue("MongoServer"), xe.zXPathValue("MongoDatabase"), xe.zXPathValue("MongoCollection"), xe.zXPathValue("MongoDocumentItemName"));
            //    documentStore.DefaultSort = xe.zXPathValue("MongoDefaultSort");
            //    detailWebDataManager.DocumentStore = documentStore;
            //}

            //documentStore.GetDataKey = headerPage => headerPage.GetKey();
            //documentStore.Deserialize = document => (IEnumDataPages_new<int, IHeaderData_new>)BsonSerializer.Deserialize<Vosbooks_HeaderPage>(document);
            //detailWebDataManager.DocumentStore = MongoDocumentStore<int, Vosbooks_PostDetail>.Create(xe);
            detailWebDataManager.DocumentStore = MongoDocumentStore <MagazinesGratuits_PostDetail_v2> .Create(xe);

            return(detailWebDataManager);
        }
Пример #28
0
        //private static string GetScanZone(QuestionsParameters parameters, string imageFile)
        //{
        //    // format: "top:left:height:width,...", example "zone=0:0:100:100,50:50:50:50"
        //    if (parameters.PageColumn == 1)
        //        return null;
        //    else if (parameters.PageColumn == 2)
        //    {
        //        int width;
        //        int height;
        //        zimg.GetImageWidthHeight(imageFile, out width, out height);
        //        string zone;
        //        switch (parameters.PageRotate)
        //        {
        //            case PageRotate.NoRotate:
        //            case PageRotate.Rotate180:
        //                int width2 = width / 2;
        //                zone = $"0:0:{width2}:{height},{width2}:0:{width - width2}:{height}";
        //                break;
        //            case PageRotate.Rotate90:
        //            case PageRotate.Rotate270:
        //                int height2 = height / 2;
        //                zone = $"0:0:{width}:{height2},0:{height2}:{width}:{height - height2}";
        //                break;
        //            default:
        //                throw new PBException($"unknow page rotation {parameters.PageRotate}");
        //        }
        //        return zone;
        //    }
        //    else
        //        throw new PBException($"can't create scan zone for {parameters.PageColumn} columns");
        //}

        //private OcrRequest CreateOcrRequest()
        //{
        //    return new OcrRequest { Language = "french,english", OutputFormat = "txt" };
        //}

        //private OcrWebService CreateOcrWebService()
        //{
        //    XmlConfig config = XmlConfig.CurrentConfig;
        //    XmlConfig ocrWebServiceConfig = config.GetConfig("OcrWebServiceConfig");
        //    OcrWebService ocrWebService = new OcrWebService(ocrWebServiceConfig.GetExplicit("UserName"), ocrWebServiceConfig.GetExplicit("LicenseCode"), _timeout);
        //    //ocrWebService.UserName = ocrWebServiceConfig.GetExplicit("UserName");
        //    //ocrWebService.LicenseCode = ocrWebServiceConfig.GetExplicit("LicenseCode");
        //    string cacheDirectory = config.Get("OcrWebServiceCacheDirectory");
        //    if (cacheDirectory != null)
        //    {
        //        UrlCache urlCache = new UrlCache(cacheDirectory);
        //        urlCache.UrlFileNameType = UrlFileNameType.Host | UrlFileNameType.Path;
        //        if (config.Get("OcrWebServiceCacheDirectory/@option")?.ToLower() == "indexedfile")
        //            urlCache.IndexedFile = true;
        //        ocrWebService.HttpManager.SetCacheManager(urlCache);
        //    }
        //    return ocrWebService;
        //}

        private ScanManager CreateScanManager()
        {
            XmlConfig config = XmlConfig.CurrentConfig;
            XmlConfig ocrWebServiceConfig = config.GetConfig("OcrWebServiceConfig");
            UrlCache  urlCache            = null;
            string    cacheDirectory      = config.Get("OcrWebServiceCacheDirectory");

            if (cacheDirectory != null)
            {
                urlCache = new UrlCache(cacheDirectory);
                urlCache.UrlFileNameType = UrlFileNameType.Host | UrlFileNameType.Path;
                if (config.Get("OcrWebServiceCacheDirectory/@option")?.ToLower() == "indexedfile")
                {
                    urlCache.IndexedFile = true;
                }
            }
            ScanManager scanManager = new ScanManager(ocrWebServiceConfig.GetExplicit("UserName"), ocrWebServiceConfig.GetExplicit("LicenseCode"), urlCache);

            scanManager.Language     = "french,english";
            scanManager.OutputFormat = "txt";
            return(scanManager);
        }
Пример #29
0
        protected virtual void CreateDetailWebDataManager(XElement xe)
        {
            _detailWebDataManager = new WebDataManager <TDetailData>();

            _detailWebDataManager.WebLoadDataManager = new WebLoadDataManager <TDetailData>();

            UrlCache urlCache = UrlCache.Create(xe);

            if (urlCache != null)
            {
                urlCache.GetUrlSubDirectoryFunction = GetDetailCacheUrlSubDirectory;
                _detailWebDataManager.WebLoadDataManager.UrlCache = urlCache;
            }

            _detailWebDataManager.WebLoadDataManager.InitLoadFromWeb          = InitLoadFromWeb;
            _detailWebDataManager.WebLoadDataManager.GetHttpRequestParameters = GetHttpRequestParameters;
            _detailWebDataManager.WebLoadDataManager.GetData = GetDetailData;
            _detailWebDataManager.GetKeyFromHttpRequest      = GetDetailKey;
            _detailWebDataManager.LoadImages = LoadDetailImages;

            _detailWebDataManager.DocumentStore = MongoDocumentStore <TDetailData> .Create(xe);
        }
        protected virtual void CreateDetailWebDataManager(XElement xe, IEnumerable <NamedGetData <TDetailData> > namedGetDatas)
        {
            _detailDataManager = new WebDataManager_v5 <THeaderData, TDetailData>();

            UrlCache urlCache = UrlCache.Create(xe);

            if (urlCache != null)
            {
                urlCache.GetUrlSubDirectory = GetDetailCacheUrlSubDirectory;
            }

            _detailDataManager.HttpManager = new HttpManager_v2();
            _detailDataManager.HttpManager.TraceException  = true;
            _detailDataManager.HttpManager.UrlCache        = urlCache;
            _detailDataManager.HttpManager.InitLoadFromWeb = InitLoadFromWeb;
            //_detailDataManager.WebLoadDataManager.GetData = GetDetailData;
            _detailDataManager.CreateData = CreateDetailData;
            _detailDataManager.AddNamedGetDatas(namedGetDatas);
            SetHttpRequestParameters(_detailDataManager.HttpManager.RequestParameters);

            //_detailDataManager.GetKeyFromHttpRequest = GetDetailKey;

            _detailDataManager.Store = MongoDataStore.Create(xe);
            MongoDataSerializer <TDetailData> dataSerializer = new MongoDataSerializer <TDetailData>();

            dataSerializer.ItemName           = xe.zXPathValue("MongoDocumentItemName");
            _detailDataManager.DataSerializer = dataSerializer;

            UrlCache imageUrlCache = UrlCache.Create(xe.zXPathElement("Image"));

            _detailDataManager.WebLoadImageManager = new WebLoadImageManager_v2 <TDetailData>();
            if (imageUrlCache != null)
            {
                _detailDataManager.WebLoadImageManager.WebImageCacheManager = new WebImageCacheManager_v3(imageUrlCache);
                _detailDataManager.WebLoadImageManager.WebImageCacheManager.TraceException = true;
                _detailDataManager.GetImageSubDirectory = GetDetailImageCacheUrlSubDirectory;
            }
        }