示例#1
0
        protected void ActualizarEstadoButton_Click(object sender, EventArgs e)
        {
            string NroCertif = "";
            NroCertif = ((Entidades.Sesion)Session["Sesion"]).Cuit.NroSerieCertifITF;
            if (NroCertif.Equals(string.Empty))
            {
                ScriptManager.RegisterClientScriptBlock(this, GetType(), "Message", Funciones.TextoScript("Aún no disponemos de su certificado digital."), false);
                return;
            }
            try
            {
                Entidades.Comprobante comprobante = (Entidades.Comprobante)Session["comprobantePDF"];
                if (comprobante != null)
                {
                    string certificado = "";
                    certificado = CaptchaDotNet2.Security.Cryptography.Encryptor.Encrypt(NroCertif, "srgerg$%^bg", Convert.FromBase64String("srfjuoxp")).ToString();

                    //Consultar y Actualizar estado on-line.                              
                    org.dyndns.cedweb.consulta.ConsultaIBK clcdyndnsConsultaIBK = new org.dyndns.cedweb.consulta.ConsultaIBK();
                    string ConsultaIBKUtilizarServidorExterno = System.Configuration.ConfigurationManager.AppSettings["ConsultaIBKUtilizarServidorExterno"];
                    RN.Sesion.GrabarLogTexto(Server.MapPath("~/Consultar.txt"), "Parametro ConsultaIBKUtilizarServidorExterno: " + ConsultaIBKUtilizarServidorExterno);
                    if (ConsultaIBKUtilizarServidorExterno == "SI")
                    {
                        clcdyndnsConsultaIBK.Url = System.Configuration.ConfigurationManager.AppSettings["ConsultaIBKurl"];
                        RN.Sesion.GrabarLogTexto(Server.MapPath("~/Consultar.txt"), "Parametro ConsultaIBKurl: " + System.Configuration.ConfigurationManager.AppSettings["ConsultaIBKurl"]);
                    }
                    System.Threading.Thread.Sleep(2000);
                    org.dyndns.cedweb.consulta.ConsultarResult clcrdyndns = new org.dyndns.cedweb.consulta.ConsultarResult();
                    clcrdyndns = clcdyndnsConsultaIBK.Consultar(Convert.ToInt64(comprobante.Cuit), comprobante.NroLote, comprobante.NroPuntoVta, certificado);
                    FeaEntidades.InterFacturas.lote_comprobantes lc = new FeaEntidades.InterFacturas.lote_comprobantes();
                    lc = Funciones.Ws2Fea(clcrdyndns);
                    string XML = "";
                    RN.Comprobante.SerializarLc(out XML, lc);
                    //c.Leer(comprobante, ((Entidades.Sesion)Session["Sesion"]));
                    comprobante.Response = XML;
                    if (lc.cabecera_lote.resultado == "A")
                    {
                        comprobante.WF.Estado = "Vigente";
                        RN.Comprobante.Actualizar(comprobante, (Entidades.Sesion)Session["Sesion"]);
                        RN.Comprobante.Leer(comprobante, ((Entidades.Sesion)Session["Sesion"]));
                        Session["comprobantePDF"] = comprobante;
                        ActualizarEstadoPanel.Visible = false;
                        DescargarPDFPanel.Visible = true;
                    }
                    else if (lc.cabecera_lote.resultado == "R")
                    {
                        comprobante.WF.Estado = "Rechazado";
                        RN.Comprobante.Actualizar(comprobante, (Entidades.Sesion)Session["Sesion"]);
                        RN.Comprobante.Leer(comprobante, ((Entidades.Sesion)Session["Sesion"]));
                        Session["comprobantePDF"] = comprobante;
                        ActualizarEstadoPanel.Visible = false;
                        DescargarPDFPanel.Visible = false;
                    }
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterClientScriptBlock(this, GetType(), "Message", Funciones.TextoScript("Problemas al enviar el comprobante a Interfacturas.  " + ex.Message), false);
            }
        }
示例#2
0
        protected void AccionSubirAInterfacturasButton_Click(object sender, EventArgs e)
        {
            if (Funciones.SessionTimeOut(Session))
            {
                Response.Redirect("~/SessionTimeout.aspx");
            }
            else
            {
                Entidades.Sesion sesion = (Entidades.Sesion)Session["Sesion"];
                ActualizarEstadoPanel.Visible = false;
                DescargarPDFPanel.Visible = false;
                //ActualizarEstadoButton.DataBind();
                //DescargarPDFButton.DataBind();
                if (sesion.Usuario.Id == null)
                {
                    ScriptManager.RegisterClientScriptBlock(this, GetType(), "Message", Funciones.TextoScript("Su sesión ha caducado por inactividad. Por favor vuelva a loguearse."), false);
                }
                else
                {
                    try
                    {
                        string NroCertif = "";
                        NroCertif = sesion.Cuit.NroSerieCertifITF;
                        if (NroCertif.Equals(string.Empty))
                        {
                            ScriptManager.RegisterClientScriptBlock(this, GetType(), "Message", Funciones.TextoScript("Aún no disponemos de su certificado digital."), false);
                            return;
                        }
                        try
                        {
                            if (ValidarCamposObligatorios(""))
                            {
                                string certificado = "";
                                string respuesta = "";
                                certificado = CaptchaDotNet2.Security.Cryptography.Encryptor.Encrypt(NroCertif, "srgerg$%^bg", Convert.FromBase64String("srfjuoxp")).ToString();
                                org.dyndns.cedweb.envio.EnvioIBK edyndns = new org.dyndns.cedweb.envio.EnvioIBK();
                                string EnvioIBKUtilizarServidorExterno = System.Configuration.ConfigurationManager.AppSettings["EnvioIBKUtilizarServidorExterno"];
                                if (EnvioIBKUtilizarServidorExterno == "SI")
                                {
                                    edyndns.Url = System.Configuration.ConfigurationManager.AppSettings["EnvioIBKurl"];
                                }
                                org.dyndns.cedweb.envio.lc lcIBK = new org.dyndns.cedweb.envio.lc();
                                FeaEntidades.InterFacturas.lote_comprobantes lcFea = GenerarLote(false);

                                //Grabar en base de datos
                                lcFea.cabecera_lote.DestinoComprobante = "ITF";
                                lcFea.comprobante[0].cabecera.informacion_comprobante.Observacion = "";
                                RN.Comprobante.Registrar(lcFea, null, IdNaturalezaComprobanteTextBox.Text, "ITF", "PteEnvio", PeriodicidadEmisionDropDownList.SelectedValue, DateTime.ParseExact(FechaProximaEmisionDatePickerWebUserControl.Text, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture), Convert.ToInt32(CantidadComprobantesAEmitirTextBox.Text), Convert.ToInt32(CantidadComprobantesEmitidosTextBox.Text), Convert.ToInt32(CantidadDiasFechaVtoTextBox.Text), string.Empty, false, string.Empty, string.Empty, string.Empty, sesion);

                                AjustarLoteParaITF(lcFea); 

                                lcIBK = Conversor.Entidad2IBK(lcFea);

                                respuesta = edyndns.EnviarIBK(lcIBK, certificado);

                                //VIEJO MODO DE USO
                                //certificado = NroCertif;
                                //FeaEntidades.InterFacturas.lote_comprobantes lcFea = GenerarLote();
                                //respuesta = RN.Comprobante.EnviarIBK(lcFea, certificado);

                                respuesta = respuesta.Replace("'", "-");

                                ScriptManager.RegisterClientScriptBlock(this, GetType(), "Message", Funciones.TextoScript(respuesta), false);

                                if (respuesta == "Comprobante enviado satisfactoriamente a Interfacturas.")
                                {
                                    Entidades.Comprobante comprobante = new Entidades.Comprobante();
                                    comprobante.Cuit = lcFea.comprobante[0].cabecera.informacion_vendedor.cuit.ToString();
                                    comprobante.TipoComprobante.Id = lcFea.comprobante[0].cabecera.informacion_comprobante.tipo_de_comprobante;
                                    comprobante.NroPuntoVta = lcFea.comprobante[0].cabecera.informacion_comprobante.punto_de_venta;
                                    comprobante.Nro = lcFea.comprobante[0].cabecera.informacion_comprobante.numero_comprobante;
                                    RN.Comprobante.Leer(comprobante, sesion);
                                    comprobante.WF.Estado = "PteConf";
                                    RN.Comprobante.Actualizar(comprobante, sesion);
                                    RN.Comprobante.Leer(comprobante, sesion);
                                    //Consultar y Actualizar estado on-line.                              
                                    org.dyndns.cedweb.consulta.ConsultaIBK clcdyndnsConsultaIBK = new org.dyndns.cedweb.consulta.ConsultaIBK();
                                    string ConsultaIBKUtilizarServidorExterno = System.Configuration.ConfigurationManager.AppSettings["ConsultaIBKUtilizarServidorExterno"];
                                    RN.Sesion.GrabarLogTexto(Server.MapPath("~/Consultar.txt"), "Parametro ConsultaIBKUtilizarServidorExterno: " + ConsultaIBKUtilizarServidorExterno);
                                    if (ConsultaIBKUtilizarServidorExterno == "SI")
                                    {
                                        clcdyndnsConsultaIBK.Url = System.Configuration.ConfigurationManager.AppSettings["ConsultaIBKurl"];
                                        RN.Sesion.GrabarLogTexto(Server.MapPath("~/Consultar.txt"), "Parametro ConsultaIBKurl: " + System.Configuration.ConfigurationManager.AppSettings["ConsultaIBKurl"]);
                                    }
                                    System.Threading.Thread.Sleep(2000);
                                    org.dyndns.cedweb.consulta.ConsultarResult clcrdyndns = new org.dyndns.cedweb.consulta.ConsultarResult();
                                    clcrdyndns = clcdyndnsConsultaIBK.Consultar(Convert.ToInt64(lcFea.comprobante[0].cabecera.informacion_vendedor.cuit), lcFea.cabecera_lote.id_lote, lcFea.comprobante[0].cabecera.informacion_comprobante.punto_de_venta, certificado);
                                    FeaEntidades.InterFacturas.lote_comprobantes lc = new FeaEntidades.InterFacturas.lote_comprobantes();
                                    lc = Funciones.Ws2Fea(clcrdyndns);
                                    string XML = "";
                                    RN.Comprobante.SerializarLc(out XML, lc);
                                    comprobante.Response = XML;
                                    if (lc.cabecera_lote.resultado == "A")
                                    {
                                        comprobante.WF.Estado = "Vigente";
                                        RN.Comprobante.Actualizar(comprobante, sesion);
                                        RN.Comprobante.Leer(comprobante, sesion);
                                        Session["comprobantePDF"] = comprobante;
                                        ActualizarEstadoPanel.Visible = false;
                                        DescargarPDFPanel.Visible = true;
                                    }
                                    else if (lc.cabecera_lote.resultado == "R")
                                    {
                                        comprobante.WF.Estado = "Rechazado";
                                        RN.Comprobante.Actualizar(comprobante, sesion);
                                        RN.Comprobante.Leer(comprobante, sesion);
                                        Session["comprobantePDF"] = comprobante;
                                        ActualizarEstadoPanel.Visible = false;
                                        DescargarPDFPanel.Visible = false;
                                    }
                                }
                                else
                                {
                                    ScriptManager.RegisterClientScriptBlock(this, GetType(), "Message", Funciones.TextoScript("Problemas al enviar el comprobante a Interfacturas. " + Funciones.TextoScript(respuesta)), false);
                                }
                            }
                        }
                        catch (System.Web.Services.Protocols.SoapException soapEx)
                        {
                            try
                            {
                                XmlDocument doc = new XmlDocument();
                                doc.LoadXml(soapEx.Detail.OuterXml);
                                XmlNamespaceManager nsManager = new
                                    XmlNamespaceManager(doc.NameTable);
                                nsManager.AddNamespace("errorNS",
                                    "http://www.cedeira.com.ar/webservices");
                                XmlNode Node =
                                    doc.DocumentElement.SelectSingleNode("errorNS:Error", nsManager);
                                string errorNumber =
                                    Node.SelectSingleNode("errorNS:ErrorNumber",
                                    nsManager).InnerText;
                                string errorMessage =
                                    Node.SelectSingleNode("errorNS:ErrorMessage",
                                    nsManager).InnerText;
                                string errorSource =
                                    Node.SelectSingleNode("errorNS:ErrorSource",
                                    nsManager).InnerText;
                                ScriptManager.RegisterClientScriptBlock(this, GetType(), "Message", Funciones.TextoScript(soapEx.Actor.Trim() + ": " + errorMessage), false);
                            }
                            catch (Exception)
                            {
                                throw soapEx;
                            }
                        }

                    }
                    catch (Exception ex)
                    {
                        ScriptManager.RegisterClientScriptBlock(this, GetType(), "Message", Funciones.TextoScript("Problemas al enviar el comprobante a Interfacturas.  " + ex.Message), false);
                    }
                }
            }
        }
        protected void ComprobantesGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "ConsultaOnLine")
            {
                int item = Convert.ToInt32(e.CommandArgument);
                List <FeaEntidades.InterFacturas.Listado.emisor_comprobante_listado> lista = (List <FeaEntidades.InterFacturas.Listado.emisor_comprobante_listado>)ViewState["Comprobantes"];
                FeaEntidades.InterFacturas.Listado.emisor_comprobante_listado        elem  = lista[item];
                try
                {
                    string NroCertif = ((Entidades.Sesion)Session["Sesion"]).Cuit.NroSerieCertifITF;
                    if (NroCertif.Equals(string.Empty))
                    {
                        MensajeLabel.Text = "Aún no disponemos de su certificado digital";
                        return;
                    }
                    GrabarLogTexto("~/Consultar.txt", "Consulta de Lote CUIT: " + ((Entidades.Sesion)Session["Sesion"]).Cuit.Nro + "  Nro.Lote: " + elem.id_lote + "  Nro. Punto de Vta.: " + elem.punto_de_venta);
                    GrabarLogTexto("~/Consultar.txt", "NroSerieCertifITF: " + NroCertif);
                    if (NroCertif.Equals(string.Empty))
                    {
                        MensajeLabel.Text = "Aún no disponemos de su certificado digital";
                        return;
                    }

                    string certificado = CaptchaDotNet2.Security.Cryptography.Encryptor.Encrypt(NroCertif, "srgerg$%^bg", Convert.FromBase64String("srfjuoxp")).ToString();
                    org.dyndns.cedweb.consulta.ConsultaIBK clcdyndns = new org.dyndns.cedweb.consulta.ConsultaIBK();
                    string ConsultaIBKUtilizarServidorExterno        = System.Configuration.ConfigurationManager.AppSettings["ConsultaIBKUtilizarServidorExterno"];
                    GrabarLogTexto("~/Consultar.txt", "Parametro ConsultaIBKUtilizarServidorExterno: " + ConsultaIBKUtilizarServidorExterno);
                    if (ConsultaIBKUtilizarServidorExterno == "SI")
                    {
                        clcdyndns.Url = System.Configuration.ConfigurationManager.AppSettings["ConsultaIBKurl"];
                        GrabarLogTexto("~/Consultar.txt", "Parametro ConsultaIBKurl: " + System.Configuration.ConfigurationManager.AppSettings["ConsultaIBKurl"]);
                    }
                    org.dyndns.cedweb.consulta.ConsultarResult clcrdyndns = new org.dyndns.cedweb.consulta.ConsultarResult();
                    clcrdyndns = clcdyndns.Consultar(Convert.ToInt64(((Entidades.Sesion)Session["Sesion"]).Cuit.Nro), elem.id_lote, elem.punto_de_venta, certificado);
                    //Entidades.Comprobante comprobante = new Entidades.Comprobante();
                    Session["ComprobanteATratar"] = new Entidades.ComprobanteATratar(Entidades.Enum.TratamientoComprobante.ConsultaITF, clcrdyndns);
                    string script = "window.open('/ComprobanteConsulta.aspx', '');";
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "popup", script, true);
                }
                catch (System.Web.Services.Protocols.SoapException soapEx)
                {
                    try
                    {
                        XmlDocument doc = new XmlDocument();
                        doc.LoadXml(soapEx.Detail.OuterXml);
                        XmlNamespaceManager nsManager = new
                                                        XmlNamespaceManager(doc.NameTable);
                        nsManager.AddNamespace("errorNS",
                                               "http://www.cedeira.com.ar/webservices");
                        XmlNode Node =
                            doc.DocumentElement.SelectSingleNode("errorNS:Error", nsManager);
                        string errorNumber =
                            Node.SelectSingleNode("errorNS:ErrorNumber",
                                                  nsManager).InnerText;
                        string errorMessage =
                            Node.SelectSingleNode("errorNS:ErrorMessage",
                                                  nsManager).InnerText;
                        string errorSource =
                            Node.SelectSingleNode("errorNS:ErrorSource",
                                                  nsManager).InnerText;
                        MensajeLabel.Text = soapEx.Actor + " : " + errorMessage.Replace("\r", "").Replace("\n", "");
                    }
                    catch (Exception)
                    {
                        throw soapEx;
                    }
                }
            }
        }
