public override string GetVideoUrl(VideoInfo video)
        {
            System.Net.WebProxy proxyObj = null; // new System.Net.WebProxy("127.0.0.1", 8118);
            if (!string.IsNullOrEmpty(proxy)) proxyObj = new System.Net.WebProxy(proxy);

            string playlist = GetWebData(string.Format(videoUrlFormatString, new System.Uri(video.VideoUrl).AbsolutePath.Substring(1)), proxy: proxyObj);
            if (playlist.Length > 0)
            {
                if (playlist.IndexOf("error_country_block.swf") >= 0) throw new OnlineVideosException("Video blocked for your country.");
                string url = "";
                XmlDocument data = new XmlDocument();
                data.LoadXml(playlist);
                video.PlaybackOptions = new Dictionary<string, string>();
                foreach (XmlElement elem in data.SelectNodes("//rendition"))
                {
                    url = ((XmlElement)elem.SelectSingleNode("src")).InnerText;
                    if (!url.EndsWith(".swf"))
                    {
                        video.PlaybackOptions.Add(string.Format("{0}x{1} | {2} | .{3}", elem.GetAttribute("width"), elem.GetAttribute("height"), elem.GetAttribute("bitrate"), elem.GetAttribute("type").Substring(elem.GetAttribute("type").Length - 3)), url);
                    }
                }
                return url;
            }
            return "";
        }
Example #2
0
        public static void ApplyProxySettings()
        {
            System.Net.WebProxy proxy = null;
            if (Properties.Settings.Default.UseProxy == true)
            {
                proxy = new System.Net.WebProxy(Properties.Settings.Default.ProxyAddress, Properties.Settings.Default.ProxyPort);
                switch (Settings.ProxyAuth)
                {
                case ProxyAuthEnum.DefaultAuthentification:
                    proxy.UseDefaultCredentials = true;
                    break;

                case ProxyAuthEnum.CustomAuthentification:
                    proxy.Credentials = new System.Net.NetworkCredential(
                        Settings.ProxyUsername,
                        MangosProvider.Decrypt(Settings.ProxyPassword));
                    break;

                case ProxyAuthEnum.NoAuthentification:
                default:
                    break;
                }
            }
            System.Net.WebRequest.DefaultWebProxy = proxy;
        }
Example #3
0
        public System.Net.WebProxy ProxyFromOptions()
        {
            System.Net.WebProxy proxy = new System.Net.WebProxy();
            Uri addressUri            = null;

            // Try and create this URi from the address given in the file. It can fail if it's
            // malformed, or it can fail if they specify an IP without http://.
            if (!Uri.TryCreate(address, UriKind.Absolute, out addressUri))
            {
                // Try and create it again, appending http:// this time (rooting it)
                if (!Uri.TryCreate("http://" + address, UriKind.Absolute, out addressUri))
                {
                    // Could not understand the URL. Exception case.
                    return(null);
                }
            }

            proxy.Address = addressUri;
            if (this.username == null || this.password == null)
            {
                proxy.UseDefaultCredentials = true;
            }
            else
            {
                proxy.Credentials = new System.Net.NetworkCredential(this.username, this.password);
            }
            return(proxy);
        }
Example #4
0
        public async void TestProxyWithRedirect()
        {
            var proxy = new System.Net.WebProxy("127.0.0.1", 8580);
            proxy.BypassList = new string[] { "http://www.bing.com" };

            //use a proxy 
            var request = new HttpRequest(new Uri("http://www.google.com"))
            {               
                Proxy = proxy
            };
            var response = await request.GetResponseAsync().ConfigureAwait(false);
            Assert.AreEqual(200, (int)response.StatusCode);
            Assert.AreEqual("www.google.com", response.ResponseUri.Host);
            response.Close();

            //disable a proxy
           request = new HttpRequest(new Uri("http://www.bing.com"))
            {
                Proxy = proxy                
            };          
           response = await request.GetResponseAsync().ConfigureAwait(false);
            Assert.AreEqual(200, (int)response.StatusCode);
            Assert.AreEqual("cn.bing.com", response.ResponseUri.Host);
            response.Close();
        }
Example #5
0
 public static bool Test(string url , string proxyaddress , string proxyport , string username , string password ,bool isProxy )
 {
     try
     {
         System.Net.WebProxy proxy = null;
         if (isProxy)
         {
             proxy = new System.Net.WebProxy(proxyaddress + ":" + proxyport, true);
             if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
             {
                 proxy.Credentials = new System.Net.NetworkCredential(username, password);
             }
             else
             {
                 //proxy.Credentials = new System.Net;
             }
         }
         System.Net.WebRequest req = System.Net.WebRequest.Create(url);
         req.Timeout = 10000;
         req.Proxy = proxy;
         req.GetResponse();
         req.Abort();
         req = null;
         return true;
     }
     catch (Exception ex)
     {
         LogHelper.WriteLog("测试代理服务器失败:代理服务器:"+ proxyaddress+":"+ proxyport +",用户名:"+username +"密码:"+password + Environment.NewLine + "错误:"+ ex.Message );
         return false;
     }
 }
Example #6
0
 /// <summary>
 /// Initalizes WMS server and parses the Capabilities request
 /// </summary>
 /// <param name="url">URL of wms server</param>
 /// <param name="proxy">Proxy to use</param>
 public Client(string url, System.Net.WebProxy proxy)
 {
     System.Text.StringBuilder strReq = new StringBuilder(url);
     if (!url.Contains("?"))
     {
         strReq.Append("?");
     }
     if (!strReq.ToString().EndsWith("&") && !strReq.ToString().EndsWith("?"))
     {
         strReq.Append("&");
     }
     if (!url.ToLower().Contains("service=wms"))
     {
         strReq.AppendFormat("SERVICE=WMS&");
     }
     if (!url.ToLower().Contains("request=getcapabilities"))
     {
         strReq.AppendFormat("REQUEST=GetCapabilities&");
     }
     try
     {
         XmlDocument xml = GetRemoteXml(strReq.ToString(), proxy);
         ParseCapabilities(xml);
     }
     catch (Exception e)
     {
         throw new ApplicationException("Could not create WMS Client", e);
     }
 }
Example #7
0
        bool InitSyncMLFacade(SyncMLFacade r)
        {
            r.User = syncSettings.User;
            //    facade.ContactMediumType = ContactExchangeType.Vcard21;
            string password = ObtainPasswordFromSettingsOrUx();

            if (String.IsNullOrEmpty(password))
            {
                return(false);
            }
            else
            {
                r.Password = password;
            }

            r.BasicUriText = syncSettings.BasicUri;

            r.DeviceAddress = syncSettings.DeviceAddress;

            r.LastAnchorTime            = syncItem.LastAnchorTime;
            r.LastAnchor                = syncItem.LastAnchor; // Next anchor is generated so before alert
            r.VendorName                = syncSettings.VendorName;
            r.ModelName                 = syncSettings.ModelName;
            r.ModelVersion              = syncSettings.ModelVersion;
            r.ContactDataSourceAtServer = syncItem.RemoteName;

            r.LastAnchorChangedEvent += HandleLastAnchorChanged;


            #region Wire event handlings to Facade's events regarding to visual effects
            r.StartOperationEvent   += HandleStartOperation;
            r.EndOperationEvent     += HandleEndOperation;
            r.OperationStatusEvent  += HandleOperationMessage;
            r.ServerDeviceInfoEvent += HandleServerDeviceInfo;

            r.InitProgressBarEvent      += HandleInitProgressBar;
            r.IncrementProgressBarEvent += HandleIncrementProgressBar;
            r.StageMessageEvent         += new EventHandler <StatusEventArgs>(HandleStageMessageEvent);

            r.InitProgressBarReceivingEvent      += HandleInitProgressBarReceiving;
            r.IncrementProgressBarReceivingEvent += HandleIncrementProgressBarReceiving;
            r.StageMessageReceivingEvent         += HandleStageMessageReceivingEvent;
            r.GracefulStopEvent += new EventHandler <EventArgs>(facade_GracefulStopEvent);
            #endregion

            System.Net.WebProxy proxy;
            if (syncSettings.UseProxy)
            {
                proxy = new System.Net.WebProxy(syncSettings.Proxy);
                proxy.UseDefaultCredentials = true;
            }
            else
            {
                proxy = null;
            }

            r.Proxy = proxy;

            return(true);
        }
Example #8
0
 public SimpleProxy(System.Net.WebProxy proxy)
 {
     this.WebProxy    = proxy;
     this.Working     = false;
     this.LastChecked = null;
     this.ProxyUri    = proxy.Address;
 }
Example #9
0
        static System.Net.WebProxy GetWebProxy()
        {
            System.Net.WebProxy proxy;

            if (!Backend.Get<bool> (PROXY_USE_PROXY))
                return null;

            try {
                string host = Backend.Get<string> (PROXY_HOST);
                int port = Backend.Get<int> (PROXY_PORT);

                string uri = "http://" + host + ":" + port.ToString ();
                proxy = new System.Net.WebProxy (uri);

                string [] bypass_list = Backend.Get<string[]> (PROXY_BYPASS_LIST);
                if (bypass_list != null) {
                    for (int i = 0; i < bypass_list.Length; i++) {
                        bypass_list [i] = "http://" + bypass_list [i];
                    }
                    proxy.BypassList = bypass_list;
                }

                string username = Backend.Get<string> (PROXY_USER);
                string password = Backend.Get<string> (PROXY_PASSWORD);

                proxy.Credentials = new System.Net.NetworkCredential (username, password);
            } catch (Exception e) {
                Log.Warning ("Failed to set the web proxy settings");
                Log.DebugException (e);
                return null;
            }

            return proxy;
        }
Example #10
0
        } // End Function ConvertWebProxy

        public static System.Net.WebProxy ConvertWebProxWrapper(System.Net.IWebProxy iproxy, string type)
        {
            System.Net.WebProxy obj = null;
            if (iproxy == null)
            {
                return(obj);
            }

            System.Type t = iproxy.GetType();

            while (t != null && !string.Equals(t.Name, type, System.StringComparison.InvariantCultureIgnoreCase))
            {
                t = t.BaseType;
            } // Whend

            if (t == null)
            {
                return(obj);
            }

            System.Reflection.FieldInfo fi = t.GetField("webProxy", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);

            if (fi == null)
            {
                return(obj);
            }

            obj = (System.Net.WebProxy)fi.GetValue(iproxy);
            return(obj);
        } // End Function ConvertWebProxWrapper
Example #11
0
        public WebClient2(bool withUserAgent = false)
        {
            if (withUserAgent && UserAgent != null && UserAgent.Length > 0)
            {
                Headers.Add(System.Net.HttpRequestHeader.UserAgent, UserAgent);
            }

            if (UseProxy)
            {
                if (UseSystemProxySettings)
                {
                    // TODO not yet implemented
                    // TODO retrieve proxy settings e.g. from Windows Control Panel
                    // TODO use that data here
                }
                else
                {
                    if (ProxyServer != null && ProxyServer.Length > 0)
                    {
                        Proxy = new System.Net.WebProxy(ProxyServer, ProxyPort);
                        if (ProxyUsername != null && ProxyUsername.Length > 0)
                        {
                            Proxy.Credentials = new System.Net.NetworkCredential(ProxyUsername, ProxyPassword ?? "");
                        }
                    }
                }
            }
        }
Example #12
0
        public override string GetVideoUrl(VideoInfo video)
        {
            System.Net.WebProxy proxyObj = null; // new System.Net.WebProxy("127.0.0.1", 8118);
            if (!string.IsNullOrEmpty(proxy))
            {
                proxyObj = new System.Net.WebProxy(proxy);
            }

            string playlist = GetWebData(string.Format(videoUrlFormatString, new System.Uri(video.VideoUrl).AbsolutePath.Substring(1)), proxy: proxyObj);

            if (playlist.Length > 0)
            {
                if (playlist.IndexOf("error_country_block.swf") >= 0)
                {
                    throw new OnlineVideosException("Video blocked for your country.");
                }
                string      url  = "";
                XmlDocument data = new XmlDocument();
                data.LoadXml(playlist);
                video.PlaybackOptions = new Dictionary <string, string>();
                foreach (XmlElement elem in data.SelectNodes("//rendition"))
                {
                    url = ((XmlElement)elem.SelectSingleNode("src")).InnerText;
                    if (!url.EndsWith(".swf"))
                    {
                        video.PlaybackOptions.Add(string.Format("{0}x{1} | {2} | .{3}", elem.GetAttribute("width"), elem.GetAttribute("height"), elem.GetAttribute("bitrate"), elem.GetAttribute("type").Substring(elem.GetAttribute("type").Length - 3)), url);
                    }
                }
                return(url);
            }
            return("");
        }
