public ActionResult GetFactoryList(string organizeId) { List <DepartmentEntity> datas = departmentCache.GetList(organizeId).ToList(); List <DepartmentEntity> lists = datas.Where(t => t.Nature == "车间").ToList <DepartmentEntity>(); return(Content(lists.ToJson())); }
public ActionResult GetTreeJson(string organizeId, string keyword) { var data = departmentCache.GetList(organizeId).ToList(); if (!string.IsNullOrEmpty(keyword)) { data = data.TreeWhere(t => t.FullName.Contains(keyword), "DepartmentId"); } var treeList = new List <TreeEntity>(); foreach (DepartmentEntity item in data) { TreeEntity tree = new TreeEntity(); bool hasChildren = data.Count(t => t.ParentId == item.DepartmentId) == 0 ? false : true; tree.id = item.DepartmentId; tree.text = item.FullName; tree.value = item.DepartmentId; tree.isexpand = true; tree.complete = true; tree.hasChildren = hasChildren; tree.parentId = item.ParentId; treeList.Add(tree); } return(Content(treeList.TreeToJson())); }
/// <summary> /// 获取部门数据 /// </summary> /// <returns></returns> private object GetDepartmentData() { var data = daDepartmentCache.GetList(); var dict = new Dictionary <string, object>(); foreach (var entity in data) { var fieldItem = new { entity.EnCode, entity.FullName, entity.OrganizeId }; dict.Add(entity.DepartmentId, fieldItem); } return(dict); }
public ActionResult GetDepartmentTreeJson(string userGroupId) { var roleEntity = roleBLL.GetEntity(userGroupId); var organizeEntity = organizeBLL.GetEntity(roleEntity.OrganizeId); var data = departmentCache.GetList(roleEntity.OrganizeId); var treeList = new List <TreeEntity>(); TreeEntity tree = new TreeEntity(); tree.id = organizeEntity.OrganizeId; tree.text = organizeEntity.FullName; tree.value = organizeEntity.OrganizeId; tree.isexpand = true; tree.complete = true; tree.hasChildren = true; tree.parentId = "0"; treeList.Add(tree); foreach (DepartmentEntity item in data) { tree = new TreeEntity(); bool hasChildren = data.Count(t => t.ParentId == item.DepartmentId) == 0 ? false : true; tree.id = item.DepartmentId; tree.text = item.FullName; tree.value = item.DepartmentId; if (item.ParentId == "0") { tree.parentId = roleEntity.OrganizeId; } else { tree.parentId = item.ParentId; } tree.isexpand = true; tree.complete = true; tree.hasChildren = hasChildren; treeList.Add(tree); } return(Content(treeList.TreeToJson())); }
/// <summary> /// 获取部门数据 /// </summary> /// <returns></returns> private object GetDepartmentData() { var data = departmentCache.GetList(); Dictionary <string, object> dictionary = new Dictionary <string, object>(); foreach (DepartmentEntity item in data) { var fieldItem = new { EnCode = item.EnCode, FullName = item.FullName, OrganizeId = item.OrganizeId }; dictionary.Add(item.DepartmentId, fieldItem); } return(dictionary); }
public ActionResult GetTreeJson(string organizeId, string keyword) { var data = departmentCache.GetList(organizeId).ToList(); if (!string.IsNullOrEmpty(keyword)) { data = data.TreeWhere(t => t.FullName.Contains(keyword), "DepartmentId"); } var list = data.Select(t => new TreeEntity { id = t.DepartmentId, parentId = t.ParentId, text = t.FullName, value = t.DepartmentId, isexpand = true, complete = true, hasChildren = data.Count(d => d.ParentId == t.DepartmentId) > 0 }).ToList(); return(Content(list.TreeToJson())); }
public ActionResult GetPostListJson(string orgCode, string isOrg) { var dept = new DepartmentBLL().GetEntityByCode(orgCode); if (dept != null) { isOrg = dept.EnCode; var entity = new DepartmentBLL().GetEntity(dept.OrganizeId); if (entity != null) { orgCode = entity.EnCode; } } else { isOrg = "true"; } DepartmentCache departBll = new DepartmentCache(); DepartmentEntity departList = departBll.GetList().Where(t => t.EnCode == orgCode).FirstOrDefault(); var data = postCache.GetList(departList.OrganizeId, isOrg).OrderBy(x => x.SortCode); return(Content(data.ToJson())); }
public ActionResult OrganizeTreeJson(string userGroupId) { var existAuthorizeData = permissionBLL.GetAuthorizeDataList(userGroupId).ToList(); var organizedata = organizeBLL.GetOrganizeList().ToList(); var departmentdata = departmentCache.GetList().ToList(); var treeList = new List <TreeEntity>(); foreach (OrganizeEntity item in organizedata) { TreeEntity tree = new TreeEntity(); bool hasChildren = organizedata.Count(t => t.ParentId == item.Id) != 0; if (hasChildren == false) { hasChildren = departmentdata.Count(t => t.OrganizeId == item.Id) != 0; if (hasChildren == false) { continue; } } tree.id = item.Id; tree.text = item.FullName; tree.value = item.Id; tree.parentId = item.ParentId; tree.img = item.ParentId == "0" ? "fa fa-sitemap" : "fa fa-home"; tree.checkstate = existAuthorizeData.Count(t => t.ResourceId == item.Id); tree.showcheck = true; tree.isexpand = true; tree.complete = true; tree.hasChildren = hasChildren; treeList.Add(tree); } foreach (DepartmentEntity item in departmentdata) { TreeEntity tree = new TreeEntity(); bool hasChildren = departmentdata.Count(t => t.ParentId == item.Id) != 0; tree.id = item.Id; tree.text = item.FullName; tree.value = item.Id; if (item.ParentId == "0") { tree.parentId = item.OrganizeId; } else { tree.parentId = item.ParentId; } tree.checkstate = existAuthorizeData.Count(t => t.ResourceId == item.Id); tree.showcheck = true; tree.isexpand = true; tree.complete = true; tree.img = "fa fa-umbrella"; tree.hasChildren = hasChildren; treeList.Add(tree); } int authorizeType = -1; if (existAuthorizeData.ToList().Count > 0) { authorizeType = existAuthorizeData.ToList()[0].AuthorizeType.ToInt(); } var jsonData = new { authorizeType = authorizeType, authorizeData = existAuthorizeData, treeJson = treeList.TreeToJson(), }; return(Content(jsonData.TryToJson())); }
public ActionResult GetTreeJson(string keyword) { var organizedata = organizeCache.GetList(); var departmentdata = departmentCache.GetList(); var userdata = userCache.GetList(); var treeList = new List <TreeEntity>(); foreach (OrganizeEntity item in organizedata) { #region 机构 TreeEntity tree = new TreeEntity(); bool hasChildren = organizedata.Count(t => t.ParentId == item.OrganizeId) == 0 ? false : true; if (hasChildren == false) { hasChildren = departmentdata.Count(t => t.OrganizeId == item.OrganizeId) == 0 ? false : true; if (hasChildren == false) { continue; } } tree.id = item.OrganizeId; tree.text = item.FullName; tree.value = item.OrganizeId; tree.parentId = item.ParentId; tree.isexpand = true; tree.complete = true; tree.hasChildren = hasChildren; tree.Attribute = "Sort"; tree.AttributeValue = "Organize"; treeList.Add(tree); #endregion } foreach (DepartmentEntity item in departmentdata) { #region 部门 TreeEntity tree = new TreeEntity(); tree.id = item.DepartmentId; tree.text = item.FullName; tree.value = item.DepartmentId; if (item.ParentId == "0") { tree.parentId = item.OrganizeId; } else { tree.parentId = item.ParentId; } tree.isexpand = true; tree.complete = true; tree.hasChildren = true; tree.Attribute = "Sort"; tree.AttributeValue = "Department"; treeList.Add(tree); #endregion } foreach (UserEntity item in userdata) { #region 用户 TreeEntity tree = new TreeEntity(); tree.id = item.UserId; tree.text = item.RealName; tree.value = item.Account; tree.parentId = item.DepartmentId; tree.title = item.RealName + "(" + item.Account + ")"; tree.isexpand = true; tree.complete = true; tree.hasChildren = false; tree.Attribute = "Sort"; tree.AttributeValue = "User"; tree.img = "fa fa-user"; treeList.Add(tree); #endregion } if (!string.IsNullOrEmpty(keyword)) { treeList = treeList.TreeWhere(t => t.text.Contains(keyword), "id", "parentId"); } return(Content(treeList.TreeToJson())); }
public ActionResult GetTreeJson(string keyword) { var organizeData = organizeCache.GetList().ToList(); var departmentData = departmentCache.GetList().ToList(); var userData = userCache.GetList().ToList(); var treeList = new List <TreeEntity>(); #region 机构 foreach (var item in organizeData) { var tree = new TreeEntity(); var hasChildren = organizeData.Count(t => t.ParentId == item.OrganizeId) != 0; if (hasChildren == false) { hasChildren = organizeData.Count(t => t.OrganizeId == item.OrganizeId) != 0; if (hasChildren == false) { continue; } } tree.id = item.OrganizeId; tree.text = item.FullName; tree.value = item.OrganizeId; tree.parentId = item.ParentId; tree.isexpand = true; tree.complete = true; tree.hasChildren = true; tree.Attribute = "Sort"; tree.AttributeValue = "Organize"; treeList.Add(tree); } #endregion #region 部门 treeList.AddRange(departmentData.Select(t => new TreeEntity { id = t.DepartmentId, text = t.FullName, value = t.DepartmentId, parentId = t.ParentId == "0"?t.OrganizeId:t.ParentId, isexpand = true, complete = true, hasChildren = true, Attribute = "Sort", AttributeValue = "Department" })); #endregion #region 用户 treeList.AddRange(userData.Select(item => new TreeEntity { id = item.UserId, text = item.RealName, value = item.Account, parentId = item.DepartmentId, title = item.RealName + "(" + item.Account + ")", isexpand = true, complete = true, hasChildren = false, Attribute = "Sort", AttributeValue = "User", img = "fa fa-user" })); #endregion if (!string.IsNullOrEmpty(keyword)) { treeList = treeList.TreeWhere(t => t.text.Contains(keyword), "id", "parentId"); } return(Content(treeList.TreeToJson())); }
public HttpResponseMessage GetUserTreeJson() { var organizedata = organizeCache.GetList(); var departmentdata = departmentCache.GetList(); var userdata = userCache.GetList(); var treeList = new List <TreeEntity>(); foreach (OrganizeEntity item in organizedata) { #region 机构 TreeEntity tree = new TreeEntity(); bool hasChildren = organizedata.Count(t => t.ParentId == item.OrganizeId) == 0 ? false : true; if (hasChildren == false) { hasChildren = departmentdata.Count(t => t.OrganizeId == item.OrganizeId) == 0 ? false : true; if (hasChildren == false) { continue; } } tree.id = item.OrganizeId; tree.text = item.FullName; tree.value = item.OrganizeId; tree.parentId = item.ParentId; tree.isexpand = true; tree.complete = true; tree.hasChildren = hasChildren; tree.Attribute = "Sort"; tree.AttributeValue = "Organize"; treeList.Add(tree); #endregion } foreach (DepartmentEntity item in departmentdata) { #region 部门 TreeEntity tree = new TreeEntity(); tree.id = item.DepartmentId; tree.text = item.FullName; tree.value = item.DepartmentId; if (item.ParentId == "0") { tree.parentId = item.OrganizeId; } else { tree.parentId = item.ParentId; } tree.isexpand = true; tree.complete = true; tree.hasChildren = true; tree.Attribute = "Sort"; tree.AttributeValue = "Department"; treeList.Add(tree); #endregion } foreach (UserEntity item in userdata) { #region 用户 TreeEntity tree = new TreeEntity(); tree.id = item.UserId; tree.text = item.RealName; tree.value = item.Account; tree.parentId = item.DepartmentId; tree.title = item.RealName + "(" + item.Account + ")"; tree.isexpand = true; tree.complete = true; tree.hasChildren = false; tree.Attribute = "Sort"; tree.AttributeValue = "User"; tree.img = "fa fa-user"; treeList.Add(tree); #endregion } //if (!string.IsNullOrEmpty(keyword)) //{ // treeList = treeList.TreeWhere(t => t.text.Contains(keyword), "id", "parentId"); //} HttpResponseMessage ut = new HttpResponseMessage { Content = new StringContent(treeList.ToJson(), Encoding.GetEncoding("UTF-8"), "application/json") }; return(ut); // return Content(treeList.TreeToJson()); }