X-Git-Url: https://git.llucax.com/z.facultad/75.10/miklolife.git/blobdiff_plain/922bcccc3ca42670309e8f27f4fdc8600606c6ef..1c4cf971e3b30f540ddc8541ce0634737331edb5:/demo/src/Reportes/InfoPrestacionesReport.cs diff --git a/demo/src/Reportes/InfoPrestacionesReport.cs b/demo/src/Reportes/InfoPrestacionesReport.cs index f454c70..a127f1c 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,54 @@ 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.Schemas.Add( string.Empty, this.XsdPathNombre ); + valReader.ValidationType = ValidationType.Schema; + + valReader.ValidationEventHandler += new ValidationEventHandler(valReader_ValidationEventHandler); + + while (valReader.Read()) { } + + valReader.Close(); + + return (this._validationErrors.Count == 0) ; } ///