Exemplo n.º 1
0
        public object OrgTreeMove(PostClass PostClass)
        {
            bool bool_ref = false;

            if (PostClass.PostData.ToString().Split('☻').Length == 2)
            {
                string       orgOid   = PostClass.PostData.ToString().Split('☻')[0];
                string       moveType = PostClass.PostData.ToString().Split('☻')[1];
                Base_OrgInfo MoveOrg  = _service.FindBy(o => o.OID == orgOid).FirstOrDefault();
                if (moveType == "up")
                {
                    bool_ref = _service.MoveWithTree(MoveOrg, -1);
                }
                else if (moveType == "down")
                {
                    bool_ref = _service.MoveWithTree(MoveOrg, 1);
                }
            }
            return(bool_ref);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取该组织机构下的所有节点——用户为ext treegrid提供数据
        /// </summary>
        /// <param name="orgId">根组织机构id,加载所有组织机构未00000000-0000-0000-0000-000000000000</param>
        /// <returns>json(object)</returns>
        public object GetOrgListForTreegrid(string orgId)
        {
            #region "取出符合要求的所有组织机构"
            List <Base_OrgInfo> orgList = _service.FindBy(o => o.ParentOID == orgId).ToList();
            int lt = 0;
            int rt = 0;
            foreach (Base_OrgInfo org in orgList)
            {
                if (lt == 0 && rt == 0)
                {
                    lt = org.LT;
                    rt = org.RT;
                }
                else
                {
                    if (org.LT < lt)
                    {
                        lt = org.LT;
                    }
                    if (org.RT > rt)
                    {
                        rt = org.RT;
                    }
                }
            }
            List <Base_OrgInfo> selectOrgList = _service.FindBy(o => o.LT >= lt && o.RT <= rt).ToList();
            #endregion
            StringBuilder _orgJson = new StringBuilder();
            _orgJson.Append("{\"text\":\"根节点\",\"OID\":\"" + Guid.Empty.ToString() + "\",\"expanded\":true,\"children\":[");

            int lastTreeLevel    = 0;
            int currentTreeLevel = 0;
            int firstTreeLevel   = selectOrgList.OrderBy(o => o.LT).ToList()[0].TreeLevel;
            foreach (Base_OrgInfo co in selectOrgList.OrderBy(o => o.LT))
            {
                currentTreeLevel = co.TreeLevel;

                if (currentTreeLevel < lastTreeLevel)
                {
                    _orgJson.Remove(_orgJson.Length - 1, 1);
                    for (int j = 0; j < lastTreeLevel - currentTreeLevel; j++)
                    {
                        _orgJson.Append("]},");
                    }
                }

                _orgJson.Append("{");
                _orgJson.Append("OID:'");
                _orgJson.Append(co.OID);
                _orgJson.Append("',Code:'");
                _orgJson.Append(co.Code);
                _orgJson.Append("',text:'");
                _orgJson.Append(co.Name);
                _orgJson.Append("',Name:'");
                _orgJson.Append(co.Name);
                _orgJson.Append("',ParentOID:'");
                _orgJson.Append(co.ParentOID);
                _orgJson.Append("',LT:");
                _orgJson.Append(co.LT);
                _orgJson.Append(",RT:");
                _orgJson.Append(co.RT);
                _orgJson.Append(",TreeLevel:");
                _orgJson.Append(co.TreeLevel);
                _orgJson.Append(",OrgLevel:");
                _orgJson.Append(co.OrgLevel);
                _orgJson.Append(",OrgNo:'");
                _orgJson.Append(co.OrgNo);
                _orgJson.Append("',EnglishName:'");
                _orgJson.Append(co.EnglishName);
                _orgJson.Append("',Description:'");
                _orgJson.Append(co.Description);
                _orgJson.Append("',ShortName:'");
                _orgJson.Append(co.ShortName);
                _orgJson.Append("',SortCode:'");
                _orgJson.Append(co.SortCode);
                _orgJson.Append("',State:");
                _orgJson.Append(co.State);
                _orgJson.Append(",OrgType:");
                _orgJson.Append(co.OrgType);
                _orgJson.Append(",checked:false");
                _orgJson.Append(",iconCls:'noIcon'");
                _orgJson.Append(",CreateTime:'");
                _orgJson.Append(co.CreateTime);

                _orgJson.Append((selectOrgList.Where(op => op.ParentOID == co.OID.ToString()).ToList().Count == 0) ? "',leaf: true}," : (co.TreeLevel == 1) ? "',expanded:true,children:[" : "',expanded:false,children:[");
                lastTreeLevel = currentTreeLevel;
            }
            _orgJson.Remove(_orgJson.Length - 1, 1);
            for (int j = currentTreeLevel - firstTreeLevel; j > 0; j--)
            {
                _orgJson.Append("]}");
            }

            _orgJson.Append("]}");
            string jsonData = _orgJson.ToString();
            return(Common.NewtonJsonHelper.Deserialize <object>(jsonData, null));
        }