/// <summary> /// 1.目的:同時新增多筆配本指定分類 /// 2.傳入參數:@新增資料集 xmltype /// 傳入參數:處理結果 /// 3.處理表格:VDS_ALO_DIS_PATTERN(m:配本指定分類設定檔) /// 4.處理邏輯: /// /// ※以下僅針對特殊欄位說明,共通欄位請Fllow共通處理原則(CreateDate、Updatedate...等) /// 4.1) 判斷與處理新增 /// if (檢查新增資料中,已存在同PK但Enable設定為false 的資料) /// { /// 若有則設定Enable 設定為true重新啟用。 /// } /// else /// { /// a) 計算需新增筆數 /// b) 根據需新增筆數,Booking 取得系統ID /// c) 新增資料到目標資料表[m] /// } /// /// 4.2) 上述新增或更新需在同一個transation中一起Commit; /// 4.3) 發生任何失敗,則整批Rollback,設定回傳錯誤訊息。 /// 4.3) 記錄訊息到共用Error Log檔,並Raise Error /// </summary> /// <param name="dtMulti"></param> /// <param name="RootDBT"></param> public bool CreateMultiDissPatterns(DataTable dtMulti, DbTransaction RootDBT) { #region bool bResult = false; bool IsRootTranscation = false; try { VDS_ALO_DIS_PATTERN_DBO ALOM = new VDS_ALO_DIS_PATTERN_DBO(ref USEDB); //判斷是否有傳入Root Transcation IsRootTranscation = (RootDBT == null) ? true : false; #region 啟動交易或指定RootTranscation if (IsRootTranscation) { //獨立呼叫啟動Transcation Conn = USEDB.CreateConnection(); Conn.Open(); DBT = Conn.BeginTransaction(); } else { DBT = RootDBT; } #endregion ArrayList ParameterList = new ArrayList(); for (Int32 i = 0; i <= dtMulti.Rows.Count - 1; i++) { ParameterList.Clear(); ParameterList.Add(dtMulti.Rows[i]["DIS_USER"]); ParameterList.Add(dtMulti.Rows[i]["ROOT_NO"]); ParameterList.Add(dtMulti.Rows[i]["PMA"]); ParameterList.Add(dtMulti.Rows[i]["PATTERN"]); ParameterList.Add(dtMulti.Rows[i]["ITEM"]); ALOM.doCreate(ParameterList, DBT); } #region 交易成功 if (IsRootTranscation) { //獨立呼叫Transcation成立 DBT.Commit(); } #endregion bResult = true; return bResult; } catch (Exception ex) { #region 交易失敗 if (IsRootTranscation) { //獨立呼叫Transcation失敗 DBT.Rollback(); } #endregion throw GetNewException(ex); } finally { #region 判斷是否關閉交易連線 if (IsRootTranscation) { //獨立呼叫Transcation,關閉連線 if (Conn.State == ConnectionState.Connecting) { Conn.Close(); } } #endregion } #endregion }
/// <summary> /// 基本表單新增BCO /// </summary> /// <param name="ParameterList">輸入變數</param> /// <param name="RootDBT">是否有主交易,無主交易輸入null</param> /// <returns>回傳新增之成功與否</returns> public bool CreateDisPattern(ArrayList ParameterList, DbTransaction RootDBT ) { #region bool bResult = false; bool IsRootTranscation = false; try { VDS_ALO_DIS_PATTERN_DBO ALOM = new VDS_ALO_DIS_PATTERN_DBO(ref USEDB); //判斷是否有傳入Root Transcation IsRootTranscation = (RootDBT == null) ? true : false; #region 啟動交易或指定RootTranscation if (IsRootTranscation) { //獨立呼叫啟動Transcation Conn = USEDB.CreateConnection(); Conn.Open(); DBT = Conn.BeginTransaction(); } else { DBT = RootDBT; } #endregion bResult = ALOM.doCreate(ParameterList, DBT); #region 交易成功 if (IsRootTranscation) { //獨立呼叫Transcation成立 DBT.Commit(); } #endregion return bResult; } catch (Exception ex) { #region 交易失敗 if (IsRootTranscation) { //獨立呼叫Transcation失敗 DBT.Rollback(); } #endregion throw GetNewException(ex); } finally { #region 判斷是否關閉交易連線 if (IsRootTranscation) { //獨立呼叫Transcation,關閉連線 if (Conn.State == ConnectionState.Connecting) { Conn.Close(); } } #endregion } #endregion }