Example #13
0
        } // End Function HTTP_Post

        public static System.Net.WebProxy ConvertWebProxy(System.Net.IWebProxy iproxy)
        {
            System.Net.WebProxy wp = null;

            try
            {
                if (object.ReferenceEquals(iproxy.GetType(), typeof(System.Net.WebProxy)))
                {
                    wp = (System.Net.WebProxy)iproxy;
                }
                if (wp != null)
                {
                    return(wp);
                }

                wp = ConvertWebProxWrapper(iproxy, "WebProxyWrapper");
                if (wp != null)
                {
                    return(wp);
                }

                wp = ConvertWebProxWrapper(iproxy, "WebProxyWrapperOpaque");
                if (wp != null)
                {
                    return(wp);
                }
            }
            catch (System.Exception ex)
            {
                LogLine(ex.Message);
                LogLine(ex.StackTrace);
            }

            return(wp);
        } // End Function ConvertWebProxy
 public static bool Test(string url, string proxyaddress, string proxyport, string username, string password, bool isProxy)
 {
     try
     {
         System.Net.WebProxy proxy = null;
         if (isProxy)
         {
             proxy = new System.Net.WebProxy(proxyaddress + ":" + proxyport, true);
             if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
             {
                 proxy.Credentials = new System.Net.NetworkCredential(username, password);
             }
             else
             {
                 //proxy.Credentials = new System.Net;
             }
         }
         System.Net.WebRequest req = System.Net.WebRequest.Create(url);
         req.Timeout = 10000;
         req.Proxy   = proxy;
         req.GetResponse();
         req.Abort();
         req = null;
         return(true);
     }
     catch (Exception ex)
     {
         LogHelper.WriteLog("测试代理服务器失败:代理服务器:" + proxyaddress + ":" + proxyport + ",用户名:" + username + "密码:" + password + Environment.NewLine + "错误:" + ex.Message);
         return(false);
     }
 }
Example #15
0
        public MongoDatabase GetSystemDatabaseSPT(ref MongoDatabase dbMongoREAD, string s_mongo_ip, string database, string collection)
        {
            string url = "Server=" + s_mongo_ip;

            try
            {
                if (dbMongoREAD == null)
                {
                    System.Net.WebProxy wprxWS = new System.Net.WebProxy();
                    wprxWS.Credentials = System.Net.CredentialCache.DefaultCredentials;

                    mClient      = new MongoClient(url);
                    globalserver = mClient.GetServer();

                    MongoServer server = mClient.GetServer();

                    //Creating network connection;
                    dbMongoREAD = server.GetDatabase(database);
                    if (dbMongoREAD == null)
                    {
                        //MessageBox.Show("Snaphsot could not make a connection to server for read/write");
                        return(null);
                    }
                }

                return(dbMongoREAD);
            }
            catch (MongoException me)
            {
                Trace.WriteLine(me.Message);
            }

            //Could not connect to network!
            return(null);
        }
Example #16
0
 public Search()
 {
     this.Url = "http://localhost/MRcgi/MRWebServices.pl";
     // Comment out if not using a proxy server.
     System.Net.IWebProxy proxyObject = new System.Net.WebProxy("http://localhost:8888/", false);
     this.Proxy = proxyObject;
 }
Example #17
0
        /// <summary>
        /// Initial the webservice API.
        /// </summary>
        /// <param name="client">client</param>
        /// <param name="userName">user name</param>
        /// <param name="password">password</param>
        public MailAdapter(String client, String userName, String password , System.Net.WebProxy oWebProxy)
        {
            this.client = client;
            this.userName = userName;
            this.password = password;
            this.oWebProxy = oWebProxy;
            exportService = new cn.tripolis.dialogue.export.ExportService();
            exportAuthInfo = new cn.tripolis.dialogue.export.AuthInfo
                {
                    client = client,
                    username = userName,
                    password = password
                };
            exportService.authInfo = exportAuthInfo;
            exportService.Proxy = oWebProxy;

            importService = new cn.tripolis.dialogue.import.ImportService();
            importAuthInfo = new cn.tripolis.dialogue.import.AuthInfo
                {
                    client = client,
                    username = userName,
                    password = password
                };
            importService.authInfo = importAuthInfo;
            importService.Proxy = oWebProxy;
        }
Example #18
0
        private void SetProxy(ref System.Net.HttpWebRequest Request)
        {
            if (m_ProxyHost != "")
            {
                try
                {
                    System.Net.WebProxy P = new System.Net.WebProxy(m_ProxyHost + ":" + m_ProxyPort.SafeInt() + "/", true);

                    if (m_ProxyUser != "")
                    {
                        P.Credentials = new System.Net.NetworkCredential(m_ProxyUser, m_ProxyPassword);
                    }

                    Request.Proxy = P;
                }
                catch (Exception ex)
                {
                    ex.LogError();
                    // modGlobal.ErrMsgBox(ex.Message);
                    //Request.Proxy = System.Net.GlobalProxySelection.GetEmptyWebProxy();
                    Request.Proxy = null;
                }
            }
            else
            {
                Request.Proxy = Request.Proxy = null;;
            }
        }
Example #19
0
 /// <summary>
 /// Downloads servicedescription from WMS service
 /// </summary>
 /// <returns>XmlDocument from Url. Null if Url is empty or inproper XmlDocument</returns>
 private XmlDocument GetRemoteXml(string Url, System.Net.WebProxy proxy)
 {
     try
     {
         System.Net.WebRequest myRequest;
         myRequest = System.Net.WebRequest.Create(Url);
         if (proxy != null)
         {
             myRequest.Proxy = proxy;
         }
         System.Net.WebResponse myResponse = myRequest.GetResponse();
         System.IO.Stream       stream     = myResponse.GetResponseStream();
         XmlTextReader          r          = new XmlTextReader(Url, stream);
         r.XmlResolver = null;
         XmlDocument doc = new XmlDocument();
         doc.XmlResolver = null;
         doc.Load(r);
         stream.Close();
         nsmgr = new XmlNamespaceManager(doc.NameTable);
         return(doc);
     }
     catch (System.Exception ex)
     {
         throw new ApplicationException("Could not download capabilities", ex);
     }
 }
Example #20
0
 /// <summary>
 /// Initializes a new layer, and downloads and parses the service description
 /// </summary>
 /// <param name="layername">Layername</param>
 /// <param name="url">Url of WMS server</param>
 /// <param name="cachetime">Time for caching Service Description (ASP.NET only)</param>
 /// <param name="proxy">Proxy</param>
 public WmsLayer(string layername, string url, TimeSpan cachetime, System.Net.WebProxy proxy)
 {
     this.proxy     = proxy;
     timeOut        = 10000;
     this.Name      = layername;
     this.Cachetime = cachetime;
     this.Url       = url;   // Also does the initialization if an non-empty url was given
 }
Example #21
0
        /// <summary>
        /// Initial the webservice API.
        /// </summary>
        /// <param name="client">client</param>
        /// <param name="userName">user name</param>
        /// <param name="password">password</param>
        public DiaLogueSeriveFor51(String client, String userName, String password, System.Net.WebProxy oWebProxy)
        {
            this.client = client;
            this.userName = userName;
            this.password = password;
            this.oWebProxy = oWebProxy;

        }
Example #22
0
        public CreateIssue()
        {
            this.Url = "http://10.0.12.206/hMRcgi/MRWebServices.pl";

            // Comment this out if not using a proxy server.
            System.Net.IWebProxy proxyObject = new System.Net.WebProxy("http://localhost:8888/", false);
            this.Proxy = proxyObject;
        }
Example #23
0
        public void WebProxyTest()
        {
            Configuration c = new Configuration();

            System.Net.WebProxy webProxy = new System.Net.WebProxy("http://myProxyUrl:80/");
            webProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
            c.Proxy = webProxy;
        }
Example #24
0
        static void Main(string[] args)
        {
            // Create a request to get the capabilities document from the server.
            System.UriBuilder serverUri =
                new System.UriBuilder(@"http://viz.globe.gov/viz-bin/wmt.cgi");
            Wms.Client.CapabilitiesRequestBuilder capsRequest =
                new Wms.Client.CapabilitiesRequestBuilder(serverUri.Uri);

            // Retrieve the capabilities document and cache it locally.
            System.Net.WebRequest wr = System.Net.WebRequest.Create(capsRequest.Uri);

            // Handle any proxy the system may have defined.
            System.Net.WebProxy proxy = System.Net.WebProxy.GetDefaultProxy();
            if (proxy.Address != null)
            {
                wr.Proxy = proxy;
            }

            System.Net.WebResponse response = wr.GetResponse();
            string fileName = System.IO.Path.GetTempPath() + @"capabilities.xml";

            copyStreamToFile(response.GetResponseStream(), fileName);

            // Parse the capabilities document and create a capabilities object
            // for reading the parsed information. This is done by creating a Server
            // object to represent the server associated with the capabilities.
            Wms.Client.Server       server = new Wms.Client.Server(fileName);
            Wms.Client.Capabilities caps   = server.Capabilities;

            // Create a GetMap request using the MapRequestBuilder class. When
            // creating the request, use the URI given in the server's capabilities
            // document. This URI may be different than the one used to get the
            // capabilities document.
            Wms.Client.MapRequestBuilder mapRequest =
                new Wms.Client.MapRequestBuilder(new System.Uri(caps.GetMapRequestUri));
            mapRequest.Layers      = "COASTLINES,RATMIN";
            mapRequest.Styles      = ",";        // use default style for each layer
            mapRequest.Format      = "image/gif";
            mapRequest.Srs         = "EPSG:4326";
            mapRequest.BoundingBox = "-180.0,-90.0,180.0,90.0";
            mapRequest.Height      = 300;
            mapRequest.Width       = 600;
            mapRequest.Transparent = false;

            // Retrieve the map and cache it locally.
            System.Net.WebRequest mwr = System.Net.WebRequest.Create(mapRequest.Uri);
            if (proxy.Address != null)
            {
                mwr.Proxy = proxy;
            }
            System.Net.WebResponse mresponse = mwr.GetResponse();
            string mapFileName = System.IO.Path.GetTempPath() + @"wmsmap.gif";

            copyStreamToFile(mresponse.GetResponseStream(), mapFileName);

            // Use Internet Explorer to display the map.
            invokeIe(mapFileName);
        }
Example #25
0
        public void loadFromRegistry(String sRequestedHostname)
        {
            migrateOldSettings();
            Microsoft.Win32.RegistryKey cu = Microsoft.Win32.Registry.CurrentUser;
            String accountKey = CONFIG_KEY;

            if (sRequestedHostname.Length > 0)
            {
                accountKey = ACCOUNTS_KEY + "\\" + sRequestedHostname;
            }

            Microsoft.Win32.RegistryKey f5Key = cu.OpenSubKey(accountKey);
            if (null != f5Key)
            {
                Object obj = null;
                if (null != (obj = f5Key.GetValue("Hostname")))
                {
                    m_hostname = Convert.ToString(obj);
                }
                if (null != (obj = f5Key.GetValue("Port")))
                {
                    m_port = Convert.ToInt32(obj);
                }
                if (null != (obj = f5Key.GetValue("Username")))
                {
                    m_username = Convert.ToString(obj);
                }
                if (null != (obj = f5Key.GetValue("UseProxy")))
                {
                    if (null != (obj = f5Key.GetValue("ProxyHost")))
                    {
                        String address = Convert.ToString(obj);
                        int    port    = 8080;

                        if (null != (obj = f5Key.GetValue("ProxyPort")))
                        {
                            port = Convert.ToInt32(obj);
                        }
                        m_proxy = new System.Net.WebProxy(address, port);

                        if (null != (obj = f5Key.GetValue("ProxyUser")))
                        {
                            m_proxy.Credentials = new System.Net.NetworkCredential();
                            ((System.Net.NetworkCredential)m_proxy.Credentials).UserName = Convert.ToString(obj);
                        }
                        else
                        {
                            m_proxy.UseDefaultCredentials = true;
                        }
                    }
                }
                else
                {
                    m_proxy = null;
                }
                f5Key.Close();
            }
        }
Example #26
0
        public ErrorReportDialog(string PluginUsed, string VersionString, string HavingError, System.Net.WebProxy ProxyToUse)
        {
            _PluginUsed         = PluginUsed;
            txtVersionData.Text = VersionString;
            txtHavingData.Text  = HavingError;
            _ProxyToUse         = ProxyToUse;

            InitializeComponent();
        }
Example #27
0
 public System.Net.IWebProxy ToWebProxy()
 {
     System.Net.IWebProxy proxyObject = new System.Net.WebProxy(Host, Port);
     if (!String.IsNullOrEmpty(User))
     {
         proxyObject.Credentials = new System.Net.NetworkCredential(User, Password);
     }
     return(proxyObject);
 }
