SHARE
TWEET

Untitled

a guest Jun 26th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. conex.Open();
  2. NpgsqlCommand coman = new NpgsqlCommand("SELECT pid,usename,application_name,datname,client_addr,backend_start,state,query_start,xact_start,wait_event,query FROM pg_stat_activity ORDER BY query_start DESC", conex);
  3.                 NpgsqlDataReader dat = coman.ExecuteReader();
  4.                 while (dat.Read())
  5.                 {
  6.                     Entidades obj = new Entidades();
  7.                     if (obj == null || obj !=null)
  8.  
  9.                     {                        
  10.                     obj.pid = Convert.ToInt32(dat["pid"]);
  11.                         obj.usename = Convert.ToString(dat["usename"]);
  12.                         obj.appcationName = Convert.ToString(dat["application_name"]);
  13.                         obj.datname = Convert.ToString(dat["datname"]);
  14.                         obj.client_ddr = Convert.ToString(dat["client_addr"]);
  15.                         obj.backed_star = Convert.ToDateTime(dat["backend_start"]);
  16.                         obj.state = Convert.ToString(dat["state"]);
  17.                         obj.query_star = Convert.ToDateTime(dat["query_start"]);
  18.                         obj.Xact_star = Convert.ToDateTime(dat["xact_start"]);
  19.                         obj.waiting = Convert.ToString(dat["wait_event"]);
  20.                         obj.query = Convert.ToString(dat["query"]);
  21.                         dic.Add(obj.pid, obj);
  22. if (!dic.ContainsKey(obj.pid))//si el dic no contieene el id agregar
  23.                             {
  24.                                 dic.Add(obj.pid, obj);
  25.  
  26.                             }
  27.                             else
  28.                             {
  29.                                 dic[obj.pid].query_star = obj.query_star; //actualiza tiempo de ejecucion
  30.  
  31.                             }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top