예제 #1
0
        public IHttpActionResult Delete(string roleId)
        {
            if (string.IsNullOrEmpty(roleId))
            {
                return(BadRequest("非法请求!"));
            }

            try
            {
                RoleFunctionBLL      rfBLL    = new RoleFunctionBLL();
                IList <RoleFunction> roleFuns = rfBLL.GetList(p => !p.ISDELETED && p.ROLEID.Equals(roleId));
                foreach (RoleFunction fun in roleFuns)
                {
                    fun.IsDeleted = true;
                    rfBLL.Edit(fun);
                }

                bll.Delete(roleId);

                return(Ok("ok"));
            }
            catch
            {
                return(BadRequest("异常!"));
            }
        }
예제 #2
0
        public void RoleFunctionAdd(HttpContext context)
        {
            int    RoleId        = 0;
            string FunctionArray = "";

            if (!string.IsNullOrEmpty(GetParam("RoleId", context).ToString()))
            {
                RoleId = Convert.ToInt32(GetParam("RoleId", context).ToString());
            }
            if (!string.IsNullOrEmpty(GetParam("FunctionArray", context).ToString()))
            {
                FunctionArray = GetParam("FunctionArray", context).ToString();
            }

            string          objOrder        = GetParam("RoleFunctionModel", context);
            RoleFunction    roleFunction    = JsonConvert.DeserializeObject <RoleFunction>(objOrder);
            RoleFunctionBLL roleFunctionbll = new RoleFunctionBLL();
            int             result          = 0;

            if (RoleId != 0)
            {
                if (RoleId > 0)
                {
                    result = roleFunctionbll.UpdateRoleFun(RoleId, FunctionArray) ? 1 : 0;
                }
            }
            context.Response.Write(result);
        }
예제 #3
0
        public void GetAssignCheck(HttpContext context)
        {
            RoleFunctionBLL     roleFunctionbll = new RoleFunctionBLL();
            List <RoleFunction> list            = new List <RoleFunction>();
            int RoleId = 0;

            if (!string.IsNullOrEmpty(GetParam("RoleId", context).ToString()))
            {
                RoleId = Convert.ToInt32(GetParam("RoleId", context).ToString());
            }

            list = roleFunctionbll.GetModelList(" RoleId=" + RoleId + "  AND IsDeleted=0 ");
            var b = SerializerHelper.SerializeObject(new { data = list });

            context.Response.Write(b);
        }
예제 #4
0
        public void VerifyRelationRole(HttpContext context)
        {
            var             FunctionID = context.Request.QueryString["FunctionID"];
            RoleFunctionBLL bll        = new RoleFunctionBLL();
            DataSet         ds         = new DataSet();
            int             b          = 0;

            if (!string.IsNullOrEmpty(FunctionID))
            {
                ds = bll.GetList(" FunctionId= " + FunctionID + " and IsDeleted=0");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    b = ds.Tables[0].Rows[0]["FunctionId"].ToInt();
                }
            }
            context.Response.Write(b);
        }
예제 #5
0
        public IHttpActionResult Get([FromUri] Request <HR_CNR_USER> request)
        {
            Response <IEnumerable <object> > response = new Response <IEnumerable <object> >();

            try
            {
                var model = _repository.FindAll();

                if (model == null)
                {
                    return(NotFound());
                }

                if (!string.IsNullOrEmpty(request.Keyword))
                {
                    model = model.Where(o => o.IDCARD.Equals(request.Keyword));
                }
                if (!string.IsNullOrEmpty(request.UserName))
                {
                    model = model.Where(o => o.NAME.Contains(request.UserName));
                }
                UserInfo user = new UserInfoService().GetCurrentUser();
                if (user == null)
                {
                    return(BadRequest("获取不到当前用户信息!"));
                }
                ArrayList args         = new ArrayList();
                string    filterString = new RoleFunctionBLL().GetFilterString(user.UserId, "HR_CNR_USER", PermissionType.View, ref args);
                model = model.where (filterString, args.ToArray());
                List <HR_CNR_USER> list = model.ToList();
                for (int i = 0; i < list.Count; i++)
                {
                    HR_CNR_USER entity = list[i];
                    PersonInfo  person = null;
                    if (!string.IsNullOrEmpty(entity.PERSONID))
                    {
                        int personID = 0;
                        int.TryParse(entity.PERSONID, out personID);
                        if (personID > 0)
                        {
                            person = personRepostitory.Get(personID);
                        }
                    }
                    else if (!string.IsNullOrEmpty(entity.IDCARD))
                    {
                        person = personRepostitory.Get(entity.IDCARD);
                    }
                    if (person != null)
                    {
                        if (person.BirthDate.Length <= 4)
                        {
                            continue;
                        }
                        int birthDateYear = Convert.ToInt32(person.BirthDate.Substring(0, 4));
                        entity.AGE = DateTime.Now.Year - birthDateYear + 1;
                        switch (person.Gender)
                        {
                        case "1":
                            entity.SEX = "男";
                            break;

                        case "2":
                            entity.SEX = "女";
                            break;

                        case "0":
                            entity.SEX = "未知";
                            break;

                        default:
                            entity.SEX = "其他";
                            break;
                        }
                    }
                }
                response.Data = list;
                return(Ok(response));
            }
            catch (Exception ex)
            {
                LogHelper.WriteError(ex.ToString());
                return(BadRequest(ex.Message));
            }
        }
