Ejemplo n.º 1
0
        protected bool LoadImageFromWeb(WebImage webImage, WebImageRequest imageRequest, HttpRequestParameters requestParameters = null, string subDirectory = null)
        {
            if (!imageRequest.LoadImageFromWeb || (webImage.File != null && !imageRequest.RefreshImage))
                return false;
            HttpRequest httpRequest = new HttpRequest { Url = webImage.Url };
            string file = _urlCache.GetUrlSubPath(httpRequest);
            if (subDirectory != null)
                file = zPath.Combine(subDirectory, file);
            string path = zPath.Combine(_urlCache.CacheDirectory, file);
            if (imageRequest.RefreshImage || !zFile.Exists(path))
                HttpManager.CurrentHttpManager.LoadToFile(httpRequest, path, _urlCache.SaveRequest, requestParameters);
            webImage.File = file;

            if (zFile.Exists(path))
            {
                Image image = LoadImageFromFile(path);
                if (image != null)
                {
                    webImage.Width = image.Width;
                    webImage.Height = image.Height;
                    if (imageRequest.LoadImageToData)
                        webImage.Image = image;
                }
            }
            return true;
        }
Ejemplo n.º 2
0
 public ImageCache(WebImageCacheManager webImageCacheManager, string url, HttpRequestParameters requestParameters = null, bool refreshImage = false)
 {
     _webImageCacheManager = webImageCacheManager;
     _url = url;
     _requestParameters = requestParameters;
     _refreshImage = refreshImage;
 }
Ejemplo n.º 3
0
        public override string[] UnprotectLink(string protectLink)
        {
            string key = GetKey();

            //HttpRequestParameters requestParameters = new HttpRequestParameters();
            //requestParameters.accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
            //requestParameters.headers.Add("Accept-Language", "de, en-gb;q=0.9, en;q=0.8");
            //Http2.LoadUrl(protectLink, requestParameters);

            HttpRequestParameters requestParameters = new HttpRequestParameters();
            requestParameters.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
            requestParameters.Headers.Add("Accept-Language", "de, en-gb;q=0.9, en;q=0.8");
            HttpManager.CurrentHttpManager.Load(new HttpRequest { Url = protectLink }, requestParameters);

            //string content = "action=qaptcha&qaptcha_key=Wb6aEMQQ_xxQRMgkYX-XuWsdUyGHrQpZ";
            string content = "action=qaptcha&qaptcha_key=" + key;
            requestParameters.Accept = "application/json, text/javascript, */*; q=0.01";
            requestParameters.Headers.Add("X-Requested-With", "XMLHttpRequest");
            requestParameters.ContentType = "application/x-www-form-urlencoded";
            HttpManager.CurrentHttpManager.Load(new HttpRequest { Url = __urlFormulaire, Method = HttpRequestMethod.Post, Referer = protectLink, Content = content }, requestParameters);

            //content = "Wb6aEMQQ_xxQRMgkYX-XuWsdUyGHrQpZ=&submit_captcha=VALIDER";
            content = key + "=&submit_captcha=VALIDER";
            requestParameters.Accept = "text/html, application/xhtml+xml, */*";
            requestParameters.Headers.Add("X-Requested-With", "XMLHttpRequest");
            requestParameters.ContentType = "application/x-www-form-urlencoded";
            Http http = HttpManager.CurrentHttpManager.Load(new HttpRequest { Url = protectLink, Method = HttpRequestMethod.Post, Referer = __urlFormulaire, Content = content }, requestParameters);

            //XXElement xeSource = new XXElement(Http2.HtmlReader.XDocument.Root);
            //XXElement xeSource = webResult.Http.zGetXDocument().zXXElement();
            XXElement xeSource = http.zGetXDocument().zXXElement();
            return xeSource.XPathValues(".//div[@class='all_liens']//a/@href").ToArray();
        }
Ejemplo n.º 4
0
 public override Image LoadImage(string url, HttpRequestParameters requestParameters = null, bool refreshImage = false)
 {
     MongoImage mongoImage = LoadMongoImage(url, requestParameters, refreshImage);
     if (mongoImage.Image == null)
         LoadImage(mongoImage);
     return mongoImage.Image;
 }
