示例#1
0
        public T Load(RequestFromWeb_v3 request)
        {
            LoadDataFromWeb_v3 loadDataFromWeb = new LoadDataFromWeb_v3 {
                request = request
            };

            DateTime loadFromWebDate;

            string url = request.Url;

            if (_urlCache != null)
            {
                string urlPath = _urlCache.GetUrlPath(url, request.RequestParameters);
                if (request.ReloadFromWeb || !zFile.Exists(urlPath))
                {
                    if (_firstLoadFromWeb && url.StartsWith("http://"))
                    {
                        InitLoadFromWeb();
                        _firstLoadFromWeb = false;
                    }
                    //if (!Http2.LoadToFile(url, urlPath, request.RequestParameters))
                    //    return default(T);
                    if (!Http_v3.LoadToFile(url, urlPath, request.RequestParameters))
                    {
                        return(default(T));
                    }
                }
                url = urlPath;
                // get last write time as loadFromWebDate, dont take creation time because creation time is modified when copying the file
                //loadFromWebDate = new FileInfo(urlPath).LastWriteTime;
                loadFromWebDate = zFile.CreateFileInfo(urlPath).LastWriteTime;
            }
            else
            {
                loadFromWebDate = DateTime.Now;
            }
            if (_firstLoadFromWeb && url.StartsWith("http://"))
            {
                InitLoadFromWeb();
                _firstLoadFromWeb = false;
            }
            //if (!Http2.LoadUrl(url, request.RequestParameters))
            //    return default(T);
            if (!Http_v3.LoadUrl(url, request.RequestParameters))
            {
                return(default(T));
            }
            loadDataFromWeb.loadResult      = true;
            loadDataFromWeb.loadFromWebDate = loadFromWebDate;
            return(GetDataFromWeb(loadDataFromWeb));
        }
示例#2
0
 public RequestWebData_v4(RequestFromWeb_v3 webRequest, TKey key = default(TKey), bool refreshDocumentStore = false)
     : base(webRequest.Url, webRequest.RequestParameters, webRequest.ReloadFromWeb, webRequest.LoadImage)
 {
     _key = key;
     _refreshDocumentStore = refreshDocumentStore;
 }
示例#3
0
 public RequestWebData_v3(RequestFromWeb_v3 webRequest, object key = null, bool refreshDocumentStore = false)
     : base(webRequest.Url, webRequest.RequestParameters, webRequest.ReloadFromWeb, webRequest.LoadImage)
 {
     _key = key;
     _refreshDocumentStore = refreshDocumentStore;
 }