Ejemplo n.º 1
0
        public LoadDataFromWeb_v4 Load(RequestFromWeb_v4 webRequest)
        {
            LoadDataFromWeb_v4 loadDataFromWeb = new LoadDataFromWeb_v4 {
                WebRequest = webRequest
            };

            DateTime loadFromWebDate;

            HttpRequest httpRequest = webRequest.HttpRequest;

            if (_urlCache != null)
            {
                string urlPath = _urlCache.GetUrlPath(httpRequest);
                if (webRequest.ReloadFromWeb || !zFile.Exists(urlPath))
                {
                    if (_firstLoadFromWeb && httpRequest.Url.StartsWith("http://"))
                    {
                        InitLoadFromWeb();
                        _firstLoadFromWeb = false;
                    }
                    //if (!HttpManager.CurrentHttpManager.LoadToFile(httpRequest, urlPath, GetHttpRequestParameters()))
                    //    return default(T);
                    if (!HttpManager.CurrentHttpManager.LoadToFile(httpRequest, urlPath, _exportRequest, GetHttpRequestParameters()))
                    {
                        return(loadDataFromWeb);
                    }
                }
                httpRequest = new HttpRequest {
                    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 && httpRequest.Url.StartsWith("http://"))
            {
                InitLoadFromWeb();
                _firstLoadFromWeb = false;
            }
            loadDataFromWeb.Http = HttpManager.CurrentHttpManager.Load(httpRequest, GetHttpRequestParameters());
            //if (loadDataFromWeb.Http == null)
            //    return default(T);
            if (loadDataFromWeb.Http != null)
            {
                loadDataFromWeb.LoadResult      = true;
                loadDataFromWeb.LoadFromWebDate = loadFromWebDate;
            }
            return(loadDataFromWeb);
        }
Ejemplo n.º 2
0
        public T LoadData(RequestFromWeb_v4 webRequest)
        {
            LoadDataFromWeb_v4 loadDataFromWeb = Load(webRequest);

            if (loadDataFromWeb.LoadResult)
            {
                return(_getData(loadDataFromWeb));
            }
            else
            {
                return(default(T));
            }
        }
Ejemplo n.º 3
0
 public RequestWebData_v6(RequestFromWeb_v4 request, bool refreshDocumentStore = false)
     : base(request.HttpRequest, request.ReloadFromWeb, request.LoadImage)
 {
     _refreshDocumentStore = refreshDocumentStore;
 }
Ejemplo n.º 4
0
 public RequestWebData_v5(RequestFromWeb_v4 request, TKey key = default(TKey), bool refreshDocumentStore = false)
     : base(request.HttpRequest, request.ReloadFromWeb, request.LoadImage)
 {
     _key = key;
     _refreshDocumentStore = refreshDocumentStore;
 }