Beispiel #1
0
        /// <summary>
        /// 读取数据库,生成一个树结构,包含所有的节点
        /// </summary>
        /// <returns></returns>
        public static DbRemoteTree GetRemoteTree()
        {
            DbRemoteTree tree = new DbRemoteTree(string.Empty, string.Empty, RemoteType.dir);
            Dictionary <string, DbRemoteTree> keyValues = new Dictionary <string, DbRemoteTree>();

            var Dirs = _tableDirectory.FindAll();

            foreach (DbItemDirectory item in Dirs)
            {
                DbRemoteTree treeItem = new DbRemoteTree(item.Id, item.Name, RemoteType.dir);
                keyValues.Add(item.Id, treeItem);
            }

            foreach (DbItemDirectory item in Dirs)
            {
                if (string.IsNullOrEmpty(item.ParentId))
                {
                    tree.Dirs.Add(keyValues[item.Id]);
                }
                else
                {
                    if (!keyValues.ContainsKey(item.ParentId))
                    {
                        continue;
                    }
                    keyValues[item.ParentId].Dirs.Add(keyValues[item.Id]);
                }
            }

            foreach (DbItemRemoteLink item in _tableRemoteLink.FindAll())
            {
                DbRemoteTree treeItem = new DbRemoteTree(item.Id, item.Name, (RemoteType)(item.Type));
                if (string.IsNullOrEmpty(item.ParentId))
                {
                    tree.Items.Add(treeItem);
                }
                else
                {
                    if (!keyValues.ContainsKey(item.ParentId))
                    {
                        continue;
                    }
                    keyValues[item.ParentId].Items.Add(treeItem);
                }
                keyValues.Add(item.Id, treeItem);
            }
            return(tree);
        }
Beispiel #2
0
 public RemoteTreeViewItem(DbRemoteTree remoteTree)
 {
     Header     = remoteTree.Name;
     RemoteTree = remoteTree;
     RemoteType = remoteTree.Type;
 }