Ejemplo n.º 1
0
        /// <summary>
        /// 根据岗位名称查找
        /// </summary>
        /// <param name="postCode"></param>
        /// <returns></returns>
        private List <PortalTreeNode> LoadNodesByPostCode(string postCode)
        {
            List <string> postUsers = this.Engine.Organization.GetUsersByJobCode(this.UserValidator.UserID, postCode, string.Empty);

            List <PortalTreeNode> childNodes = new List <PortalTreeNode>();

            if (postUsers == null || postUsers.Count == 0)
            {
                return(childNodes);
            }

            List <Unit> units = this.Engine.Organization.GetUnits(postUsers.ToArray());

            if (units == null || units.Count == 0)
            {
                return(childNodes);
            }

            foreach (Unit childUnit in units)
            {
                PortalTreeNode childNode = this.GetTreeNodeFromUnit(childUnit);
                childNodes.Add(childNode);
            }
            return(childNodes);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 创建组织机构的树节点
        /// </summary>
        /// <param name="unitID"></param>
        /// <param name="child"></param>
        /// <param name="imgName"></param>
        /// <returns></returns>
        private PortalTreeNode BuildOrgChildNode(string unitID, OThinker.Organization.Unit child, string imgName, string pagePath)
        {
            //组织机构没有Code使用ObjectIDea,user对象使用Code
            string Code = child.ObjectID;

            if (child.UnitType == OThinker.Organization.UnitType.User)
            {
                Code = ((OThinker.Organization.User)child).Code;
            }

            PortalTreeNode node = new PortalTreeNode()
            {
                Text     = "_" + child.Name,//在资源文件解析的时候,如果以_开头,则返回_之后的字符串,否则会根据资源文件里面的字符串替换,组织结构名称会找不到
                ObjectID = child.ObjectID,
                Code     = Code,
                IsLeaf   = child.UnitType == OThinker.Organization.UnitType.User,
                //Icon = this.PortalImageRoot + imgName,
                Icon        = imgName,
                ParentID    = unitID,
                ShowPageUrl = GetOrgTreeNodeEditUrl(pagePath, child.UnitID, unitID),
                NodeType    = FunctionNodeType.Organization
            };

            if (!node.IsLeaf)
            {
                //if (string.IsNullOrWhiteSpace(LoadDataUrl))
                node.LoadDataUrl = GetLoadDataUrl(node.ObjectID, node.Code, FunctionNodeType.Organization);
                //else
                //    node.LoadDataUrl = LoadDataUrl + node.ObjectID;
            }
            return(node);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 递归获取子组织单元
        /// </summary>
        /// <param name="parentTreeNode"></param>
        private void LoadChildrenNodes(PortalTreeNode parentTreeNode)
        {
            List <Unit> childUnits = null;

            childUnits = this.Engine.Organization.GetChildUnits(parentTreeNode.Code,
                                                                this.getChildUnitType(),
                                                                false,
                                                                State.Active);
            if (!UserValidator.User.IsAdministrator)
            {
                childUnits = childUnits.Where(w => w.Visibility != OThinker.Organization.VisibleType.OnlyAdmin).ToList();
            }

            // 按照OrganizationUnit, Group, User的顺序进行排列
            ArrayList unitList = SortOrgList(childUnits.ToArray());

            if (childUnits != null)
            {
                List <PortalTreeNode> childNodes = new List <PortalTreeNode>();
                foreach (Unit childUnit in unitList)
                {
                    if (this.VisibleUnits.Length > 0)
                    {
                        if (childUnit.UnitType == UnitType.OrganizationUnit)
                        {
                            if (!this.VisibleUnitIds.Contains(childUnit.ObjectID))
                            {
                                continue;
                            }
                        }
                        else if (childUnit.UnitType == UnitType.User)
                        {
                            if (!this.VisibleUnitIds.Contains(childUnit.ParentID))
                            {
                                continue;
                            }
                        }
                    }
                    if (childUnit is Organization.User)
                    {
                        //系统、禁用、离职用户无法搜索
                        //if (((Organization.User)childUnit).IsSystemUser == true ||
                        //     ((Organization.User)childUnit).State == State.Inactive ||
                        //     ((Organization.User)childUnit).ServiceState == UserServiceState.Dismissed)
                        if (((Organization.User)childUnit).State == State.Inactive ||
                            ((Organization.User)childUnit).ServiceState == UserServiceState.Dismissed)
                        {
                            continue;
                        }
                    }
                    PortalTreeNode childNode = this.GetTreeNodeFromUnit(childUnit);
                    childNodes.Add(childNode);
                }
                parentTreeNode.children = childNodes;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 查找用户
        /// </summary>
        /// <param name="searchKey"></param>
        /// <param name="parentId"></param>
        /// <returns></returns>
        public List <PortalTreeNode> SearchUser(string searchKey, string parentId)
        {
            List <PortalTreeNode> childNodes = new List <PortalTreeNode>();

            //OU
            if (this.OrgUnitVisible)
            {
                searchKey = searchKey.Replace("'", string.Empty).Replace("-", string.Empty);
                var querySql = "SELECT TOP 20 ObjectID from OT_OrganizationUnit WHERE Name LIKE '%" + searchKey + "%'";
                System.Data.DataTable dtUnit = Engine.Query.QueryTable(string.Format(querySql, searchKey, parentId));
                if (dtUnit != null)
                {
                    List <string> UnitIDs = new List <string>();
                    foreach (System.Data.DataRow row in dtUnit.Rows)
                    {
                        var id = row[OThinker.Organization.User.PropertyName_ObjectID] + string.Empty;
                        if (!string.IsNullOrEmpty(id))
                        {
                            UnitIDs.Add(id);
                        }
                    }
                    if (UnitIDs.Count > 0)
                    {
                        List <Organization.Unit> units = this.Engine.Organization.GetUnits(UnitIDs.ToArray());
                        foreach (Unit childUnit in units)
                        {
                            PortalTreeNode childNode = this.GetTreeNodeFromUnit(childUnit);
                            childNode.Code = "";
                            childNodes.Add(childNode);
                        }
                    }
                }
            }
            //用户
            if (this.UserVisible)
            {
                List <User> users = this.Engine.Organization.QueryUserByParentID(searchKey, State.Active, parentId, 10);
                if (users == null || users.Count() == 0)
                {
                    return(childNodes);
                }
                foreach (Unit childUnit in users)
                {
                    PortalTreeNode childNode = this.GetTreeNodeFromUnit(childUnit);
                    childNodes.Add(childNode);
                }
            }
            return(childNodes);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 组织机构数据
 /// </summary>
 /// <param name="ParameterValueStr"></param>
 /// <returns></returns>
 public JsonResult OrganizationData()
 {
     return(ExecuteFunctionRun(() =>
     {
         AbstractPortalTreeHandler handler = new OrganizationHandler(this);
         PortalTreeNode companyNode = new PortalTreeNode();
         var myCompany = Engine.Organization.Company;
         companyNode.ObjectID = myCompany.ObjectID;
         companyNode.Code = myCompany.UnitID;
         companyNode.Text = myCompany.Name;
         companyNode.Icon = "fa fa-building-o";
         companyNode.IsLeaf = false;
         object treeObj = handler.CreatePortalTree(companyNode.ObjectID, companyNode.Code);
         companyNode.CreateChildren(treeObj);
         return Json(new object[] { companyNode }, JsonRequestBehavior.AllowGet);
     }, string.Empty));
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 获取一个树节点
        /// </summary>
        /// <param name="unit"></param>
        /// <returns></returns>
        private PortalTreeNode GetTreeNodeFromUnit(Unit unit)
        {
            PortalTreeNode treeNode = new PortalTreeNode();

            treeNode.ObjectID = unit.ObjectID;

            if (unit is Organization.User)
            {
                treeNode.Code         = ((Organization.User)unit).Code;
                treeNode.ExtendObject = new
                {
                    UnitType       = ((Organization.User)unit).UnitType.ToString().Substring(0, 1),
                    DepartmentName = this.Engine.Organization.GetName(unit.ParentID)
                };
            }
            else
            {
                var  childUnits  = this.Engine.Organization.GetChildUnits(unit.UnitID, UnitType.Group | UnitType.OrganizationUnit | UnitType.User, false, State.Active);
                bool hasChildren = childUnits != null && childUnits.Any(s => s.UnitType == UnitType.Group || s.UnitType == UnitType.OrganizationUnit);
                treeNode.Code         = unit.UnitID;
                treeNode.ExtendObject = new
                {
                    UnitType      = unit.UnitType.ToString().Substring(0, 1),
                    HasChildren   = hasChildren,//是否有子组织单元或者组
                    ChildrenCount = childUnits.Count()
                };
            }

            treeNode.Text   = unit.Name;
            treeNode.IsLeaf = unit.UnitType == UnitType.Group;
            if (unit.UnitType == UnitType.OrganizationUnit)
            {
                treeNode.Icon = "icon-zuzhitubiao";
            }
            else if (unit.UnitType == UnitType.Group)
            {
                treeNode.Icon = "fa fa-users";
            }
            else
            {
                treeNode.Icon = "fa fa-user";
            }
            return(treeNode);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 根据用户帐号查找
        /// </summary>
        /// <param name="userCodes"></param>
        /// <returns></returns>
        private List <PortalTreeNode> LoadNodesByUserCodes(string userCodes)
        {
            List <PortalTreeNode> childNodes = new List <PortalTreeNode>();

            string[] codes = userCodes.Split(new string[] { ";", "," }, StringSplitOptions.RemoveEmptyEntries);
            if (codes.Length == 0)
            {
                return(childNodes);
            }
            foreach (string code in codes)
            {
                OThinker.Organization.User user = this.Engine.Organization.GetUserByCode(code);
                if (user != null)
                {
                    PortalTreeNode childNode = this.GetTreeNodeFromUnit(user);
                    childNodes.Add(childNode);
                }
            }

            return(childNodes);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="FunctionNode"></param>
        /// <param name="toolBarCode"></param>
        /// <returns></returns>
        private PortalTreeNode BuildCompanyNode(FunctionNode FunctionNode, string toolBarCode)
        {
            PortalTreeNode companyNode = new PortalTreeNode();

            //
            FunctionNode parentNode = controller.Engine.FunctionAclManager.GetFunctionNodeByCode(FunctionNode.ParentCode);

            var myCompany = controller.Engine.Organization.GetUnit(controller.Engine.Organization.RootUnit.ObjectID);

            companyNode.ObjectID = myCompany.ObjectID;
            companyNode.Code     = myCompany.UnitID;
            companyNode.Text     = "_" + myCompany.Name;//组织结构名称需要加上"_",否则前端显示时候会以资源文件中的字符串替换,找不到会显示ID
            companyNode.IsLeaf   = false;
            //companyNode.ShowPageUrl = FunctionNode.Url;
            companyNode.ParentID    = parentNode.ObjectID;
            companyNode.LoadDataUrl = GetLoadDataUrl(myCompany.ObjectID, FunctionNode.Code, FunctionNode.NodeType);
            companyNode.ShowPageUrl = ConstantString.PagePath_EditCompany + "&ID=" + myCompany.UnitID;
            companyNode.ToolBarCode = toolBarCode;
            companyNode.NodeType    = FunctionNodeType.Organization;
            companyNode.Icon        = "fa fa-building-o";
            return(companyNode);
        }
Ejemplo n.º 9
0
 public JsonResult LoadOrgTreeNodes()
 {
     if (!string.IsNullOrEmpty(this.OrgPostCode))
     { // 显示指定角色的用户
         List <PortalTreeNode> results = this.LoadNodesByPostCode(this.OrgPostCode);
         return(Json(results, JsonRequestBehavior.AllowGet));
     }
     else if (!string.IsNullOrEmpty(this.UserCodes))
     { // 显示指定帐号的用户集合
         List <PortalTreeNode> results = this.LoadNodesByUserCodes(this.UserCodes);
         return(Json(results, JsonRequestBehavior.AllowGet));
     }
     else
     {
         if (SearchKey != string.Empty && !LoadTree)
         {// 搜索用户
             List <PortalTreeNode> results = this.SearchUser(this.SearchKey, this.ParentID);
             return(Json(results, JsonRequestBehavior.AllowGet));
         }
         else
         {
             PortalTreeNode treeNode = this.GetTreeNodeFromUnit(ParentUnit);
             this.LoadChildrenNodes(treeNode);
             if (Recursive)
             {
                 return(Json(new PortalTreeNode[1] {
                     treeNode
                 }, JsonRequestBehavior.AllowGet));
             }
             else
             {
                 return(Json(treeNode.children, JsonRequestBehavior.AllowGet));
             }
         }
     }
 }
        private void SetChildTreeNode(ControllerBase context, PortalTreeNode node)
        {
            //不显示组织模型、数据模型、流程包的子节点
            if (node.Code == FunctionNode.Category_Organization_Code ||
                node.NodeType == FunctionNodeType.BizObject ||
                node.NodeType == FunctionNodeType.BizWorkflowPackage ||
                node.NodeType == FunctionNodeType.BizRule)
            {
                return;
            }

            List <PortalTreeNode> children = CreateHandler(context, node.NodeType).CreatePortalTree(node.ObjectID, node.Code) as List <PortalTreeNode>;

            if (children != null && node.Code == FunctionNode.Category_ServiceMoniter_Code)
            {
                // 根据模块授权过滤部署节点
                List <PortalTreeNode> childrenAuthorized = new List <PortalTreeNode>();
                foreach (PortalTreeNode child in children)
                {
                    if (child.Code == FunctionNode.Category_Apps_Code && !AppsAuthorized ||
                        child.Code == FunctionNode.Category_BizBus_Code && !BizBusAuthorized ||
                        child.Code == FunctionNode.Category_BizRule_Code && !BizRuleAuthorized ||
                        child.Code == FunctionNode.Category_BPA_Code && !BPAAuthorized)
                    {
                        continue;
                    }
                    childrenAuthorized.Add(child);
                }
                children = childrenAuthorized;
            }

            List <PortalTreeNode> childrenFilter = new List <PortalTreeNode>();

            if (children != null)
            {
                // 节点的最新更新时间
                Dictionary <ConfigurationChange, DateTime> modifiedTimeDic = this.Engine.Interactor.GetConfigurationChanges();
                foreach (PortalTreeNode child in children)
                {
                    if (!filterCode.Contains(child.Code))
                    {
                        ConfigurationChange key = new ConfigurationChange(child.NodeType, child.Code);
                        //主数据和流程包只呈现发布后的
                        if (child.NodeType == FunctionNodeType.BizObject || child.NodeType == FunctionNodeType.BizWorkflowPackage)
                        {
                            if (modifiedTimeDic.Keys.Contains(key))
                            {
                                child.NeedDeploy = modifiedTimeDic[key] > lastDeploymentTime;
                                childrenFilter.Add(child);
                            }
                        }
                        else
                        {
                            child.NeedDeploy = true;
                            if (modifiedTimeDic.Keys.Contains(key))
                            {
                                child.NeedDeploy = modifiedTimeDic[key] > lastDeploymentTime;
                            }
                            childrenFilter.Add(child);
                        }
                    }
                }
            }
            node.children = childrenFilter;

            if (children != null)
            {
                foreach (PortalTreeNode child in childrenFilter)
                {
                    SetChildTreeNode(context, child);
                }
            }
        }
        /// <summary>
        /// 将FunctionNode转为PortalTree展示给客户端用
        /// </summary>
        /// <param name="functionID"></param>
        /// <param name="nodes"></param>
        /// <returns></returns>
        protected List <PortalTreeNode> ConvertToPortalTree(string functionID, FunctionNode[] nodes)
        {
            List <PortalTreeNode> treeNodeList = new List <PortalTreeNode>();

            if (nodes == null)
            {
                return(treeNodeList);
            }
            //排序
            //nodes = nodes.OrderBy(p => p.NodeType).ThenBy(p => p.SortKey).ToArray();
            nodes = nodes.OrderBy(p => p.SortKey).ToArray();
            foreach (FunctionNode node in nodes)
            {
                string showUrl     = GetShowPageUrl(functionID, node);
                string toolBarCode = GetToolbarCode(node);
                //string IconUrl = GetIconUrl(node);
                string IconUrl = node.IconCss;
                List <PortalTreeNode> children = GetChildren(node);
                switch (node.Code)
                {
                case FunctionNode.Category_ServiceMoniter_Code:    //后台根节点,默认展开第一级
                    PortalTreeNode adminRooNode = new PortalTreeNode()
                    {
                        ObjectID = node.ObjectID,
                        Code     = node.Code,
                        Text     = getGlobalDisplayName(node),
                        //Icon = this.PortalRoot + "/" + node.IconUrl,
                        Icon        = IconUrl,
                        ShowPageUrl = node.Url,
                        IsLeaf      = true,
                        ParentID    = functionID,
                        NodeType    = node.NodeType
                    };
                    adminRooNode.CreateChildren(this.CreatePortalTree(node.ObjectID, node.Code));
                    treeNodeList.Add(adminRooNode);
                    break;

                case FunctionNode.Organization_Data_Code:    //组织机构
                    treeNodeList.Add(BuildCompanyNode(node, toolBarCode));
                    break;

                default:
                    #region 纠正叶子节点
                    //有子菜单、业务规则、流程模型、业务服务,都不是叶子节点
                    FunctionNode[] ChildrenNodes = controller.UserValidator.GetFunctionsByParentCode(node.Code);
                    bool           isLeaf        = ChildrenNodes == null || ChildrenNodes.Length == 0;
                    if (isLeaf)
                    {
                        isLeaf = children == null;
                        if (isLeaf)
                        {
                            isLeaf = string.IsNullOrWhiteSpace(toolBarCode);    //如果有工具栏,基本上都是有子菜单的
                            if (isLeaf)
                            {
                                isLeaf = !(node.Code == FunctionNode.BizRule_ListRuleTable_Code ||
                                           node.Code == FunctionNode.Category_ProcessModel_Code ||
                                           node.Code == FunctionNode.BizBus_BizService_Code ||
                                           node.Code == FunctionNode.ProcessModel_BizMasterData_Code);
                            }
                        }
                    }
                    #endregion

                    treeNodeList.Add(new PortalTreeNode()
                    {
                        ObjectID = node.ObjectID,
                        Code     = node.Code,
                        Text     = getGlobalDisplayName(node),
                        //Icon = ((IconUrl != null && IconUrl.StartsWith("data:image")) ? IconUrl : (this.PortalRoot + "/" + IconUrl)),
                        Icon                  = node.IconCss,
                        ShowPageUrl           = showUrl,
                        LoadDataUrl           = isLeaf ? string.Empty : GetLoadDataUrl(node.ObjectID, node.Code, node.NodeType, node.OwnSchemaCode),
                        IsLeaf                = isLeaf,
                        ParentID              = functionID,
                        ToolBarCode           = toolBarCode,
                        children              = children,
                        IsLock                = (node.IsLocked == true ? true : false),
                        IsLockedByCurrentUser = (node.IsLocked == true && node.LockedBy == controller.UserValidator.UserID),
                        NodeType              = node.NodeType,
                        OwnSchemaCode         = node.OwnSchemaCode
                    });
                    break;
                }
            }
            return(treeNodeList);
        }