예제 #1
0
        /// <summary>
        /// 记录重试次数
        /// </summary>
        /// <param name="scriptNodeCaseID">脚本节点实例ID</param>
        /// <returns>更新后的重试次数</returns>
        public int RecordTryTimes(long scriptNodeCaseID)
        {
            string sqlUpdate = "UPDATE " + TableName + " SET RETRY_TIME=RETRY_TIME+1 WHERE ID =?";
            string sqlGet    = "SELECT RETRY_TIME FROM " + TableName + " WHERE ID =?";
            int    i         = 0;

            using (BDBHelper dbHelper = new BDBHelper())
            {
                i = dbHelper.ExecuteNonQueryParams(sqlUpdate, scriptNodeCaseID);
                if (i > 0)
                {
                    i = dbHelper.ExecuteScalarIntParams(sqlGet, scriptNodeCaseID);
                }
            }

            return(i);
        }
예제 #2
0
파일: BF_DATABASE.cs 프로젝트: radtek/SRMS
        /// <summary>
        /// 在指定数据库执行查询语句
        /// </summary>
        /// <param name="dbID">数据库ID</param>
        /// <param name="psd">二次密码验证(执行DDL语句时传入)</param>
        /// <param name="sql">SQL语句</param>
        /// <param name="paramList">参数列表</param>
        /// <returns>DataTable</returns>
        public int ExecuteSQL(int dbID, string psd, string sql, List <object> paramList)
        {
            int i = 0;

            if (dbID < 0)
            {
                throw new Exception("错误的数据库ID");
            }
            if (string.IsNullOrWhiteSpace(sql))
            {
                throw new Exception("SQL语句不可为空");
            }
            string s = sql.Trim();

            if (s.ToUpper().StartsWith("SELECT ") == true)
            {
                throw new Exception("只能执行非SELECT语句!");
            }

            if (psd != "lb@em")
            {
                throw new Exception("二次验证密码不正确,非SELECT语句需要二次验证密码!");
            }

            using (BDBHelper dbHelper = GetBDBHelper(dbID))
            {
                try
                {
                    if (paramList == null || paramList.Count < 1)
                    {
                        i = dbHelper.ExecuteNonQuery(sql);
                    }
                    else
                    {
                        i = dbHelper.ExecuteNonQueryParams(sql, paramList);
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("在数据库" + dbID + "执行SQL查询出错:" + ex.Message);
                }
            }

            return(i);
        }
예제 #3
0
파일: BF_DATABASE.cs 프로젝트: radtek/SRMS
 /// <summary>
 /// 在指定数据库上执行SQL语句
 /// </summary>
 /// <param name="dbID"></param>
 /// <param name="sql"></param>
 /// <param name="paramList"></param>
 /// <returns></returns>
 public int ExecuteNonQuery(int dbID, string sql, List <object> paramList)
 {
     using (BDBHelper dbHelper = GetBDBHelper(dbID))
     {
         try
         {
             if (paramList == null || paramList.Count < 1)
             {
                 return(dbHelper.ExecuteNonQuery(sql));
             }
             else
             {
                 return(dbHelper.ExecuteNonQueryParams(sql, paramList));
             }
         }
         catch (Exception ex)
         {
             throw new Exception("在数据库" + dbID + "执行SQL语句出错:" + ex.Message);
         }
     }
 }
예제 #4
0
        /// <summary>
        /// 递归更新子节点的层级
        /// </summary>
        /// <param name="pCode"></param>
        /// <param name="level"></param>
        /// <param name="dbHelper"></param>
        /// <param name="updateCount"></param>
        public void RefreshSubNodesLevel(int pCode, int level, BDBHelper dbHelper, ref int updateCount)
        {
            level++;
            string    sqlSelect = "SELECT CODE FROM BF_DEPARTMENT WHERE P_CODE=?";
            DataTable dt        = dbHelper.ExecuteDataTableParams(sqlSelect, pCode);

            if (dt == null || dt.Rows.Count < 1)
            {
                return;
            }
            string sqlUpdate = "UPDATE BF_DEPARTMENT SET DEPT_LEVEL=" + level + " WHERE P_CODE=?";
            int    i         = dbHelper.ExecuteNonQueryParams(sqlUpdate, pCode);

            if (i > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    int code = Convert.ToInt32(dr["CODE"]);
                    RefreshSubNodesLevel(code, level, dbHelper, ref updateCount);
                }
            }
            updateCount += i;
        }