Ejemplo n.º 1
0
        private void BuildOrgTree(AjaxTreeNode tn, List<string> dataPriveleges)
        {
            IDictionary<string, object> dic = new Dictionary<string, object>();
            dic.Add("ParentID", tn.ID);
            dic.Add("Status", "0");
            IList<Organization> orgs =repository.FindAll<Organization>(dic);//.Where(o => IsAdmin || dataPriveleges.Exists(p => o.OwnerOrg.StartsWith(p))).OrderBy(o => o.SortOrder).ToList();
            if (orgs.Count == 0 && string.Equals(Request.QueryString["Entry"], "Operator"))
            {
                BuildUserTree(tn);
            }
            foreach (var item in orgs)
            {
                string value = string.Format("{0}/{1}", tn.Value, item.ID);

                AjaxTreeNode node = new AjaxTreeNode()
                {
                    ID = item.ID,
                    Text = item.Name,
                    Value = value,
                    Tag = "Org",
                    NodeIcoSrc = tn.NodeIcoSrc,
                    IcoSrc = string.Format("{0}Plugins/Authorize/Content/Themes/{1}/Images/{2}", WebUtil.GetRootPath(), Skin, getResourceIcon(item.Type.Cast<ResourceType>(ResourceType.Menu))),
                    Target = "ifrMain"
                };

                tn.ChildNodes.Add(node);
                BuildOrgTree(node, dataPriveleges);
            }
        }