Example #28
0
 public void clear()
 {
     m_hostname = "";
     m_port     = -1;
     m_endpoint = "";
     m_username = "";
     m_password = "";
     m_proxy    = null;
 }
Example #29
0
        public string GuardarLlave(string UserName)
        {
            string Errores = "";

            try
            {
                DLBovedaContra objBov = new DLBovedaContra();
                string         Llave  = DatosGenerales.GenerarLlaveUnica(DatosGenerales.LongitudLlaveBoveda);

                DataTable Parametros = new DataTable();

                Parametros = DatosGenerales.GenerateTransposedTable(objBov.ObtenerParametros());

                if (Parametros.TableName != "Error")
                {
                    string To        = Parametros.Rows[0]["To"].ToString();
                    string UsarProxy = Parametros.Rows[0]["UsarProxy"].ToString();
                    string ProxyIP   = Parametros.Rows[0]["ProxyIP"].ToString();
                    string ProxyU    = Parametros.Rows[0]["ProxyU"].ToString();
                    string ProxyP    = Parametros.Rows[0]["ProxyP"].ToString();

                    System.Net.WebProxy proxyObj = System.Net.WebProxy.GetDefaultProxy();
                    proxyObj.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

                    if (UsarProxy == "S")
                    {
                        System.Net.WebProxy proxyObject = new System.Net.WebProxy(ProxyIP, true);
                        proxyObject.Credentials = new System.Net.NetworkCredential(ProxyU, ProxyP);
                        System.Net.WebRequest.DefaultWebProxy = proxyObject;
                    }

                    Mailer.MailerServiceSoapClient mail = new Mailer.MailerServiceSoapClient();

                    ParseMailAcc(To);

                    Errores = mail.SendMailAttTxt("", CorreoTo, CorreosCC, "Bóveda contraseñas - " + Environment.MachineName, "El usuario " + UserName + " ha solicitado una nueva llave.", true, Llave, DatosGenerales.GeneraNombreArchivoRnd("Bov_", ".bkey"));

                    System.Net.WebRequest.DefaultWebProxy = proxyObj;

                    if (Errores == "")
                    {
                        objBov.GuardarLlave(UserName, DatosGenerales.ObtenerHashCadena(Llave));
                    }
                }
                else
                {
                    Errores = Parametros.Rows[0][0].ToString();
                }
            }
            catch (Exception ex)
            {
                Errores = ex.Message;
            }

            return(Errores);
        }
Example #30
0
        //Logic really doesn't require seperate methods unless they verify the protocol...

        public static System.IO.Stream HttpWebRequestDownload(System.Uri location, System.Net.WebProxy proxy = null, System.Net.NetworkCredential credential = null)
        {
            if (false == location.Scheme.StartsWith(System.Uri.UriSchemeHttp, System.StringComparison.InvariantCultureIgnoreCase))
            {
                throw new System.ArgumentException("Must start with System.Uri.UriSchemeHttp", "location.Scheme");
            }

            using (DownloadAdapter d = DownloadAdapter.HttpWebRequestDownload(location, proxy, credential))
                return(d.ResponseOutputStream);
        }
Example #31
0
 public async void TestProxy()
 {
     var proxy = new System.Net.WebProxy("127.0.0.1", 8580);
     var request = new HttpRequest(new Uri("http://www.google.com"))
     {
         Proxy = proxy
     };
     var response = await request.GetResponseAsync().ConfigureAwait(false);
     Assert.AreEqual(200, (int)response.StatusCode);
 }
Example #32
0
        } // End Function ConvertWebProxWrapper

        public static void LogProxy(System.Net.WebProxy proxy, string url)
        {
            Log("Proxy: ");
            if (proxy == null)
            {
                LogLine("is NULL");
                return;
            }
            else
            {
                LogLine(proxy.GetType().AssemblyQualifiedName);
            }


            Log("Address: ");
            if (proxy.Address == null)
            {
                LogLine("NULL");
            }
            else
            {
                LogLine(proxy.Address.OriginalString);
            }

            Log("IsBypassed: ");
            System.Uri uri = new System.Uri(url);
            LogLine(proxy.IsBypassed(uri));

            Log("BypassList: ");
            if (proxy.BypassList == null || proxy.BypassList.Length == 0)
            {
                LogLine("NULL");
            }
            else
            {
                LogLine(string.Join(System.Environment.NewLine, proxy.BypassList));
            }

            Log("BypassProxyOnLocal: ");
            LogLine(proxy.BypassProxyOnLocal);


            Log("UseDefaultCredentials: ");
            LogLine(proxy.UseDefaultCredentials);

            Log("Credentials: ");
            if (proxy.Credentials == null)
            {
                LogLine("NULL");
            }
            else
            {
                LogLine(proxy.Credentials);
            }
        }
Example #33
0
        /// <summary>
        /// Initial the webservice API.
        /// </summary>
        /// <param name="client">client</param>
        /// <param name="userName">user name</param>
        /// <param name="password">password</param>
        public DialogueService_new(String client, String userName, String password, System.Net.WebProxy oWebProxy)
        {
            this.client = client;
            this.userName = userName;
            this.password = password;
            this.oWebProxy = oWebProxy;
            //string strDomain = ConfigurationSettings.AppSettings["domain"].ToString();
            ////判断是否启用代理服务器
            //if (strDomain.Trim() != "")
            //{
            //    //域访问名
            //    string strUserName = ConfigurationSettings.AppSettings["UserName"].ToString();
            //    //域访问密码
            //    string strPassWord = ConfigurationSettings.AppSettings["PassWord"].ToString();
            //    //代理地址
            //    string strHost = ConfigurationSettings.AppSettings["Host"].ToString();
            //    //代理端口
            //    int strPort = Convert.ToInt32(ConfigurationSettings.AppSettings["Port"].ToString());
            //    //设置代理
            //    System.Net.WebProxy oWebProxy = new System.Net.WebProxy(strHost, strPort);
            //    // 获取或设置提交给代理服务器进行身份验证的凭据
            //    oWebProxy.Credentials = new System.Net.NetworkCredential(strUserName, strPassWord, strDomain);
            //    objService.Proxy = oWebProxy;
            //}
            subscriptionService = new cn.tripolis.dialogue.subscription.SubscriptionService();
            subscriptionAuthInfo = new cn.tripolis.dialogue.subscription.AuthInfo
                {
                    client = client,
                    username = userName,
                    password = password
                };
            subscriptionService.authInfo = subscriptionAuthInfo;
            subscriptionService.Proxy = oWebProxy;

            exportService = new cn.tripolis.dialogue.export.ExportService();
            exportAuthInfo = new cn.tripolis.dialogue.export.AuthInfo
                {
                    client = client,
                    username = userName,
                    password = password
                };
            exportService.authInfo = exportAuthInfo;
            exportService.Proxy = oWebProxy;

            importService = new cn.tripolis.dialogue.import.ImportService();
            importAuthInfo = new cn.tripolis.dialogue.import.AuthInfo
            {
                client = client,
                username = userName,
                password = password
            };
            importService.authInfo = importAuthInfo;
            importService.Proxy = oWebProxy;
        }
Example #34
0
        public System.Net.IWebProxy RetornaProxy()
        {
            System.Net.NetworkCredential credencial = new System.Net.NetworkCredential(LerGravarXML.ObterValor("proxyUsuario"), LerGravarXML.ObterValor("proxySenha"));
            System.Net.IWebProxy         proxy;

            //proxy = new System.Net.WebProxy(LerGravarXML.ObterValor("proxyServidor"), Convert.ToInt32(LerGravarXML.ObterValor("proxyPorta")));
            proxy             = new System.Net.WebProxy(LerGravarXML.ObterValor("proxyServidor") + ":" + Convert.ToInt32(LerGravarXML.ObterValor("proxyPorta")));
            proxy.Credentials = credencial;

            return(proxy);
        }
Example #35
0
        public static void SetGlobalProxy()
        {
            var proxyAddress         = Environment.GetEnvironmentVariable("PROXY_ADDRESS");
            var bypassProxyAddresses = Environment.GetEnvironmentVariable("BYPASS_PROXY_ADDRESSES");

            var webProxy = new System.Net.WebProxy(proxyAddress);

            webProxy.BypassArrayList.AddRange(bypassProxyAddresses.Split(','));
            webProxy.BypassProxyOnLocal = true;

            System.Net.WebRequest.DefaultWebProxy = webProxy;
        }
Example #36
0
        private Webservices CreateWebService()
        {
            Webservices searcher = new RegexLib.Services.Webservices();

            System.Net.WebProxy myProxy = ProxyFactory.Create(AppContext.Instance.Settings.ProxySettings, searcher.Url);
            if (myProxy != null)
            {
                searcher.Proxy = myProxy;
            }

            return(searcher);
        }
Example #37
0
 /// <summary>
 /// Initializes a new layer, and downloads and parses the service description
 /// </summary>
 /// <param name="layername">Layername</param>
 /// <param name="url">Url of WMS server</param>
 /// <param name="cachetime">Time for caching Service Description (ASP.NET only)</param>
 /// <param name="proxy">Proxy</param>
 public WmsLayer(string layername, string url, TimeSpan cachetime, System.Net.WebProxy proxy)
 {
     _Proxy           = proxy;
     _TimeOut         = 10000;
     this.LayerName   = layername;
     _ContinueOnError = true;
     if (System.Web.HttpContext.Current != null && System.Web.HttpContext.Current.Cache["SharpMap_WmsClient_" + url] != null)
     {
         wmsClient = (SharpMap.Web.Wms.Client)System.Web.HttpContext.Current.Cache["SharpMap_WmsClient_" + url];
     }
     else
     {
         wmsClient = new SharpMap.Web.Wms.Client(url, _Proxy);
         if (System.Web.HttpContext.Current != null)
         {
             System.Web.HttpContext.Current.Cache.Insert("SharpMap_WmsClient_" + url, wmsClient, null,
                                                         System.Web.Caching.Cache.NoAbsoluteExpiration, cachetime);
         }
     }
     //Set default mimetype - We prefer compressed formats
     if (OutputFormats.Contains("image/jpeg"))
     {
         _MimeType = "image/jpeg";
     }
     else if (OutputFormats.Contains("image/png"))
     {
         _MimeType = "image/png";
     }
     else if (OutputFormats.Contains("image/gif"))
     {
         _MimeType = "image/gif";
     }
     else             //None of the default formats supported - Look for the first supported output format
     {
         bool formatSupported = false;
         foreach (System.Drawing.Imaging.ImageCodecInfo encoder in System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders())
         {
             if (OutputFormats.Contains(encoder.MimeType.ToLower()))
             {
                 formatSupported = true;
                 _MimeType       = encoder.MimeType;
                 break;
             }
         }
         if (!formatSupported)
         {
             throw new ArgumentException("GDI+ doesn't not support any of the mimetypes supported by this WMS service");
         }
     }
     _LayerList  = new Collection <string>();
     _StylesList = new Collection <string>();
 }
Example #38
0
        /// <summary>
        /// Efetua as definições do proxy
        /// </summary>
        /// <returns>Retorna as definições do Proxy</returns>
        /// <param name="servidor">Endereço do servidor de proxy</param>
        /// <param name="usuario">Usuário para autenticação no servidor de proxy</param>
        /// <param name="senha">Senha do usuário para autenticação no servidor de proxy</param>
        /// <param name="porta">Porta de comunicação do servidor proxy</param>
        /// <remarks>
        /// Autor: Wandrey Mundin Ferreira
        /// Data: 29/09/2009
        /// </remarks>
        public static System.Net.IWebProxy DefinirProxy(string servidor, string usuario, string senha, int porta)
        {
            System.Net.NetworkCredential credencial = new System.Net.NetworkCredential(usuario, senha);
            System.Net.IWebProxy         proxy;
            proxy = new System.Net.WebProxy(servidor, porta);

            if (!String.IsNullOrEmpty(usuario.Trim()) && usuario.Trim().Length > 0)
            {
                proxy.Credentials = credencial;
            }

            return(proxy);
        }
Example #39
0
        /// <summary>
        /// Efetua as definições do proxy
        /// </summary>
        /// <returns>Retorna as definições do Proxy</returns>
        /// <param name="servidor">Endereço do servidor de proxy</param>
        /// <param name="usuario">Usuário para autenticação no servidor de proxy</param>
        /// <param name="senha">Senha do usuário para autenticação no servidor de proxy</param>
        /// <param name="porta">Porta de comunicação do servidor proxy</param>
        /// <remarks>
        /// Autor: Wandrey Mundin Ferreira
        /// Data: 29/09/2009
        /// </remarks>
        public static System.Net.IWebProxy DefinirProxy(string servidor, string usuario, string senha, int porta)
        {
            System.Net.NetworkCredential credencial = new System.Net.NetworkCredential(usuario, senha);
            System.Net.IWebProxy proxy;
            proxy = new System.Net.WebProxy(servidor, porta);

            if (!String.IsNullOrEmpty(usuario.Trim()) && usuario.Trim().Length > 0)
            {
                proxy.Credentials = credencial;
            }

            return proxy;
        }
