public Task(TaskType type, Connection client = null, object args = null) { Type = type; _client = client; _args = args; Query = null; }
void ExecuteQuery(DBQuery q) { LogThread.Log(string.Format("ExecuteQuery - {0}", q.SqlString), LogThread.LogMessageType.Debug); MySqlCommand cmd = new MySqlCommand(q.SqlString, _sql); if (q.Read) { MySqlDataReader reader = cmd.ExecuteReader(); List<object[]> rows = new List<object[]>(); while (reader.Read()) { object[] row = new object[reader.FieldCount]; for (int i = 0; i < reader.FieldCount; i++) { row[i] = reader[i]; } rows.Add(row); } reader.Close(); q.Rows = rows; } else { cmd.ExecuteNonQuery(); } OnQueryComplete(q, null); }
public DBQuery AddDBQuery(string sql, Task task, bool read = true) { if( task == null ) task = new Task(-1); long key = UniqueKey(); DBQuery q = new DBQuery(sql, read, key); task.Query = q; _pqLock.WaitOne(); LogInterface.Log("Adding Query with key: " + key, LogInterface.LogMessageType.Debug, true); _pendingQueries[key] = task; _pqLock.ReleaseMutex(); _db.AddQuery(q); return q; }
public void AddQuery(DBQuery query) { _queriesLock.WaitOne(); _queries.Add(query); _queriesLock.ReleaseMutex(); }