예제 #6
0
        public IHttpActionResult Post([FromBody] Request <ExtRole> request)
        {
            try
            {
                IList <RoleFunction> roleFuns = request.Data.RoleFuns;
                string roleId         = request.Data.RoleID;
                string roleName       = request.Data.RoleName;
                int    systemCategory = (int)request.Data.SystemCategory;
                string remark         = request.Data.Remark;

                MetaDataBLL     metaBLL   = new MetaDataBLL();
                List <MetaData> metaDatas = metaBLL.GetList(string.Empty);

                RoleFunctionBLL rfBLL = new RoleFunctionBLL();
                Role            mode  = new Role();
                if (string.IsNullOrEmpty(roleId))
                {
                    mode.RoleName       = roleName;
                    mode.SystemCategory = systemCategory;
                    mode.Remark         = remark;
                    mode.CreateDateTime = DateTime.Now;

                    roleId = bll.Add(mode);
                    if (string.IsNullOrEmpty(roleId))
                    {
                        return(BadRequest("异常"));
                    }

                    foreach (RoleFunction fun in roleFuns)
                    {
                        fun.RoleID         = roleId;
                        fun.CreateDateTime = DateTime.Now;

                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                        sb.AppendFormat("<data version=\"2.0\">");

                        string[] _arr1 = fun.DataRange.Split(',');
                        foreach (string str in _arr1)
                        {
                            string[] _arr2 = str.Split('#');
                            if (_arr2.Length != 5)
                            {
                                continue;
                            }
                            int    _id = int.Parse(_arr2[1]);
                            string col = GetValue(metaDatas, _id);
                            sb.AppendFormat("<item>");
                            sb.AppendFormat("<relationship>{0}</relationship>", _arr2[3]);
                            sb.AppendFormat("<nameID>{0}</nameID>", _arr2[1]);
                            sb.AppendFormat("<name>{0}</name>", _arr2[0]);
                            sb.AppendFormat("<operation>{0}</operation>", _arr2[2]);
                            sb.AppendFormat("<value>{0}</value>", _arr2[4]);
                            sb.AppendFormat("<column>{0}</column>", col);
                            sb.AppendFormat("</item>");
                        }
                        sb.AppendFormat("</data>");

                        rfBLL.Add(fun);
                    }
                }
                else
                {
                    mode = bll.Get(roleId);
                    if (mode == null)
                    {
                        return(BadRequest("该记录不存在!"));
                    }
                    mode.RoleName       = roleName;
                    mode.SystemCategory = systemCategory;
                    mode.Remark         = remark;
                    mode.EditTime       = DateTime.Now;

                    bll.Edit(mode);
                    List <RoleFunction> hasRF = rfBLL.GetList(p => p.ROLEID.Equals(roleId) && p.ISDELETED == false);
                    foreach (RoleFunction fun in hasRF)
                    {
                        rfBLL.Delete(fun.RoleFunctionID);
                    }

                    foreach (RoleFunction fun in roleFuns)
                    {
                        fun.RoleID         = roleId;
                        fun.CreateDateTime = DateTime.Now;

                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                        sb.AppendFormat("<data version=\"2.0\">");

                        string[] _arr1 = fun.DataRange.Split(',');
                        foreach (string str in _arr1)
                        {
                            string[] _arr2 = str.Split('#');
                            if (_arr2.Length != 5)
                            {
                                continue;
                            }
                            int    _id = int.Parse(_arr2[1]);
                            string col = GetValue(metaDatas, _id);
                            sb.AppendFormat("<item>");
                            sb.AppendFormat("<relationship>{0}</relationship>", _arr2[3]);
                            sb.AppendFormat("<nameID>{0}</nameID>", _arr2[1]);
                            sb.AppendFormat("<name>{0}</name>", _arr2[0]);
                            sb.AppendFormat("<operation>{0}</operation>", _arr2[2]);
                            sb.AppendFormat("<value>{0}</value>", _arr2[4]);
                            sb.AppendFormat("<column>{0}</column>", col);
                            sb.AppendFormat("</item>");
                        }
                        sb.AppendFormat("</data>");
                        fun.DataRange = sb.ToString();

                        rfBLL.Add(fun);
                    }
                }

                return(Ok("ok"));
            }
            catch (Exception ex)
            {
                LogHelper.WriteInfo(ex.ToString());
                return(BadRequest("异常!"));
            }
        }