示例#4
0
		protected void ConsultarLoteIBKButton_Click(object sender, EventArgs e)
		{
			using (FileStream fs = File.Open(Server.MapPath("~/Consultar.txt"), FileMode.Append, FileAccess.Write))
			{
				using (StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8))
				{
					sw.WriteLine("Consulta de:" + Cuit_VendedorTextBox.Text);
				}
			}
			if (CedWebRN.Fun.NoEstaLogueadoUnUsuarioPremium((CedWebEntidades.Sesion)Session["Sesion"]))
			{
				if (!MonedaComprobanteDropDownList.Enabled)
				{
					ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('Esta funcionalidad es exclusiva del SERVICIO PREMIUM.  Contáctese con Cedeira Software Factory para acceder al servicio.');</script>");
				}
				else
				{
					ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('Su sesión ha caducado por inactividad. Por favor vuelva a loguearse.')</script>");
				}
			}
			else
			{
				try
				{
					if (Cuit_VendedorTextBox.Text.Equals(string.Empty))
					{
						ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('Falta ingresar el CUIT del vendedor');</script>");
						return;
					}
					if (Id_LoteTextbox.Text.Equals(string.Empty))
					{
						ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('Falta ingresar el nro de lote');</script>");
						return;
					}
					if (Punto_VentaTextBox.Text.Equals(string.Empty))
					{
						ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('Falta ingresar el punto de venta');</script>");
						return;
					}


					CedWebEntidades.Cuenta cta = ((CedWebEntidades.Sesion)Session["Sesion"]).Cuenta;

					if (cta.NroSerieCertificado.Equals(string.Empty))
					{
						ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('Aún no disponemos de su certificado digital.');</script>");
						return;
					}

					string certificado = CaptchaDotNet2.Security.Cryptography.Encryptor.Encrypt(cta.NroSerieCertificado, "srgerg$%^bg", Convert.FromBase64String("srfjuoxp")).ToString();

					//Ir por WS
					org.dyndns.cedweb.consulta.ConsultaIBK clcdyndns = new org.dyndns.cedweb.consulta.ConsultaIBK();

					org.dyndns.cedweb.consulta.ConsultarResult clcrdyndns = new org.dyndns.cedweb.consulta.ConsultarResult();
					clcrdyndns = clcdyndns.Consultar(Convert.ToInt64(Cuit_VendedorTextBox.Text), Convert.ToInt64(Id_LoteTextbox.Text), Convert.ToInt32(Punto_VentaTextBox.Text), certificado);

					CompletarUI(clcrdyndns, e);

				}
				catch (System.Web.Services.Protocols.SoapException soapEx)
				{
					try
					{
						XmlDocument doc = new XmlDocument();
						doc.LoadXml(soapEx.Detail.OuterXml);
						XmlNamespaceManager nsManager = new
							XmlNamespaceManager(doc.NameTable);
						nsManager.AddNamespace("errorNS",
							"http://www.cedeira.com.ar/webservices");
						XmlNode Node =
							doc.DocumentElement.SelectSingleNode("errorNS:Error", nsManager);
						string errorNumber =
							Node.SelectSingleNode("errorNS:ErrorNumber",
							nsManager).InnerText;
						string errorMessage =
							Node.SelectSingleNode("errorNS:ErrorMessage",
							nsManager).InnerText;
						string errorSource =
							Node.SelectSingleNode("errorNS:ErrorSource",
							nsManager).InnerText;
						ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('" + soapEx.Actor + " : " + errorMessage.Replace("\r", "").Replace("\n", "") + "');</script>");
					}
					catch (Exception)
					{
						throw soapEx;
					}
				}
				catch (System.Security.Cryptography.CryptographicException ex)
				{
					using (FileStream fs = File.Open(Server.MapPath("~/ConsultarErrores.txt"), FileMode.Append, FileAccess.Write))
					{
						using (StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8))
						{
							sw.WriteLine("Consulta de:" + Cuit_VendedorTextBox.Text);
							sw.WriteLine(ex.Message);
							sw.WriteLine(ex.StackTrace);
							if (ex.InnerException != null)
							{
								sw.WriteLine(ex.InnerException.Message);
							}
						}
					}
					ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('" + ex.Message.Replace("\r", "").Replace("\n", "") + "');</script>");
				}
				catch (Exception ex)
				{
					ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('Problemas al consultar a Interfacturas.\\n " + ex.Message.Replace("\n", "") + "');</script>");
				}
			}
		}
