public void ActualizarEstadoComprobante(dto.ComprobanteByIdRequest request, byte estado) { var comprobante = new dom.Comprobante().BuscarPorId(request.IdComprobante); comprobante.Estado = estado; new dom.Comprobante().Modificar(comprobante); }
public string GenerarComprobanteElectronicoPago(dto.ComprobanteElectronicoRequest req) { string URL_BASE = "http://13.68.199.98/wssCustomerETDLoadASPUBL21/CustomerETDLoadASP.asmx"; //string url = URL_BASE + "/" + NombreMetodo; string url = URL_BASE; WebRequest request = WebRequest.Create(url); request.Method = "POST"; request.ContentType = "text/xml; charset=utf-8;"; string postData = req.Xml; byte[] byteArray = Encoding.ASCII.GetBytes(postData); request.ContentLength = byteArray.Length; using (var writeStream = request.GetRequestStream()) { writeStream.Write(byteArray, 0, byteArray.Length); } var xmlDocRequest = new XmlDocument(); xmlDocRequest.LoadXml(req.Xml); var nombreArchivo = "Archivos/ruc_" + req.Ruc + "_" + req.Serie + "_" + req.Folio + "_" + DateTime.Now.ToString("yyyy-MM-dd_HH_mm_ss") + ".xml"; xmlDocRequest.Save(nombreArchivo); string responseFromServer = string.Empty; string CodigoError = string.Empty; string Mensajes = string.Empty; string TrackId = string.Empty; using (var response = (HttpWebResponse)request.GetResponse()) { var respuestita = response.GetResponseStream(); StreamReader reader = new StreamReader(respuestita); responseFromServer = reader.ReadToEnd(); var xmlDoc = new XmlDocument(); xmlDoc.LoadXml(responseFromServer); CodigoError = xmlDoc.GetElementsByTagName("Codigo")[0].InnerText; Mensajes = xmlDoc.GetElementsByTagName("Mensajes")[0].InnerText; TrackId = xmlDoc.GetElementsByTagName("TrackId")[0].InnerText; } string respuesta = string.Empty; if (CodigoError == "DOK") { dto.ComprobanteByIdRequest requestComprobante = new dto.ComprobanteByIdRequest(); requestComprobante.IdComprobante = req.IdComprobante; new app.Comprobante().ActualizarEstadoComprobante(requestComprobante, 2); respuesta = "El documento ha sido procesado con exito"; } else { respuesta = "Ha ocurrido un problema con el envio del documento.\nInfo:" + Mensajes; } return(respuesta); }
public string GenerarAnulacionComprobanteElectronicoPago(dto.ComprobanteAnulacionElectronicaRequest req) { string URL_BASE = "http://13.68.199.98/wssCargaBajas/cargaBajas.asmx"; string url = URL_BASE; WebRequest request = WebRequest.Create(url); request.Method = "POST"; request.ContentType = "text/xml; charset=utf-8;"; string postData = req.Xml; byte[] byteArray = Encoding.ASCII.GetBytes(postData); request.ContentLength = byteArray.Length; using (var writeStream = request.GetRequestStream()) { writeStream.Write(byteArray, 0, byteArray.Length); } string responseFromServer = string.Empty; string CodigoError = string.Empty; string Mensajes = string.Empty; string TrackId = string.Empty; using (var response = (HttpWebResponse)request.GetResponse()) { var respuestita = response.GetResponseStream(); StreamReader reader = new StreamReader(respuestita); responseFromServer = reader.ReadToEnd(); var xmlDoc = new XmlDocument(); xmlDoc.LoadXml(responseFromServer); CodigoError = xmlDoc.GetElementsByTagName("Codigo")[0].InnerText; Mensajes = xmlDoc.GetElementsByTagName("Mensajes")[0].InnerText; TrackId = xmlDoc.GetElementsByTagName("TrackId")[0].InnerText; var nombreArchivo = "Logs/" + req.Ruc + "_" + req.Serie + "_" + req.Folio + "_" + DateTime.Now.ToString("yyyy-MM-dd_HH_mm_ss") + ".log"; System.IO.File.WriteAllText(nombreArchivo, Mensajes); } string respuesta = string.Empty; //if (CodigoError.IndexOf("Error") == -1) //{ dto.ComprobanteByIdRequest requestComprobante = new dto.ComprobanteByIdRequest(); requestComprobante.IdComprobante = req.IdComprobante; new app.Comprobante().AnularComprobante(req, 5); respuesta = "El documento ha sido procesado con exito"; //} //else //{ // respuesta.Mensaje = "Ha ocurrido un problema con el envio del documento.\nInfo:" + Mensajes; //} return(respuesta); }
public ent.Comprobante ObtenerComprobanteById(dto.ComprobanteByIdRequest request) { var comprobante = new dom.Comprobante().BuscarPorId(request.IdComprobante); comprobante.Comprobantedetalle = new dom.ComprobanteDetalles().Buscar(c => c.ComprobanteId == request.IdComprobante); var Resultado = Mapper.Map <dato.Comprobante, ent.Comprobante>(comprobante); Resultado.ComprobanteTipoNombre = new dom.TablaDato().BuscarPrimero(c => c.Relacion == "comprobantetipo" && c.Value == Resultado.ComprobanteTipoId.ToString()).Nombre; Resultado.EstadoNombre = new dom.TablaDato().BuscarPrimero(c => c.Relacion == "comprobanteestado" && c.Value == Resultado.Estado.ToString()).Nombre; Resultado.MedioPagoNombre = new dom.TablaDato().BuscarPrimero(c => c.Relacion == "MedioPago" && c.Value == Resultado.MedioPago.ToString()).Nombre; if (comprobante.TipoOperacionId.HasValue) { Resultado.TipoOperacionNombre = new dom.TablaDato().BuscarPrimero(c => c.Relacion == "TipoOperacion" && Convert.ToInt32(c.Value) == Resultado.TipoOperacionId).Nombre; } if (!String.IsNullOrEmpty(comprobante.DetraccionId)) { Resultado.DetraccionNombre = new dom.TablaDato().BuscarPrimero(c => c.Relacion == "Detraccion" && c.Value == Resultado.DetraccionId).Nombre; } if (!String.IsNullOrEmpty(comprobante.TipoNotaId)) { string relacionTipoNota = string.Empty; if (Resultado.ComprobanteTipoId == 7) { relacionTipoNota = "tiponotacredito"; } if (Resultado.ComprobanteTipoId == 8) { relacionTipoNota = "tiponotadebito"; } Resultado.TipoNotaNombre = new dom.TablaDato().BuscarPrimero(c => c.Relacion == relacionTipoNota && c.Value == comprobante.TipoNotaId).Nombre; } Resultado.HoraEmisionDate = DateTime.Now; return(Resultado); }
public ent.Comprobante ObtenerComprobanteById(dto.ComprobanteByIdRequest request) { return(new app.Comprobante().ObtenerComprobanteById(request)); }