Example #40
0
        public static bool IsInternetAvailable()
        {
            try
            {
                //Call url 
                System.Uri url = new System.Uri("http://www.google.com.vn");
                System.Net.WebRequest req = default(System.Net.WebRequest);
                req = System.Net.WebRequest.Create(url);
                req.Timeout = 15000;//15s
                System.Net.WebResponse resp = default(System.Net.WebResponse);
                //------Proxy
                if (st.fProxyOption == "2")//2-Use IE proxy
                {
                    System.Net.WebProxy pr = System.Net.WebProxy.GetDefaultProxy();
                    pr.Credentials = System.Net.CredentialCache.DefaultCredentials;
                    req.Proxy = pr;
                }
                else if (st.fProxyOption == "3")//3-Manual proxy
                {
                    string strProxyIP = st.fProxyIP;
                    string strProxyPort = st.fProxyPort;
                    string strProxyUser = st.fProxyUser;
                    string strProxyPass =st.fProxyPass;
                    if (!String.IsNullOrEmpty(strProxyIP))
                    {
                        System.Net.WebProxy pr = new System.Net.WebProxy(strProxyIP, Convert.ToInt32(strProxyPort));
                        if (!string.IsNullOrEmpty(strProxyUser))
                        {
                            System.Net.NetworkCredential cr = new System.Net.NetworkCredential(strProxyUser, strProxyPass);
                            pr.Credentials = cr;
                        }
                        req.Proxy = pr;
                    }
                }
                else//1-No proxy (là 1 hoặc giá trị khác thì là no proxy
                {
                    //Do nothing for proxy
                }
                //------End

                resp = req.GetResponse();
                resp.Close();
                req = null;
                return true;
            }
            catch
            {
                return false;
            }
        }
Example #41
0
        public System.Net.WebProxy ProxyFromOptions()
        {
            System.Net.WebProxy proxy = new System.Net.WebProxy();
            Uri addressUri = null;

            // Try and create this URi from the address given in the file. It can fail if it's
            // malformed, or it can fail if they specify an IP without http://.
            if (!Uri.TryCreate(address, UriKind.Absolute, out addressUri))
            {
                // Try and create it again, appending http:// this time (rooting it)
                if (!Uri.TryCreate("http://" + address, UriKind.Absolute, out addressUri))
                {
                    // Could not understand the URL. Exception case.
                    return null;
                }
            }

            proxy.Address = addressUri;
            if (this.username == null || this.password == null)
                proxy.UseDefaultCredentials = true;
            else
                proxy.Credentials = new System.Net.NetworkCredential(this.username, this.password);
            return proxy;
        }
        System.Net.WebProxy getProxy()
        {
            if (string.IsNullOrEmpty(proxy))
                return null;

            System.Net.WebProxy proxyObj = new System.Net.WebProxy(proxy);
            if (!string.IsNullOrEmpty(proxyUsername) && !string.IsNullOrEmpty(proxyPassword))
                proxyObj.Credentials = new System.Net.NetworkCredential(proxyUsername, proxyPassword);
            return proxyObj;
        }
Example #43
0
        public static void EnviarIBK(out IBK.lote_response Lr, FeaEntidades.InterFacturas.lote_comprobantes lc, string certificado)
        {
            IBK.lote_comprobantes lcIBK = new IBK.lote_comprobantes();
            lcIBK = Fea2Ibk(lc);
			IBK.FacturaWebServiceConSchema objIBK;
			objIBK = new IBK.FacturaWebServiceConSchema();
            objIBK.Url = System.Configuration.ConfigurationManager.AppSettings["URLinterfacturas"];
            if (System.Configuration.ConfigurationManager.AppSettings["Proxy"] != null && System.Configuration.ConfigurationManager.AppSettings["Proxy"] != "")
            {
                System.Net.WebProxy wp = new System.Net.WebProxy(System.Configuration.ConfigurationManager.AppSettings["Proxy"], false);
                string usuarioProxy = System.Configuration.ConfigurationManager.AppSettings["UsuarioProxy"];
                string claveProxy = System.Configuration.ConfigurationManager.AppSettings["ClaveProxy"];
                string dominioProxy = System.Configuration.ConfigurationManager.AppSettings["DominioProxy"];
                System.Net.NetworkCredential networkCredential = new System.Net.NetworkCredential(usuarioProxy, claveProxy, dominioProxy);
                wp.Credentials = networkCredential;
                objIBK.Proxy = wp;
            }
            string storeLocation = System.Configuration.ConfigurationManager.AppSettings["StoreLocation"];
            X509Store store;
            if (storeLocation == "CurrentUser")
            {
                store = new X509Store(StoreLocation.CurrentUser);
            }
            else 
            {
                store = new X509Store(StoreLocation.LocalMachine);
            }
            store.Open(OpenFlags.ReadOnly);
            X509Certificate2Collection col = store.Certificates.Find(X509FindType.FindBySerialNumber, certificado, true);
            if (col.Count.Equals(1))
            {
                //objIBK.RequestEncoding = System.Text.Encoding.GetEncoding("iso-8859-1");
                objIBK.ClientCertificates.Add(col[0]);
                System.Threading.Thread.Sleep(1000);
                IBK.lote_comprobantes_response lcr = objIBK.receiveFacturasConSchema(lcIBK);
                IBK.lote_response lr = new IBK.lote_response();
                try
                {
                    lr = ((IBK.lote_response)lcr.Item);
                    if (lr.estado == "OK")
                    {
                        Lr = lr;
                    }
                    else
                    {
                        Lr = lr;
                        StringBuilder errorText = new StringBuilder();
                        if (Lr.errores_lote != null)
                        {
                            errorText.Append("Lote Nro.: [" + Lr.id_lote + "] \r\n");
                            foreach (RN.IBK.error elote in Lr.errores_lote)
                            {
                                errorText.Append(elote.codigo_error + " - " + elote.descripcion_error + " \r\n");
                            }
                            errorText.Append("\r\n");
                        }
                        if (Lr.comprobante_response != null)
                        {
                            foreach (RN.IBK.comprobante_response comprobante in Lr.comprobante_response)
                            {
                                if (comprobante.errores_comprobante != null)
                                {
                                    errorText.Append("Nro. de Comprobante: [" + comprobante.numero_comprobante + "]  Punto de Venta: [" + comprobante.punto_de_venta + "]  Tipo de Comprobante: [" + comprobante.tipo_de_comprobante + "] \r\n");
                                    foreach (RN.IBK.error ecomprobante in comprobante.errores_comprobante)
                                    {
                                        errorText.Append(ecomprobante.codigo_error + " - " + ecomprobante.descripcion_error + " \r\n");
                                    }
                                }
                            }
                        }
                        throw new EX.Lote.ProblemasEnvio(errorText.ToString());
                    }
                }
                catch (InvalidCastException)
                {
                    StringBuilder errorText = new StringBuilder();
                    if (lcr.Item != null)
                    {
                        if (lcr.Item.GetType() == typeof(IBK.lote_comprobantes_responseErrores_response))
                        {
                            IBK.lote_comprobantes_responseErrores_response lcrEr = new RN.IBK.lote_comprobantes_responseErrores_response();
                            errorText.Append("Nro. de Lote: [" + lc.cabecera_lote.id_lote + "] \r\n");
                            lcrEr = (IBK.lote_comprobantes_responseErrores_response)lcr.Item;
                            foreach (IBK.error error in lcrEr.error)
                            {
                                errorText.Append(error.codigo_error + " - " + error.descripcion_error + " \r\n");
                            }
                        }
                    }
                    throw new Exception(errorText.ToString());
                }
            }
            else
            {
                throw new Exception("Su certificado no está disponible en nuestro repositorio");
            }
        }
Example #44
0
        public static FeaEntidades.InterFacturas.lote_comprobantes ConsultarIBK(out IBK.error[] RespErroresLote, out IBK.error[] RespErroresComprobantes, IBK.consulta_lote_comprobantes clc, string certificado)
        {
            FeaEntidades.InterFacturas.lote_comprobantes lc = new FeaEntidades.InterFacturas.lote_comprobantes();
            lc.cabecera_lote = new FeaEntidades.InterFacturas.cabecera_lote();
            lc.comprobante = new FeaEntidades.InterFacturas.comprobante[1];
            IBK.error[] respErroresLote = new IBK.error[0];
            IBK.error[] respErroresComprobantes = new IBK.error[0];
			IBK.FacturaWebServiceConSchema objIBK;
			objIBK = new IBK.FacturaWebServiceConSchema();
            objIBK.Url = System.Configuration.ConfigurationManager.AppSettings["URLinterfacturas"];
            if (System.Configuration.ConfigurationManager.AppSettings["Proxy"] != "")
            {
                System.Net.WebProxy wp = new System.Net.WebProxy(System.Configuration.ConfigurationManager.AppSettings["Proxy"], false);
                string usuarioProxy = System.Configuration.ConfigurationManager.AppSettings["UsuarioProxy"];
                string claveProxy = System.Configuration.ConfigurationManager.AppSettings["ClaveProxy"];
                string dominioProxy = System.Configuration.ConfigurationManager.AppSettings["DominioProxy"];
                System.Net.NetworkCredential networkCredential = new System.Net.NetworkCredential(usuarioProxy, claveProxy, dominioProxy);
                wp.Credentials = networkCredential;
                objIBK.Proxy = wp;
            }
            string storeLocation = System.Configuration.ConfigurationManager.AppSettings["StoreLocation"];
            X509Store store;
            if (storeLocation == "CurrentUser")
            {
                store = new X509Store(StoreLocation.CurrentUser);
            }
            else
            {
                store = new X509Store(StoreLocation.LocalMachine);
            }
            store.Open(OpenFlags.ReadOnly);
            X509Certificate2Collection col = store.Certificates.Find(X509FindType.FindBySerialNumber, certificado, true);
            if (col.Count.Equals(1))
            {
                objIBK.ClientCertificates.Add(col[0]);
                System.Threading.Thread.Sleep(1000);
                IBK.consulta_lote_comprobantes_response clcr = objIBK.getLoteFacturasConSchema(clc);
                IBK.consulta_lote_response clr;
                try
                {
                    clr = (IBK.consulta_lote_response)clcr.Item;
                    IBK.lote_comprobantes lcIBK = (IBK.lote_comprobantes)clr.Item;
                    lc = Ibk2Fea(lcIBK);
                }
                catch (InvalidCastException)
                {
                    StringBuilder errorText = new StringBuilder();
                    if (clcr.Item != null)
                    {
                        errorText.Append("Lote Nro.: [" + clc.id_lote + "] \r\n");
                        if (clcr.Item.GetType() == typeof(IBK.consulta_lote_response))
                        {
                            clr = (IBK.consulta_lote_response)clcr.Item;
                            IBK.consulta_lote_responseErrores_consulta errores = (IBK.consulta_lote_responseErrores_consulta)clr.Item;
                            foreach (IBK.error elote in errores.error)
                            {
                                errorText.Append(elote.codigo_error + " - " + elote.descripcion_error + " \r\n");
                            }
                            RespErroresLote = errores.error;
                        }
                        else
                        {
                            IBK.consulta_lote_comprobantes_responseErrores_response clcrEr;
                            clcrEr = (IBK.consulta_lote_comprobantes_responseErrores_response)clcr.Item;
                            foreach (IBK.error elote in clcrEr.error)
                            {
                                errorText.Append(elote.codigo_error + " - " + elote.descripcion_error + " \r\n");
                            }
                            RespErroresComprobantes = clcrEr.error;
                        }
                    }
                    throw new Exception(errorText.ToString());
                }
                RespErroresLote = respErroresLote;
                RespErroresComprobantes = respErroresComprobantes;
                return lc;
            }
            else
            {
                throw new Exception("Su certificado no está disponible en nuestro repositorio");
            }
        }
 public void clear()
 {
     m_hostname = "";
     m_port = -1;
     m_endpoint = "";
     m_username = "";
     m_password = "";
     m_proxy = null;
 }
