X-Git-Url: https://git.llucax.com/z.facultad/75.10/miklolife.git/blobdiff_plain/922bcccc3ca42670309e8f27f4fdc8600606c6ef..cee792200bd75616f2989980a76bb4a7042da6f5:/demo/src/Reportes/InfoPrestacionesReport.cs diff --git a/demo/src/Reportes/InfoPrestacionesReport.cs b/demo/src/Reportes/InfoPrestacionesReport.cs index f454c70..277bef0 100644 --- a/demo/src/Reportes/InfoPrestacionesReport.cs +++ b/demo/src/Reportes/InfoPrestacionesReport.cs @@ -1,10 +1,20 @@ +#region Usings + using System; using System.Collections; using System.Xml; +using System.Xml.Schema; using System.Globalization; +using System.IO; +using System.Configuration; + +using System.Reflection; + +#endregion Usings namespace Reportes { + /// /// Clase que representa un archivo de Información de Prestaciones Realizadas enviado por el /// Prestador. @@ -100,10 +110,73 @@ namespace Reportes #region Métodos privados + private ArrayList _validationErrors = new ArrayList(); + + private void valReader_ValidationEventHandler(object sender, ValidationEventArgs e) + { + this._validationErrors.Add( e.Message ); + } + + private string _xsdPathNombre = null; + private string XsdPathNombre + { + get + { + if ( this._xsdPathNombre == null ) + { + string currentDir = Directory.GetCurrentDirectory(); + string xsdPath = Path.Combine( currentDir, ConfigurationSettings.AppSettings["DirectorioRecursos"] ); + if ( ! Directory.Exists(xsdPath) ) + { + Directory.CreateDirectory( xsdPath ); + } + + return ( Path.Combine( xsdPath, "infoPrestaciones_schema.xsd" ) ); + } + else + return this._xsdPathNombre; + } + } + private bool ValidarContraSchema( XmlDocument xmlDoc ) { - #warning Seguir acá - return true; + this._validationErrors.Clear(); + + NameTable nt = new NameTable(); + XmlNamespaceManager nm = new XmlNamespaceManager( nt ); + XmlParserContext pc = new XmlParserContext( null, nm, null, XmlSpace.None ); + + XmlValidatingReader valReader = new XmlValidatingReader( xmlDoc.OuterXml, XmlNodeType.Element, pc ); + + valReader.ValidationType = ValidationType.Schema; + //XmlSchemaCollection schemaColl = new XmlSchemaCollection(); + //schemaColl.Add( null, this.XsdPathNombre ); + + valReader.Schemas.Add( "", this.XsdPathNombre ); // schemaColl ); + + valReader.ValidationEventHandler += new ValidationEventHandler(valReader_ValidationEventHandler); + + //while ( valReader.Read() ); + + while (valReader.Read()) + { + if (valReader.IsStartElement()) + { + if (valReader.Prefix==String.Empty) + Console.WriteLine("<{0}>", valReader.LocalName); + else + { + Console.Write("<{0}:{1}>", valReader.Prefix, valReader.LocalName); + Console.WriteLine(" The namespace URI is " + + valReader.NamespaceURI); + } + } + } + + + valReader.Close(); + + return (this._validationErrors.Count == 0) ; } ///