]> git.llucax.com Git - z.facultad/75.10/miklolife.git/commitdiff
El sueño me gana... mañana sigo con RyC
authorGuillermo Rugilo <guillerugilo@yahoo.com.ar>
Wed, 6 Jul 2005 06:13:51 +0000 (06:13 +0000)
committerGuillermo Rugilo <guillerugilo@yahoo.com.ar>
Wed, 6 Jul 2005 06:13:51 +0000 (06:13 +0000)
demo/src/Controlador/RecibirPrestacionesController.cs
demo/src/Reportes/InfoPrestacionesReport.cs

index 2f6cb77071d254a2d314cfea0c1568d7d9f36b21..e068778bf3454a86feb99faba539ab353ff54bf0 100644 (file)
@@ -107,6 +107,7 @@ namespace Controlador
                        catch ( Exception e )\r
                        {\r
                                Console.WriteLine( e.Message );\r
+                               Console.Read();\r
                        }\r
                }\r
 \r
index f454c701185b806a43683eca1298fc0f7236b453..277bef07ef211b4b577c5c6678ad7e18a4302305 100644 (file)
@@ -1,10 +1,20 @@
+#region Usings\r
+\r
 using System;\r
 using System.Collections;\r
 using System.Xml;\r
+using System.Xml.Schema;\r
 using System.Globalization;\r
+using System.IO;\r
+using System.Configuration;\r
+\r
+using System.Reflection;\r
+\r
+#endregion Usings\r
 \r
 namespace Reportes\r
 {\r
+       \r
        /// <summary>\r
        /// Clase que representa un archivo de Información de Prestaciones Realizadas enviado por el \r
        /// Prestador.\r
@@ -100,10 +110,73 @@ namespace Reportes
 \r
                #region Métodos privados\r
 \r
+               private ArrayList _validationErrors = new ArrayList();\r
+\r
+               private void valReader_ValidationEventHandler(object sender, ValidationEventArgs e)\r
+               {\r
+                       this._validationErrors.Add( e.Message );\r
+               }\r
+\r
+               private string _xsdPathNombre = null;\r
+               private string XsdPathNombre\r
+               {\r
+                       get \r
+                       { \r
+                               if ( this._xsdPathNombre == null )\r
+                               {\r
+                                       string currentDir = Directory.GetCurrentDirectory();\r
+                                       string xsdPath = Path.Combine( currentDir, ConfigurationSettings.AppSettings["DirectorioRecursos"] );\r
+                                       if ( ! Directory.Exists(xsdPath) )\r
+                                       {\r
+                                               Directory.CreateDirectory( xsdPath );\r
+                                       }\r
+\r
+                                       return ( Path.Combine( xsdPath, "infoPrestaciones_schema.xsd" ) );\r
+                               }\r
+                               else\r
+                                       return this._xsdPathNombre;\r
+                       }\r
+               }\r
+\r
                private bool ValidarContraSchema( XmlDocument xmlDoc )\r
                {\r
-                       #warning Seguir acá\r
-                       return true;\r
+                       this._validationErrors.Clear();\r
+\r
+                       NameTable nt = new NameTable();\r
+                       XmlNamespaceManager nm = new XmlNamespaceManager( nt );\r
+                       XmlParserContext pc = new XmlParserContext( null, nm, null, XmlSpace.None );\r
+\r
+                       XmlValidatingReader valReader = new XmlValidatingReader( xmlDoc.OuterXml, XmlNodeType.Element, pc );\r
+\r
+                       valReader.ValidationType = ValidationType.Schema;\r
+                       //XmlSchemaCollection schemaColl = new XmlSchemaCollection();\r
+                       //schemaColl.Add( null, this.XsdPathNombre );\r
+                       \r
+                       valReader.Schemas.Add( "", this.XsdPathNombre ); // schemaColl );\r
+\r
+                       valReader.ValidationEventHandler += new ValidationEventHandler(valReader_ValidationEventHandler);\r
+\r
+                       //while ( valReader.Read() );\r
+\r
+                       while (valReader.Read())\r
+                       {\r
+                               if (valReader.IsStartElement())\r
+                               {\r
+                                       if (valReader.Prefix==String.Empty)\r
+                                               Console.WriteLine("<{0}>", valReader.LocalName);\r
+                                       else\r
+                                       {\r
+                                               Console.Write("<{0}:{1}>", valReader.Prefix, valReader.LocalName);\r
+                                               Console.WriteLine(" The namespace URI is " +\r
+                                                       valReader.NamespaceURI);\r
+                                       }\r
+                               }\r
+                       }\r
+\r
+\r
+                       valReader.Close();\r
+\r
+                       return (this._validationErrors.Count == 0) ;\r
                }\r
 \r
                /// <summary>\r