コード例 #1
0
ファイル: DataItemController.cs プロジェクト: wyh0395/Berry
        public ActionResult GetTreeJson(string keyword)
        {
            var data = dataItemBLL.GetDataItemList().ToList();

            if (!string.IsNullOrEmpty(keyword))
            {
                data = data.TreeWhere(t => t.ItemName.Contains(keyword), "");
            }
            var treeList = new List <TreeEntity>();

            foreach (DataItemEntity item in data)
            {
                TreeEntity tree        = new TreeEntity();
                bool       hasChildren = data.Count(t => t.ParentId == item.Id) != 0;
                tree.id             = item.Id;
                tree.text           = item.ItemName;
                tree.value          = item.ItemCode;
                tree.parentId       = item.ParentId;
                tree.isexpand       = true;
                tree.complete       = true;
                tree.Attribute      = "isTree";
                tree.AttributeValue = item.IsTree.ToString();
                tree.hasChildren    = hasChildren;
                treeList.Add(tree);
            }
            //return Json(treeList, JsonRequestBehavior.AllowGet);
            return(Content(treeList.TreeToJson()));
        }
コード例 #2
0
        public ActionResult GetTreeJson(string keyword)
        {
            var data = _dataItemBll.GetDataItemList().ToList();

            if (!string.IsNullOrEmpty(keyword))
            {
                data = data.TreeWhere(t => t.ItemName.Contains(keyword), "");
            }
            var treeList = new List <TreeEntity>();

            foreach (DataItemEntity item in data)
            {
                bool       hasChildren = data.Count(t => t.ParentId == item.ItemId) != 0;
                TreeEntity tree        = new TreeEntity
                {
                    Id             = item.ItemId,
                    Text           = item.ItemName,
                    Value          = item.ItemCode,
                    ParentId       = item.ParentId,
                    Isexpand       = true,
                    Complete       = true,
                    Attribute      = "isTree",
                    AttributeValue = item.IsTree.ToString(),
                    HasChildren    = hasChildren
                };
                treeList.Add(tree);
            }
            return(Content(treeList.TreeToJson()));
        }
コード例 #3
0
        /// <summary>
        /// 数据字典列表
        /// </summary>
        /// <returns></returns>
        public IEnumerable <DataItemEntity> GetDataItemList()
        {
            List <DataItemEntity> cacheList = CacheFactory.CacheFactory.GetCacheInstance().GetCache <List <DataItemEntity> >(_dataItemBll.CacheKey);

            if (cacheList == null)
            {
                cacheList = _dataItemBll.GetDataItemList().ToList();
                CacheFactory.CacheFactory.GetCacheInstance().WriteCache(cacheList, _dataItemBll.CacheKey);
            }

            return(cacheList);
        }