private bool HasCodeValue(TreeCodeTable cdm, ref string key) { if (cdm.KeyValues != null && cdm.KeyValues.Count() > 0) { key = string.Join("", cdm.KeyValues); if (key.IsEmpty()) { return(false); } return(true); } return(false); }
public string LoadTreeFormatJson(string regName, string ds) { SetPostDataSet(ds); var dt = GetCodeTableInstance(regName); TreeCodeTable cdm = dt as TreeCodeTable; // cdm.Initialize(PostDataSet); TreeCodeTableModel result = null; string key = ""; bool isCodeValue = HasCodeValue(cdm, ref key); if (isCodeValue) { result = cdm.GetDisplayTreeNode(key); if (result == null) { result = cdm.GetChildrenNode(cdm.Root); } } else { result = cdm.GetChildrenNode(cdm.Root); } //FormaterTreeText(result); //if (result != null && result.Children != null) //{ if (result.CODE_VALUE == "0") { return(ReturnJson(result.Children.ToArray())); } else { if (result.Children.Count() == 1) { if (result.Children.First().CODE_VALUE == cdm.Root) { return(ReturnJson(result.Children.ToArray())); } } result.CODE_TEXT = cdm[result.CODE_VALUE].CODE_TEXT; //result.open = true; } //} //else return(ReturnJson(new TreeCodeTableModel[] { result })); //return FastJson(result); }
public string LoadSubtreeFormatJson(string ztree, string ds, string regName, string CODE_VALUE) { SetPostDataSet(ds); var dt = GetCodeTableInstance(regName); TreeCodeTable cdm = dt as TreeCodeTable; if (!ztree.IsEmpty()) { CODE_VALUE = (ztree.Split('=')[1]).ToString(); } if (string.IsNullOrEmpty(CODE_VALUE)) { CODE_VALUE = cdm.Root; } var res = cdm.GetChildrenNode(CODE_VALUE); //if (CODE_VALUE == "0") //FormaterTreeText(res); return(ReturnJson(res.Children.ToArray())); // return FastJson(res); }