public ResAcc <string> CancelarFactura(string sUuid, string sRfc, byte[] ArchivoPfx, string sContraseniaPfx) { var Res = new ResAcc <string>(); try { var oServicio = new Edicom.CFDiService(); // Se manda cancelar la factura, prueba o normal if (this.Prueba) { Res.Respuesta = "Resultado de prueba. No hay mecanismo de cancelación en Edicom."; } else { CancelaResponse oCancel = oServicio.cancelaCFDi(this.Usuario, this.Contrasenia, sRfc, new string[] { sUuid }, ArchivoPfx, sContraseniaPfx); Res.Respuesta = oCancel.ack; } Res.Exito = true; } catch (Exception e) { Res.Mensaje = e.Message; } return(Res); }
ICancelaResponse ICFDIService.CancelaCFDI(string user, string password, string rfc, string[] uuid, byte[] pfx, string pfxPassword) { // throw new NotImplementedException(); var response = new CancelaResponse { ack = "CANCELADO_PRUEBA_NO_VALIDO", text = "~CANCELADO_PRUEBA_NO_VALIDO", uuids = uuid.ToList() }; //CancelaResponse response = this.cancelaCFDi(user, password, rfc, uuid, pfx, pfxPassword); CancelaResponseBase responseBase = new CancelaResponseBase(); responseBase.Ack = response.ack; responseBase.Text = response.text; System.Collections.Generic.List <string> uuidsList = new System.Collections.Generic.List <string>(); foreach (string uuidItem in response.uuids) { uuidsList.Add(uuidItem); } responseBase.UUIDs = uuidsList.ToArray(); System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(response.GetType()); MemoryStream ms = new MemoryStream(); XmlWriterSettings settings = new XmlWriterSettings(); settings.Encoding = new UTF8Encoding(); XmlWriter xmlWriter = XmlWriter.Create(ms, settings); x.Serialize(xmlWriter, response); string xmlContent = Encoding.UTF8.GetString(ms.GetBuffer()); responseBase.XmlResponse = xmlContent; return(responseBase); }
ICancelaResponse ICFDIService.CancelaCFDI(string user, string password, string rfc, string[] uuid, byte[] pfx, string pfxPassword) { // throw new NotImplementedException(); var response = new CancelaResponse { ack = "CANCELADO_PRUEBA_NO_VALIDO", text = "~CANCELADO_PRUEBA_NO_VALIDO", uuids = uuid.ToList() }; //CancelaResponse response = this.cancelaCFDi(user, password, rfc, uuid, pfx, pfxPassword); CancelaResponseBase responseBase = new CancelaResponseBase(); responseBase.Ack = response.ack; responseBase.Text = response.text; System.Collections.Generic.List<string> uuidsList = new System.Collections.Generic.List<string>(); foreach (string uuidItem in response.uuids) { uuidsList.Add(uuidItem); } responseBase.UUIDs = uuidsList.ToArray(); System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(response.GetType()); MemoryStream ms = new MemoryStream(); XmlWriterSettings settings = new XmlWriterSettings(); settings.Encoding = new UTF8Encoding(); XmlWriter xmlWriter = XmlWriter.Create(ms, settings); x.Serialize(xmlWriter, response); string xmlContent = Encoding.UTF8.GetString(ms.GetBuffer()); responseBase.XmlResponse = xmlContent; return responseBase; }