public static List <QueryHistory> GetQueryHistory() { List <QueryHistory> result = new List <QueryHistory>(); string sql = "t.databaseId=@1"; if (S.Get("ShowClosedQueries", false)) { sql = T.AppendTo(sql, "t.visible<>0", " and "); } if (sql != "") { sql = " where " + sql; } sql = @" select q.id, q.tab_id, q.expr, q.when_changed, t.visible, t.name, q.failed, q.rows, q.ms from queries q inner join tabs t on t.id=q.tab_id " + sql + " order by q.when_changed desc limit 100"; using (QSqlLite s = new QSqlLite()) { s.Open(sql, A.dbId); while (s.GetRow()) { string z = s.GetString(6); result.Add(new QueryHistory { queryVersionId = s.GetInt(0), id = s.GetInt(1), expr = s.GetString(2), whenChanged = Convert.ToDouble(s.GetString(3)).ToDateTime(), visible = s.GetBool(4), label = s.GetString(5), failed = s.GetBool(6), rows = s.GetInt(7), ms = (s.GetString(8) == "" ? 0 : Convert.ToInt32(s.GetString(8))) }); } } return(result); }
public static List <QueryInfo> GetQueryInfo(IEnumerable <int> ids) { List <QueryInfo> result = new List <QueryInfo>(); string idList = ids.Join(); if (idList != "") { using (QSqlLite s = new QSqlLite()) { // this order will put the newest versions at the bottom of the results // so if multiple version are opened, it will end up with the latest version anyways s.Open(@" select t.id, t.name, q.expr, t.visible, q.id from queries q inner join tabs t on t.id=q.tab_id where q.id in (" + idList + ") order by q.id"); while (s.GetRow()) { result.Add(new QueryInfo { queryVersionId = s.GetInt(4), visible = s.GetBool(3), queryId = s.GetInt(0), tabLabel = s.GetString(1), expr = s.GetString(2) }); } } } return(result); }