Ejemplo n.º 1
0
 /// <summary>
 /// 批查询完成时的事件触发处理过程
 /// </summary>
 /// <param name="e"></param>
 private void raiseevent_sqlec(SQLExecuteCompleteArgs e)
 {
     if (ExecuteCompleted != null)
     {
         if (_sc != null)
         {
             SendOrPostCallback sd = delegate(object data)
             {
                 ExecuteCompleted.Invoke(this, e);
             };
             //线程同步处理
             _sc.Send(sd, e);
         }
         else
         {
             ExecuteCompleted.Invoke(this, e);
         }
     }
 }
Ejemplo n.º 2
0
        public void GetData(string sqlstr, int pageindex, int pagesize, long sid, string tablename = "")
        {
            if (_Idbcmd == null)
            {
                raiseevent_sqlec(new SQLExecuteCompleteArgs(sid, new DataTable(), false));
                return;
            }

            Action<object> objA = delegate(object data)
            {
                DataTable dt = new DataTable() { TableName = string.IsNullOrEmpty(tablename) ? "Table" : tablename };
                bool comp = false;
                try
                {

                    _Idbcmd.CommandText = sqlstr;
                    if (_Idbcmd.Connection.State != ConnectionState.Open)
                    {
                        _Idbcmd.Connection.Open();
                    }
                    if (pagesize < 1)
                    {
                        _DA.Fill(dt);
                    }
                    else
                    {
                        _DA.Fill(pagesize * pageindex, pagesize, dt);
                    }
                    comp = true;
                }
                catch (Exception ex)
                {
                    RaiseEvent(new DataOperationErrorMessageArgs(sqlstr, ex.Message));
                }
                SQLExecuteCompleteArgs sqlec = new SQLExecuteCompleteArgs(sid, dt, comp);
                raiseevent_sqlec(sqlec);
            };

            ThreadPool.QueueUserWorkItem(new WaitCallback(objA));
        }
Ejemplo n.º 3
0
        public void ExecuteQuery(string sqlstr, long sid)
        {
            Action<object> objA = delegate(object data)
            {
                int count = 0;
                bool comp = false;
                if (_Idbcmd != null)
                {
                    try
                    {

                        _Idbcmd.CommandText = sqlstr;

                        if (_Idbcmd.Connection.State != ConnectionState.Open)
                        {
                            _Idbcmd.Connection.Open();
                        }
                        //实物处理开始
                        _Idbcmd.Transaction = _Idbcmd.Connection.BeginTransaction();

                        count = _Idbcmd.ExecuteNonQuery();
                        if (_Idbcmd.Transaction != null)
                        {
                            //提交事务
                            _Idbcmd.Transaction.Commit();
                        }
                        comp = true;
                    }
                    catch (Exception ex)
                    {
                        if (_Idbcmd.Transaction != null)
                        {
                            //回滚事务
                            _Idbcmd.Transaction.Rollback();
                        }
                        RaiseEvent(new DataOperationErrorMessageArgs(sqlstr, ex.Message));
                        comp = false;
                    }
                }
                SQLExecuteCompleteArgs sqlec = new SQLExecuteCompleteArgs(sid, count, comp);
                raiseevent_sqlec(sqlec);
            };
            ThreadPool.QueueUserWorkItem(new WaitCallback(objA));
        }
Ejemplo n.º 4
0
        public void GetData(string sqlstr, long sid)
        {
            if (_Idbcmd == null)
            {
                raiseevent_sqlec(new SQLExecuteCompleteArgs(sid, new DataSet(), false));
                return;
            }

            Action<object> objA = delegate(object data)
            {
                DataSet ds = new DataSet();
                bool comp = false;
                try
                {
                    _Idbcmd.CommandText = sqlstr;
                    if (_Idbcmd.Connection.State != ConnectionState.Open)
                    {
                        _Idbcmd.Connection.Open();
                    }
                    _DA.Fill(ds);
                    comp = true;
                }
                catch (Exception ex)
                {
                    RaiseEvent(new DataOperationErrorMessageArgs(sqlstr, ex.Message));
                }
                SQLExecuteCompleteArgs sqlec = new SQLExecuteCompleteArgs(sid, ds, comp);
                raiseevent_sqlec(sqlec);
            };

            ThreadPool.QueueUserWorkItem(new WaitCallback(objA));
        }
Ejemplo n.º 5
0
 private void _GDC_public_ExecuteCompleted(object sender, SQLExecuteCompleteArgs e)
 {
     //switch (e.SessionID)
     //{
     //    case 8888:      //查询分析
     //    default:
     //        break;
     //}
 }