Esempio n. 1
0
 private static void ValidarUrl(string Url, eFact_Tester.Entidades.Certificado Certificado, System.Net.WebProxy Wp)
 {
     IBK.FacturaWebServiceConSchema objIBK;
     objIBK = new IBK.FacturaWebServiceConSchema();
     objIBK.Url = Url;
     if (Wp != null)
     {
         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]);
         object o = objIBK.getLoteFacturasConSchema(new eFact_Tester.IBK.consulta_lote_comprobantes());
     }
     else
     {
         throw new Exception("Certificado no encontrado. Nro.Serie: " + Certificado.Numero);
     }
 }
Esempio n. 2
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");
            }
        }