Exemplo n.º 1
0
        /// <summary>
        /// 从全部当前激活的合同中排除
        /// </summary>
        /// <param name="id"></param>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public ERROR_CODE Exclude(long id, long user_id)
        {
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {
                // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            var exc      = new ctt_contract_dal();
            var exc_role = new ctt_contract_exclusion_role_dal();
            ctt_contract_exclusion_role role = new ctt_contract_exclusion_role();

            var excc = exc.FindListBySql <ctt_contract>($"select * from ctt_contract where status_id = 1 and end_date> CURDATE() and delete_time = 0");

            if (excc.Count > 0)
            {
                foreach (var i in excc)
                {
                    var exccrole = exc_role.FindListBySql <ctt_contract_exclusion_role>($"select * from ctt_contract_exclusion_role where role_id={id} and contract_id={i.id} and delete_time=0");
                    if (exccrole == null)
                    {
                        try
                        {
                            role.contract_id    = i.id;
                            role.id             = (int)(_dal.GetNextIdCom());
                            role.role_id        = id;
                            role.create_user_id = role.update_user_id = user_id;
                            role.create_time    = role.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                            exc_role.Insert(role);
                            var add_log = new sys_oper_log()
                            {
                                user_cate           = "用户",
                                user_id             = (int)user.id,
                                name                = user.name,
                                phone               = user.mobile == null ? "" : user.mobile,
                                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.CONTRACT_EXCLUSTION_ROLE, //角色
                                oper_object_id      = role.id,                                         // 操作对象id
                                oper_type_id        = (int)OPER_LOG_TYPE.ADD,
                                oper_description    = _dal.AddValue(role),
                                remark              = "新增合同例外因素--角色"
                            };                                      // 创建日志
                            new sys_oper_log_dal().Insert(add_log); // 插入日志
                        }
                        catch
                        {
                            return(ERROR_CODE.ERROR);
                        }
                    }
                }
            }
            else
            {
                return(ERROR_CODE.CONTRACT_NO_ACTIVE);
            }
            return(ERROR_CODE.SUCCESS);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取一个合同可选的角色列表
        /// </summary>
        /// <param name="contractId"></param>
        /// <returns></returns>
        public List <sys_role> GetAvailableRoles(long contractId)
        {
            var list          = new sys_role_dal().GetList();
            var exclusionList = new ctt_contract_exclusion_role_dal().FindListByContractId(contractId);

            if (exclusionList == null || exclusionList.Count == 0)
            {
                return(list);
            }

            List <sys_role> roles = new List <sys_role>();

            foreach (var role in list)
            {
                if (!exclusionList.Exists(r => r.role_id == role.id))
                {
                    roles.Add(role);
                }
            }

            return(roles);
        }