Ejemplo n.º 2
0
        private void BuildUserTree(AjaxTreeNode tn)
        {
            Organization org = repository.GetDomain<Organization>(tn.ID);
            List<Operator> operatorList = repository.Query<Operator>().Where(o => o.OwnerOrg.Equals(org.Code)).ToList();
            foreach (var item in operatorList)
            {
                //string value = string.Format("{0}/{1}", tn.Value, item.ID);

                AjaxTreeNode node = new AjaxTreeNode()
                {
                    ID = item.ID,
                    Text = item.UserName,
                    Value = item.ID,
                    Tag = "Operator",
                    ShowCheckBox = true,
                    Checked = false,
                };
                tn.ChildNodes.Add(node);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 创建目录树方法
        /// </summary>
        /// <param name="tn">目录树的节点</param>
        private void BuildTree(AjaxTreeNode tn)
        {
            List<Resource> resources =repository.All<Resource>().Where(o => o.ParentID == tn.ID).OrderBy(o => o.SortOrder).ToList();

            foreach (var res in resources)
            {
                AjaxTreeNode node = new AjaxTreeNode()
                {
                    ID = res.ID,
                    Text = res.Text,
                    Value = res.ID,
                    Tag = res.Type.ToString(),
                    NodeIcoSrc = tn.NodeIcoSrc,
                    IcoSrc = string.Format("{0}Plugins/Authorize/Content/Themes/{1}/Images/{2}", WebUtil.GetRootPath(), Skin, getResourceIcon(res.Type.Cast<ResourceType>(ResourceType.Menu)))
                };

                tn.ChildNodes.Add(node);
                //递归获取目录树
                BuildTree(node);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 创建目录树方法
        /// </summary>
        /// <param name="tn">目录树的节点</param>
        private void BuildTree(AjaxTreeNode tn)
        {
            List<Dict> dicts = dictService.All().Where(o => o.ParentID == tn.ID).OrderBy(o => o.SortOrder).ToList();

            foreach (var dict in dicts)
            {
                AjaxTreeNode node = new AjaxTreeNode()
                {
                    ID = dict.ID,
                    Text = dict.Text,
                    Value = dict.ID,
                    Tag = dict.ID,
                    NodeIcoSrc = tn.NodeIcoSrc,
                    IcoSrc = string.Format("{0}Plugins/eCloud/Content/Themes/{1}/Images/{2}", WebUtil.GetRootPath(), Skin, getResourceIcon("childDict"))
                };

                tn.ChildNodes.Add(node);
                //递归获取目录树
                BuildTree(node);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 初始化树
        /// </summary>
        private void InitTree()
        {
            AjaxTree1.PostType = PostType.None;
            AjaxTree1.ShowNodeIco = true;
            AjaxTree1.ShowCheckBox = !string.Equals(Request.QueryString["Entry"], "Operator");
            AjaxTree1.IsAjaxLoad = false;
            AjaxTree1.SelectionMode = SelectionMode.Single;
            AjaxTree1.Nodes.Clear();

            List<string> dataPriveleges =new AuthorizeService().GetDataPriveleges(User.ID);

            string root = Configure.Get("OrgRootID");
            Organization org = repository.GetDomain<Organization>(root);
            if (org == null) return;
            AjaxTreeNode parentNode = new AjaxTreeNode()
            {
                ID = org.ID,
                Text = org.Name,
                Value = org.Code,
                Tag = org.ID,
                NodeState = AgileEAP.WebControls.NodeState.Open,
                IcoSrc = string.Format("{0}Plugins/Authorize/Content/Themes/{1}/Images/orgtree.gif", WebUtil.GetRootPath(), Skin),
                Target = "ifrMain",
                VirtualNodeCount = repository.All<Organization>().Count(o => o.ParentID == root)
            };

            AjaxTree1.Nodes.Add(parentNode);

            BuildOrgTree(parentNode, dataPriveleges);
        }
        /// <summary>
        /// 初始化树
        /// </summary>
        private void InitRolePrivilege(string userID, short authFlag)
        {
            try
            {
                AjaxTree1.PostType = PostType.NoPost;
                AjaxTree1.IsAjaxLoad = false;
                AjaxTree1.ShowNodeIco = false;
                AjaxTree1.ShowCheckBox = true;
                AjaxTree1.SelectionMode = authFlag == 2 ? SelectionMode.Multiple : SelectionMode.RelatedMultiple;
                AjaxTree1.Nodes.Clear();

                Resource appResource = repository.All<Resource>().FirstOrDefault(o => o.ID == AppID);
                string rootPriId = GetPidByResId(appResource.ID);
                List<string> privilegeIDs = authService.GetAllPrivilegeIDs(userID);

                IDictionary<string, object> parameters = new Dictionary<string, object>();
                parameters.SafeAdd("OperatorID", userID);
                parameters.SafeAdd("AuthFlag", authFlag);
                List<SpecialPrivilege> sPrivileges =repository.FindAll<SpecialPrivilege>(parameters).ToList();
                List<string> sPrivilegeIDs = sPrivileges == null ? new List<string>() : sPrivileges.Select(o => o.PrivilegeID).ToList();

                AjaxTreeNode appNode = new AjaxTreeNode()
                {
                    ID = rootPriId,
                    Text = appResource.Text,
                    Value = rootPriId,
                    Tag = "root",
                    IcoSrc = string.Format("{0}Plugins/Authorize/Content/Themes/{1}/Images/menu.gif", WebUtil.GetRootPath(), Skin),
                    NodeState = NodeState.Open,
                    Checked = sPrivilegeIDs.Contains(rootPriId),
                    ShowCheckBox = !(authFlag == 1 && (privilegeIDs.Contains(rootPriId)))

                };
                AjaxTree1.Nodes.Add(appNode);

                List<Resource> resources = repository.All<Resource>().Where(o => o.ParentID == appResource.ID && (IsAdmin || GetResourceIDsByUser().Contains(o.ID))).OrderBy(o => o.SortOrder).ToList();
                resources = ResourcesFilter(resources, privilegeIDs, authFlag);
                foreach (Resource resource in resources)
                {
                    string priId = GetPidByResId(resource.ID);
                    AjaxTreeNode node = new AjaxTreeNode()
                    {
                        ID = priId,
                        Text = resource.Text,
                        Value = resource.ID,
                        Tag = ResourceType.Page.ToString(),
                        NodeState = NodeState.Open,
                        Checked = sPrivilegeIDs.Contains(priId),
                        ShowCheckBox = !(authFlag == 1 && privilegeIDs.Contains(priId))
                    };
                    AddChildResource(node, privilegeIDs, sPrivilegeIDs, authFlag);
                    appNode.ChildNodes.SafeAdd(node);
                }
            }
            catch (Exception ex)
            {
                log.Error(string.Format("加载用户{0}特殊权限出错", userID), ex);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 获取子节点
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        private AjaxTreeNodeCollection getChildrenNodes(string id)
        {
            AjaxTreeNodeCollection result = new AjaxTreeNodeCollection();

            IList<Participantor> participantors = workflowEngine.GetRoleAndOrgParticipantors().Where(p => p.ParentID == id).ToList();
            foreach (Participantor participantor in participantors)
            {
                AjaxTreeNode node = new AjaxTreeNode()
                {
                    ID = participantor.ID,
                    Text = participantor.Name,
                    Value = participantor.ID,
                    Tag = Enum.Parse(typeof(ParticipantorType), participantor.ParticipantorType.ToString()).ToString(),
                    IcoSrc = string.Format("{0}Plugins/Workflow/Content/Themes/{1}/Images/{2}", WebUtil.GetRootPath(), Skin, getResourceIcon(participantor.ParticipantorType.ToSafeString())),
                    VirtualNodeCount = workflowEngine.GetRoleAndOrgParticipantors().Count(o => o.ParentID == participantor.ID),
                };

                result.Add(node);
            }
            return result;
        }
Ejemplo n.º 8
0
        private AjaxTreeNodeCollection getChildrenNodes(string id)
        {
            AjaxTreeNodeCollection result = new AjaxTreeNodeCollection();

            IList<Organization> organizations = repository.All<Organization>().Where(o => o.ParentID == id && o.Status == 0).OrderBy(o => o.SortOrder).ToList<Organization>();

            if (organizations != null)
            {
                foreach (var org in organizations)
                {
                    AjaxTreeNode node = new AjaxTreeNode()
                    {
                        ID = org.ID,
                        Text = org.Name,
                        Value = org.ID,
                        Tag = org.Type.ToString(),
                        IcoSrc = string.Format("{0}Plugins/Authorize/Content/Themes/{1}/Images/{2}", WebUtil.GetRootPath(), Skin, getResourceIcon(ResourceType.Menu)),
                        VirtualNodeCount = repository.All<Organization>().Count(o => o.ParentID == org.ID) + authService.GetEmployees(org.ID).Count
                    };
                    result.Add(node);
                }
            }

            IList<Employee> employees =authService.GetEmployees(id);

            if (employees != null)
            {
                foreach (var employee in employees)
                {
                    AjaxTreeNode newNode = CreateNode(employee);
                    result.Add(newNode);
                }
            }

            return result;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 初始化树
        /// </summary>
        private void InitTree(string roleID)
        {
            AjaxTree1.PostType = PostType.NoPost;
            AjaxTree1.SelectionMode = SelectionMode.Single;
            AjaxTree1.ShowNodeIco = true;
            AjaxTree1.ShowCheckBox = true;
            AjaxTree1.IsAjaxLoad = false;
            AjaxTree1.Nodes.Clear();

            IDictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.SafeAdd("RoleID", roleID);
            IList<RolePrivilege> rolePrivileges =repository.FindAll<RolePrivilege>(parameters);
            List<string> privileges = rolePrivileges != null ? rolePrivileges.Select(o => o.PrivilegeID).ToList() : new List<string>();
            List<string> metaIDs = repository.FindAll<Privilege>(null).Where(o => privileges.Contains(o.ID) && !string.IsNullOrEmpty(o.MetaDataID)).Select(o => o.MetaDataID).ToList();
            List<string> orgIDs = repository.FindAll<MetaData>(null).Where(o => metaIDs.Contains(o.ID)).Select(o => o.Value).ToList();
            List<Organization> orgRoots = repository.Query<Organization>().Where(o => o.ParentID == "-1").ToList();
            if (orgRoots != null)
            {
                foreach (var org in orgRoots)
                {
                    AjaxTreeNode parentOrgNode = new AjaxTreeNode()
                    {
                        ID = org.ID,
                        Text = org.Name,
                        Value = org.Code,
                        Tag = org.Type.ToString(),
                        IcoSrc = string.Format("{0}Plugins/Authorize/Content/Themes/{1}/Images/{2}", WebUtil.GetRootPath(), Skin, getResourceIcon("city")),
                        NodeState = NodeState.Open,
                        Checked = orgIDs.Exists(o => o.EndsWith(org.ID)),
                    };
                    AjaxTree1.Nodes.Add(parentOrgNode);
                    AddOrg(org, parentOrgNode, orgIDs);
                }
            }
            //List<Organization> orgs = sOrg.All().Where(o => o.ParentID == "-1").OrderBy(o => o.SortOrder).ToList();
            //IDictionary<string, object> parameters = new Dictionary<string, object>();
            //parameters.SafeAdd("RoleID", roleID);
            //IList<RolePrivilege> rolePrivileges = rolePrivilegeService.FindAll(parameters);
            //List<string> privileges = rolePrivileges != null ? rolePrivileges.Select(o => o.PrivilegeID).ToList() : new List<string>();
            //List<string> metaIDs = new AgileEAP.Infrastructure.Service.PrivilegeService().FindAll(null).Where(o => privileges.Contains(o.ID) && !string.IsNullOrEmpty(o.MetaDataID)).Select(o => o.MetaDataID).ToList();
            //List<string> orgIDs = new MetaDataService().FindAll(null).Where(o => metaIDs.Contains(o.ID)).Select(o => o.Value).ToList();
            ////if (User.UserType != 0)
            ////    orgs = orgs.Where(o => orgIDs.Contains(o.ID)).ToList();
            ////获取数据权限树加载深度
            //int maxDepth = AgileEAP.Core.Configure.Get<int>("DataPrivilegeTreeLoadDepth");
            //foreach (var org in orgs)
            //{
            //    AjaxTreeNode node = new AjaxTreeNode()
            //    {
            //        ID = org.ID,
            //        Text = org.Name,
            //        Value = org.ID,
            //        Tag = org.Type.ToString(),
            //        IcoSrc = string.Format("{0}Plugins/Authorize/Content/Themes/{1}/Images/{2}", WebUtil.GetRootPath(), Skin, getResourceIcon(org.Type.Cast<ResourceType>(ResourceType.Menu))),
            //        Checked = orgIDs.Exists(o => o.EndsWith(org.ID)),
            //        NodeState = NodeState.Open
            //    };
            //    BuildTree(node, orgIDs, maxDepth, 1);
            //    AjaxTree1.Nodes.Add(node);
            //}
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 创建目录树方法
        /// </summary>
        /// <param name="tn">目录树的节点</param>
        private void BuildTree(AjaxTreeNode tn, List<string> orgIDs, int maxDepth, int currentDepth)
        {
            if (maxDepth <= currentDepth) return;

            List<Organization> organizations =repository.All<Organization>().Where(o => o.ParentID == tn.ID).OrderBy(o => o.SortOrder).ToList();

            foreach (var org in organizations)
            {
                AjaxTreeNode node = new AjaxTreeNode()
                {
                    ID = org.ID,
                    Text = org.Name,
                    Value = org.Code,
                    Tag = org.Type.ToString(),
                    NodeIcoSrc = tn.NodeIcoSrc,
                    LinkUrl = string.Format("{0}AuthorizeCenter/OrgUserList.aspx?orgid={1}", WebUtil.GetRootPath(), org.ID),
                    Target = "_blank",
                    IcoSrc = string.Format("{0}Plugins/Authorize/Content/Themes/{1}/Images/{2}", WebUtil.GetRootPath(), Skin, getResourceIcon(org.Type.Cast<ResourceType>(ResourceType.Menu))),
                    Checked = orgIDs.Exists(o => o.EndsWith(org.ID))
                };

                tn.ChildNodes.Add(node);

                BuildTree(node, orgIDs, maxDepth, currentDepth + 1);
            }
        }
Ejemplo n.º 11
0
 private void AddOrg(Organization org, AjaxTreeNode parentOrgNode, List<string> orgIDs)
 {
     List<Organization> organizations = repository.Query<Organization>().Where(o => o.ParentID == org.ID).ToList();
     if (organizations != null && organizations.Count > 0)
     {
         foreach (var organization in organizations)
         {
             AjaxTreeNode childOrgNode = new AjaxTreeNode()
             {
                 ID = organization.ID,
                 Text = organization.Name,
                 Value = organization.ID,
                 Tag=organization.Type.ToString(),
                 Checked = orgIDs.Exists(o => o.EndsWith(organization.ID)),
                 IcoSrc = string.Format("{0}Plugins/Authorize/Content/Themes/{1}/Images/{2}", WebUtil.GetRootPath(), Skin, getResourceIcon("city")),
                 NodeState =NodeState.Close,
             };
             parentOrgNode.ChildNodes.Add(childOrgNode);
             //AddVirtualMachine(childOrgNode);
             AddOrg(organization, childOrgNode,  orgIDs );
         }
     }
 }
Ejemplo n.º 12
0
        /// <summary>
        /// 初始化树
        /// </summary>
        private void InitRolePrivilege(string roleID)
        {
            AjaxTree1.PostType = PostType.NoPost;
            AjaxTree1.IsAjaxLoad = false;
            AjaxTree1.ShowNodeIco = false;
            AjaxTree1.ShowCheckBox = true;
            AjaxTree1.Nodes.Clear();

            //Resource appResource = repository.All<Resource>().FirstOrDefault(o => o.ID == ApplicationContext.AppID);
            AgileEAP.Infrastructure.Domain.SysParam sysparam =repository.Query<SysParam>().FirstOrDefault(o=>o.Name=="AppID");
            string rootPriId = GetPidByResId(sysparam.Value);

            IDictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.SafeAdd("RoleID", roleID);
            IList<RolePrivilege> rolePrivileges =repository.FindAll<RolePrivilege>(parameters);
            List<string> privileges = rolePrivileges != null ? rolePrivileges.Select(o => o.PrivilegeID).ToList() : new List<string>();

            AjaxTreeNode appNode = new AjaxTreeNode()
            {
                ID = rootPriId,
                Text = sysparam.Description,
                Value = rootPriId,
                Tag = "root",
                IcoSrc = string.Format("{0}Plugins/Authorize/Content/Themes/{1}/Images/menu.gif", WebUtil.GetRootPath(), Skin),
                NodeState = NodeState.Open,
                Checked = privileges.Contains(rootPriId),

            };
            AjaxTree1.Nodes.Add(appNode);

            //取得当前登录角色的权限组合
            List<string> privilegeIDs = authService.GetPrivilegeIDs(User.ID);

            //根据权限id取到资源id集合
            List<string> resIDs =repository.All<Privilege>().Where(o => User.UserType == (short)UserType.Administrator || privilegeIDs.Contains(o.ID)).Select(o => o.ResourceID).ToList();

            //根据权限id取到操作项id集合
            List<string> operateIds =repository.All<Privilege>().Where(p => !string.IsNullOrWhiteSpace(p.OperateID) && (User.UserType == (short)UserType.Administrator || privilegeIDs.Contains(p.ID))).Select(p => p.OperateID).ToList() ?? new List<string>();

            List<Resource> resources = repository.All<Resource>().Where(o => o.ParentID == sysparam.Value && (User.UserType == (short)UserType.Administrator || resIDs.Contains(o.ID))).OrderBy(o => o.SortOrder).ToList();

            foreach (Resource resource in resources)
            {
                string priId = GetPidByResId(resource.ID);
                AjaxTreeNode node = new AjaxTreeNode()
                {
                    ID = priId,
                    Text = resource.Text,
                    Value = resource.ID,
                    Tag = ResourceType.Page.ToString(),
                    NodeState = NodeState.Open,
                    Checked = privileges.Contains(priId)
                };

                AddChildResource(node, privileges, resIDs, operateIds);
                appNode.ChildNodes.SafeAdd(node);
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 绑定操作项(因为树用了级联,所以判断如果下边有操作项的时候,将模拟一个访问)
        /// </summary>
        /// <param name="parentNode">父节点</param>
        /// <param name="privileges">权限集合</param>
        void BuildOperate(AjaxTreeNode parentNode, List<string> privileges, List<string> operateIds)
        {
            List<Privilege> operates = repository.All<Privilege>().Where(p => p.ResourceID == parentNode.Value && !string.IsNullOrWhiteSpace(p.OperateID) && operateIds.Contains(p.OperateID)).ToList(); //取得资源相关的所有操作项id

            //   List<Operate> operates = new OperateService().All().Where(o => operateIDs.Contains(o.ID)).ToList(); //根据操作项id集合得到操作项集合

            //判断如果下边有操作项的时候,将模拟一个访问
            if (operates.Count > 0)
            {
                AjaxTreeNode node = new AjaxTreeNode()
                {
                    ID = "tempAccess",
                    Text = "访问",
                    Value = "tempAccess",
                    Tag = "Operate",
                    Checked = parentNode.Checked
                };
                parentNode.ChildNodes.SafeAdd(node);
            }

            foreach (var operate in operates)
            {
                AjaxTreeNode node = new AjaxTreeNode()
                {
                    ID = operate.ID,
                    Text = operate.Name,
                    Value = operate.ID,
                    Tag = "Operate",
                    Checked = privileges.Contains(operate.ID)
                };
                parentNode.ChildNodes.SafeAdd(node);
            }
        }
Ejemplo n.º 14
0
        void AddChildResource(AjaxTreeNode parentNode, List<string> privileges, List<string> resIDs, List<string> operateIds)
        {
            List<Resource> resources = repository.All<Resource>().Where(o => o.ParentID == parentNode.Value && resIDs.Contains(o.ID)).OrderBy(o => o.SortOrder).ToList();
            foreach (var resource in resources)
            {
                string priId = GetPidByResId(resource.ID);
                AjaxTreeNode node = new AjaxTreeNode()
                {
                    ID = priId,
                    Text = resource.Text,
                    Value = resource.ID,
                    NodeState = NodeState.Close,
                    IcoSrc = string.Format("{0}Plugins/Authorize/Content/Themes/{1}/Images/{2}", WebUtil.GetRootPath(), Skin, getResourceIcon(resource.Type.Cast<ResourceType>(ResourceType.Menu))),
                    Checked = privileges.Contains(priId)
                };

                BuildOperate(node, privileges, operateIds);

                parentNode.ChildNodes.SafeAdd(node);
                AddChildResource(node, privileges, resIDs, operateIds);
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 初始化树
        /// </summary>
        private void InitTree()
        {
            AjaxTree1.PostType = PostType.NoPost;
            AjaxTree1.IsAjaxLoad = false;
            AjaxTree1.ShowNodeIco = true;
            AjaxTree1.ShowCheckBox = true;
            AjaxTree1.SelectionMode = SelectionMode.Single;
            AjaxTree1.Nodes.Clear();

            Resource resource =repository.All<Resource>().FirstOrDefault(o => o.ID == AppID);
            AjaxTreeNode appNode = new AjaxTreeNode()
            {
                ID = resource.ID,
                Text = resource.Text,
                Value = resource.Type.ToString(),
                Tag = "root",
                IcoSrc = string.Format("{0}Plugins/Authorize/Content/Themes/{1}/Images/resource.gif", WebUtil.GetRootPath(), Skin),
                NodeState = NodeState.Open
            };

            AjaxTree1.Nodes.Add(appNode);

            List<Resource> resources =repository.All<Resource>().Where(o => o.ParentID == appNode.ID).OrderBy(o => o.SortOrder).ToList();

            foreach (var res in resources)
            {
                AjaxTreeNode node = new AjaxTreeNode()
                {
                    ID = res.ID,
                    Text = res.Text,
                    Value = res.ID,
                    Tag = res.Type.ToString(),
                    IcoSrc = string.Format("{0}Plugins/Authorize/Content/Themes/{1}/Images/{2}", WebUtil.GetRootPath(), Skin, getResourceIcon(res.Type.Cast<ResourceType>(ResourceType.Menu)))
                };

                BuildTree(node);

                appNode.ChildNodes.Add(node);
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 初始化树
        /// </summary>
        private void InitTree()
        {
            AjaxTree1.PostType = PostType.None;
            AjaxTree1.ShowNodeIco = true;
            AjaxTree1.ShowCheckBox = false;
            AjaxTree1.IsAjaxLoad = true;
            AjaxTree1.SelectionMode = SelectionMode.Single;
            AjaxTree1.Nodes.Clear();

            List<Organization> organizations =repository.All<Organization>().Where(o => o.ParentID == "OR1000000001" && o.Status == 0).OrderBy(o => o.SortOrder).ToList();//中国电信广东公司 的id
            foreach (var org in organizations)
            {
                AjaxTreeNode node = new AjaxTreeNode()
                {
                    ID = org.ID,
                    Text = org.Name,
                    Value = org.ID,
                    Tag = org.Type.ToString(),
                    IcoSrc = string.Format("{0}Plugins/Authorize/Content/Themes/{1}/Images/{2}", WebUtil.GetRootPath(), Skin, getResourceIcon(ResourceType.Menu)),
                    VirtualNodeCount = repository.All<Organization>().Count(o => o.ParentID == org.ID) + authService.GetEmployees(org.ID).Count
                };

                AjaxTree1.Nodes.Add(node);
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 初始化树
        /// </summary>
        private void InitTree()
        {
            AjaxTree1.PostType = PostType.NoPost;
            AjaxTree1.IsAjaxLoad = false;
            AjaxTree1.ShowNodeIco = true;
            AjaxTree1.ShowCheckBox = false;
            AjaxTree1.Nodes.Clear();

            Dict appDict = dictService.All().FirstOrDefault(o => o.ID == AppID);
            AjaxTreeNode appNode = new AjaxTreeNode()
            {
                ID = appDict.ID,
                Text = appDict.Text,
                Value = appDict.Name,
                Tag = "root",
                NodeState = NodeState.Open,
                IcoSrc = string.Format("{0}Plugins/eCloud/Content/Themes/{1}/Images/dictionary.png", WebUtil.GetRootPath(), Skin)
            };
            AjaxTree1.Nodes.Add(appNode);

            List<Dict> dicts = dictService.All().Where(o => o.ParentID == appNode.ID).OrderBy(o => o.SortOrder).ToList();
            foreach (var dict in dicts)
            {
                AjaxTreeNode node = new AjaxTreeNode()
                {
                    ID = dict.ID,
                    Text = dict.Text,
                    Value = dict.ID,
                    Tag = dict.ID,
                    IcoSrc = string.Format("{0}Plugins/eCloud/Content/Themes/{1}/Images/{2}", WebUtil.GetRootPath(), Skin, getResourceIcon("childDict"))
                };

                BuildTree(node);

                appNode.ChildNodes.Add(node);
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 创建目录树方法
        /// </summary>
        /// <param name="tn">目录树的节点</param>
        private void BuildTree(AjaxTreeNode tn)
        {
            List<Participantor> resources = workflowEngine.GetRoleAndOrgParticipantors().Where(o => o.ParentID == tn.ID).OrderBy(o => o.SortOrder).ToList();

            foreach (var res in resources)
            {
                AjaxTreeNode node = new AjaxTreeNode()
                {
                    ID = res.ID,
                    Text = res.Name,
                    Value = res.ID,
                    Tag = Enum.Parse(typeof(ParticipantorType), res.ParticipantorType.ToString()).ToString(),
                    NodeIcoSrc = tn.NodeIcoSrc,
                    // LinkUrl = string.Format("{0}AuthorizeCenter/OrgUserList.aspx?orgid={1}", WebUtil.GetRootPath(), res.ID),
                    //Target = "ifrMain",
                    IcoSrc = string.Format("{0}Plugins/Workflow/Content/Themes/{1}/Images/{2}", WebUtil.GetRootPath(), Skin, getResourceIcon(res.ParticipantorType.ToString()))
                };

                tn.ChildNodes.Add(node);
                //递归获取目录树
                BuildTree(node);
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 初始化树
        /// </summary>
        private void InitTree()
        {
            AjaxTree1.PostType = PostType.NoPost;
            AjaxTree1.IsAjaxLoad = false;
            AjaxTree1.ShowCheckBox = string.Equals(Request.QueryString["Entry"], "Choose");
            AjaxTree1.ShowNodeIco = true;
            AjaxTree1.SelectionMode = SelectionMode.Single;
            AjaxTree1.Nodes.Clear();

            Catalog appCatalog = catalogService.All().FirstOrDefault(o => o.ParentID == "0");
            AjaxTreeNode appNode = new AjaxTreeNode()
            {
                ID = appCatalog.ID,
                Text = appCatalog.CatalogName,
                Value = appCatalog.ID,
                Tag = "root",
                NodeState = NodeState.Open,
                IcoSrc = string.Format("{0}Plugins/eCloud/Content/Themes/{1}/Images/menu.gif", WebUtil.GetRootPath(), Skin)
            };
            AjaxTree1.Nodes.Add(appNode);

            List<Catalog> catalogs = catalogService.All().Where(o => o.ParentID == appNode.ID).OrderBy(o => o.SortOrder).ToList();
            foreach (var catalog in catalogs)
            {
                AjaxTreeNode node = new AjaxTreeNode()
                {
                    ID = catalog.ID,
                    Text = catalog.CatalogName,
                    Value = catalog.ID,
                    Tag = catalog.ID,
                    IcoSrc = string.Format("{0}Plugins/eCloud/Content/Themes/{1}/Images/{2}", WebUtil.GetRootPath(), Skin, getResourceIcon("childDict"))
                };

                BuildTree(node);

                appNode.ChildNodes.Add(node);
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 初始化树
        /// </summary>
        private void InitTree()
        {
            AjaxTree1.PostType = PostType.None;
            AjaxTree1.ShowNodeIco = true;
            AjaxTree1.ShowCheckBox = string.Equals(Request.QueryString["Entry"], "Choose") || string.Equals(Request.QueryString["Entry"], "ConfigureRolePrivilege");
            AjaxTree1.IsAjaxLoad = true;
            AjaxTree1.SelectionMode = SelectionMode.Single;
            AjaxTree1.EnableOndblclick = true;
            AjaxTree1.Nodes.Clear();

            IList<Participantor> all = workflowEngine.GetRoleAndOrgParticipantors();
            Participantor orgParticipant = all.FirstOrDefault(p => p.ParticipantorType == ParticipantorType.Org && p.ParentID == "-1");

            //加载第一层中国电信广东分公司节点
            AjaxTreeNode parentNode = new AjaxTreeNode()
            {
                ID = orgParticipant.ID,
                Text = orgParticipant.Name,
                Value = orgParticipant.ID,
                Tag = Enum.Parse(typeof(ParticipantorType), orgParticipant.ParticipantorType.ToString()).ToString(),
                NodeState = NodeState.Open,
                IcoSrc = string.Format("{0}Plugins/Workflow/Content/Themes/{1}/Images/{2}", WebUtil.GetRootPath(), Skin, getResourceIcon(orgParticipant.ParticipantorType.ToString())),
                VirtualNodeCount = all.Count(o => o.ParentID == orgParticipant.ID)
            };
            AjaxTree1.Nodes.Add(parentNode);

            //加载第一层角色树节点
            AjaxTreeNode roleNode = new AjaxTreeNode()
            {
                ID = "role",
                Text = "角色",
                Value = "roleTree",
                Tag = "Role",
                NodeState = NodeState.Open,
                IcoSrc = string.Format("{0}Plugins/Workflow/Content/Themes/{1}/Images/{2}", WebUtil.GetRootPath(), Skin, getResourceIcon("Role")),
                VirtualNodeCount = all.Count(o => o.ParticipantorType == ParticipantorType.Role)
            };
            AjaxTree1.Nodes.Add(roleNode);

            //第二层组织结构节点
            IList<Participantor> participantors = all.Where(p => p.ParentID == orgParticipant.ID).ToList();
            foreach (var org in participantors)
            {
                AjaxTreeNode node = new AjaxTreeNode()
                {
                    ID = org.ID,
                    Text = org.Name,
                    Value = org.ID,
                    Tag = Enum.Parse(typeof(ParticipantorType), org.ParticipantorType.ToString()).ToString(),
                    IcoSrc = string.Format("{0}Plugins/Workflow/Content/Themes/{1}/Images/{2}", WebUtil.GetRootPath(), Skin, getResourceIcon(org.ParticipantorType.ToString())),
                    VirtualNodeCount = all.Count(o => o.ParentID == org.ID)
                };

                parentNode.ChildNodes.Add(node);
            }

            //第二层角色节点
            IList<Participantor> roles = all.Where(p => p.ParticipantorType == ParticipantorType.Role).ToList();
            foreach (var role in roles)
            {
                AjaxTreeNode node = new AjaxTreeNode()
                {
                    ID = role.ID,
                    Text = role.Name,
                    Value = role.ID,
                    Tag = Enum.Parse(typeof(ParticipantorType), role.ParticipantorType.ToString()).ToString(),
                    IcoSrc = string.Format("{0}Plugins/Workflow/Content/Themes/{1}/Images/{2}", WebUtil.GetRootPath(), Skin, getResourceIcon(role.ParticipantorType.ToString())),
                    VirtualNodeCount = all.Count(o => o.ParentID == role.ID)
                };
                roleNode.ChildNodes.Add(node);
            }
        }
        /// <summary>
        /// 绑定操作项(因为树用了级联,所以判断如果下边有操作项的时候,将模拟一个访问)
        /// </summary>
        /// <param name="parentNode">父节点</param>
        /// <param name="privilegeIDs">权限集合</param>
        void BuildOperate(AjaxTreeNode parentNode, List<string> privilegeIDs, List<string> sPrivilegeIDs, short authFlag)
        {
            List<AgileEAP.Infrastructure.Domain.Privilege> operates = repository.All<Privilege>().Where(p => p.ResourceID == parentNode.Value && !string.IsNullOrWhiteSpace(p.OperateID)).ToList(); //取得资源相关的所有操作项id

            //按类型过滤
            if (authFlag == 2)
            {
                operates = operates.Where(o => privilegeIDs.Contains(o.ID)).ToList();//只显示角色已经开通了的
            }

            //判断如果下边有操作项的时候,将模拟一个访问
            if (operates.Count > 0)
            {
                AjaxTreeNode node = new AjaxTreeNode()
                {
                    ID = "tempAccess",
                    Text = "访问",
                    Value = "tempAccess",
                    Tag = "Operate",
                    ShowCheckBox = parentNode.ShowCheckBox
                };
                parentNode.ChildNodes.SafeAdd(node);
            }

            foreach (var operate in operates)
            {
                AjaxTreeNode node = new AjaxTreeNode()
                {
                    ID = operate.ID,
                    Text = operate.Name,
                    Value = operate.ID,
                    Tag = "Operate",
                    Checked = sPrivilegeIDs.Contains(operate.ID),
                    ShowCheckBox = !(authFlag == 1 && privilegeIDs.Contains(operate.ID))
                };
                parentNode.ChildNodes.SafeAdd(node);
            }
        }