Exemple #1
0
        /// <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);
        }
Exemple #2
0
        public JsonResult Create(FormCollection collection)
        {
            AssignUserInfo();
            WF_STREAMBusiness = Get <WF_STREAMBusiness>();
            var result = new JsonResultBO(true);

            try
            {
                var myobj = new WF_STREAM();
                myobj.create_at      = DateTime.Now;
                myobj.create_by      = currentUser.ID;
                myobj.WF_NAME        = collection["WF_NAME"].ToString();
                myobj.WF_DESCRIPTION = collection["WF_DESCRIPTION"].ToString();
                myobj.LEVEL_ID       = collection["CATEGORY"].ToIntOrZero();
                WF_STREAMBusiness.Save(myobj);
            }
            catch
            {
                result.Status  = false;
                result.Message = "Không thêm mới được";
            }
            return(Json(result));
        }