Ejemplo n.º 5
0
 public static Http Load(HttpRequest httpRequest, HttpRequestParameters requestParameters = null, string exportFile = null, bool setExportFileExtension = false)
 {
     RazSource();
     __xmlDocumentSourceType = XmlDocumentSourceType.Http;
     //__http = __httpManager.Load(httpRequest, requestParameters);
     __http = HttpManager.CurrentHttpManager.Load(httpRequest, requestParameters, exportFile, setExportFileExtension);
     return __http;
 }
Ejemplo n.º 6
0
 public Http(HttpRequest httpRequest, HttpRequestParameters requestParameters = null)
 {
     _httpRequest = httpRequest;
     if (requestParameters != null)
         _requestParameters = requestParameters;
     else
         _requestParameters = new HttpRequestParameters();
     _progress = new Progress();
 }
Ejemplo n.º 7
0
        private Http _Load(HttpRequest httpRequest, HttpRequestParameters requestParameters = null, string exportFile = null, bool setExportFileExtension = false)
        {
            Trace.WriteLine(1, "Load \"{0}\" ({1}){2}", httpRequest.Url, httpRequest.Method, exportFile != null ? "(\"" + exportFile + "\")" : null);
            Http http = CreateHttp(httpRequest, requestParameters, exportFile, setExportFileExtension);

            http.LoadAsText();

            return http;
        }
Ejemplo n.º 8
0
 public virtual bool LoadImagesFromWeb(IEnumerable<WebImage> images, WebImageRequest imageRequest, HttpRequestParameters requestParameters = null, string subDirectory = null)
 {
     if (!imageRequest.LoadImageFromWeb && !imageRequest.RefreshImage)
         return false;
     bool ret = false;
     foreach (WebImage image in images)
     {
         if (LoadImageFromWeb(image, imageRequest, requestParameters, subDirectory))
             ret = true;
     }
     return ret;
 }
Ejemplo n.º 9
0
        public Http Load(HttpRequest httpRequest, HttpRequestParameters requestParameters = null, string exportFile = null, bool setExportFileExtension = false)
        {
            try
            {
                for (int i = 0; i < _loadRepeatIfError - 1; i++)
                {
                    try
                    {
                        return _Load(httpRequest, requestParameters, exportFile, setExportFileExtension);
                    }
                    catch (Exception ex)
                    {
                        if (ex is WebException)
                        {
                            WebException wex = (WebException)ex;
                            // WebExceptionStatus : ConnectFailure, PipelineFailure, ProtocolError, ReceiveFailure, SendFailure, ServerProtocolViolation, Timeout, UnknownError
                            // $$pb modif le 27/01/2015 WebExceptionStatus.NameResolutionFailure  ex : "The remote name could not be resolved: 'pixhost.me'"
                            if (wex.Status == WebExceptionStatus.ProtocolError || wex.Status == WebExceptionStatus.NameResolutionFailure)
                                throw;
                        }
                        if (ex is ProtocolViolationException)
                            throw;
                        Trace.WriteLine(1, "Error : \"{0}\" ({1})", ex.Message, ex.GetType().ToString());
                    }
                }
                return _Load(httpRequest, requestParameters, exportFile, setExportFileExtension);
            }
            catch (Exception ex)
            {
                //Load("http://www.frboard.com/magazines-et-journaux/441873-multi-les-journaux-mardi-13-aout-2013-pdf-lien-direct.html");
                //15/08/2013 12:00:32 Error : A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 5.199.168.178:80 (System.Net.Sockets.SocketException)
                //Unable to connect to the remote server (System.Net.WebException)
                //----------------------
                //   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
                //   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
                //----------------------
                //   at System.Net.HttpWebRequest.GetResponse()
                //   at pb.old.Http.OpenWebRequest() in c:\pib\dropbox\pbeuz\Dropbox\dev\project\Source\Source_01\Source\PB_Tools\\Http_Html.cs:line 911
                //   at pb.old.Http.Open() in c:\pib\dropbox\pbeuz\Dropbox\dev\project\Source\Source_01\Source\PB_Tools\\Http_Html.cs:line 780
                //   at pb.old.Http.Load() in c:\pib\dropbox\pbeuz\Dropbox\dev\project\Source\Source_01\Source\PB_Tools\\Http_Html.cs:line 503
                //   at pb.old.HtmlXmlReader.Load(String sUrl) in c:\pib\dropbox\pbeuz\Dropbox\dev\project\Source\Source_01\Source\PB_Tools\\HtmlXmlReader.cs:line 426
                //   at Print.download.w.Test_frboard_02()
                //   at Print.download.w.Run()

                if (_traceException)
                    Trace.CurrentTrace.WriteError(ex);
                else
                    throw;
                return null;
            }
        }