Example #46
0
        public byte[] FetchUrlEx(string url, System.Collections.Specialized.NameValueCollection parameters, string title, int ntry, bool bypassProxy)
        {
            string lastException = "";
            for (int t = 0; t < ntry; t++)
            {
                try
                {
                    // Note: by default WebClient try to determine the proxy used by IE/Windows
                    WebClientEx wc = new WebClientEx();

                    if (bypassProxy)
                    {
                        // Don't use a proxy if connected to the VPN
                        wc.Proxy = null;
                    }
                    else
                    {
                        string proxyMode = Storage.Get("proxy.mode").ToLowerInvariant();
                        string proxyHost = Storage.Get("proxy.host");
                        int proxyPort = Storage.GetInt("proxy.port");
                        string proxyAuth = Storage.Get("proxy.auth").ToLowerInvariant();
                        string proxyLogin = Storage.Get("proxy.login");
                        string proxyPassword = Storage.Get("proxy.password");

                        if(proxyMode == "Tor")
                        {
                            proxyMode = "socks";
                            proxyAuth = "none";
                            proxyLogin = "";
                            proxyPassword = "";
                        }

                        if (proxyMode == "http")
                        {
                            System.Net.WebProxy proxy = new System.Net.WebProxy(proxyHost, proxyPort);
                            //string proxyUrl = "http://" + Storage.Get("proxy.host") + ":" + Storage.GetInt("proxy.port").ToString() + "/";
                            //System.Net.WebProxy proxy = new System.Net.WebProxy(proxyUrl, true);

                            if (proxyAuth != "none")
                            {
                                //wc.Credentials = new System.Net.NetworkCredential(Storage.Get("proxy.login"), Storage.Get("proxy.password"), Storage.Get("proxy.host"));
                                wc.Credentials = new System.Net.NetworkCredential(proxyLogin, proxyPassword, "");
                                proxy.Credentials = new System.Net.NetworkCredential(proxyLogin, proxyPassword, "");
                                wc.UseDefaultCredentials = false;
                            }

                            wc.Proxy = proxy;
                        }
                        else if (proxyMode == "socks")
                        {
                            // Socks Proxy supported with a curl shell
                            if (Software.CurlPath == "")
                            {
                                throw new Exception(Messages.CUrlRequiredForProxySocks);
                            }
                            else
                            {
                                string dataParameters = "";
                                if (parameters != null)
                                {
                                    foreach (string k in parameters.Keys)
                                    {
                                        if (dataParameters != "")
                                            dataParameters += "&";
                                        dataParameters += k + "=" + Uri.EscapeUriString(parameters[k]);
                                    }
                                }

                                TemporaryFile fileOutput = new TemporaryFile("bin");
                                string args = " \"" + url + "\" --socks4a " + proxyHost + ":" + proxyPort;
                                if (proxyAuth != "none")
                                {
                                    args += " -U " + proxyLogin + ":" + proxyPassword;
                                }
                                args += " -o \"" + fileOutput.Path + "\"";
                                args += " --progress-bar";
                                if (dataParameters != "")
                                    args += " --data \"" + dataParameters + "\"";
                                string str = Platform.Instance.Shell(Software.CurlPath, args);
                                byte[] bytes;
                                if (Platform.Instance.FileExists(fileOutput.Path))
                                {
                                    bytes = Platform.Instance.FileContentsReadBytes(fileOutput.Path);
                                    fileOutput.Close();
                                    return bytes;
                                }
                                else
                                {
                                    throw new Exception(str);
                                }
                            }
                        }
                        else if (proxyMode != "detect")
                        {
                            wc.Proxy = null;
                        }
                    }

                    if (parameters == null)
                        return wc.DownloadData(url);
                    else
                        return wc.UploadValues(url, "POST", parameters);
                }
                catch (Exception e)
                {
                    if (ntry == 1) // AirAuth have it's catch errors retry logic.
                        throw e;
                    else
                    {
                        lastException = e.Message;

                        if(Engine.Storage.GetBool("advanced.expert"))
                            Engine.Instance.Logs.Log(LogType.Warning, MessagesFormatter.Format(Messages.FetchTryFailed, title, (t + 1).ToString(), lastException));
                    }
                }
            }

            throw new Exception(lastException);
        }
 public void setWebProxy(String host, int port, String proxyUser, String proxyPass)
 {
     System.Net.WebProxy proxy = new System.Net.WebProxy(host, port);
     if ((proxyUser.Length > 0) && (proxyPass.Length > 0))
     {
         proxy.Credentials = new System.Net.NetworkCredential();
         ((System.Net.NetworkCredential)proxy.Credentials).UserName = proxyUser;
         ((System.Net.NetworkCredential)proxy.Credentials).Password = proxyPass;
     }
     else
     {
         proxy.UseDefaultCredentials = true;
     }
     setWebProxy(proxy);
 }
        public bool initialize(String hostname, long port, String username, String password, String proxyServer, long proxyPort, String proxyUser, String proxyPass)
        {
            m_bInitialized = false;
            try
            {
                System.Net.ServicePointManager.ServerCertificateValidationCallback = RemoteCertificateValidationCallback;

                m_ci.setEndpoint(hostname, port, "/iControl/iControlPortal.cgi");
                if ((null != username) && (null != password))
                {
                    m_ci.setCredentials(username, password);
                }
                else
                {
                    m_ci.setCredentials("", "");
                }

                if ((null != proxyServer) && (0 != proxyPort))
                {
                    m_proxyServer = new System.Net.WebProxy(proxyServer, Convert.ToInt32(proxyPort));
                    if ((0 == proxyUser.Length) && (0 == proxyPass.Length))
                    {
                        m_proxyServer.UseDefaultCredentials = true;
                    }
                    else
                    {
                        System.Net.NetworkCredential proxyCreds = new System.Net.NetworkCredential();
                        proxyCreds.UserName = proxyUser;
                        proxyCreds.Password = proxyPass;
                        m_proxyServer.Credentials = proxyCreds;
                    }
                }
                else
                {
                    m_proxyServer = null;
                }

                m_ASMLoggingProfile = null;
                m_ASMObjectParams = null;
                m_ASMPolicy = null;
                m_ASMPolicyGroup = null;
                m_ASMSystemConfiguration = null;
                m_ASMWebApplication = null;
                m_ASMWebApplicationGroup = null;

                m_ClassificationApplication = null;
                m_ClassificationCategory = null;
                m_ClassificationSignatureDefinition = null;
                m_ClassificationSignatureUpdateSchedule = null;
                m_ClassificationSignatureVersion = null;

                m_GlobalLBApplication = null;
                m_GlobalLBDataCenter = null;
                m_GlobalLBDNSSECKey = null;
                m_GlobalLBDNSSECZone = null;
                m_GlobalLBGlobals = null;
                m_GlobalLBLink = null;
                m_GlobalLBMonitor = null;
                m_GlobalLBPool = null;
                m_GlobalLBPoolMember = null;
                m_GlobalLBProberPool = null;
                m_GlobalLBRegion = null;
                m_GlobalLBRule = null;
                m_GlobalLBServer = null;
                m_GlobalLBTopology = null;
                m_GlobalLBVirtualServer = null;
                m_GlobalLBVirtualServerV2 = null;
                m_GlobalLBWideIP = null;

                m_iCallPeriodicHandler = null;
                m_iCallPerpetualHandler = null;
                m_iCallScript = null;
                m_iCallTriggeredHandler = null;

                m_LocalLBClass = null;
                m_LocalLBDataGroupFile = null;
                m_LocalLBDNSCache = null;
                m_LocalLBDNSExpress = null;
                m_LocalLBDNSGlobals = null;
                m_LocalLBDNSServer = null;
                m_LocalLBDNSTSIGKey = null;
                m_LocalLBDNSZone = null;
                m_LocalLBiFile = null;
                m_LocalLBiFileFile = null;
                m_LocalLBLSNPool = null;
                m_LocalLBMonitor = null;
                m_LocalLBNAT = null;
                m_LocalLBNATV2 = null;
                m_LocalLBNodeAddress = null;
                m_LocalLBNodeAddressV2 = null;
                m_LocalLBPool = null;
                m_LocalLBPoolMember = null;
                m_LocalLBProfileAnalytics = null;
                m_LocalLBProfileAuth = null;
                m_LocalLBProfileClassification = null;
                m_LocalLBProfileClientSSL = null;
                m_LocalLBProfileDiameter = null;
                m_LocalLBProfileDiameterEndpoint = null;
                m_LocalLBProfileDNS = null;
                m_LocalLBProfileDNSLogging = null;
                m_LocalLBProfileFastHttp = null;
                m_LocalLBProfileFastL4 = null;
                m_LocalLBProfileFIX = null;
                m_LocalLBProfileFTP = null;
                m_LocalLBProfileHttp = null;
                m_LocalLBProfileHttpClass = null;
                m_LocalLBProfileHttpCompression = null;
                m_LocalLBProfileICAP = null;
                m_LocalLBProfileIIOP = null;
                m_LocalLBProfileOneConnect = null;
                m_LocalLBProfilePCP = null;
                m_LocalLBProfilePersistence = null;
                m_LocalLBProfilePPTP = null;
                m_LocalLBProfileRADIUS = null;
                m_LocalLBProfileRequestAdapt = null;
                m_LocalLBProfileRequestLogging = null;
                m_LocalLBProfileResponseAdapt = null;
                m_LocalLBProfileRTSP = null;
                m_LocalLBProfileSCTP = null;
                m_LocalLBProfileServerSSL = null;
                m_LocalLBProfileSIP = null;
                m_LocalLBProfileSMTPS = null;
                m_LocalLBProfileSPDY = null;
                m_LocalLBProfileSPM = null;
                m_LocalLBProfileStream = null;
                m_LocalLBProfileTCP = null;
                m_LocalLBProfileTCPAnalytics = null;
                m_LocalLBProfileUDP = null;
                m_LocalLBProfileUserStatistic = null;
                m_LocalLBProfileWebAcceleration = null;
                m_LocalLBProfileXML = null;
                m_LocalLBRAMCacheInformation = null;
                m_LocalLBRateClass = null;
                m_LocalLBRule = null;
                m_LocalLBSNAT = null;
                m_LocalLBSNATPool = null;
                m_LocalLBSNATPoolMember = null;
                m_LocalLBSNATTranslationAddress = null;
                m_LocalLBSNATTranslationAddressV2 = null;
                m_LocalLBVirtualAddress = null;
                m_LocalLBVirtualAddressV2 = null;
                m_LocalLBVirtualServer = null;

                m_LogDestinationArcSight = null;
                m_LogDestinationIPFIX = null;
                m_LogDestinationLocalSyslog = null;
                m_LogDestinationRemoteHighSpeedLog = null;
                m_LogDestinationRemoteSyslog = null;
                m_LogDestinationSplunk = null;
                m_LogFilter = null;
                m_LogPublisher = null;

                m_LTConfigClass = null;
                m_LTConfigField = null;

                m_ManagementApplicationPresentationScript = null;
                m_ManagementApplicationService = null;
                m_ManagementApplicationTemplate = null;
                m_ManagementCCLDAPConfiguration = null;
                m_ManagementCertLDAPConfiguration = null;
                m_ManagementChangeControl = null;
                m_ManagementCLIScript = null;
                m_ManagementCRLDPConfiguration = null;
                m_ManagementCRLDPServer = null;
                m_ManagementDBVariable = null;
                m_ManagementDevice = null;
                m_ManagementDeviceGroup = null;
                m_ManagementEM = null;
                m_ManagementEventNotification = null;
                m_ManagementEventSubscription = null;
                m_ManagementFeatureModule = null;
                m_ManagementFolder = null;
                m_ManagementGlobals = null;
                m_ManagementKeyCertificate = null;
                m_ManagementLDAPConfiguration = null;
                m_ManagementLicenseAdministration = null;
                m_ManagementNamed = null;
                m_ManagementOCSPConfiguration = null;
                m_ManagementOCSPResponder = null;
                m_ManagementPartition = null;
                m_ManagementProvision = null;
                m_ManagementRADIUSConfiguration = null;
                m_ManagementRADIUSServer = null;
                m_ManagementResourceRecord = null;
                m_ManagementSFlowDataSource = null;
                m_ManagementSFlowGlobals = null;
                m_ManagementSFlowReceiver = null;
                m_ManagementSMTPConfiguration = null;
                m_ManagementSNMPConfiguration = null;
                m_ManagementTACACSConfiguration = null;
                m_ManagementTMOSModule = null;
                m_ManagementTrafficGroup = null;
                m_ManagementTrust = null;
                m_ManagementUserManagement = null;
                m_ManagementView = null;
                m_ManagementZone = null;
                m_ManagementZoneRunner = null;

                m_NetworkingAdminIP = null;
                m_NetworkingARP = null;
                m_NetworkingBWControllerPolicy = null;
                m_NetworkingInterfaces = null;
                m_NetworkingIPsecIkeDaemon = null;
                m_NetworkingIPsecIkePeer = null;
                m_NetworkingIPsecManualSecurityAssociation = null;
                m_NetworkingIPsecPolicy = null;
                m_NetworkingIPsecTrafficSelector = null;
                m_NetworkingiSessionAdvertisedRoute = null;
                m_NetworkingiSessionAdvertisedRouteV2 = null;
                m_NetworkingiSessionDatastor = null;
                m_NetworkingiSessionDeduplication = null;
                m_NetworkingiSessionLocalInterface = null;
                m_NetworkingiSessionPeerDiscovery = null;
                m_NetworkingiSessionRemoteInterface = null;
                m_NetworkingiSessionRemoteInterfaceV2 = null;
                m_NetworkingLLDPGlobals = null;
                m_NetworkingMulticastRoute = null;
                m_NetworkingPacketFilter = null;
                m_NetworkingPacketFilterGlobals = null;
                m_NetworkingPortMirror = null;
                m_NetworkingProfileFEC = null;
                m_NetworkingProfileGRE = null;
                m_NetworkingProfileIPIP = null;
                m_NetworkingProfileIPsec = null;
                m_NetworkingProfileLightweight4Over6Tunnel = null;
                m_NetworkingProfileV6RD = null;
                m_NetworkingProfileVXLAN = null;
                m_NetworkingProfileWCCPGRE = null;
                m_NetworkingRouteDomain = null;
                m_NetworkingRouteDomainV2 = null;
                m_NetworkingRouterAdvertisement = null;
                m_NetworkingRouteTable = null;
                m_NetworkingRouteTableV2 = null;
                m_NetworkingSelfIP = null;
                m_NetworkingSelfIPPortLockdown = null;
                m_NetworkingSelfIPV2 = null;
                m_NetworkingSTPGlobals = null;
                m_NetworkingSTPInstance = null;
                m_NetworkingSTPInstanceV2 = null;
                m_NetworkingTrunk = null;
                m_NetworkingTunnel = null;
                m_NetworkingVLAN = null;
                m_NetworkingVLANGroup = null;

                m_PEMFormatScript = null;
                m_PEMForwardingEndpoint = null;
                m_PEMInterceptionEndpoint = null;
                m_PEMListener = null;
                m_PEMPolicy = null;
                m_PEMServiceChainEndpoint = null;
                m_PEMSubscriber = null;

                m_SecurityDoSDevice = null;
                m_SecurityDoSWhitelist = null;
                m_SecurityFirewallAddressList = null;
                m_SecurityFirewallGlobalAdminIPRuleList = null;
                m_SecurityFirewallGlobalRuleList = null;
                m_SecurityFirewallPolicy = null;
                m_SecurityFirewallPortList = null;
                m_SecurityFirewallRuleList = null;
                m_SecurityFirewallWeeklySchedule = null;
                m_SecurityIPIntelligenceBlacklistCategory = null;
                m_SecurityIPIntelligenceFeedList = null;
                m_SecurityIPIntelligenceGlobalPolicy = null;
                m_SecurityIPIntelligencePolicy = null;
                m_SecurityLogProfile = null;
                m_SecurityProfileDNSSecurity = null;
                m_SecurityProfileDoS = null;
                m_SecurityProfileIPIntelligence = null;

                m_SystemCertificateRevocationListFile = null;
                m_SystemCluster = null;
                m_SystemConfigSync = null;
                m_SystemConnections = null;
                m_SystemDisk = null;
                m_SystemExternalMonitorFile = null;
                m_SystemFailover = null;
                m_SystemGeoIP = null;
                m_SystemHAGroup = null;
                m_SystemHAStatus = null;
                m_SystemInet = null;
                m_SystemInternal = null;
                m_SystemLightweightTunnelTableFile = null;
                m_SystemPerformanceSFlow = null;
                m_SystemServices = null;
                m_SystemSession = null;
                m_SystemSoftwareManagement = null;
                m_SystemStatistics = null;
                m_SystemSystemInfo = null;
                m_SystemVCMP = null;

                m_WebAcceleratorApplications = null;
                m_WebAcceleratorPolicies = null;
                m_WebAcceleratorProxyMessage = null;

                // Attempt connection and only return initialized if connection succeeds.

                m_sessionIdentifier = SESSIONID_UNKNOWN;

                m_bInitialized = true;

                if (m_bPingDuringInitialize)
                {
                    String sVersion = SystemSystemInfo.get_version();
                }

            }
            catch (Exception ex)
            {
                m_lastException = ex;
                m_bInitialized = false;
            }
            return m_bInitialized;
        }
