コード例 #1
0
ファイル: PermissionService.svc.cs プロジェクト: JuRogn/OA
        public static string GetCustomerPermissionJson(string roleId)
        {
            using (EntityMenuCustomPermBLL bll = new EntityMenuCustomPermBLL())
            {
                IQueryable<T_SYS_ENTITYMENUCUSTOMPERM> cuspers = bll.GetCustomPermByRoleID(roleId);
                var q = from ent in cuspers
                        group ent by new
                        {
                            ent.T_SYS_ENTITYMENU.ENTITYMENUID,
                            ent.T_SYS_PERMISSION.PERMISSIONID
                        }
                            into g
                            select new
                            {

                                MenuId = g.Key.ENTITYMENUID,
                                PermissionId = g.Key.PERMISSIONID,
                                g
                            };

                CustomerPermission obj = new CustomerPermission();
                obj.EntityMenuId = q.FirstOrDefault().MenuId;
                obj.PermissionValue = new List<PermissionValue>();

                foreach (var menus in q)
                {
                    PermissionValue menuP = new PermissionValue();
                    menuP.Permission = menus.PermissionId;
                    menuP.OrgObjects = new List<OrgObject>();
                    foreach (var item in menus.g)
                    {
                        OrgObject orgobj = new OrgObject();
                        if (!string.IsNullOrWhiteSpace(item.COMPANYID))
                        {
                            orgobj.OrgID = item.COMPANYID;
                            orgobj.OrgType = "0";
                        }
                        if (!string.IsNullOrWhiteSpace(item.DEPARTMENTID))
                        {
                            orgobj.OrgID = item.DEPARTMENTID;
                            orgobj.OrgType = "1";
                        }
                        if (!string.IsNullOrWhiteSpace(item.POSTID))
                        {
                            orgobj.OrgID = item.POSTID;
                            orgobj.OrgType = "2";
                        }
                        menuP.OrgObjects.Add(orgobj);
                    }
                    obj.PermissionValue.Add(menuP);
                }


                //objs.PermissionValue = p;
                return JsonHelper.GetJson<CustomerPermission>(obj);
            }
        }
コード例 #2
0
ファイル: PermissionService.svc.cs プロジェクト: JuRogn/OA
        public List<CustomerPermission> GetCutomterPermissionObj(string RoleID)
        {
            //EntityMenuCustomPermBLL bll = new EntityMenuCustomPermBLL();
            //IQueryable<T_SYS_ENTITYMENUCUSTOMPERM> CusPermissions = bll.GetCustomPermByRoleID(RoleID);
            try
            {
                SMT.Foundation.Log.Tracer.Debug("开始获取自定义角色222:" + RoleID + " " + System.DateTime.Now.ToString());
                using (EntityMenuCustomPermBLL bll = new EntityMenuCustomPermBLL())
                {

                    IQueryable<V_EntityMenuCustomperm> cuspers = bll.GetCustomPermByRoleIDNew(RoleID);
                    List<CustomerPermission> CusPers = new List<CustomerPermission>();
                    if (cuspers != null)
                    {
                        //var entiyMenuPs = from ent in cuspers
                        //                  where ent.T_SYS_ROLE.ROLEID == RoleID
                        //                  select ent;
                        SMT.Foundation.Log.Tracer.Debug("开始获取自定义角色记录数:" + cuspers.Count().ToString() + " " + System.DateTime.Now.ToString());
                        if (cuspers.Count() > 0)
                        {
                            //遍历取菜单
                            foreach (var menus in cuspers)
                            {
                                CustomerPermission obj = new CustomerPermission();
                                obj.EntityMenuId = menus.ENTITYMENUID;
                                obj.PermissionValue = new List<PermissionValue>();

                                if (cuspers.Count() > 0)
                                {
                                    var ent1 = from ent in CusPers
                                               where ent.EntityMenuId == obj.EntityMenuId
                                               select ent;
                                    if (ent1.Count() > 0)
                                        continue;
                                }
                                //遍历取权限
                                var Perms = from ent in cuspers
                                            where ent.ENTITYMENUID == menus.ENTITYMENUID
                                            select ent;
                                foreach (var Perm in Perms)
                                {
                                    PermissionValue menuP = new PermissionValue();
                                    menuP.Permission = Perm.PERMISSIONID;
                                    menuP.OrgObjects = new List<OrgObject>();
                                    //遍历组织架构
                                    var orgObj = from ent in cuspers
                                                 where ent.ENTITYMENUID == menus.ENTITYMENUID
                                                 && ent.PERMISSIONID == Perm.PERMISSIONID
                                                 select ent;

                                    foreach (var item in orgObj)
                                    {
                                        OrgObject orgobj = new OrgObject();
                                        if (!string.IsNullOrWhiteSpace(item.COMPANYID))
                                        {
                                            orgobj.OrgID = item.COMPANYID;
                                            orgobj.OrgType = "0";
                                        }
                                        if (!string.IsNullOrWhiteSpace(item.DEPARTMENTID))
                                        {
                                            orgobj.OrgID = item.DEPARTMENTID;
                                            orgobj.OrgType = "1";
                                        }
                                        if (!string.IsNullOrWhiteSpace(item.POSTID))
                                        {
                                            orgobj.OrgID = item.POSTID;
                                            orgobj.OrgType = "2";
                                        }
                                        menuP.OrgObjects.Add(orgobj);
                                    }
                                    obj.PermissionValue.Add(menuP);
                                }
                                CusPers.Add(obj);

                            }
                        }
                    }


                    return CusPers;

                }
            }
            catch (Exception ex)
            {
                SMT.Foundation.Log.Tracer.Debug("GetCutomterPermissionObj:" + ex.Message.ToString());
                return null;
            }


        }