/// <summary>
        /// 執行SQL 作業Does the run SQL.
        /// </summary>
        /// <remarks>
        /// 執行以下項目
        /// 1. 執行SQL
        ///    a.若傳回值為0 表示無問題--> 結束
        ///    b.若傳回值大於0 表示有問題 --> 產生報表 --> 發MAIL 通知
        /// </remarks>
        private bool DoRunSQL(ICheckRule aRule, ref int RecordCount)
        {
            try
            {
                aRule.CKSQL = ParaTrans.Format(aRule.CKSQL);
                switch (RuleType)
                {
                case SQLRuleType.Check:
                    SqlParameter[] px = { };
                    RecordCount = SqlHelper.ExecuteScalar <int>(aRule.DB_Mod.DBConnString, aRule.CKSQL, px);
                    break;

                case SQLRuleType.Maintain:
                    RecordCount = SqlHelper.ExecuteNonQuery(aRule.DB_Mod.DBConnString, aRule.CKSQL);
                    break;

                default:
                    RecordCount = -1;
                    break;
                }
                return(true);
            }
            catch (Exception ex)
            {
                RecordCount = -1;
                return(false);

                throw ex;
            }
        }
示例#2
0
 /// <summary>
 /// 檢查執行後結果 會依照模式不同而有不同的處理方式
 /// </summary>
 /// <param name="ResultCount">檢查後筆數</param>
 /// <param name="aRule">a rule.</param>
 /// <remarks>主要給後續在實作內容</remarks>
 protected override void OnCheckResult(int ResultCount, ICheckRule aRule)
 {
     if (ResultCount != 0)     //當筆數大於0時表示檢查結果需要輸出報表
     {
         aRule.LSSQL = ParaTrans.Format(aRule.LSSQL);
         SqlParameter[] px  = { };
         DataTable      dt4 = SqlHelper.ExecuteDataTable(aRule.DB_Mod.DBConnString, aRule.LSSQL, px);
         DoSendMail(aRule, GenerateHTMLReport.GenerateBody(dt4, aRule).ToString());
     }
     ;
 }