public ActionResult DetailVanBanDen(long id, int type = VANBANDEN_CONSTANT.CHUA_XULY) { AssignUserInfo(); wfItemUserProcess = Get <WF_ITEM_USER_PROCESSBusiness>(); wfReviewUserBusiness = Get <WF_REVIEW_USERBusiness>(); dmDanhMucDataBusiness = Get <DM_DANHMUC_DATABusiness>(); hscvVanBanDenBusiness = Get <HSCV_VANBANDENBusiness>(); attachmentBusiness = Get <TAILIEUDINHKEMBusiness>(); var HSCVREADVANBANBusiness = Get <HSCVREADVANBANBusiness>(); HSCV_VANBANDEN entityVanBanDen = hscvVanBanDenBusiness.Find(id); bool canAccess = wfItemUserProcess.CheckPermissionProcess(id, true == entityVanBanDen.IS_NOIBO ? MODULE_CONSTANT.VANBANDENNOIBO : MODULE_CONSTANT.VANBANDEN, currentUser.ID); bool canReview = wfReviewUserBusiness.CheckPermissionReview(id, true == entityVanBanDen.IS_NOIBO ? MODULE_CONSTANT.VANBANDENNOIBO : MODULE_CONSTANT.VANBANDEN, currentUser.ID); if ((!canAccess && !canReview) || entityVanBanDen == null) { return(Redirect("/Home/UnAuthor")); } var checkread = HSCVREADVANBANBusiness.repository.All() .Where(x => x.USER_ID == currentUser.ID && x.TYPE == 1 && x.VANBAN_ID == id).FirstOrDefault(); if (checkread == null) { HSCV_READVANBAN readObj = new HSCV_READVANBAN(); readObj.TYPE = 1; readObj.USER_ID = currentUser.ID; readObj.VANBAN_ID = id; HSCVREADVANBANBusiness.Save(readObj); } DetailVanBanDenViewModel model = new DetailVanBanDenViewModel(); DM_DANHMUC_DATA entityDonViGui = dmDanhMucDataBusiness.Find(entityVanBanDen.DONVI_ID); DM_DANHMUC_DATA entityDoKhan = dmDanhMucDataBusiness.Find(entityVanBanDen.DOKHAN_ID); DM_DANHMUC_DATA entityDoUuTien = dmDanhMucDataBusiness.Find(entityVanBanDen.DOMAT_ID); DM_DANHMUC_DATA entityLinhVucVanBan = dmDanhMucDataBusiness.Find(entityVanBanDen.LINHVUCVANBAN_ID); DM_DANHMUC_DATA entityLoaiVanBan = dmDanhMucDataBusiness.Find(entityVanBanDen.LOAIVANBAN_ID); DM_DANHMUC_DATA entityLoaiCoQuan = dmDanhMucDataBusiness.Find(entityVanBanDen.LOAI_COQUAN_ID); DM_DANHMUC_DATA entityThongTinLoaiVanBan = dmDanhMucDataBusiness.Find(entityVanBanDen.THONGTIN_LOAI_ID); DM_DANHMUC_DATA entityCongVanDen = dmDanhMucDataBusiness.Find(entityVanBanDen.CONGVAN_DEN_ID); model.currentUserId = currentUser.ID; model.entityVanBanDen = entityVanBanDen; model.nameOfDonViGui = entityDonViGui != null ? entityDonViGui.TEXT : string.Empty; model.nameOfDoKhan = entityDoKhan != null ? entityDoKhan.TEXT : string.Empty; model.nameOfDoUuTien = entityDoUuTien != null ? entityDoUuTien.TEXT : string.Empty; model.nameOfLinhVucVanBan = entityLinhVucVanBan != null ? entityLinhVucVanBan.TEXT : string.Empty; model.nameOfLoaiVanBan = entityLoaiVanBan != null ? entityLoaiVanBan.TEXT : string.Empty; model.nameOfLoaiCoQuan = entityLoaiCoQuan != null ? entityLoaiCoQuan.TEXT : string.Empty; model.nameOfThongTinLoaiBan = entityThongTinLoaiVanBan != null ? entityThongTinLoaiVanBan.TEXT : string.Empty; model.nameOfCongVanDen = entityCongVanDen != null ? entityCongVanDen.TEXT : string.Empty; model.groupOfTaiLieuDinhKems = attachmentBusiness.GetDataByItemID(entityVanBanDen.ID, LOAITAILIEU.VANBANDEN); model.typeOfVanBanDen = type; bool isFinish = hscvVanBanDenBusiness.CheckIsFinish(id); model.canCreateCalendar = (entityVanBanDen.NGUOITAO == currentUser.ID && isFinish); if (isFinish == false && entityVanBanDen.NGAYCONGTAC != null) { //kiểm tra người dùng có bước xử lý hay không? bool hasSteps = false; wfProcessBusiness = Get <WF_PROCESSBusiness>(); wfReviewUserBusiness = Get <WF_REVIEW_USERBusiness>(); wfReviewBusiness = Get <WF_REVIEWBusiness>(); wfStateBusiness = Get <WF_STATEBusiness>(); wfStepBusiness = Get <WF_STEPBusiness>(); wfStateFunctionBusiness = Get <WF_STATE_FUNCTIONBusiness>(); WF_PROCESS process = wfProcessBusiness.repository.All() .Where(x => x.ITEM_ID == id && x.ITEM_TYPE == MODULE_CONSTANT.VANBANDEN && x.USER_ID == currentUser.ID).FirstOrDefault(); WF_REVIEW reviewReject = wfReviewBusiness.repository.All() .Where(x => x.ITEMID == id && x.ITEMTYPE == MODULE_CONSTANT.VANBANDEN && x.IS_REJECT == true) .OrderByDescending(x => x.ID).FirstOrDefault(); WF_FUNCTION function = null; bool requireReview = false; List <WF_STEP> nextSteps = new List <WF_STEP>(); List <StepBackBO> stepsBack = new List <StepBackBO>(); if (process != null) { if (process != null || reviewReject != null) { WF_STATE startState = wfStateBusiness.Find(process.CURRENT_STATE); if (startState != null) { if (startState.IS_KETTHUC != true) { nextSteps = wfStepBusiness.GetListNextStep(process.WF_ID.GetValueOrDefault(), startState.ID); stepsBack = wfStepBusiness.GetListNextStepBack(process); } function = wfStateFunctionBusiness.CheckGetFunction(startState.ID, entityVanBanDen.ID, MODULE_CONSTANT.VANBANDEN); } } else if (process.IS_PENDING == true) { WF_REVIEW reviewFinish = wfReviewBusiness.repository.All() .Where(x => x.ITEMID == id && x.ITEMTYPE == MODULE_CONSTANT.VANBANDEN && x.IS_FINISH != true) .OrderByDescending(x => x.ID).FirstOrDefault(); if (reviewFinish != null) { requireReview = wfReviewUserBusiness.CheckReviewing(reviewFinish.ID, currentUser.ID); } } hasSteps = (nextSteps.Any() || stepsBack.Any() || function != null || requireReview == true); } model.hasSteps = hasSteps; if (hasSteps) { entityVanBanDen.NGAYCONGTAC = new DateTime(entityVanBanDen.NGAYCONGTAC.Value.Year, entityVanBanDen.NGAYCONGTAC.Value.Month, entityVanBanDen.NGAYCONGTAC.Value.Day); lichCongTacBusiness = Get <LICHCONGTACBusiness>(); model.isDuplicateCalendar = lichCongTacBusiness.repository.All() .Where(x => x.LANHDAO_ID == currentUser.ID && x.NGAY_CONGTAC.Equals(entityVanBanDen.NGAYCONGTAC.Value)).Count() > 0; } } return(View(model)); }
public ActionResult DetailVanBan(long ID) { AssignUserInfo(); #region check quyền truy cập của người dùng đến văn bản hiện tại WF_ITEM_USER_PROCESSBusiness = Get <WF_ITEM_USER_PROCESSBusiness>(); WF_PROCESSBusiness = Get <WF_PROCESSBusiness>(); HSCV_VANBANDIBusiness = Get <HSCV_VANBANDIBusiness>(); DM_NGUOIDUNGBusiness = Get <DM_NGUOIDUNGBusiness>(); var WF_REVIEW_USERBusiness = Get <WF_REVIEW_USERBusiness>(); DM_DANHMUC_DATABusiness DM_DANHMUC_DATABusiness = Get <DM_DANHMUC_DATABusiness>(); // check quyền truy cập theo workflow bool HasPermissionAccess = WF_ITEM_USER_PROCESSBusiness.CheckPermissionProcess(ID, MODULE_CONSTANT.VANBANTRINHKY, currentUser.ID); // check quyền truy cập với quyền review bool HasPermissionReview = WF_REVIEW_USERBusiness.CheckPermissionReview(ID, MODULE_CONSTANT.VANBANTRINHKY, currentUser.ID); bool HasPermissionMainProcess = WF_PROCESSBusiness.CheckPermissionProcess(ID, MODULE_CONSTANT.VANBANTRINHKY, currentUser.ID); if (!HasPermissionAccess && !HasPermissionReview) { return(Redirect("/Home/UnAuthor")); } ThongTinVanBanDiVM myModel = new ThongTinVanBanDiVM(); myModel.VanBanTrinhKy = HSCV_VANBANDIBusiness.Find(ID); myModel.HasPermissionMainProcess = HasPermissionMainProcess; if (myModel.VanBanTrinhKy == null) { return(Redirect("/Home/UnAuthor")); } #region lấy tên danh mục - do dữ liệu văn bản rất lớn cho nên không join với bảng danh mục mà thực hiện 3,4 câu sub-query, tốc độ nhanh hơn // chỉ áp dụng kiểu truy vấn này với màn hình chi tiết 1 văn bản // ở màn hình danh sách tuyệt đối không áp dụng query ntn var DanhMucDoKhan = DM_DANHMUC_DATABusiness.Find(myModel.VanBanTrinhKy.DOKHAN_ID); if (DanhMucDoKhan != null) { myModel.STR_DOKHAN = DanhMucDoKhan.TEXT; } var DanhMucDoUuTien = DM_DANHMUC_DATABusiness.Find(myModel.VanBanTrinhKy.DOUUTIEN_ID); if (DanhMucDoUuTien != null) { myModel.STR_DOUUTIEN = DanhMucDoUuTien.TEXT; } var DanhMucLinhVuc = DM_DANHMUC_DATABusiness.Find(myModel.VanBanTrinhKy.LINHVUCVANBAN_ID); if (DanhMucLinhVuc != null) { myModel.STR_LINHVUCVANBAN = DanhMucLinhVuc.TEXT; } var DanhMucLoaiVanBan = DM_DANHMUC_DATABusiness.Find(myModel.VanBanTrinhKy.LOAIVANBAN_ID); if (DanhMucLoaiVanBan != null) { myModel.STR_LOAIVANBAN = DanhMucLoaiVanBan.TEXT; } var NguoiKyVanBan = DM_NGUOIDUNGBusiness.Find(myModel.VanBanTrinhKy.NGUOIKY_ID); if (NguoiKyVanBan != null) { myModel.STR_NGUOIKY = NguoiKyVanBan.HOTEN; } //Danh sách tài liệu đính kèm của văn bản TAILIEUDINHKEMBusiness = Get <TAILIEUDINHKEMBusiness>(); myModel.ListTaiLieu = TAILIEUDINHKEMBusiness.GetDataByItemID(ID, LOAITAILIEU.VANBAN); if (!string.IsNullOrEmpty(myModel.VanBanTrinhKy.DONVINHAN_INTERNAL_ID)) { CCTC_THANHPHANBusiness = Get <CCTC_THANHPHANBusiness>(); myModel.ListDonVi = CCTC_THANHPHANBusiness.GetDataByIds(myModel.VanBanTrinhKy.DONVINHAN_INTERNAL_ID.ToListInt(',')); } else { myModel.ListDonVi = new List <CCTC_THANHPHAN>(); } #endregion #endregion #region danh sách comment var HscvVanBanDiTraoDoiBusiness = Get <HSCV_VANBANDI_TRAODOIBusiness>(); myModel.LstNoiDungTraoDoi = HscvVanBanDiTraoDoiBusiness.GetListCommentByVanBanDiId(ID); myModel.LstRootComment = myModel.LstNoiDungTraoDoi.Where(x => x.REPLY_ID == null).OrderByDescending(x => x.NGAYTAO).ToList(); List <long> LstRootCommentIds = myModel.LstRootComment.Select(x => x.ID).ToList(); var LstTaiLieuComment = TAILIEUDINHKEMBusiness.GetDataForTaskByListItemId(LstRootCommentIds, LOAITAILIEU.NOIDUNGTRAODOIVANBANDI); myModel.LstTaiLieuComment = LstTaiLieuComment; #endregion return(View(myModel)); }