Ejemplo n.º 10
0
 public MongoImage LoadMongoImage(string url, HttpRequestParameters requestParameters = null, bool refreshImage = false)
 {
     if (!refreshImage)
     {
         BsonDocument document = GetCollection().zFindOneById<BsonDocument>(BsonValue.Create(url));
         if (document != null)
         {
             //return BsonSerializer.Deserialize<MongoImage>(document);
             MongoImage mongoImage = BsonSerializer.Deserialize<MongoImage>(document);
             if (mongoImage.Width != 0 && mongoImage.Height != 0)
                 return mongoImage;
         }
     }
     return CreateMongoImage(url, requestParameters);
 }
Ejemplo n.º 11
0
 public override Image LoadImage(string url, HttpRequestParameters requestParameters = null, bool refreshImage = false)
 {
     HttpRequest httpRequest = new HttpRequest { Url = url };
     string file = _urlCache.GetUrlSubPath(httpRequest);
     string urlPath = zPath.Combine(_urlCache.CacheDirectory, file);
     if (refreshImage || !zFile.Exists(urlPath))
     {
         if (!HttpManager.CurrentHttpManager.LoadToFile(httpRequest, urlPath, _urlCache.SaveRequest, requestParameters))
         {
             urlPath = null;
             file = null;
         }
     }
     if (urlPath != null)
         return zimg.LoadBitmapFromFile(urlPath);
     return null;
 }
Ejemplo n.º 12
0
 private Image _LoadImage(HttpRequest httpRequest, HttpRequestParameters requestParameters = null)
 {
     Trace.WriteLine(1, "LoadImage(\"{0}\");", httpRequest.Url);
     if (httpRequest.Url.StartsWith("http://"))
     {
         return CreateHttp(httpRequest, requestParameters).LoadImage();
     }
     else
     {
         try
         {
             return zimg.LoadBitmapFromFile(httpRequest.Url);
         }
         catch (Exception ex)
         {
             pb.Trace.WriteLine("Error : \"{0}\" ({1})", ex.Message, ex.GetType().ToString());
             return null;
         }
     }
 }
Ejemplo n.º 13
0
 public Image LoadImage(HttpRequest httpRequest, HttpRequestParameters requestParameters = null)
 {
     try
     {
         for (int i = 0; i < _loadRepeatIfError - 1; i++)
         {
             try
             {
                 return _LoadImage(httpRequest, requestParameters);
             }
             catch (Exception ex)
             {
                 if (!ex.GetType().FullName.StartsWith("System.Net."))
                     throw;
                 if (ex is WebException)
                 {
                     WebException wex = (WebException)ex;
                     // WebExceptionStatus : ConnectFailure, PipelineFailure, ProtocolError, ReceiveFailure, SendFailure, ServerProtocolViolation, Timeout, UnknownError
                     // $$pb modif le 27/01/2015 WebExceptionStatus.NameResolutionFailure  ex : "The remote name could not be resolved: 'pixhost.me'"
                     if (wex.Status == WebExceptionStatus.ProtocolError || wex.Status == WebExceptionStatus.NameResolutionFailure)
                         throw;
                 }
                 Trace.WriteLine(1, "Error : \"{0}\" ({1})", ex.Message, ex.GetType().ToString());
             }
         }
         return _LoadImage(httpRequest, requestParameters);
     }
     catch (Exception ex)
     {
         Trace.WriteLine("Error : \"{0}\" ({1})", ex.Message, ex.GetType().ToString());
         return null;
     }
 }
