public JsonResult Create(FormCollection collection) { AssignUserInfo(); WF_MODULEBusiness = Get <WF_MODULEBusiness>(); var result = new JsonResultBO(true); try { var myobj = new WF_MODULE(); myobj.WF_STREAM_ID = collection["WF_STREAM_ID"]; myobj.create_at = DateTime.Now; myobj.create_by = currentUser.ID; myobj.MODULE_CODE = collection["MODULE_CODE"].ToString(); myobj.MODULE_TITLE = collection["MODULE_TITLE"].ToString(); if (WF_MODULEBusiness.ExistCode(myobj.MODULE_CODE)) { result.Message = "Module này đã tồn tài"; result.Status = false; } else { WF_MODULEBusiness.Save(myobj); } } catch { result.Status = false; result.Message = "Không thêm mới được"; } return(Json(result)); }
/// <summary> /// @author: duynn /// @description: kiểm tra các văn bản đến gửi nội bộ đã được đọc /// </summary> /// <param name="itemType"></param> /// <param name="itemId"></param> /// <param name="departmentId"></param> /// <returns></returns> public bool CheckIsRead(string itemType, long itemId, CCTC_THANHPHAN department, UserInfoBO currentUser) { bool isRead = false; if (itemType == MODULE_CONSTANT.VANBANDENNOIBO) { WF_MODULE module = null; if (department.TYPE == 10) { module = this.context.WF_MODULE.Where(x => x.MODULE_CODE == MODULE_CONSTANT.VANBANDEN) .FirstOrDefault(); } else if (department.PARENT_ID == currentUser.DeptParentID) { module = this.context.WF_MODULE.Where(x => x.MODULE_CODE == MODULE_CONSTANT.VANBANDENNOIBO) .FirstOrDefault(); } if (module != null) { var workFlowIds = module.WF_STREAM_ID.ToListInt(','); WF_STREAM stream = this.context.WF_STREAM.Where(x => x.LEVEL_ID == department.CATEGORY && workFlowIds.Contains(x.ID)).FirstOrDefault(); WF_STATE state = this.context.WF_STATE.Where(x => x.IS_START == true && x.WF_ID == stream.ID).FirstOrDefault(); var userBusiness = new DM_NGUOIDUNGBusiness(new UnitOfWork()); List <long> userIds = new List <long>(); if (department.TYPE == 10) { userIds = userBusiness .GetUserByRoleAndParentDept(state.VAITRO_ID.GetValueOrDefault(), department.ID) .Select(x => long.Parse(x.Value)).ToList(); } else if (department.PARENT_ID == currentUser.DeptParentID) { userIds = userBusiness .GetUserByRoleAndDeptId(state.VAITRO_ID.GetValueOrDefault(), department.ID) .Select(x => long.Parse(x.Value)).ToList(); } if (!userIds.Any()) { //lấy người dùng có vai trò cao nhất var highestPriorityUser = userBusiness.GetUserHighestPriority(department.ID); userIds.Add(highestPriorityUser.ID); } isRead = (from read in this.context.HSCV_READVANBAN.Where(x => x.TYPE == 1) join vanban in this.context.HSCV_VANBANDEN.Where(x => x.VANBANDI_ID == itemId) on read.VANBAN_ID equals vanban.ID join user in this.context.DM_NGUOIDUNG on read.USER_ID equals user.ID join dept in this.context.CCTC_THANHPHAN on user.DM_PHONGBAN_ID equals dept.ID select read.USER_ID).Where(x => userIds.Contains(x)).Count() > 0; } } return(isRead); }
/// <summary> /// @author: duynn /// @description: lấy trạng thái cuối cùng của đối tượng trong luồng xử lý /// </summary> /// <param name="itemType"></param> /// <param name="user"></param> /// <returns></returns> public WF_STATE GetFinalStateOfItem(string itemType, UserInfoBO user) { WF_STATE result = new WF_STATE(); WF_MODULE wfModule = this.context.WF_MODULE.Where(x => x.MODULE_CODE == itemType).FirstOrDefault(); if (wfModule != null && string.IsNullOrEmpty(wfModule.WF_STREAM_ID) == false) { //Lấy thông tin luồng xử lý var department = this.context.CCTC_THANHPHAN.Find(user.DM_PHONGBAN_ID) ?? new CCTC_THANHPHAN(); var wfStreamIds = wfModule.WF_STREAM_ID.ToListInt(','); var wfStream = this.context.WF_STREAM .Where(x => x.LEVEL_ID == department.CATEGORY && wfStreamIds.Contains(x.ID)) .FirstOrDefault() ?? new WF_STREAM(); result = this.context.WF_STATE .Where(x => x.WF_ID == wfStream.ID && x.IS_KETTHUC == true) .FirstOrDefault(); } return(result); }