public void CompletarWS(org.dyndns.cedweb.consulta.ConsultarResult lc) { if (lc.comprobante[0].resumen.impuestos != null) { impuestos = new System.Collections.Generic.List <FeaEntidades.InterFacturas.resumenImpuestos>(); foreach (org.dyndns.cedweb.consulta.ConsultarResultComprobanteResumenImpuestos imp in lc.comprobante[0].resumen.impuestos) { if (imp.importe_impuesto_moneda_origenSpecified) { imp.importe_impuesto = imp.importe_impuesto_moneda_origen; } FeaEntidades.InterFacturas.resumenImpuestos ri = new FeaEntidades.InterFacturas.resumenImpuestos(); ri.codigo_impuesto = imp.codigo_impuesto; ri.codigo_jurisdiccion = imp.codigo_jurisdiccion; ri.codigo_jurisdiccionSpecified = imp.codigo_jurisdiccionSpecified; ri.descripcion = imp.descripcion; ri.importe_impuesto = imp.importe_impuesto; ri.importe_impuesto_moneda_origen = imp.importe_impuesto_moneda_origen; ri.importe_impuesto_moneda_origenSpecified = imp.importe_impuesto_moneda_origenSpecified; ri.jurisdiccion_municipal = imp.jurisdiccion_municipal; ri.porcentaje_impuesto = imp.porcentaje_impuesto; ri.porcentaje_impuestoSpecified = imp.porcentaje_impuestoSpecified; impuestos.Add(ri); } if (impuestos.Count.Equals(0)) { impuestos.Add(new FeaEntidades.InterFacturas.resumenImpuestos()); } impuestosGridView.DataSource = impuestos; impuestosGridView.DataBind(); ViewState["impuestos"] = impuestos; } }
public void CompletarDetallesWS(org.dyndns.cedweb.consulta.ConsultarResult lc) { if (lc.comprobante[0].resumen.descuentos != null) { descuentos = new System.Collections.Generic.List <FeaEntidades.InterFacturas.resumenDescuentos>(); foreach (org.dyndns.cedweb.consulta.ConsultarResultComprobanteResumenDescuentos r in lc.comprobante[0].resumen.descuentos) { if (r.importe_descuento_moneda_origenSpecified) { r.importe_descuento = r.importe_descuento_moneda_origen; } FeaEntidades.InterFacturas.resumenDescuentos rd = new FeaEntidades.InterFacturas.resumenDescuentos(); rd.alicuota_iva_descuento = r.alicuota_iva_descuento; rd.alicuota_iva_descuentoSpecified = r.alicuota_iva_descuentoSpecified; rd.descripcion_descuento = r.descripcion_descuento; rd.importe_descuento = r.importe_descuento; rd.importe_descuento_moneda_origen = r.importe_descuento_moneda_origen; rd.importe_descuento_moneda_origenSpecified = r.importe_descuento_moneda_origenSpecified; rd.importe_iva_descuento = r.importe_iva_descuento; rd.importe_iva_descuento_moneda_origen = r.importe_iva_descuento_moneda_origen; rd.importe_iva_descuento_moneda_origenSpecified = r.importe_iva_descuento_moneda_origenSpecified; rd.importe_iva_descuentoSpecified = r.importe_iva_descuentoSpecified; rd.porcentaje_descuento = r.porcentaje_descuento; rd.porcentaje_descuentoSpecified = r.porcentaje_descuentoSpecified; descuentos.Add(rd); } if (descuentos.Count.Equals(0)) { descuentos.Add(new FeaEntidades.InterFacturas.resumenDescuentos()); } descuentosGridView.DataSource = descuentos; descuentosGridView.DataBind(); ViewState["descuentos"] = descuentos; } }
public void CompletarDetallesWS(org.dyndns.cedweb.consulta.ConsultarResult lc) { lineas = new System.Collections.Generic.List <FeaEntidades.InterFacturas.linea>(); foreach (org.dyndns.cedweb.consulta.ConsultarResultComprobanteDetalleLinea l in lc.comprobante[0].detalle.linea) { FeaEntidades.InterFacturas.linea linea = new FeaEntidades.InterFacturas.linea(); //Compatibilidad con archivos xml viejos. Verificar si la descripcion está en Hexa. if (l.descripcion != "" && l.descripcion.Substring(0, 1) == "%") { linea.descripcion = RN.Funciones.HexToString(l.descripcion).Replace("<br>", System.Environment.NewLine); } else { linea.descripcion = l.descripcion.Replace("<br>", System.Environment.NewLine); } if (l.alicuota_ivaSpecified) { linea.alicuota_iva = l.alicuota_iva; } else { linea.alicuota_iva = new FeaEntidades.IVA.SinInformar().Codigo; } linea.alicuota_ivaSpecified = l.alicuota_ivaSpecified; linea.importe_ivaSpecified = l.importe_ivaSpecified; if (l.unidad != null) { linea.unidad = l.unidad; } else { linea.unidad = Convert.ToString(new FeaEntidades.CodigosUnidad.SinInformar().Codigo); } linea.cantidad = l.cantidad; linea.cantidadSpecified = l.cantidadSpecified; linea.codigo_producto_comprador = l.codigo_producto_comprador; linea.codigo_producto_vendedor = l.codigo_producto_vendedor; linea.indicacion_exento_gravado = l.indicacion_exento_gravado; if (l.importes_moneda_origen == null) { linea.importe_total_articulo = l.importe_total_articulo; linea.importe_iva = l.importe_iva; linea.precio_unitario = l.precio_unitario; linea.precio_unitarioSpecified = l.precio_unitarioSpecified; } else { linea.importe_total_articulo = l.importes_moneda_origen.importe_total_articulo; linea.importe_iva = l.importes_moneda_origen.importe_iva; linea.precio_unitario = l.importes_moneda_origen.precio_unitario; linea.precio_unitarioSpecified = l.importes_moneda_origen.precio_unitarioSpecified; } lineas.Add(linea); } detalleGridView.DataSource = lineas; detalleGridView.DataBind(); BindearDropDownLists(); ViewState["lineas"] = lineas; }
public void CompletarWS(org.dyndns.cedweb.consulta.ConsultarResult lc) { if (lc.comprobante[0].cabecera.informacion_comprobante.referencias != null) { referencias = new System.Collections.Generic.List <FeaEntidades.InterFacturas.informacion_comprobanteReferencias>(); foreach (org.dyndns.cedweb.consulta.ConsultarResultComprobanteCabeceraInformacion_comprobanteReferencias r in lc.comprobante[0].cabecera.informacion_comprobante.referencias) { FeaEntidades.InterFacturas.informacion_comprobanteReferencias referencia = new FeaEntidades.InterFacturas.informacion_comprobanteReferencias(); referencia.codigo_de_referencia = r.codigo_de_referencia; referencia.dato_de_referencia = r.dato_de_referencia; List <FeaEntidades.CodigosReferencia.CodigoReferencia> listaCR = new List <FeaEntidades.CodigosReferencia.CodigoReferencia>(); List <FeaEntidades.CodigosReferencia.Exportaciones.Exportacion> listaCRExpo = new List <FeaEntidades.CodigosReferencia.Exportaciones.Exportacion>(); string idtipo = ((Entidades.Sesion) Session["Sesion"]).UN.PuntosVta.Find(delegate(Entidades.PuntoVta pv) { return(pv.Nro == Convert.ToInt32(puntoDeVenta)); }).IdTipoPuntoVta; switch (idtipo) { case "Comun": case "RG2904": case "BonoFiscal": listaCR = FeaEntidades.CodigosReferencia.CodigoReferencia.Lista(); referencia.descripcioncodigo_de_referencia = listaCR.Find(delegate(FeaEntidades.CodigosReferencia.CodigoReferencia cr) { return(cr.Codigo == r.codigo_de_referencia.ToString()); }).Descr; break; case "Exportacion": listaCRExpo = FeaEntidades.CodigosReferencia.Exportaciones.Exportacion.Lista(); referencia.descripcioncodigo_de_referencia = listaCRExpo.Find(delegate(FeaEntidades.CodigosReferencia.Exportaciones.Exportacion cr) { return(cr.Codigo == r.codigo_de_referencia.ToString()); }).Descr; break; default: throw new Exception("Tipo de punto de venta no contemplado en la lógica de la aplicación (" + idtipo + ")"); } referencias.Add(referencia); } if (referencias.Count.Equals(0)) { referencias.Add(new FeaEntidades.InterFacturas.informacion_comprobanteReferencias()); } referenciasGridView.DataSource = referencias; referenciasGridView.DataBind(); ViewState["referencias"] = referencias; } }
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); } }
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 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>"); } } }
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; } } } }
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; } } }