示例#1
0
        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));
        }
示例#2
0
        public object MoveUpDown(string nodeId, TreeNodeMoveDirection direction)
        {
            TkDebug.AssertArgumentNull(nodeId, "nodeId", this);

            TreeUtil.SortTree(this, fTreeScheme.TreeDefinition, nodeId, direction);
            UpdateDatabase();
            return(CreateKeyData());
        }
示例#3
0
        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());
        }
示例#4
0
        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));
        }
示例#5
0
 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());
     }
 }
示例#6
0
        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());
        }
示例#7
0
        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());
            }
        }
示例#8
0
        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;
            }
        }
示例#9
0
 private IEnumerable <ITreeNode> GetTreeNodes(IParamBuilder builder)
 {
     builder = GetCustomParamBuilder(builder);
     return(TreeUtil.SelectData(fSelector, this,
                                () => fSelector.Select(builder, fOrder), null));
 }
示例#10
0
 public ITreeNode GetTreeNode(string id)
 {
     return(TreeUtil.GetTreeNode(fSelector, this, id));
 }