Ejemplo n.º 14
0
        private bool _LoadToFile(HttpRequest httpRequest, string file, bool exportRequest = false, HttpRequestParameters requestParameters = null)
        {
            Trace.WriteLine(1, "LoadToFile(\"{0}\", \"{1}\");", httpRequest.Url, file);
            Http http = CreateHttp(httpRequest, requestParameters);

            return http.LoadToFile(file, exportRequest);
        }
Ejemplo n.º 15
0
 public static Image LoadImage(string url, HttpRequestParameters requestParameters = null)
 {
     return HttpManager.CurrentHttpManager.LoadImage(new HttpRequest { Url = url }, requestParameters);
 }
Ejemplo n.º 16
0
        public static Http Login(XXElement xeSource)
        {
            XmlConfig localConfig = new XmlConfig(XmlConfig.CurrentConfig.GetExplicit("LocalConfig"));
            string login = localConfig.GetExplicit("DownloadAutomateManager/Ebookdz/Login");
            string hashPassword = Crypt.ComputeMD5Hash(localConfig.GetExplicit("DownloadAutomateManager/Ebookdz/Password")).zToHex(lowercase: true);

            // <base href="http://www.ebookdz.com/forum/" />
            string urlBase = xeSource.XPathValue("//head//base/@href");
            //string urlBase = xeSource.XPathValue("//body//base/@href");
            //Trace.WriteLine("urlBase : \"{0}\"", urlBase);
            XXElement xeForm = xeSource.XPathElement("//form[@id='navbar_loginform']");
            if (xeForm.XElement == null)
            {
                //Trace.WriteLine("element not found \"//form[@id='navbar_loginform']\"");
                throw new PBException("element form not found \"//form[@id='navbar_loginform']\"");
            }
            //Trace.WriteLine("form action : \"{0}\"", xeForm.XPathValue("@action"));
            string urlForm = zurl.GetUrl(urlBase, xeForm.XPathValue("@action"));
            string method = xeForm.XPathValue("@method");
            //Trace.WriteLine("urlForm : \"{0}\" method {1}", urlForm, method);
            StringBuilder sb = new StringBuilder();
            bool first = true;
            foreach (XXElement xeInput in xeForm.XPathElements(".//input"))
            {
                string name = xeInput.XPathValue("@name");
                if (name == null)
                    continue;
                string value = null;
                if (name == "vb_login_username")
                    value = login;
                else if (name == "vb_login_password")
                    value = null;
                else if (name == "vb_login_md5password" || name == "vb_login_md5password_utf")
                    value = hashPassword;
                else
                    value = xeInput.XPathValue("@value");
                if (!first)
                    sb.Append("&");
                sb.AppendFormat("{0}={1}", name, value);
                first = false;
            }
            string content = sb.ToString();
            //Trace.WriteLine("content : \"{0}\"", content);

            HttpRequest httpRequest = new HttpRequest { Url = urlForm, Content = content, Method = Http.GetHttpRequestMethod(method) };
            HttpRequestParameters httpRequestParameters = new HttpRequestParameters();
            Http http = HttpManager.CurrentHttpManager.Load(httpRequest, httpRequestParameters);
            //xeSource = new XXElement(http.zGetXmlDocument().Root);
            //if (!IsLoggedIn(xeSource))
            //    throw new PBException("unable login to http://www.ebookdz.com/");
            return http;
        }
Ejemplo n.º 17
0
 public DebridLinkFr()
 {
     TraceDataRegistry.CurrentTraceDataRegistry.Register("DebridLinkFr_v2", this);
     _requestParameters = new HttpRequestParameters { Encoding = Encoding.UTF8 };
     _authenticateRequestParameters = new HttpRequestParameters { Encoding = Encoding.UTF8 };
 }
Ejemplo n.º 18
0
 public static bool LoadToFile(string url, string file, bool exportRequest = false, HttpRequestParameters requestParameters = null)
 {
     return HttpManager.CurrentHttpManager.LoadToFile(new HttpRequest { Url = url }, file, exportRequest, requestParameters);
 }