Example #49
0
        public FeaEntidades.InterFacturas.lote_comprobantes ConsultarIBK(out List<FeaEntidades.InterFacturas.error> RespErroresLote, out List<FeaEntidades.InterFacturas.error> RespErroresComprobantes, eFact_Tester.IBK.consulta_lote_comprobantes clc, string url, eFact_Tester.Entidades.Certificado Certificado, eFact_Tester.Entidades.Proxy Proxy)
        {
            FeaEntidades.InterFacturas.lote_comprobantes lc = new FeaEntidades.InterFacturas.lote_comprobantes();
            lc.cabecera_lote = new FeaEntidades.InterFacturas.cabecera_lote();
            lc.comprobante = new FeaEntidades.InterFacturas.comprobante[1];
            IBK.error[] respErroresLote = new IBK.error[0];
            IBK.error[] respErroresComprobantes = new IBK.error[0];
			IBK.FacturaWebServiceConSchema objIBK;
			objIBK = new IBK.FacturaWebServiceConSchema();
            objIBK.Url = url;
            if (Proxy != null)
            {
                System.Net.WebProxy wp = new System.Net.WebProxy(Proxy.Servidor, false);
                System.Net.NetworkCredential networkCredential = new System.Net.NetworkCredential(Proxy.Usuario, Proxy.Clave, Proxy.Dominio);
                wp.Credentials = networkCredential;
                objIBK.Proxy = wp;
            }
            X509Store store;
            if (Certificado.LugarDeAlmacenamiento == eFact_Tester.Entidades.Certificado.Almacenamiento.CurrentUser)
            {
                store = new X509Store(StoreLocation.CurrentUser);
            }
            else
            {
                store = new X509Store(StoreLocation.LocalMachine);
            }
            store.Open(OpenFlags.ReadOnly);
            X509Certificate2Collection col = store.Certificates.Find(X509FindType.FindBySerialNumber, Certificado.Numero, true);
            if (col.Count.Equals(1))
            {
                objIBK.ClientCertificates.Add(col[0]);
                System.Threading.Thread.Sleep(1000);
                IBK.consulta_lote_comprobantes_response clcr = objIBK.getLoteFacturasConSchema(clc);
                IBK.consulta_lote_response clr;
                try
                {
                    clr = (IBK.consulta_lote_response)clcr.Item;
                    IBK.lote_comprobantes lcIBK = (IBK.lote_comprobantes)clr.Item;
                    lc = Ibk2Fea(lcIBK);
                }
                catch (InvalidCastException)
                {
                    StringBuilder errorText = new StringBuilder();
                    if (clcr.Item != null)
                    {
                        errorText.Append("Nro. de Lote: [" + clc.id_lote + "] \r\n");
                        if (clcr.Item.GetType() == typeof(IBK.consulta_lote_response))
                        {
                            clr = (IBK.consulta_lote_response)clcr.Item;
                            IBK.consulta_lote_responseErrores_consulta errores = (IBK.consulta_lote_responseErrores_consulta)clr.Item;
                            foreach (IBK.error elote in errores.error)
                            {
                                errorText.Append(elote.codigo_error + " - " + elote.descripcion_error + " \r\n");
                            }
                            RespErroresLote = Ibk2Fea(errores.error);
                        }
                        else
                        {
                            IBK.consulta_lote_comprobantes_responseErrores_response clcrEr;
                            clcrEr = (IBK.consulta_lote_comprobantes_responseErrores_response)clcr.Item;
                            foreach (IBK.error elote in clcrEr.error)
                            {
                                errorText.Append(elote.codigo_error + " - " + elote.descripcion_error + " \r\n");
                            }
                            RespErroresComprobantes = Ibk2Fea(clcrEr.error);
                        }
                    }
                    throw new Exception(errorText.ToString());
                }
                RespErroresLote = new List<FeaEntidades.InterFacturas.error>();
                RespErroresComprobantes = new List<FeaEntidades.InterFacturas.error>();
                return lc;
            }
            else
            {
                throw new Exception("Su certificado no está disponible en nuestro repositorio");
            }
        }
Example #50
0
 public FeaEntidades.InterFacturas.lote_response EnviarIBK(out List<FeaEntidades.InterFacturas.error> RespErroresLote, out List<FeaEntidades.InterFacturas.error> RespErroresComprobantes, FeaEntidades.InterFacturas.lote_comprobantes lc, string url, eFact_Tester.Entidades.Certificado Certificado, eFact_Tester.Entidades.Proxy Proxy)
 {
     FeaEntidades.InterFacturas.lote_response Lr = new FeaEntidades.InterFacturas.lote_response();
     IBK.lote_comprobantes lcIBK = new IBK.lote_comprobantes();
     lcIBK = Fea2Ibk(lc);
     IBK.error[] respErroresLote = new IBK.error[0];
     IBK.error[] respErroresComprobantes = new IBK.error[0];
     IBK.FacturaWebServiceConSchema objIBK;
     objIBK = new IBK.FacturaWebServiceConSchema();
     objIBK.Url = url;
     if (Proxy != null)
     {
         System.Net.WebProxy wp = new System.Net.WebProxy(Proxy.Servidor, false);
         System.Net.NetworkCredential networkCredential = new System.Net.NetworkCredential(Proxy.Usuario, Proxy.Clave, Proxy.Dominio);
         wp.Credentials = networkCredential;
         objIBK.Proxy = wp;
     }
     X509Store store;
     if (Certificado.LugarDeAlmacenamiento == eFact_Tester.Entidades.Certificado.Almacenamiento.CurrentUser)
     {
         store = new X509Store(StoreLocation.CurrentUser);
     }
     else
     {
         store = new X509Store(StoreLocation.LocalMachine);
     }
     store.Open(OpenFlags.ReadOnly);
     X509Certificate2Collection col = store.Certificates.Find(X509FindType.FindBySerialNumber, Certificado.Numero, true);
     if (col.Count.Equals(1))
     {
         objIBK.ClientCertificates.Add(col[0]);
         IBK.lote_comprobantes_response lcr = objIBK.receiveFacturasConSchema(lcIBK);
         IBK.lote_response lr = new IBK.lote_response();
         RespErroresLote = new List<FeaEntidades.InterFacturas.error>();
         RespErroresComprobantes = new List<FeaEntidades.InterFacturas.error>();
         try
         {
             lr = ((IBK.lote_response)lcr.Item);
             if (lr.estado == "OK")
             {
                 Lr = Ibk2Fea(lr);
             }
             else
             {
                 Lr = Ibk2Fea(lr);
                 StringBuilder errorText = new StringBuilder();
                 if (lr.errores_lote != null)
                 {
                     errorText.Append("Nro. de Lote: [" + Lr.id_lote + "] \r\n");
                     foreach (IBK.error elote in lr.errores_lote)
                     {
                         errorText.Append(elote.codigo_error + " - " + elote.descripcion_error + " \r\n");
                     }
                     RespErroresLote.AddRange(Ibk2Fea(lr.errores_lote));
                 }
                 if (lr.comprobante_response != null)
                 {
                     foreach (IBK.comprobante_response comprobante in lr.comprobante_response)
                     {
                         if (comprobante.errores_comprobante != null)
                         {
                             if (lr.errores_lote != null)
                             {
                                 errorText.Append("\r\n");
                             }
                             errorText.Append("Punto de Venta: [" + comprobante.punto_de_venta + "]  Tipo de Comprobante: [" + comprobante.tipo_de_comprobante + "]  Nro. de Comprobante: [" + comprobante.numero_comprobante + "] \r\n");
                             foreach (IBK.error ecomprobante in comprobante.errores_comprobante)
                             {
                                 errorText.Append(ecomprobante.codigo_error + " - " + ecomprobante.descripcion_error + " \r\n");
                             }
                             RespErroresComprobantes.AddRange(Ibk2Fea(comprobante.errores_comprobante));
                         }
                     }
                 }
                 throw new Exception(errorText.ToString());
             }
             return Lr;
         }
         catch (InvalidCastException)
         {
             StringBuilder errorText = new StringBuilder();
             if (lcr.Item != null)
             {
                 if (lcr.Item.GetType() == typeof(IBK.lote_comprobantes_responseErrores_response))
                 {
                     IBK.lote_comprobantes_responseErrores_response lcrEr = new IBK.lote_comprobantes_responseErrores_response();
                     errorText.Append("Nro. de Lote: [" + lc.cabecera_lote.id_lote + "] \r\n");
                     lcrEr = (IBK.lote_comprobantes_responseErrores_response)lcr.Item;
                     foreach (IBK.error error in lcrEr.error)
                     {
                         errorText.Append(error.codigo_error + " - " + error.descripcion_error + " \r\n");
                     }
                     RespErroresLote = Ibk2Fea(lcrEr.error);
                 }
             }
             throw new Exception(errorText.ToString());
         }
     }
     else
     {
         throw new Exception("Su certificado no está disponible en nuestro repositorio");
     }
 }
