public DataTable Select(string sql) { DataTable table = new DataTable(); try { Connection.Open(); using (Command = new OracleCommand()) { Command.CommandText = Regex.Replace(sql, @"\s+", " "); Command.Connection = Connection; using (DataAdapter = new OracleDataAdapter(Command)) { DataAdapter.Fill(table); Connection.Close(); } } } catch (Exception e) { Connection.Close(); Ambiente.Message("Algo salío mal con: " + MethodBase.GetCurrentMethod().Name + "\n" + e.ToString()); return(null); } Connection.Close(); return(table); }
public bool Probar(string sql) { try { Connection.Open(); using (Command = new OracleCommand()) { Command.CommandText = Regex.Replace(sql, @"\s+", " "); Command.Connection = Connection; var reader = Command.ExecuteReader(); if (Connection.State == ConnectionState.Open) { Connection.Close(); } return(true); } } catch (Exception e) { if (Connection.State == ConnectionState.Open) { Connection.Close(); } Ambiente.Message("Algo salío mal con: " + MethodBase.GetCurrentMethod().Name + " @" + GetType().Name + "\n" + e.Message); return(false); } }
public OracleContext(string stringConnection) { try { Connection = new OracleConnection(stringConnection); } catch (Exception ex) { Ambiente.Message("Algo salío mal con: " + MethodBase.GetCurrentMethod().Name + "\n" + ex.ToString()); } }
public static void IniciarTimer() { if (!timer.Enabled) { timer.Enabled = true; } else { Ambiente.Message("El subproceso ya está corriendo."); } }
public static void Inicializar() { //Oracle connection Ambiente.Oracledb = new OracleContext("Data Source = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = dbprd.cn44gpgzqk7s.us-east-1.rds.amazonaws.com)(PORT = 1521)))(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = dbprd))); User Id = tasy; Password = aloisk;"); //Local connection using (var db = new SyncContext()) { try { if (db.Database.EnsureCreated()) { Ambiente.Message("La base de datos se creó exitosamente"); } var config = db.Configuracion.FirstOrDefault(); if (config != null) { Ambiente.Interval = config.Ninterval; Ambiente.MinAbiertas = config.NminAbiertas; Ambiente.IniciarConWin = config.InicarConWindows; Ambiente.NMinCat = config.NminCat; Ambiente.IniciarTimerAuto = config.IniciarTimerAuto; SincronizadorController.Inicializa(Ambiente.Interval); } else { var c = new Configuracion(); c.InicarConWindows = true; c.Ninterval = 2000; c.NminAbiertas = 1; c.NminCat = 5; c.IniciarTimerAuto = false; db.Add(c); db.SaveChanges(); Ambiente.Interval = c.Ninterval; Ambiente.MinAbiertas = c.NminAbiertas; Ambiente.IniciarConWin = c.InicarConWindows; Ambiente.NMinCat = c.NminCat; Ambiente.IniciarTimerAuto = c.IniciarTimerAuto; SincronizadorController.Inicializa(Ambiente.Interval); Ambiente.Message("No se encontró el registro de configuración, pero se generó uno automáticamente. Configúrelo desde la configuración general."); } } catch (Exception e) { Ambiente.Message(e.Message); } } }
public List <HttpRequestConfig> SelectAllVigentes() { try { using (var db = new SyncContext()) { return(db.HttpRequestConfig.Where(x => x.IsDeleted == false).ToList()); } } catch (Exception ex) { Ambiente.Message("Algo salío mal con: " + MethodBase.GetCurrentMethod().Name + " @" + GetType().Name + "\n" + ex.Message); } return(null); }
public Abierta SelectOneByAtendimiento(string NrAtendimento) { try { using (var db = new SyncContext()) { return(db.Abierta.FirstOrDefault(x => x.NrAtendimento.Equals(NrAtendimento.Trim()))); } } catch (Exception ex) { Ambiente.Message("Algo salío mal con: " + MethodBase.GetCurrentMethod().Name + " @" + GetType().Name + "\n" + ex.Message); } return(null); }
public List <Complemento> SelectAll() { try { using (var db = new SyncContext()) { return(db.Complemento.ToList()); } } catch (Exception ex) { Ambiente.Message("Algo salío mal con: " + MethodBase.GetCurrentMethod().Name + " @" + GetType().Name + "\n" + ex.Message); } return(null); }
public List <Configuracion> SelectOneOverList(int Id) { try { using (var db = new SyncContext()) { return(db.Configuracion.Where(x => x.ConfiguracionId == Id).ToList()); } } catch (Exception ex) { Ambiente.Message("Algo salío mal con: " + MethodBase.GetCurrentMethod().Name + " @" + GetType().Name + "\n" + ex.Message); } return(null); }
public List <Query> SelectAll() { try { using (var db = new SyncContext()) { return(db.Query.Where(x => x.Vigente == true).ToList()); } } catch (Exception ex) { Ambiente.Message("Algo salío mal con: " + MethodBase.GetCurrentMethod().Name + " @" + GetType().Name + "\n" + ex.Message); } return(null); }
public Complemento SelectOne(int Id) { try { using (var db = new SyncContext()) { return(db.Complemento.FirstOrDefault(x => x.ComplementoId == Id)); } } catch (Exception ex) { Ambiente.Message("Algo salío mal con: " + MethodBase.GetCurrentMethod().Name + " @" + GetType().Name + "\n" + ex.Message); } return(null); }
public Configuracion SelectTopOne() { try { using (var db = new SyncContext()) { return(db.Configuracion.FirstOrDefault()); } } catch (Exception ex) { Ambiente.Message("Algo salío mal con: " + MethodBase.GetCurrentMethod().Name + " @" + GetType().Name + "\n" + ex.Message); } return(null); }
public List <Configuracion> SelectMany(int cantidad) { try { using (var db = new SyncContext()) { return(db.Configuracion.Take(cantidad).ToList()); } } catch (Exception ex) { Ambiente.Message("Algo salío mal con: " + MethodBase.GetCurrentMethod().Name + " @" + GetType().Name + "\n" + ex.Message); } return(null); }
public Establecimiento SelectOneByClave(string cd_registro) { try { using (var db = new SyncContext()) { return(db.Establecimiento.FirstOrDefault(x => x.CdEstabelecimento.Equals(cd_registro.Trim()))); } } catch (Exception ex) { Ambiente.Message("Algo salío mal con: " + MethodBase.GetCurrentMethod().Name + " @" + GetType().Name + "\n" + ex.Message); } return(null); }
public bool InsertRange(List <Complemento> lista) { try { using (var db = new SyncContext()) { db.AddRange(lista); db.SaveChanges(); return(true); } } catch (Exception ex) { Ambiente.Message("Algo salío mal con: " + MethodBase.GetCurrentMethod().Name + " @" + GetType().Name + "\n" + ex.Message); } return(false); }
public bool Update(Complemento o) { try { using (var db = new SyncContext()) { db.Entry(o).State = EntityState.Modified; db.SaveChanges(); return(true); } } catch (Exception ex) { Ambiente.Message("Algo salío mal con: " + MethodBase.GetCurrentMethod().Name + " @" + GetType().Name + "\n" + ex.Message); } return(false); }
public bool InsertOne(Configuracion o) { try { using (var db = new SyncContext()) { db.Add(o); db.SaveChanges(); return(true); } } catch (Exception ex) { Ambiente.Message("Algo salío mal con: " + MethodBase.GetCurrentMethod().Name + " @" + GetType().Name + "\n" + ex.Message); } return(false); }
public bool Delete(Abierta o) { try { using (var db = new SyncContext()) { db.Remove(o); db.SaveChanges(); return(true); } } catch (Exception ex) { Ambiente.Message("Algo salío mal con: " + MethodBase.GetCurrentMethod().Name + " @" + GetType().Name + "\n" + ex.Message); } return(false); }
public bool Delete(int Id) { try { using (var db = new SyncContext()) { var temp = db.Complemento.FirstOrDefault(x => x.ComplementoId == Id); if (temp != null) { db.Remove(temp); } db.SaveChanges(); return(true); } } catch (Exception ex) { Ambiente.Message("Algo salío mal con: " + MethodBase.GetCurrentMethod().Name + " @" + GetType().Name + "\n" + ex.Message); } return(false); }