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 JsonResult SavePhatHanhVanBan(FormCollection col) { AssignUserInfo(); SMSDAL.SendSMSDAL sms = new SMSDAL.SendSMSDAL(); SYS_TINNHANBusiness = Get <SYS_TINNHANBusiness>(); LogSMSBusiness = Get <LogSMSBusiness>(); HSCV_VANBANDIBusiness = Get <HSCV_VANBANDIBusiness>(); HSCV_VANBANDENBusiness = Get <HSCV_VANBANDENBusiness>(); DM_NHOMDANHMUCBusiness = Get <DM_NHOMDANHMUCBusiness>(); DM_DANHMUC_DATABusiness = Get <DM_DANHMUC_DATABusiness>(); TAILIEUDINHKEMBusiness = Get <TAILIEUDINHKEMBusiness>(); DM_NGUOIDUNGBusiness = Get <DM_NGUOIDUNGBusiness>(); WF_MODULEBusiness = Get <WF_MODULEBusiness>(); WF_PROCESSBusiness = Get <WF_PROCESSBusiness>(); WF_STATE_FUNCTIONBusiness = Get <WF_STATE_FUNCTIONBusiness>(); WF_STATEBusiness = Get <WF_STATEBusiness>(); WF_STREAMBusiness = Get <WF_STREAMBusiness>(); WF_FUNCTION_DONEBusiness = Get <WF_FUNCTION_DONEBusiness>(); WF_LOGBusiness = Get <WF_LOGBusiness>(); WF_ITEM_USER_PROCESSBusiness = Get <WF_ITEM_USER_PROCESSBusiness>(); CCTC_THANHPHANBusiness = Get <CCTC_THANHPHANBusiness>(); string selectedDept = col["department-choose"]; long? ID = col["ID"].ToLongOrNULL(); if (0 >= ID) { return(Json(new { Type = "ERROR", Message = "Không tìm thấy văn bản cần lưu sổ và phát hành" })); } #region cập nhật thông tin văn bản đi HSCV_VANBANDI VanBanDi = HSCV_VANBANDIBusiness.Find(ID); if (VanBanDi == null) { return(Json(new { Type = "ERROR", Message = "Không tìm thấy văn bản cần lưu sổ và phát hành" })); } if (!string.IsNullOrEmpty(col["SOHIEU"])) { VanBanDi.SOHIEU = col["SOHIEU"]; } VanBanDi.USER_RECEIVE_DIRECTLY = col["USERS_RECEIVE_SPECIAL"]; VanBanDi.DONVINHAN_INTERNAL_ID = selectedDept; VanBanDi.SOTHEOSO = col["SOTHEOSO"]; VanBanDi.SOVANBAN_ID = col["SOVANBAN_ID"].ToIntOrNULL(); if (!string.IsNullOrEmpty(col["TRICHYEU"])) { VanBanDi.TRICHYEU = col["TRICHYEU"].Trim(); } if (!string.IsNullOrEmpty(col["NGAY_HIEULUC"])) { try { VanBanDi.NGAYCOHIEULUC = col["NGAY_HIEULUC"].ToDateTime(); } catch (Exception e) { } } if (!string.IsNullOrEmpty(col["NGAYHET_HIEULUC"])) { try { VanBanDi.NGAYHETHIEULUC = col["NGAYHET_HIEULUC"].ToDateTime(); } catch (Exception e) { } } if (!string.IsNullOrEmpty(col["NGAYBANHANH"])) { try { VanBanDi.NGAYBANHANH = col["NGAYBANHANH"].ToDateTime(); } catch (Exception e) { } } HSCV_VANBANDIBusiness.Save(VanBanDi); #endregion //cập nhật số đi theo văn bản vào số văn bản hiện tại int numbSoDiTheoSo = VanBanDi.SOTHEOSO.GetPrefixNumber(); DM_DANHMUC_DATABusiness.UpdateSoVanBan(VanBanDi.SOVANBAN_ID.GetValueOrDefault(), numbSoDiTheoSo); #region Convert Văn bản List <int> ListDonVi = selectedDept.ToListInt(','); DateTime? NGAY_HIEULUC = col["NGAY_HIEULUC"].ToDateTime(); DateTime? NGAYHET_HIEULUC = col["NGAYHET_HIEULUC"].ToDateTime(); string TRICHYEU = col["TRICHYEU"]; string SOHIEU = col["SOHIEU"]; if (!string.IsNullOrEmpty(SOHIEU)) { SOHIEU = SOHIEU.Trim(); } if (!string.IsNullOrEmpty(TRICHYEU)) { TRICHYEU = TRICHYEU.Trim(); } List <TAILIEUDINHKEM> ListTaiLieu = TAILIEUDINHKEMBusiness.GetDataByItemID(ID.HasValue ? ID.Value : 0, LOAITAILIEU.VANBAN); DM_NGUOIDUNG NguoiDung = DM_NGUOIDUNGBusiness.Find(VanBanDi.NGUOIKY_ID); #endregion #region cập nhật wf function done var process = WF_PROCESSBusiness.GetProcess(VanBanDi.ID, MODULE_CONSTANT.VANBANTRINHKY); var function = WF_STATE_FUNCTIONBusiness.GetStateFunction((int)process.CURRENT_STATE); var functionDone = new WF_FUNCTION_DONE(); functionDone.ITEM_TYPE = MODULE_CONSTANT.VANBANTRINHKY; functionDone.ITEM_ID = VanBanDi.ID; functionDone.STATE = process.CURRENT_STATE; functionDone.FUNCTION_STATE = function.ID; functionDone.create_at = DateTime.Now; functionDone.create_by = currentUser.ID; WF_FUNCTION_DONEBusiness.Save(functionDone); var log = new WF_LOG(); log.ITEM_ID = VanBanDi.ID; log.ITEM_TYPE = MODULE_CONSTANT.VANBANTRINHKY; log.MESSAGE = "<div class='label label-info'>Đã phát hành</div>"; log.WF_ID = process.WF_ID; log.create_at = DateTime.Now; log.create_by = currentUser.ID; log.NGUOIXULY_ID = currentUser.ID; WF_LOGBusiness.Save(log); //Ghi nhận luồng đã xử lý xong var state = WF_STATEBusiness.Find(process.CURRENT_STATE); if (state != null && state.IS_KETTHUC == true) { process.IS_END = true; WF_PROCESSBusiness.Save(process); } var itemprocess = WF_ITEM_USER_PROCESSBusiness.repository.All().Where(x => x.ITEM_ID == process.ITEM_ID && x.ITEM_TYPE == process.ITEM_TYPE && x.STEP_ID == process.CURRENT_STATE) .FirstOrDefault(); if (itemprocess != null) { itemprocess.DAXULY = true; WF_ITEM_USER_PROCESSBusiness.Save(itemprocess); } #endregion //gửi văn bản đi cho đơn vị SaveVanBanPhatHanhToDonVi(VanBanDi, sms); //gửi văn bản đi cho cá nhân SaveVanBanPhatHanhToCaNhan(VanBanDi, sms); return(Json(new { Type = "SUCCESS", Message = "Lưu sổ và phát hành văn bản thành công" })); }
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)); }