public static DataSet ExecuteQuery(Server svr, string query) { DataSet tmpSet = new DataSet(); string[] pQuery = ParseQuery(query); svr.Connector.Open(); for (int i = 0; i < pQuery.Length; i++) if (bgwQueryRunner.CancellationPending) i = pQuery.Length; else { try { DataTable tmpTable = new DataTable(); SqlCommand sqlCmd = new SqlCommand(pQuery[i], svr.Connector); sqlCmd.CommandTimeout = 0; SqlDataAdapter tmpCom = new SqlDataAdapter(sqlCmd); tmpCom.Fill(tmpTable); if (tmpTable.Columns.Count > 0) tmpSet.Tables.Add(tmpTable); } catch (Exception ex) { QMain.ReportEx(ex, "QQuery", "ExecuteQuery"); svr.Connector.Close(); } } svr.Connector.Close(); return tmpSet; }
public static List<Table> GetTableList(string db, Server svr) { svr.ConnectorDB = db; SqlConnection conn = svr.Connector; List<Table> tblList = new List<Table>(); try { string dbQuery = "SELECT table_name, table_schema FROM Information_Schema.Tables where Table_Type = 'BASE TABLE' ORDER BY table_name"; conn.Open(); SqlCommand tmp1 = new SqlCommand(dbQuery, conn); SqlDataReader rdFirstSet = tmp1.ExecuteReader(); while (rdFirstSet.Read()) { Table tmpTable = new Table(); tmpTable.TableName = rdFirstSet[0].ToString(); tmpTable.TableSchema = rdFirstSet[1].ToString(); tblList.Add(tmpTable); } conn.Close(); } catch (Exception ex) { QEngine_Main.ReportEx(ex, "QEngine_Info", "GetTableList"); } return tblList; }
public bool Initialize(Server Server) { try { Server = new Server(Server); Load(); UI = new QueryUI(Server) as UserControl; return true; } catch (Exception ex) { QMain.ReportEx(ex, "QueryUtility", "Initialize(Server)"); return false; } }
public bool Initialize() { string svr = ""; if (SetConnection(ref svr)) { Server = new Server(svr); Load(); UI = new QueryUI(Server) as UserControl; return true; } return false; }
public static Server CreateServer(string connection) { Server tmpSvr = new Server(connection); try { tmpSvr.Connector.Open(); tmpSvr.Connector.Close(); tmpSvr.InstanceID = tmpSvr.Machine + "\\" + tmpSvr.Name; tmpSvr.LoadDatabaseSet(); } catch (SqlException sql_ex) { ReportEx(sql_ex, "Engine", "CreateServer"); tmpSvr = null; } catch (Exception ex) { ReportEx(ex, "Engine", "CreateServer"); tmpSvr = null; } return tmpSvr; }
public Server(Server svr) { Databases = svr.Databases; DBMap = svr.DBMap; Mapped = svr.Mapped; InfoMessages = svr.InfoMessages; ErrorMessages = svr.ErrorMessages; InstanceID = svr.InstanceID; Name = svr.Name; Machine = svr.Machine; UserID = svr.UserID; Password = svr.Password; ConnectionString = svr.ConnectionString; TimeOut = svr.TimeOut; Connector = svr.Connector; }
public void initializeServer(Server svr) { _Svr = new Server(svr); txtMessages.DataBindings.Add("Text", _Svr, "InfoMessages"); }
public void LoadColumnSet(Server svr) { Columns = QInfo.GetColumnList(svr.Connector, TableName); ColMap = new ColumnMap(Columns.Count); }
public QueryUI(Server svr) { _Svr = svr; InitializeComponent(); }
public QueryUI(Server svr, string query) { _Svr = svr; InitializeComponent(); }
public void LoadTableSet(Server svr) { Tables = QInfo.GetTableList(Name, svr); TBLMap = new TableMap(Tables.Count); }
public QueryUI() { _Svr = new Server(); InitializeComponent(); }
public bool Initialize(Server Server, string query) { try { Server = new Server(Server); Load(); UI = new QueryUI(Server, query) as UserControl; ExecuteQuery_Click(new Object(), new EventArgs()); return true; } catch (Exception ex) { QMain.ReportEx(ex, "QueryUtility", "Initialize(Server, Query)"); return false; } }
public static int StartProcess(ToolStripMenuItem inItem, Server svr) { string tag = inItem.Tag.ToString(); string[] tagItems = tag.Split(new char[] {','}); int process = -1; switch (tagItems[0]) { case "Query": process = StartQuery("", svr); break; case "Plugin": process = StartPlugin(tagItems); if(process != -1) Global.QliteProcesses[process].Page.Tag = Global.QliteProcesses[process].Page.Tag + "," + process.ToString(); break; } return process; }
public static int StartProcess(TreeNode inNode, Server svr) { string query = "SELECT * FROM " + inNode.Text.ToUpper(); return StartQuery(query, svr); }
public static int StartProcess(ToolStripItem inItem, Server svr) { string tag = inItem.Tag.ToString(); string[] tagItems = tag.Split(new char[] {','}); int process = Global.Processes.Count(); foreach (var p in Global.Plugins.Catalog.Parts) foreach (var ed in p.ExportDefinitions) if (ed.ContractName == "IPlugin") foreach (var meta in ed.Metadata) if (meta.Key == "Name" && meta.Value == tag) { //process = StartPlugin(tag); process = StartPlugin((IPlugin)p); Global.Processes[process].UI.Tag = Global.Processes[process].UI.Tag + ", " + process.ToString(); } return process; }
private static int StartQuery(string query, Server svr) { QueryPlug tmpQuery = new QueryPlug(); if (svr.Connector == null && tmpQuery.Initialize()) return SetProcess(tmpQuery); else { if (query == "" && tmpQuery.Initialize(svr)) return SetProcess(tmpQuery); else if (tmpQuery.Initialize(svr, query)) return SetProcess(tmpQuery); } return -1; }