/// <summary>
 /// Deserializes workflow markup into an ComprobanteComplemento object
 /// </summary>
 /// <param name="input">string workflow markup to deserialize</param>
 /// <param name="obj">Output ComprobanteComplemento object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this Serializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string input, out ComprobanteComplemento obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(ComprobanteComplemento);
     try
     {
         obj = Deserialize(input);
         return(true);
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return(false);
     }
 }
Exemplo n.º 2
0
        public bool GenerarXML(out String XML, out String Errores)
        {
            XML     = String.Empty;
            Errores = String.Empty;
            bool Resultado = false;

            try
            {
                if (Pagos != null)
                {
                    XmlDocument doc         = new XmlDocument();
                    String      XMLPago     = String.Empty;
                    String      ErroresPago = String.Empty;
                    if (Pagos.GenerarXML(out XMLPago, out ErroresPago))
                    {
                        doc.LoadXml(XMLPago);
                        ComprobanteComplemento ComPago = new ComprobanteComplemento();
                        ComPago.Any.Add(doc.DocumentElement);
                        if (Complemento == null)
                        {
                            Complemento = new List <ComprobanteComplemento>();
                        }
                        Complemento.Add(ComPago);
                    }
                    else
                    {
                        Errores += ErroresPago;
                    }
                }

                if (ImpuestosLocales != null)
                {
                    XmlDocument doc           = new XmlDocument();
                    String      XMLImpLoc     = String.Empty;
                    String      ErroresImpLoc = String.Empty;
                    if (ImpuestosLocales.GenerarXML(out XMLImpLoc, out ErroresImpLoc))
                    {
                        doc.LoadXml(XMLImpLoc);
                        ComprobanteComplemento ComImpLoc = new ComprobanteComplemento();
                        ComImpLoc.Any.Add(doc.DocumentElement);
                        if (Complemento == null)
                        {
                            Complemento = new List <ComprobanteComplemento>();
                        }
                        Complemento.Add(ComImpLoc);
                    }
                    else
                    {
                        Errores += ErroresImpLoc;
                    }
                }

                if (Nomina != null)
                {
                    schemaLocation += " http://www.sat.gob.mx/nomina12 http://www.sat.gob.mx/sitio_internet/cfd/nomina/nomina12.xsd";
                    XmlDocument doc           = new XmlDocument();
                    String      XMLNomina     = String.Empty;
                    String      ErroresNomina = String.Empty;
                    if (Nomina.GenerarXML(out XMLNomina, out ErroresNomina))
                    {
                        doc.LoadXml(XMLNomina);
                        ComprobanteComplemento ComNomina = new ComprobanteComplemento();
                        ComNomina.Any.Add(doc.DocumentElement);
                        if (Complemento == null)
                        {
                            Complemento = new List <ComprobanteComplemento>();
                        }
                        Complemento.Add(ComNomina);
                    }
                    else
                    {
                        Errores += ErroresNomina;
                    }
                }


                if (String.IsNullOrEmpty(Errores))
                {
                    XML = Serialize(System.Text.Encoding.UTF8);
                    XML = XML.Replace("&amp;apos;", "&apos;").Replace("&amp;quot;", "&quot;").Replace("&amp;lt;", "&lt;").Replace("&amp;gt;", "&gt;").Replace("&amp;amp;", "&amp;");
                    return(!String.IsNullOrEmpty(XML));
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    Errores += ex.Message + " innerex: " + ex.InnerException.Message;
                }
                else
                {
                    Errores += ex.Message;
                }
            }


            return(Resultado);
        }
 public static bool LoadFromFile(string fileName, out ComprobanteComplemento obj)
 {
     System.Exception exception = null;
     return(LoadFromFile(fileName, out obj, out exception));
 }
 public static bool LoadFromFile(string fileName, out ComprobanteComplemento obj, out System.Exception exception)
 {
     return(LoadFromFile(fileName, System.Text.Encoding.UTF8, out obj, out exception));
 }
 /// <summary>
 /// Deserializes xml markup from file into an ComprobanteComplemento object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output ComprobanteComplemento object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this Serializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, System.Text.Encoding encoding, out ComprobanteComplemento obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(ComprobanteComplemento);
     try
     {
         obj = LoadFromFile(fileName, encoding);
         return(true);
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return(false);
     }
 }
 public static bool Deserialize(string input, out ComprobanteComplemento obj)
 {
     System.Exception exception = null;
     return(Deserialize(input, out obj, out exception));
 }