Ejemplo n.º 19
0
        public static void Test_DebridLink_01()
        {
            //HttpRun.Load("https://api.debrid-link.fr/rest/token/1R6858wC6lO15X8i/new");
            string urlBase = "https://api.debrid-link.fr/rest/";
            //string login = RunSource.CurrentRunSource.Config.GetConfig("LocalConfig").GetExplicit("DownloadAutomateManager/DebridLink/Login");
            string login = XmlConfig.CurrentConfig.GetConfig("LocalConfig").GetExplicit("DownloadAutomateManager/DebridLink/Login");
            string password = XmlConfig.CurrentConfig.GetConfig("LocalConfig").GetExplicit("DownloadAutomateManager/DebridLink/Password");
            //string publickey = "1R6858wC6lO15X8i";
            string publickey = XmlConfig.CurrentConfig.GetConfig("LocalConfig").GetExplicit("DownloadAutomateManager/DebridLink/PublicKey");
            //string sessidTime = "all";
            string sessidTime = XmlConfig.CurrentConfig.GetConfig("LocalConfig").GetExplicit("DownloadAutomateManager/DebridLink/SessidTime");
            string url = urlBase + string.Format("token/{0}/new", publickey);
            HttpRequestParameters requestParameters = new HttpRequestParameters { Encoding = Encoding.UTF8 };
            Http http = HttpManager.CurrentHttpManager.Load(new HttpRequest { Url = url }, requestParameters);
            DateTime dt = DateTime.Now;
            http.ResultText.zTraceJson();
            BsonDocument doc = BsonSerializer.Deserialize<BsonDocument>(http.ResultText);
            string token = doc.zGet("value.token").zAsString();
            string validTokenUrl = doc.zGet("value.validTokenUrl").zAsString();
            string key = doc.zGet("value.key").zAsString();
            int ts = doc.zGet("ts").zAsInt();
            Trace.WriteLine("request time   : \"{0:dd/MM/yyyy HH:mm:ss}\"", dt);
            Trace.WriteLine("result         : \"{0}\"", doc.zGet("result").zAsString());
            Trace.WriteLine("token          : \"{0}\"", token);
            Trace.WriteLine("validTokenUrl  : \"{0}\"", validTokenUrl);
            Trace.WriteLine("key            : \"{0}\"", key);
            Trace.WriteLine("ts             : \"{0}\"", ts);
            Trace.WriteLine("ts             : \"{0:dd/MM/yyyy HH:mm:ss}\"", zdate.UnixTimeStampToDateTime(ts));
            Trace.WriteLine("ts             : \"{0}\"", zdate.UnixTimeStampToDateTime(ts) - dt);

            // validTokenUrl : "https://secure.debrid-link.fr/user/2_2d481d8991e4db60f43d24d9d387b75699db7a0157182967/login"
            http = HttpManager.CurrentHttpManager.Load(new HttpRequest { Url = validTokenUrl }, requestParameters);

            // <script>if (window!=window.top) { top.location.href='https://secure.debrid-link.fr/login'; }</script>
            // <form action='' method='POST' class='form-horizontal'>
            // <input type='text' class='form-control' name='user'>
            // <input type='password' class='form-control' name='password'>
            // <input type='hidden' value='10_a3a206c4398f195283a4843d44f017f3211275e443747173' name='token'>
            // <input type='submit' style='display:none'>
            // <button type='submit' name='authorizedToken' value='1' class='btn btn-dl'>Envoyer</button>

            XXElement xeSource = http.zGetXDocument().zXXElement();

            // script : if (window!=window.top) { top.location.href='https://secure.debrid-link.fr/login'; }
            string script = xeSource.XPathValue("//head//script//text()");
            if (script == null)
            {
                Trace.WriteLine("//head//script not found");
                return;
            }
            Trace.WriteLine("script : \"{0}\"", script);
            Regex rg = new Regex("top\\.location\\.href=[\"'](.*)[\"']", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
            Match match = rg.Match(script);
            if (!match.Success)
            {
                Trace.WriteLine("top.location.href='...' not found in script");
                return;
            }
            url = match.Groups[1].Value;
            Trace.WriteLine("login url : \"{0}\"", url);

            XXElement xeForm = xeSource.XPathElement("//form");
            string action = xeForm.AttribValue("action");
            Trace.WriteLine("form action : \"{0}\"", action);
            if (action != null && action != "")
                url = action;
            HttpRequestMethod method = Http.GetHttpRequestMethod(xeForm.AttribValue("method"));
            Trace.WriteLine("form method : {0}", method);

            //XmlConfig localConfig = new XmlConfig(RunSource.CurrentRunSource.Config.GetExplicit("LocalConfig"));
            //string login = localConfig.GetExplicit("DownloadAutomateManager/DebridLink/Login");
            //string password = localConfig.GetExplicit("DownloadAutomateManager/DebridLink/Password");
            StringBuilder content = new StringBuilder();
            bool first = true;
            string name, value;
            //foreach (XXElement xe in xeForm.XPathElements(".//input"))
            foreach (XXElement xe in xeForm.DescendantFormItems())
            {
                name = xe.AttribValue("name");
                if (name == null)
                    continue;
                if (name == "user")
                    value = login;
                else if (name == "password")
                    value = password;
                else if (name == "sessidTime")
                    value = sessidTime;
                else
                    value = xe.AttribValue("value");
                if (!first)
                    content.Append('&');
                content.AppendFormat("{0}={1}", name, value);
                Trace.WriteLine("{0}={1}", name, value);
                first = false;
            }
            //XXElement xeButton = xeForm.XPathElement(".//button");
            //name = xeButton.AttribValue("name");
            //value = xeButton.AttribValue("value");
            //if (name != null && value != null)
            //{
            //    content.AppendFormat("&{0}={1}", name, value);
            //    Trace.WriteLine("{0}={1}", name, value);
            //}

            // "user=la_beuze&password=xxxxxx&sessidTime=all&token=10_56b51ee12ad5dabcac620230cda436cab94bd37154742765&authorizedToken=1"
            //  user=la_beuze&password=pbeuz0&sessidTime=all&token=10_3205776c76bb0479b1d57e9bf834b38ae2c5d10669848384&authorizedToken=1
            Trace.WriteLine("content : \"{0}\"", content.ToString());
            http = HttpManager.CurrentHttpManager.Load(new HttpRequest { Url = url, Method = method, Content = content.ToString() }, requestParameters);

            // <div class='panel-body'>
            // <div class='alert alert-success'>
            // La session a bien été activée. Vous pouvez utiliser l'application API Test
            // </div>
            // </div>
            xeSource = http.zGetXDocument().zXXElement();
            string loginMessage = xeSource.XPathValue("//div[@class='panel-body']//text()").Trim();
            Trace.WriteLine("login message : \"{0}\"", loginMessage);
        }
Ejemplo n.º 20
0
 public abstract Image LoadImage(string url, HttpRequestParameters requestParameters = null, bool refreshImage = false);
Ejemplo n.º 21
0
        protected MongoImage CreateMongoImage(string url, HttpRequestParameters requestParameters = null)
        {
            HttpRequest httpRequest = new HttpRequest { Url = url };
            string file = _urlCache.GetUrlSubPath(httpRequest);
            string path = zPath.Combine(_urlCache.CacheDirectory, file);
            if (!zFile.Exists(path))
                HttpManager.CurrentHttpManager.LoadToFile(httpRequest, path, _urlCache.SaveRequest, requestParameters);
            Image image = null;
            if (zFile.Exists(path))
            {
                try
                {
                    image = zimg.LoadBitmapFromFile(path);
                }
                catch (Exception exception)
                {
                    Trace.WriteLine("error unable to load image url \"{0}\" to \"{1}\" (WebImageMongoCacheManager.CreateMongoImage())", url, path);
                    Trace.Write("error : ");
                    Trace.WriteLine(exception.Message);
                }
            }
            else
            {
                Trace.WriteLine("error unable to load image url \"{0}\" to \"{1}\" (WebImageMongoCacheManager.CreateMongoImage())", url, path);
            }

            MongoImage mongoImage = new MongoImage();
            mongoImage.Url = url;
            mongoImage.File = file;
            mongoImage.Width = image != null ? image.Width : 0;
            mongoImage.Height = image != null ? image.Height : 0;
            mongoImage.Image = image;

            GetCollection().zUpdate(new QueryDocument { { "_id", BsonValue.Create(url) } }, new UpdateDocument { { "$set", mongoImage.ToBsonDocument() } }, UpdateFlags.Upsert);

            return mongoImage;
        }
Ejemplo n.º 22
0
 public virtual ImageCache GetImageCache(string url, HttpRequestParameters requestParameters = null, bool refreshImage = false)
 {
     return new ImageCache(this, url, requestParameters, refreshImage);
 }
Ejemplo n.º 23
0
 public override ImageCache GetImageCache(string url, HttpRequestParameters requestParameters = null, bool refreshImage = false)
 {
     return new ImageMongoCache(this, url, requestParameters);
 }
Ejemplo n.º 24
0
 public ImageMongoCache(WebImageCacheManager imageUrlCacheManager, string url, HttpRequestParameters requestParameters = null, bool refreshImage = false)
     : base(imageUrlCacheManager, url, requestParameters, refreshImage)
 {
 }
Ejemplo n.º 25
0
 public Http CreateHttp(HttpRequest httpRequest, HttpRequestParameters requestParameters = null, string exportFile = null, bool setExportFileExtension = false)
 {
     Http http = new Http(httpRequest, requestParameters);
     //http.HttpRetry += new Http.fnHttpRetry(LoadRetryEvent);
     http.LoadRetryTimeout = _loadRetryTimeout;
     if (exportFile != null)
     {
         http.ExportFile = exportFile;
         http.SetExportFileExtension = setExportFileExtension;
     }
     else if (_exportResult && _exportDirectory != null)
     {
         http.ExportFile = GetNewHttpFileName(httpRequest);
         http.SetExportFileExtension = true;
     }
     return http;
 }
Ejemplo n.º 26
0
 public static Http LoadAsText(HttpRequest httpRequest, HttpRequestParameters requestParameters = null, string exportFile = null, bool setExportFileExtension = false)
 {
     Http http = new Http(httpRequest, requestParameters);
     http.ExportFile = exportFile;
     http.SetExportFileExtension = setExportFileExtension;
     http.LoadAsText();
     return http;
 }
Ejemplo n.º 27
0
 public static bool LoadToFile(HttpRequest httpRequest, string file, bool exportRequest = false, HttpRequestParameters requestParameters = null)
 {
     return HttpManager.CurrentHttpManager.LoadToFile(httpRequest, file, exportRequest, requestParameters);
 }
Ejemplo n.º 28
0
 public static Image LoadImage(HttpRequest httpRequest, HttpRequestParameters requestParameters = null)
 {
     return HttpManager.CurrentHttpManager.LoadImage(httpRequest, requestParameters);
 }
Ejemplo n.º 29
0
 public bool LoadToFile(HttpRequest httpRequest, string file, bool exportRequest = false, HttpRequestParameters requestParameters = null)
 {
     try
     {
         for (int i = 0; i < _loadRepeatIfError - 1; i++)
         {
             try
             {
                 return _LoadToFile(httpRequest, file, exportRequest, requestParameters);
             }
             catch (Exception ex)
             {
                 if (ex is WebException)
                 {
                     WebException wex = (WebException)ex;
                     // WebExceptionStatus : ConnectFailure, PipelineFailure, ProtocolError, ReceiveFailure, SendFailure, ServerProtocolViolation, Timeout, UnknownError
                     // $$pb modif le 27/01/2015 WebExceptionStatus.NameResolutionFailure  ex : "The remote name could not be resolved: 'pixhost.me'"
                     if (wex.Status == WebExceptionStatus.ProtocolError || wex.Status == WebExceptionStatus.NameResolutionFailure)
                         throw;
                 }
                 Trace.WriteLine(1, "Error : \"{0}\" ({1})", ex.Message, ex.GetType().ToString());
             }
         }
         return _LoadToFile(httpRequest, file, exportRequest, requestParameters);
     }
     catch (Exception ex)
     {
         if (_traceException)
             Trace.WriteLine("Error : \"{0}\" ({1})", ex.Message, ex.GetType().ToString());
         else
             throw;
         return false;
     }
 }
Ejemplo n.º 30
0
 // bool cacheFile = false
 public HttpBase(HttpRequest httpRequest, HttpRequestParameters requestParameters = null)
 {
     _httpRequest = httpRequest;
     if (requestParameters != null)
         _requestParameters = requestParameters;
     else
         _requestParameters = new HttpRequestParameters();
     //_cacheFile = cacheFile;
     //_progress = new Progress();
 }