Ejemplo n.º 1
0
 /// <summary>
 /// 主体查询预备执行操作,这里会构造命令日志信息
 /// </summary>
 /// <param name="db">当前查询连接对象</param>
 /// <param name="SQL">当前主体要执行的查询命令</param>
 /// <param name="commandType">命令类型</param>
 /// <param name="parameters">命令参数</param>
 /// <returns>总是返回成功</returns>
 public bool OnExecuting(CommonDB db, ref string SQL, CommandType commandType, IDataParameter[] parameters)
 {
     if (this.enable)
     {
         this.currDb = db;
         db.BeginTransaction();
         //需要真实反映执行的语句顺序,CommandID的赋值推迟到执行后
         //logEntity.CommandID = CommonUtil.NewSequenceGUID();
         //logEntity.ExecuteTime = DateTime.Now;
         //使用 PrepairSQL 方法处理
         //logEntity.CommandText = SQL;
         logEntity.CommandType = commandType;
         logEntity.LogFlag     = 0;
         //logEntity.ParameterInfo = DbParameterSerialize.Serialize(parameters);
         logEntity.PrepairSQL(SQL, DbParameterSerialize.Serialize(parameters));
         if (db.ContextObject != null)
         {
             if (db.ContextObject is OQL)
             {
                 logEntity.CommandName = ((OQL)db.ContextObject).currEntity.GetTableName();
             }
             else if (db.ContextObject is EntityBase)
             {
                 logEntity.CommandName = ((EntityBase)db.ContextObject).GetTableName();
             }
             else
             {
                 logEntity.CommandName = "";
             }
         }
     }
     return(true);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 主体查询预备执行操作,这里会构造命令日志信息
        /// </summary>
        /// <param name="db">当前查询连接对象</param>
        /// <param name="SQL">当前主体要执行的查询命令</param>
        /// <param name="commandType">命令类型</param>
        /// <param name="parameters">命令参数</param>
        /// <returns>总是返回成功</returns>
        public bool OnExecuting(CommonDB db, ref string SQL, CommandType commandType, IDataParameter[] parameters)
        {
            if (this.enable)
            {
                this.currDb = db;
                db.BeginTransaction();

                logEntity.CommandID     = CommonUtil.NewSequenceGUID();
                logEntity.CommandText   = SQL;
                logEntity.CommandType   = commandType;
                logEntity.LogFlag       = 0;
                logEntity.ParameterInfo = DbParameterSerialize.Serialize(parameters);
                logEntity.ExecuteTime   = DateTime.Now;
            }
            return(true);
        }