/// <summary> /// </summary> /// <param name="SubNode"></param> /// <returns></returns> public static BsonDocument ConvertTreeNodeTozTreeBsonDoc(TreeNode SubNode) { var SingleNode = new BsonDocument(); SingleNode.Add("name", SubNode.Text + GetTagText(SubNode)); if (SubNode.Nodes.Count == 0) { SingleNode.Add("icon", "MainTreeImage" + String.Format("{0:00}", SubNode.ImageIndex) + ".png"); } else { var ChildrenList = new BsonArray(); foreach (TreeNode item in SubNode.Nodes) { ChildrenList.Add(ConvertTreeNodeTozTreeBsonDoc(item)); } SingleNode.Add("children", ChildrenList); SingleNode.Add("icon", "MainTreeImage" + String.Format("{0:00}", SubNode.ImageIndex) + ".png"); } if (SubNode.IsExpanded) { SingleNode.Add("open", "true"); } if (SubNode.Tag != null) { SingleNode.Add("click", "ShowData('" + Utility.GetTagType(SubNode.Tag.ToString()) + "','" + Utility.GetTagData(SubNode.Tag.ToString()) + "')"); } return(SingleNode); }
/// <summary> /// </summary> /// <returns></returns> public static string GetCollectionzTreeJSON(MongoServer mServer) { //获得数据 WebDataViewInfo.LimitCnt = 100; var dataList = DataViewInfo.GetDataList(ref WebDataViewInfo, mServer); var collectionName = Utility.GetTagData(WebDataViewInfo.strDBTag).Split("/".ToCharArray())[(int)EnumMgr.PathLv.CollectionLv]; var tree = new ctlTreeViewColumns(); UIHelper.FillDataToTreeView(collectionName, tree, dataList, WebDataViewInfo.SkipCnt); var array = new BsonArray(); foreach (TreeNode item in tree.TreeView.Nodes) { array.Add(ConvertTreeNodeTozTreeBsonDoc(item)); } return(array.ToJson(MongoUtility.Basic.Utility.JsonWriterSettings)); }