public IEnumerable <ITreeNode> GetDisplayTreeNodes(string id) { ITreeNode node = GetTreeNode(id); if (node == null) { return(RootNodes); } IParamBuilder builder = TreeUtil.GetValueBuilder(fSelector, fDefinition, TopLevel, node.Convert <NormalDataRowTreeNode>()); builder = GetCustomParamBuilder(builder); if (builder == null) { return(Enumerable.Empty <ITreeNode>()); } //IParamBuilder customSql = fTreeProvider.CustomSql; //if (builder == null && customSql == null) // return TreeUtil.CreateEmptyEnumerable(); //if (customSql != null) // builder = builder == null ? customSql : SqlParamBuilder.CreateParamBuilder(builder, customSql); var data = TreeUtil.SelectData(fSelector, this, () => fSelector.Select(builder, fOrder), id); return(TreeUtil.GetDisplayTreeNodes(data, id)); }
public object MoveUpDown(string nodeId, TreeNodeMoveDirection direction) { TkDebug.AssertArgumentNull(nodeId, "nodeId", this); TreeUtil.SortTree(this, fTreeScheme.TreeDefinition, nodeId, direction); UpdateDatabase(); return(CreateKeyData()); }
public object MoveTreeNode(string srcNodeId, string dstNodeId) { TkDebug.AssertArgumentNull(srcNodeId, "srcNodeId", this); TkDebug.AssertArgumentNull(dstNodeId, "dstNodeId", this); TreeUtil.MoveTree(this, fTreeScheme.TreeDefinition, srcNodeId, dstNodeId); UpdateDatabase(); return(CreateKeyData()); }
public IEnumerable <ITreeNode> GetDisplayTreeNodes(string id) { int level = fProvider.GetLevel(fDefinition, id); IParamBuilder builder = TreeUtil.GetLevelBuilder(fSelector, fDefinition, level, id, fProvider); var data = TreeUtil.SelectData(fSelector, this, () => fSelector.Select(builder), id); return(TreeUtil.GetDisplayTreeNodes(data, id)); }
public ITreeNode GetTreeNode(string id) { if (!UseCustomParamBuilder) { return(TreeUtil.GetTreeNode(fSelector, this, id)); } else { IParamBuilder builder = fSelector.CreateParamBuilder(null, new string[] { fDefinition.IdField }, id); return(GetTreeNodes(builder).FirstOrDefault()); } }
private IEnumerable <ITreeNode> SelectChildNode(string parentId, int level) { string value = fProvider.GetSqlLikeValue(fDefinition, level, parentId); IFieldInfo fieldInfo = fSelector.GetFieldInfo(fDefinition.IdField); IParamBuilder builder = SqlParamBuilder.CreateSingleSql(fSelector.Context, fieldInfo, "LIKE", value); if (!string.IsNullOrEmpty(parentId)) { builder = SqlParamBuilder.CreateParamBuilder(builder, SqlParamBuilder.CreateSingleSql(fSelector.Context, fieldInfo, "<>", fDefinition.IdField + 1, parentId)); } return(TreeUtil.SelectData(fSelector, this, () => fSelector.Select(builder), null).ToArray()); }
public IEnumerable <ITreeNode> GetChildNodes(string parentId) { TkDebug.AssertArgumentNullOrEmpty(parentId, "parentId", this); if (!UseCustomParamBuilder) { return(TreeUtil.SelectData(fSelector, this, () => fSelector.SelectWithParam(null, fOrder, fDefinition.ParentIdField, parentId), null).ToArray()); } else { IParamBuilder builder = fSelector.CreateParamBuilder(null, new string[] { fDefinition.ParentIdField }, parentId); return(GetTreeNodes(builder).ToArray()); } }
protected override void OnUpdatingRow(UpdatingEventArgs e) { base.OnUpdatingRow(e); DbTreeDefinition def = fTreeScheme.TreeDefinition; switch (e.Status) { case UpdateKind.Insert: if (string.IsNullOrEmpty(e.Row[def.ParentIdField].ToString())) { e.Row[def.ParentIdField] = def.ExecuteRootId; } e.Row[def.LeafField] = 1; e.Row[def.LayerField] = TreeUtil.GetLayer(this, def, e.Row[def.ParentIdField].ToString()); break; case UpdateKind.Update: if (IsFakeDelete && e.InvokeMethod == UpdateKind.Delete) { if (e.Row[def.LeafField].Value <int>() == 0) { throw new WebPostException("该节点下还有子节点,不能删除!"); } TreeUtil.SetParentLeaf(this, def, e.Row[def.ParentIdField].ToString()); } break; case UpdateKind.Delete: if (e.Row[def.LeafField].Value <int>() == 0) { throw new WebPostException("该节点下还有子节点,不能删除!"); } SetCommands(AdapterCommand.Update); TreeUtil.SetParentLeaf(this, def, e.Row[def.ParentIdField].ToString()); break; } }
private IEnumerable <ITreeNode> GetTreeNodes(IParamBuilder builder) { builder = GetCustomParamBuilder(builder); return(TreeUtil.SelectData(fSelector, this, () => fSelector.Select(builder, fOrder), null)); }
public ITreeNode GetTreeNode(string id) { return(TreeUtil.GetTreeNode(fSelector, this, id)); }