/// <summary> /// 簽核前置檢查作業及簽核 /// </summary> /// <param name="model"></param> public override void SignOff(ProcessWorkflowDetailViewModel model) { if (model == null) { throw new Exception("查無擔當簽核明細資料!"); } var sqlDML = ProcesswfRepo.GetSignOffDML(model); var workflowModel = ProcesswfRepo.GetWorkflowData(model.SignDocID_FK); var newDetailModel = new List <ProcessWorkflowDetailViewModel>(); //替換明細資料為頁面傳入資料 workflowModel.WorkflowDetailList.ForEach(row => { if (row.ChiefID_FK == model.ChiefID_FK) { newDetailModel.Add(model); return; } newDetailModel.Add(row); }); workflowModel.WorkflowDetailList = newDetailModel; //寫入簽核檔 ProcessIdentify(workflowModel, sqlDML, model.ChiefID_FK); }
/* * Main 狀態: * 1 草稿 * 2 待簽核 * 3 核准 * 4 駁回 * 5 取消 * 6 結案 * 7 歸檔 * Detial 狀態: * 1 * 2 待簽核 * 3 核准 * 4 駁回 * 5 取消 * 6 * 7 */ /// <summary> /// 簽核處理函式 /// </summary> /// <param name="workflowModel"></param> /// <param name="sqlDML"></param> /// <param name="orgSupervisorID"></param> public void ProcessIdentify(ProcessWorkflowViewModel workflowModel, List <MultiConditions> sqlDML, string orgSupervisorID) { var sqlList = new List <MultiConditions>(); //var detail = workflowModel.WorkflowDetailList.Single(row => orgSupervisorID.Equals(row.ChiefID_FK)); #region 0020 會有多筆資料 不該用Single var detail = workflowModel.WorkflowDetailList.FirstOrDefault(row => orgSupervisorID.Equals(row.ChiefID_FK)); #endregion 0020 會有多筆資料 不該用Single if (detail.Status == 4) { //駁回 workflowModel.FinalStatus = detail.Status; var rejectDML = ProcesswfRepo.GetRejectSQLDML(workflowModel, orgSupervisorID); //加入DML sqlList.AddRange(sqlDML); sqlList.AddRange(rejectDML); } else if (workflowModel.WorkflowDetailList.All(row => row.Status == 3)) { //會簽只差本次主管同意,同意後寫入DB並上呈簽核 var nextDML = ProcesswfRepo.GetNextSQLDML(workflowModel, orgSupervisorID); //加入DML sqlList.Add(sqlDML.Last()); sqlList.AddRange(nextDML); } else { //不符合以上情形,簽核結果直接寫入DB sqlList.AddRange(sqlDML); } ProcesswfRepo.ExecuteSQL(sqlList); }