Created
September 1, 2019 11:26
-
-
Save NrI3/f8fb30392ec161d30330c60e09fbb77c to your computer and use it in GitHub Desktop.
Manejador de JConnector.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| using System.Threading.Tasks; | |
| using Acceso_a_datos; | |
| using System.Dynamic; | |
| using System.Data; | |
| namespace Logica.Objeto | |
| { | |
| public class Resultado | |
| { | |
| List<dynamic> _lista; | |
| bool _error; | |
| dynamic _primer_objeto; | |
| string _error_mensaje; | |
| DataTable _tabla; | |
| private static Conector _conector = new Conector(); | |
| public bool error | |
| { | |
| get { return this._error; } | |
| } | |
| public List<dynamic> lista | |
| { | |
| get { return this._lista; } | |
| } | |
| public DataTable tabla | |
| { | |
| get { return this._tabla; } | |
| } | |
| public dynamic PrimerObjeto() { | |
| return _primer_objeto; | |
| } | |
| public Resultado(string nombreProcedimiento, params object[] atributos) | |
| { | |
| this._error_mensaje = ""; | |
| this._error = false; | |
| //this._lista = new Conector().Exec(nombreProcedimiento, atributos); | |
| this._lista = _conector.Exec(nombreProcedimiento, atributos); | |
| this.procesarResultado(); | |
| } | |
| public Resultado(bool esTabla, string nombreProcedimiento, params object[] atributos) | |
| { | |
| this._error_mensaje = ""; | |
| this._error = false; | |
| this._tabla = new DataTable(); | |
| //DataTable _tabla_resultado = new Conector().Exec2(nombreProcedimiento, atributos); | |
| DataTable _tabla_resultado = _conector.Exec2(nombreProcedimiento, atributos); | |
| if (_tabla_resultado != null) { | |
| this._tabla = _tabla_resultado; | |
| } | |
| } | |
| public string MensajeError() | |
| { | |
| return this._error_mensaje; | |
| } | |
| private void procesarResultado() | |
| { | |
| if (this._lista == null) | |
| { | |
| this._error = true; | |
| this._error_mensaje = "Error interno del servidor"; | |
| this._lista = null; | |
| } | |
| else if (this._lista.Count == 1) | |
| { | |
| IDictionary<String,Object> o = this._lista[0] as IDictionary<String, Object>; | |
| if (o.Keys.ElementAt(0).ToString() == "ERROR") | |
| { | |
| this._lista = null; | |
| this._error = true; | |
| this._error_mensaje = o.Values.ElementAt(0).ToString(); | |
| Console.WriteLine("ERROR DEL CONECTOR: " + this._error_mensaje); | |
| } | |
| else | |
| { | |
| this._primer_objeto = _lista[0]; | |
| } | |
| } | |
| else if (this._lista.Count > 1) | |
| { | |
| this._primer_objeto = _lista[0]; | |
| this._error = false; | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment