예제 #1
0
        protected override bool WfExecute()
        {
            vw_glab311    masterModel = null;
            int           chkCnts     = 0;
            StringBuilder sbResult    = null;

            try
            {
                //取得交易物件
                BoMaster.TRAN  = BoMaster.OfGetConntion().BeginTransaction();
                BoGlab311.TRAN = BoMaster.TRAN;

                masterModel = DrMaster.ToItem <vw_glab311>();
                var securityString = WfGetSecurityString();
                var resultList     = BoGlab311.OfGlab311Post(masterModel, "N", securityString, "", LoginInfo);

                if (resultList == null || resultList.Count == 0)
                {
                    BoGlab311.TRAN.Rollback();
                    WfShowBottomStatusMsg("無可過帳資料!");
                    return(true);
                }

                chkCnts = resultList.Where(p => p.Success == false).Count();
                if (chkCnts > 0)
                {
                    BoGlab311.TRAN.Rollback();
                    sbResult = new StringBuilder();
                    sbResult.AppendLine(string.Format("執行失敗!"));
                    sbResult.AppendLine(string.Format("過帳傳票筆數【{0}】 成功:【{1}】  失敗【{2}】",
                                                      resultList.Count,
                                                      resultList.Count - chkCnts,
                                                      chkCnts
                                                      ));
                    sbResult.AppendLine();
                    sbResult.AppendLine(string.Format("錯誤內容如下"));
                    sbResult.AppendLine("====================================");
                    foreach (Result result in resultList.Where(p => p.Success == false))
                    {
                        sbResult.AppendLine(string.Format("key1:【{0}】 錯誤訊息:【{1}】", result.Key1, result.Message));
                    }
                    WfShowErrorMsg(sbResult.ToString());
                    return(false);
                }
                BoMaster.TRAN.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                if (BoMaster.TRAN != null)
                {
                    BoMaster.TRAN.Rollback();
                }
                throw ex;
            }
        }
예제 #2
0
        protected override bool WfExecute()
        {
            vw_glab311    glab311Model = null;
            vw_glab312    glab312Model = null;
            int           chkCnts = 0;
            StringBuilder sbResult = null;
            DateTime      dtStart, dtEnd;

            try
            {
                glab312Model = DrMaster.ToItem <vw_glab312>();
                glab311Model = new vw_glab311();
                if (BoGlab311.OfGetGlaYearPeriod(Convert.ToInt16(glab312Model.gfa08), Convert.ToInt16(glab312Model.gfa09),
                                                 out dtStart, out dtEnd) == false)
                {
                    WfShowErrorMsg("無法取得期數區間,請檢核!");
                    return(false);
                }
                glab311Model.gfa02_s = dtStart;
                glab311Model.gfa02_e = dtEnd;

                //取得交易物件
                BoMaster.TRAN  = BoMaster.OfGetConntion().BeginTransaction();
                BoGlab311.TRAN = BoMaster.TRAN;
                if (WfUpdatePostRelation(glab311Model, glab312Model) == false)
                {
                    return(false);
                }
                var resultList = BoGlab311.OfGlab311Post(glab311Model, "Y", "", "", LoginInfo);

                if (resultList == null || resultList.Count == 0)
                {
                    WfShowBottomStatusMsg("無可過帳資料!");
                    BoGlab311.TRAN.Rollback();
                    return(true);
                }

                chkCnts = resultList.Where(p => p.Success == false).Count();
                if (chkCnts > 0)
                {
                    BoGlab311.TRAN.Rollback();
                    sbResult = new StringBuilder();
                    sbResult.AppendLine(string.Format("執行失敗!"));
                    sbResult.AppendLine(string.Format("過帳傳票筆數【{0}】 成功:【{1}】  失敗【{2}】",
                                                      resultList.Count,
                                                      resultList.Count - chkCnts,
                                                      chkCnts
                                                      ));
                    sbResult.AppendLine();
                    sbResult.AppendLine(string.Format("錯誤內容如下"));
                    sbResult.AppendLine("====================================");
                    foreach (Result result in resultList.Where(p => p.Success == false))
                    {
                        sbResult.AppendLine(string.Format("key1:【{0}】 錯誤訊息:【{1}】", result.Key1, result.Message));
                    }
                    WfShowErrorMsg(sbResult.ToString());
                    return(false);
                }
                BoMaster.TRAN.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                if (BoMaster.TRAN != null)
                {
                    BoMaster.TRAN.Rollback();
                }
                throw ex;
            }
        }