Ejemplo n.º 1
0
        public int AddTask(string Connection, string Sql, ReaderRecall Callback, params StringPaire[] Params)
        {
            QueryStateObject q = new QueryStateObject(Connection, Sql, Callback, Params);

            q.IDentity = mbrQueryPooler.NextIndex;
            return(mbrQueryPooler.Pushin(q));
        }
Ejemplo n.º 2
0
 private void Exec(QueryStateObject state)
 {
     if (mbrCancel)
     {
         return;
     }
     if (mbrConnections.ContainsKey(state.Connection))
     {
         IDbConnection c = mbrConnections[state.Connection];
         if (c.State != ConnectionState.Open)
         {
             c.Open();
         }
         using (IDbCommand cmd = c.CreateCommand())
         {
             cmd.CommandText = state.Sql;
             if (state.Params != null)
             {
                 cmd.Parameters.Clear();
                 foreach (StringPaire s in state.Params)
                 {
                     IDbDataParameter p = cmd.CreateParameter();
                     p.ParameterName = s.Name;
                     p.Value         = s.Value;
                     cmd.Parameters.Add(p);
                 }
             }
             try
             {
                 IDataReader r = cmd.ExecuteReader();
                 //if (r.Read())
                 //{
                 if (state.Callback != null)
                 {
                     state.Callback(r);
                 }
                 //}
                 try { r.Close(); }
                 catch { }
             }
             catch { }
         }
     }
     else
     {
         throw new Exception("Connection : [" + state.Connection + "] not exist.");
     }
 }