Example #51
0
        /// <summary>
        /// Attempts to download the Uri and (based on it's MimeType) use the DocumentFactory
        /// to get a Document subclass object that is able to parse the downloaded data.
        /// </summary>
        /// <remarks>
        /// http://www.123aspx.com/redir.aspx?res=28320
        /// </remarks>
        protected Document Download(Uri uri)
        {
            bool success = false;
            // Open the requested URL

            System.Net.WebProxy proxyObject = null;
            if (Preferences.UseProxy)
            {   // [v6] stephenlane80 suggested proxy code
                proxyObject = new System.Net.WebProxy(Preferences.ProxyUrl, true);
                proxyObject.Credentials = System.Net.CredentialCache.DefaultCredentials;
            }
            // [v6] Erick Brown [work] suggested fix for & in querystring
            string unescapedUri = Regex.Replace(uri.AbsoluteUri, @"&amp;amp;", @"&", RegexOptions.IgnoreCase);
            System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(unescapedUri);

            req.AllowAutoRedirect = true;
            req.MaximumAutomaticRedirections = 3;
            req.UserAgent = Preferences.UserAgent; //"Mozilla/6.0 (MSIE 6.0; Windows NT 5.1; Searcharoo.NET; robot)";
            req.KeepAlive = true;
            req.Timeout = Preferences.RequestTimeout * 1000; //prefRequestTimeout
            if (Preferences.UseProxy) req.Proxy = proxyObject; // [v6] stephenlane80

            // SIMONJONES http://codeproject.com/aspnet/spideroo.asp?msg=1421158#xx1421158xx
            req.CookieContainer = new System.Net.CookieContainer();
            req.CookieContainer.Add(_CookieContainer.GetCookies(uri));

            // Get the stream from the returned web response
            System.Net.HttpWebResponse webresponse = null;
            try
            {
                webresponse = (System.Net.HttpWebResponse)req.GetResponse();
            }
            catch (System.Net.WebException we)
            {   //remote url not found, 404; remote url forbidden, 403
                ProgressEvent(this, new ProgressEventArgs(2, "skipped  " + uri.AbsoluteUri + " response exception:" + we.ToString() + ""));
            }

            Document currentUriDocument = null;
            if (webresponse != null)
            {
                /* SIMONJONES */
                /* **************** this doesn't necessarily work yet...
                if (webresponse.ResponseUri != htmldoc.Uri)
                {	// we've been redirected,
                    if (visited.Contains(webresponse.ResponseUri.ToString().ToLower()))
                    {
                        return true;
                    }
                    else
                    {
                        visited.Add(webresponse.ResponseUri.ToString().ToLower());
                    }
                }*/

                try
                {
                    webresponse.Cookies = req.CookieContainer.GetCookies(req.RequestUri);
                    // handle cookies (need to do this in case we have any session cookies)
                    foreach (System.Net.Cookie retCookie in webresponse.Cookies)
                    {
                        bool cookieFound = false;
                        foreach (System.Net.Cookie oldCookie in _CookieContainer.GetCookies(uri))
                        {
                            if (retCookie.Name.Equals(oldCookie.Name))
                            {
                                oldCookie.Value = retCookie.Value;
                                cookieFound = true;
                            }
                        }
                        if (!cookieFound)
                        {
                            _CookieContainer.Add(retCookie);
                        }
                    }
                }
                catch (Exception ex)
                {
                    ProgressEvent(this, new ProgressEventArgs(3, "Cookie processing error : " + ex.Message + ""));
                }
                /* end SIMONJONES */

                currentUriDocument = DocumentFactory.New(uri, webresponse);
                success = currentUriDocument.GetResponse(webresponse);
                webresponse.Close();
                ProgressEvent(this, new ProgressEventArgs(2, "Trying index mime type: " + currentUriDocument.MimeType + " for " + currentUriDocument.Uri + ""));

                _Visited.Add(currentUriDocument.Uri);   // [v7] [email protected] capture redirected Urls
                                                        // relies on Document 'capturing' the final Uri
                                                        // this.Uri = webresponse.ResponseUri;
            }
            else
            {
                ProgressEvent(this, new ProgressEventArgs(2, "No WebResponse for " + uri + ""));
                success = false;
            }
            return currentUriDocument;
        }
        public void loadFromRegistry(String sRequestedHostname)
        {
            migrateOldSettings();
            Microsoft.Win32.RegistryKey cu = Microsoft.Win32.Registry.CurrentUser;
            String accountKey = CONFIG_KEY;

            if (sRequestedHostname.Length > 0)
            {
                accountKey = ACCOUNTS_KEY + "\\" + sRequestedHostname;
            }

            Microsoft.Win32.RegistryKey f5Key = cu.OpenSubKey(accountKey);
            if (null != f5Key)
            {
                Object obj = null;
                if (null != (obj = f5Key.GetValue("Hostname")))
                {
                    m_hostname = Convert.ToString(obj);
                }
                if (null != (obj = f5Key.GetValue("Port")))
                {
                    m_port = Convert.ToInt32(obj);
                }
                if (null != (obj = f5Key.GetValue("Username")))
                {
                    m_username = Convert.ToString(obj);
                }
                if (null != (obj = f5Key.GetValue("UseProxy")))
                {
                    if (null != (obj = f5Key.GetValue("ProxyHost")))
                    {
                        String address = Convert.ToString(obj);
                        int port = 8080;

                        if (null != (obj = f5Key.GetValue("ProxyPort")))
                        {
                            port = Convert.ToInt32(obj);
                        }
                        m_proxy = new System.Net.WebProxy(address, port);

                        if (null != (obj = f5Key.GetValue("ProxyUser")))
                        {
                            m_proxy.Credentials = new System.Net.NetworkCredential();
                            ((System.Net.NetworkCredential)m_proxy.Credentials).UserName = Convert.ToString(obj);
                        }
                        else
                        {
                            m_proxy.UseDefaultCredentials = true;
                        }
                    }
                }
                else
                {
                    m_proxy = null;
                }
                f5Key.Close();
            }
        }
Example #53
0
        public static string EnviarIBK(FeaEntidades.InterFacturas.lote_comprobantes lc, string certificado)
        {
            IBK.lote_comprobantes lcIBK = new IBK.lote_comprobantes();
            lcIBK = Fea2Ibk(lc);

            IBK.FacturaWebServiceConSchema objIBK;
            objIBK = new IBK.FacturaWebServiceConSchema();
            objIBK.Url = System.Configuration.ConfigurationManager.AppSettings["URLinterfacturas"];
            if (System.Configuration.ConfigurationManager.AppSettings["Proxy"] != null && System.Configuration.ConfigurationManager.AppSettings["Proxy"] != "")
            {
                System.Net.WebProxy wp = new System.Net.WebProxy(System.Configuration.ConfigurationManager.AppSettings["Proxy"], false);
                string usuarioProxy = System.Configuration.ConfigurationManager.AppSettings["UsuarioProxy"];
                string claveProxy = System.Configuration.ConfigurationManager.AppSettings["ClaveProxy"];
                string dominioProxy = System.Configuration.ConfigurationManager.AppSettings["DominioProxy"];

                System.Net.NetworkCredential networkCredential = new System.Net.NetworkCredential(usuarioProxy, claveProxy, dominioProxy);
                wp.Credentials = networkCredential;
                objIBK.Proxy = wp;
            }
            string storeLocation = System.Configuration.ConfigurationManager.AppSettings["StoreLocation"];
            X509Store store;
            if (storeLocation == "CurrentUser")
            {
                store = new X509Store(StoreLocation.CurrentUser);
            }
            else
            {
                store = new X509Store(StoreLocation.LocalMachine);
            }
            store.Open(OpenFlags.ReadOnly);
            X509Certificate2Collection col = store.Certificates.Find(X509FindType.FindBySerialNumber, certificado, true);
            if (col.Count.Equals(1))
            {
                objIBK.ClientCertificates.Add(col[0]);
                System.Threading.Thread.Sleep(1000);
                IBK.lote_comprobantes_response lcr = objIBK.receiveFacturasConSchema(lcIBK);

                string resultado = string.Empty;
                if (lcr.Item.GetType() == typeof(IBK.lote_comprobantes_responseErrores_response))
                {
                    resultado = ((IBK.lote_comprobantes_responseErrores_response)lcr.Item).error[0].descripcion_error;
                }
                else if (!((IBK.lote_response)(lcr.Item)).estado.Equals("OK"))
                {
                    if (((IBK.lote_response)lcr.Item).errores_lote != null)
                    {
                        resultado += "Lote Nro.: " + ((IBK.lote_response)lcr.Item).id_lote + "  Estado: " + ((IBK.lote_response)lcr.Item).estado + "\\n";
                        foreach (IBK.error error in ((IBK.lote_response)lcr.Item).errores_lote)
                        {
                            resultado += error.codigo_error + " - " + error.descripcion_error + "\\n";
                        }
                        resultado += "\\n";
                    }
                    if (((IBK.lote_response)lcr.Item).comprobante_response != null)
                    {
                        foreach (IBK.comprobante_response cr in ((IBK.lote_response)lcr.Item).comprobante_response)
                        {
                            if (cr.errores_comprobante != null)
                            {
                                resultado += "Comprobante Nro.: " + cr.numero_comprobante + "\\n";
                                foreach (IBK.error error in cr.errores_comprobante)
                                {
                                    resultado += error.codigo_error + " - " + error.descripcion_error + "\\n";
                                }
                            }
                        }
                        resultado += "\\n";
                    }
                    throw new Exception(resultado);
                }
                else
                {
                    resultado = "Comprobante enviado satisfactoriamente a Interfacturas.";
                }
                return resultado;
            }
            else
            {
                throw new Exception("Su certificado no está disponible en nuestro repositorio");
            }
        }
        private void StartOAuth_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                TwitterClient TC = new TwitterClient(App.consumer_key, App.consumer_secret);
                if (UseProxyCheckBox.IsChecked.Value)
                {
                    var proxy = new System.Net.WebProxy(ProxyAddress.Text, Convert.ToInt32(ProxyPortNumber.Text));
                    if (!(String.IsNullOrEmpty(ProxyUsername.Text) || String.IsNullOrEmpty(ProxyPasswordBox.Password)))
                    {
                        proxy.Credentials = new System.Net.NetworkCredential(ProxyUsername.Text, ProxyPasswordBox.Password);
                    }
                    TC.Proxy = proxy;
                }
                string token;
                string tokensecret = "";
                TC.GetRequestToken(out token);
                string url = TC.RedirectToAuthorize(token);
                MessageBox.Show("将打开默认浏览器以获取PIN,请确认你的浏览器能正确连接Twitter(你懂的)", "即将跳转", MessageBoxButton.OK);
                System.Diagnostics.Process.Start(url);

                string PIN = PinInputWindow.PinBox();

                TC.GetAccessToken(ref token, ref tokensecret, PIN);
                UsernameBox.Text = token;
                PasswordBox.Password = tokensecret;
            }
            catch (Exception ex)
            {
                MessageBox.Show("出错啦\n" + ex.ToString(), "出错啦");
            }
        }
