private Planesderetiro DesSerializarPR(XElement element) { IEnumerable <XElement> ImpL = element.Elements(this._ns999 + "Complemento"); Planesderetiro result; if (ImpL != null) { IEnumerable <XElement> pag = ImpL.Elements(this._ns48 + "Planesderetiro"); using (IEnumerator <XElement> enumerator = pag.GetEnumerator()) { if (enumerator.MoveNext()) { XElement e = enumerator.Current; XmlSerializer ser = new XmlSerializer(typeof(Planesderetiro)); string xml = e.ToString(); StringReader reader = new StringReader(xml); Planesderetiro comLXMLComprobante = (Planesderetiro)ser.Deserialize(reader); result = comLXMLComprobante; return(result); } } result = null; } else { result = null; } return(result); }
public string ProcesarPR(Planesderetiro pr) { string result; try { if (pr.MontTotRetiradoAnioInmAntPerSpecified && !pr.MontTotExentRetiradoAnioInmAntSpecified) { result = "PDR101 - El atributo “MontTotExentRetiradoAnioInmAnt” debe de existir"; } else if (pr.MontTotRetiradoAnioInmAntPerSpecified && !pr.MontTotExedenteAnioInmAntSpecified) { result = "PDR102 - El atributo “MontTotExedenteAnioInmAnt” debe de existir"; } else if (pr.MontTotRetiradoAnioInmAnt != pr.MontTotExentRetiradoAnioInmAnt + pr.MontTotExedenteAnioInmAnt) { result = "PDR103 - El valor de este campo debe ser igual a la suma de “MontTotExentRetiradoAnioInmAnt” mas “MontTotExedenteAnioInmAnt”"; } else { if (pr.AportacionesODepositos != null && pr.AportacionesODepositos.Count > 0) { List <string> L = new List <string>(); foreach (PlanesderetiroAportacionesODepositos a in pr.AportacionesODepositos) { if (L.Count == 0) { L.Add(a.TipoAportacionODeposito.ToString()); } else { foreach (string i in L) { if (i == a.TipoAportacionODeposito.ToString()) { result = "PDR104 - El valor de cada uno de los campos “TipoAportacionODeposito” debe ser diferente entre si."; return(result); } } L.Add(a.TipoAportacionODeposito.ToString()); } } } result = "0"; } } catch (Exception ex) { result = "PDR999 - Error no clasificado"; } return(result); }
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); }