예제 #7
0
        public IHttpActionResult Get(string roleId)
        {
            if (string.IsNullOrEmpty(roleId))
            {
                return(BadRequest("非法请求!"));
            }

            //申明返回对象
            ExtRole model = new ExtRole();
            Role    role  = bll.Get(roleId);

            if (role == null)
            {
                return(BadRequest("该记录不存在!"));
            }
            model.RoleID         = role.RoleID;
            model.RoleName       = role.RoleName;
            model.SystemCategory = role.SystemCategory;
            model.Remark         = role.Remark;
            model.ExtFuns        = new List <ExtFun>();

            FunctionBLL     fctionBLL = new FunctionBLL();
            RoleFunctionBLL rfBLL     = new RoleFunctionBLL();
            PermissionBLL   perBLL    = new PermissionBLL();

            List <Function>     Functions   = fctionBLL.GetList(p => p.ISMENU && !string.IsNullOrEmpty(p.PARENTID) && !p.ISPUBLIC && !p.ISDELETED);
            List <Permission>   Permissions = perBLL.GetList();
            List <RoleFunction> roleFuns    = rfBLL.GetList(p => !p.ISDELETED && p.ROLEID.Equals(roleId));

            foreach (Function fun in Functions)
            {
                List <Permission> _temPermission = new List <Permission>();

                foreach (Permission pm in Permissions)
                {
                    Permission _temp = new Permission();
                    _temp.PermissionID    = pm.PermissionID;
                    _temp.PermissionName  = pm.PermissionName;
                    _temp.PermissionValue = pm.PermissionValue;
                    _temp.PermissionCode  = pm.PermissionCode;
                    _temp.Remark          = pm.Remark;
                    _temp.CreateUserID    = pm.CreateUserID;
                    _temp.CreateUserName  = pm.CreateUserName;
                    _temp.CreateDateTime  = pm.CreateDateTime;
                    _temp.EditUserID      = pm.EditUserID;
                    _temp.EditUserName    = pm.EditUserName;
                    _temp.EditTime        = pm.EditTime;
                    _temp.OwnerID         = pm.OwnerID;
                    _temp.OwnerName       = pm.OwnerName;
                    _temp.IsDeleted       = pm.IsDeleted;

                    foreach (RoleFunction roleFun in roleFuns)
                    {
                        if (roleFun.FunctionID == fun.FunctionID && roleFun.PermissionValue == pm.PermissionValue)
                        {
                            _temp.Remark    = roleFun.DataRange;
                            _temp.IsDeleted = true;
                            break;
                        }
                    }

                    _temPermission.Add(_temp);
                }

                ExtFun extFun = new ExtFun();
                extFun.FunctionID   = fun.FunctionID;
                extFun.FunctionCode = "";
                extFun.FunctionName = fun.FunctionName;
                extFun.IsMenu       = fun.IsMenu;
                extFun.Permissions  = _temPermission;

                model.ExtFuns.Add(extFun);
            }

            return(Ok(model));
        }