Example #55
0
        public void ExecuteChecking()
        {
            StringBuilder sb = new StringBuilder();
            foreach (ProxyInfo objProxyInfo in m_ProxyInfoList)            
            {                
                sb.Remove(0, sb.Length);

                if (!objProxyInfo.HaveGet)
                {
                    objProxyInfo.HaveGet = true;
                    m_ProxyForm.SetText(string.Format("线程[{3}]{0}={1}:{2}校验中...\r\n", objProxyInfo.Name, objProxyInfo.Address, objProxyInfo.Port,Thread.CurrentThread.Name));
                    /*
                     * 校验过程
                     */
                    try
                    {
                        System.Net.WebProxy objWebProxy = new System.Net.WebProxy(objProxyInfo.Address, objProxyInfo.Port);
                        sb.Append(Conn.PostData(m_TestPageUrl, m_TestPageCharset, "", m_TestPageUrl, 10000, objWebProxy));

                        RegexFunc rFunc = new RegexFunc();
                        if (sb.ToString().IndexOf("Jyi链接失败") < 0 && "124.207.144.194" != rFunc.GetMatch(sb.ToString(), "您的IP地址是:\\[(.*)\\] 来自\\:"))
                        {
                            m_ProxyForm.objProxyInfoListOK.Add(objProxyInfo);//添加成功的代理
                            m_ProxyForm.SetText(string.Format("{0}={1}:{2}成功!\r\n", objProxyInfo.Name, objProxyInfo.Address, objProxyInfo.Port));
                        }
                        else
                        {
                            m_ProxyForm.SetText(string.Format("{0}={1}:{2}失败!\r\n", objProxyInfo.Name, objProxyInfo.Address, objProxyInfo.Port));
                        }
                    }
                    catch (System.UriFormatException ex)
                    {
                        m_ProxyForm.SetText(string.Format("{0}={1}:{2}无效!\r\n", objProxyInfo.Name, objProxyInfo.Address, objProxyInfo.Port));
                    }
                }

            }
            m_ProxyForm.SetText(string.Format("没有待校验的列表,线程[{0}]结束!\r\n",Thread.CurrentThread.Name));
            m_ProxyForm.finishedThreadCount++;//报告线程结束.
            Thread.CurrentThread.Abort();

            //测试是否终止
            m_ProxyForm.SetText(string.Format("没有待校验的列表,当前线程结束了么?"));
        }
Example #56
0
 public static void ApplyGlobalHTTPProxy(bool forceDefault)
 {
     try
     {
         if(Project.useProxy)
         {
             System.Net.WebProxy proxy	= new System.Net.WebProxy(Project.proxyServer, Project.proxyPort);
             proxy.BypassProxyOnLocal = true;
             System.Net.GlobalProxySelection.Select = proxy;
         }
         else if(Project.forceEmptyProxy)
         {
             System.Net.GlobalProxySelection.Select = System.Net.GlobalProxySelection.GetEmptyWebProxy();
         }
         else if(forceDefault)
         {
             System.Net.GlobalProxySelection.Select = System.Net.WebProxy.GetDefaultProxy();
         }
     }
     catch
     {
     }
 }
Example #57
0
        public static string ValidarIBK(string lc, string certificado)
        {
            RN.IBKValidate.ValidaFacturaWebService objIBK = new RN.IBKValidate.ValidaFacturaWebService();
            objIBK.Url = System.Configuration.ConfigurationManager.AppSettings["URLinterfacturasValidate"];
            if (System.Configuration.ConfigurationManager.AppSettings["Proxy"] != null && System.Configuration.ConfigurationManager.AppSettings["Proxy"] != "")
            {
                System.Net.WebProxy wp = new System.Net.WebProxy(System.Configuration.ConfigurationManager.AppSettings["Proxy"], false);
                string usuarioProxy = System.Configuration.ConfigurationManager.AppSettings["UsuarioProxy"];
                string claveProxy = System.Configuration.ConfigurationManager.AppSettings["ClaveProxy"];
                string dominioProxy = System.Configuration.ConfigurationManager.AppSettings["DominioProxy"];

                System.Net.NetworkCredential networkCredential = new System.Net.NetworkCredential(usuarioProxy, claveProxy, dominioProxy);
                wp.Credentials = networkCredential;
                objIBK.Proxy = wp;
            }
            string storeLocation = System.Configuration.ConfigurationManager.AppSettings["StoreLocation"];
            X509Store store;
            if (storeLocation == "CurrentUser")
            {
                store = new X509Store(StoreLocation.CurrentUser);
            }
            else
            {
                store = new X509Store(StoreLocation.LocalMachine);
            }
            store.Open(OpenFlags.ReadOnly);
            X509Certificate2Collection col = store.Certificates.Find(X509FindType.FindBySerialNumber, certificado, true);
            
            FeaEntidades.InterFacturas.Validar.lote_response lr = new FeaEntidades.InterFacturas.Validar.lote_response();
            if (col.Count.Equals(1))
            {
                objIBK.ClientCertificates.Add(col[0]);
                System.Threading.Thread.Sleep(1000);
                
                string resultado = string.Empty;
                resultado = objIBK.validateFacturas(lc);

                resultado = resultado.Replace("\n", "");
                resultado = resultado.Replace("<lote_comprobantes_response xmlns=\"http://lote.schemas.cfe.ib.com.ar/\">", "");
                resultado = resultado.Replace("</lote_comprobantes_response>", "");

                string xml = resultado;
                var serializer = new System.Xml.Serialization.XmlSerializer(typeof(FeaEntidades.InterFacturas.Validar.lote_response));
                using (TextReader reader = new StringReader(xml))
                {
                    lr = (FeaEntidades.InterFacturas.Validar.lote_response)serializer.Deserialize(reader);
                }

                resultado = "";
                if (!(lr.estado.Equals("OK")))
                {
                    resultado += "Lote Nro.: " + lr.id_lote + "  Estado: " + lr.estado + "\\n";
                    if (lr.errores_lote != null)
                    {
                        if (lr.errores_lote[0] != null)
                        {
                            foreach (FeaEntidades.InterFacturas.Validar.error error in lr.errores_lote)
                            {

                                resultado += error.codigo_error + " - " + error.descripcion_error + "\\n";
                            }
                        }
                    }
                    resultado += "\\n";
                    if (lr.comprobante_response != null)
                    {
                        if (lr.comprobante_response[0] != null)
                        {
                            foreach (FeaEntidades.InterFacturas.Validar.comprobante_response c in lr.comprobante_response)
                            {
                                resultado += "Comprobante Nro.: " + c.numero_comprobante + "  Estado: " + c.estado + "\\n";
                                foreach (FeaEntidades.InterFacturas.Validar.error errorc in c.errores_comprobante)
                                {
                                    resultado += errorc.codigo_error + " - " + errorc.descripcion_error + "\\n";
                                }
                                resultado += "\\n";
                            }
                        }
                    }
                }
                else
                {
                    resultado = "Comprobante validado satisfactoriamente en Interfacturas.";
                }
                return resultado;
            }
            else
            {
                throw new Exception("Su certificado no está disponible en nuestro repositorio");
            }
        }
 public void setWebProxy(System.Net.WebProxy proxy)
 {
     m_proxy = proxy;
 }
Example #59
0
        /// <summary>
        /// Initializes a new layer, and downloads and parses the service description
        /// </summary>
        /// <param name="layername">Layername</param>
        /// <param name="url">Url of WMS server's Capabilties</param>
        /// <param name="cachetime">Time for caching Service Description (ASP.NET only)</param>
        /// <param name="proxy">Proxy</param>
        public TiledWmsLayer(string layername, string url, TimeSpan cachetime, System.Net.WebProxy proxy)
        {
            _Proxy = proxy;
            _TimeOut = 10000;
            this.LayerName = layername;
            _ContinueOnError = true;

            if (System.Web.HttpContext.Current != null && System.Web.HttpContext.Current.Cache["SharpMap_WmsClient_" + url] != null)
            {
                _WmsClient = (Client)System.Web.HttpContext.Current.Cache["SharpMap_WmsClient_" + url];
            }
            else
            {
                _WmsClient = new Client(url, _Proxy);
                if (System.Web.HttpContext.Current != null)
                    System.Web.HttpContext.Current.Cache.Insert("SharpMap_WmsClient_" + url, _WmsClient, null,
                      System.Web.Caching.Cache.NoAbsoluteExpiration, cachetime);

            }
            _TileSets = TileSet.ParseVendorSpecificCapabilitiesNode(_WmsClient.VendorSpecificCapabilities);
        }
Example #60
0
        public static string ComprobanteDetalleIBK(FeaEntidades.InterFacturas.Detalle.consulta_emisor_comprobante_detalle cecd, string certificado)
        {
            RN.IBKComprobantesListado.ReporteFacturaWebService objIBK = new RN.IBKComprobantesListado.ReporteFacturaWebService();
            objIBK.Url = System.Configuration.ConfigurationManager.AppSettings["URLinterfacturasListado"];
            if (System.Configuration.ConfigurationManager.AppSettings["Proxy"] != null && System.Configuration.ConfigurationManager.AppSettings["Proxy"] != "")
            {
                System.Net.WebProxy wp = new System.Net.WebProxy(System.Configuration.ConfigurationManager.AppSettings["Proxy"], false);
                string usuarioProxy = System.Configuration.ConfigurationManager.AppSettings["UsuarioProxy"];
                string claveProxy = System.Configuration.ConfigurationManager.AppSettings["ClaveProxy"];
                string dominioProxy = System.Configuration.ConfigurationManager.AppSettings["DominioProxy"];

                System.Net.NetworkCredential networkCredential = new System.Net.NetworkCredential(usuarioProxy, claveProxy, dominioProxy);
                wp.Credentials = networkCredential;
                objIBK.Proxy = wp;
            }
            string storeLocation = System.Configuration.ConfigurationManager.AppSettings["StoreLocation"];
            X509Store store;

            if (storeLocation == "CurrentUser")
            {
                store = new X509Store(StoreLocation.CurrentUser);
            }
            else
            {
                store = new X509Store(StoreLocation.LocalMachine);
            }
            store.Open(OpenFlags.ReadOnly);

            //Serializar ( pasar de FeaEntidades.InterFacturas.consulta_emisor_comprobante_listado a String XML )
            MemoryStream ms = new MemoryStream();
            XmlTextWriter writer = new XmlTextWriter(ms, System.Text.Encoding.GetEncoding("ISO-8859-1"));
            System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(cecd.GetType());
            x.Serialize(writer, cecd);
            ms = (MemoryStream)writer.BaseStream;
            string InputTexto = ByteArrayToString(ms.ToArray());
            ms.Close();
            ms = null;

            X509Certificate2Collection col = store.Certificates.Find(X509FindType.FindBySerialNumber, certificado, true);
            if (col.Count.Equals(1))
            {
                objIBK.ClientCertificates.Add(col[0]);
                System.Threading.Thread.Sleep(1000);
                string resultado = string.Empty;
                resultado = objIBK.getComprobanteDetalle(InputTexto);

                
                //XmlTextWriter writer = new XmlTextWriter(ms, System.Text.Encoding.GetEncoding("ISO-8859-1"));
                resultado = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + resultado;
                //resultado = resultado.Replace("\n", "");
                resultado = resultado.Replace("<consulta_emisor_comprobante_detalle_response xmlns=\"http://lote.schemas.cfe.ib.com.ar/\">", "");
                resultado = resultado.Replace("</consulta_emisor_comprobante_detalle_response>", "");
                resultado = resultado.Replace("<consulta_emisor_detalle_response>", "");
                resultado = resultado.Replace("</consulta_emisor_detalle_response>", "");

                resultado = resultado.Replace("<comprobante>", "<comprobante xmlns=\"http://lote.schemas.cfe.ib.com.ar/\">");
                resultado = resultado.Replace(" xsi:nil=\"true\"", "");
                resultado = resultado.Replace("https://qacfe.interbanking.com.ar/cfeWeb/LogoService?idlogo=", "https://srv1.interfacturas.com.ar/cfeWeb/LogoService?idlogo=");
                
                ////Deserializar
                //FeaEntidades.InterFacturas.Listado.consulta_emisor_listado_response lr = new FeaEntidades.InterFacturas.Listado.consulta_emisor_listado_response();
                //string xml = resultado;
                //var serializer = new System.Xml.Serialization.XmlSerializer(typeof(FeaEntidades.InterFacturas.Listado.consulta_emisor_listado_response));
                //using (TextReader reader = new StringReader(xml))
                //{
                //    lr = (FeaEntidades.InterFacturas.Listado.consulta_emisor_listado_response)serializer.Deserialize(reader);
                //}


                //if (lcr.Item.GetType() == typeof(IBK.lote_comprobantes_responseErrores_response))
                //{
                //    resultado = ((IBK.lote_comprobantes_responseErrores_response)lcr.Item).error[0].descripcion_error;
                //}
                //else if (!((IBK.lote_response)(lcr.Item)).estado.Equals("OK"))
                //{
                //    if (((IBK.lote_response)lcr.Item).errores_lote != null)
                //    {
                //        resultado = ((IBK.lote_response)lcr.Item).errores_lote[0].descripcion_error;
                //    }
                //    else
                //    {
                //        resultado = ((IBK.lote_response)lcr.Item).comprobante_response[0].errores_comprobante[0].descripcion_error;
                //    }
                //    throw new Exception(resultado);
                //}
                //else
                //{
                //    resultado = "Comprobante enviado satisfactoriamente a Interfacturas.";
                //}
                return resultado;
            }
            else
            {
                throw new Exception("Su certificado no está disponible en nuestro repositorio");
            }
        }