From 654bbdf445d46de05b2c9e1b269ae55a6811a0f9 Mon Sep 17 00:00:00 2001 From: Guillermo Rugilo Date: Wed, 6 Jul 2005 06:13:51 +0000 Subject: [PATCH] =?utf8?q?El=20sue=C3=B1o=20me=20gana...=20ma=C3=B1ana=20s?= =?utf8?q?igo=20con=20RyC?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../RecibirPrestacionesController.cs | 1 + demo/src/Reportes/InfoPrestacionesReport.cs | 77 ++++++++++++++++++- 2 files changed, 76 insertions(+), 2 deletions(-) diff --git a/demo/src/Controlador/RecibirPrestacionesController.cs b/demo/src/Controlador/RecibirPrestacionesController.cs index 2f6cb77..e068778 100644 --- a/demo/src/Controlador/RecibirPrestacionesController.cs +++ b/demo/src/Controlador/RecibirPrestacionesController.cs @@ -107,6 +107,7 @@ namespace Controlador catch ( Exception e ) { Console.WriteLine( e.Message ); + Console.Read(); } } 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) ; } /// -- 2.43.0