示例#5
0
        protected void ConsultarLoteIBKButton_Click(object sender, EventArgs e)
        {
            if (((Entidades.Sesion)Session["Sesion"]).Usuario.Id == null)
            {
                MensajeLabel.Text = "Su sesión ha caducado por inactividad. Por favor vuelva a loguearse";
            }
            else
            {
                try
                {
                    string NroCertif = ((Entidades.Sesion)Session["Sesion"]).Cuit.NroSerieCertifITF;
                    if (NroCertif.Equals(string.Empty))
                    {
                        MensajeLabel.Text = "Aún no disponemos de su certificado digital";
                        return;
                    }
                    if (CuitConsultaTextBox.Text.Equals(string.Empty))
                    {
                        MensajeLabel.Text = "Falta ingresar el CUIT del vendedor";
                        return;
                    }
                    if (NroLoteConsultaTextBox.Text.Equals(string.Empty))
                    {
                        MensajeLabel.Text = "Falta ingresar el nro de lote";
                        return;
                    }
                    if (PtoVtaConsultaDropDownList.SelectedValue.Equals("0") || PtoVtaConsultaDropDownList.SelectedValue.Equals(string.Empty))
                    {
                        MensajeLabel.Text = "Falta ingresar el punto de venta";
                        return;
                    }
                    GrabarLogTexto("~/Consultar.txt", "Consulta de Lote CUIT: " + CuitConsultaTextBox.Text + "  Nro.Lote: " + NroLoteConsultaTextBox.Text + "  Nro. Punto de Vta.: " + PtoVtaConsultaDropDownList.SelectedValue);
                    GrabarLogTexto("~/Consultar.txt", "NroSerieCertifITF: " + NroCertif);
                    if (NroCertif.Equals(string.Empty))
                    {
                        MensajeLabel.Text = "Aún no disponemos de su certificado digital";
                        return;
                    }

                    string certificado = CaptchaDotNet2.Security.Cryptography.Encryptor.Encrypt(NroCertif, "srgerg$%^bg", Convert.FromBase64String("srfjuoxp")).ToString();
                    org.dyndns.cedweb.consulta.ConsultaIBK clcdyndns = new org.dyndns.cedweb.consulta.ConsultaIBK();
                    string ConsultaIBKUtilizarServidorExterno        = System.Configuration.ConfigurationManager.AppSettings["ConsultaIBKUtilizarServidorExterno"];
                    GrabarLogTexto("~/Consultar.txt", "Parametro ConsultaIBKUtilizarServidorExterno: " + ConsultaIBKUtilizarServidorExterno);
                    if (ConsultaIBKUtilizarServidorExterno == "SI")
                    {
                        clcdyndns.Url = System.Configuration.ConfigurationManager.AppSettings["ConsultaIBKurl"];
                        GrabarLogTexto("~/Consultar.txt", "Parametro ConsultaIBKurl: " + System.Configuration.ConfigurationManager.AppSettings["ConsultaIBKurl"]);
                    }
                    org.dyndns.cedweb.consulta.ConsultarResult clcrdyndns = new org.dyndns.cedweb.consulta.ConsultarResult();
                    clcrdyndns = clcdyndns.Consultar(Convert.ToInt64(CuitConsultaTextBox.Text), Convert.ToInt64(NroLoteConsultaTextBox.Text), Convert.ToInt32(PtoVtaConsultaDropDownList.SelectedValue), certificado);
                    Session["ComprobanteATratar"] = new Entidades.ComprobanteATratar(Entidades.Enum.TratamientoComprobante.ConsultaITF, clcrdyndns);
                    string script = "window.open('/ComprobanteConsulta.aspx', '');";
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "popup", script, true);
                }
                catch (System.Web.Services.Protocols.SoapException soapEx)
                {
                    try
                    {
                        XmlDocument doc = new XmlDocument();
                        doc.LoadXml(soapEx.Detail.OuterXml);
                        XmlNamespaceManager nsManager = new
                                                        XmlNamespaceManager(doc.NameTable);
                        nsManager.AddNamespace("errorNS",
                                               "http://www.cedeira.com.ar/webservices");
                        XmlNode Node =
                            doc.DocumentElement.SelectSingleNode("errorNS:Error", nsManager);
                        string errorNumber =
                            Node.SelectSingleNode("errorNS:ErrorNumber",
                                                  nsManager).InnerText;
                        string errorMessage =
                            Node.SelectSingleNode("errorNS:ErrorMessage",
                                                  nsManager).InnerText;
                        string errorSource =
                            Node.SelectSingleNode("errorNS:ErrorSource",
                                                  nsManager).InnerText;
                        MensajeLabel.Text = soapEx.Actor + " : " + errorMessage.Replace("\r", "").Replace("\n", "");
                    }
                    catch (Exception)
                    {
                        throw soapEx;
                    }
                }
                catch (System.Security.Cryptography.CryptographicException ex)
                {
                    using (FileStream fs = File.Open(Server.MapPath("~/ConsultarErrores.txt"), FileMode.Append, FileAccess.Write))
                    {
                        using (StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8))
                        {
                            sw.WriteLine("Consulta de:" + ((Entidades.Sesion)Session["Sesion"]).Cuit.Nro.ToString());
                            sw.WriteLine(ex.Message);
                            sw.WriteLine(ex.StackTrace);
                            if (ex.InnerException != null)
                            {
                                sw.WriteLine(ex.InnerException.Message);
                            }
                        }
                    }
                    MensajeLabel.Text = ex.Message.Replace("\r", "").Replace("\n", "");
                }
                catch (Exception ex)
                {
                    string errormsg = ex.Message.Replace("\n", "");
                    if (ex.InnerException != null)
                    {
                        try
                        {
                            errormsg = errormsg + " " + ((System.Net.Sockets.SocketException)ex.InnerException).ErrorCode;
                        }
                        catch
                        {
                        }
                        errormsg = errormsg + " " + ex.InnerException.Message.Replace("\n", "");
                    }
                    errormsg          = errormsg.Replace("'", "").Replace("\r", " ");
                    MensajeLabel.Text = "Problemas al consultar a Interfacturas.\\n " + errormsg;
                }
            }
        }