public ServiciosPlataformasTecnologicas DesSerializarSPT(XElement element, ref string erroECC) { try { IEnumerable <XElement> ImpL = element.Elements(this._ns999 + "Complemento"); ServiciosPlataformasTecnologicas result; if (ImpL != null) { IEnumerable <XElement> pag = ImpL.Elements(this._ns49 + "ServiciosPlataformasTecnologicas"); using (IEnumerator <XElement> enumerator = pag.GetEnumerator()) { if (enumerator.MoveNext()) { XElement e = enumerator.Current; XmlSerializer ser = new XmlSerializer(typeof(ServiciosPlataformasTecnologicas)); string xml = e.ToString(); StringReader reader = new StringReader(xml); ServiciosPlataformasTecnologicas comLXMLComprobante = (ServiciosPlataformasTecnologicas)ser.Deserialize(reader); result = comLXMLComprobante; return(result); } } result = null; } else { result = null; } return(result); } catch (Exception ex) { erroECC = ex.InnerException.Message; return(null); } }
public string TimbraRetencion(string comprobante, string userName, string password, string LLave, string aplicacion) { string result; try { CertificadorService.Logger.Debug(userName); if (aplicacion == "CON") { var Licencia = ValidarLicencia(LLave); if (Licencia == false) { return("Licencia no valida"); } } MembershipUser x = NtLinkLogin.ValidateUser(userName, password); if (x == null) { throw new FaultException("Nombre de usuario o contraseña incorrecta"); } XElement element = XElement.Load(new StringReader(comprobante)); Retenciones comp = TimbradoUtils.DesSerializarRetenciones(element); empresa empres = new empresa(); if (comp.Emisor != null && comp.Emisor.RFCEmisor != null) { string vemp = ValidarUsuario(comp.Emisor.RFCEmisor, x, ref empres); if (vemp != "OK") { return(vemp); } } else { return("Error: Los datos del emisor incompletos"); } //------------------------- if (comprobante.Contains("<planesderetiro11:Planesderetiro")) { Planesderetiro Plan = this.DesSerializarPR(element); ValidarPR validar = new ValidarPR(); string errorPR = validar.ProcesarPR(Plan); if (errorPR != "0") { result = errorPR; return(result); } } if (comprobante.Contains("<plataformasTecnologicas:ServiciosPlataformasTecnologicas")) { ServicioLocal.Business.ComplementoRetencion.Retenciones retencion = this.DesSerializarRetencion(element); string erroECC = ""; ServiciosPlataformasTecnologicas E2 = this.DesSerializarSPT(element, ref erroECC); ValidarSPT VE2 = new ValidarSPT(); erroECC = VE2.ProcesarSPT(E2, retencion); if (erroECC != "0") { result = erroECC; return(result); } } result = TimbradoUtils.TimbraRetencionString(comprobante, empres, true, true); } catch (FaultException ex) { result = ex.Message; } catch (Exception ex2) { result = "Error al abrir el comprobante"; } return(result); }