示例#1
0
        //动态创建泛型实例举例
        //public void Test()
        //{
        //    Type type = Type.GetType("IRAPBase.Entities.ERS_T1R1", true, true);
        //    var repositoryType = typeof(Repository<>);
        //   // IRepository  test;
        //    var repositoryInstance = Activator.CreateInstance(repositoryType.MakeGenericType(type), context);
        //    Console.WriteLine(type.FullName);
        //}
        /// <summary>
        /// 返回树的数据,支持懒加载
        /// </summary>
        /// <returns></returns>
        private IRAPTreeNodes TreeViewData(int entryNode = 0, bool includingLeaves = true)
        {
            //long[] pkArray = { PK + _treeID, _treeID };
            int    errCode = 0;
            string errText = "获取成功!";
            List <TreeNodeEntity> newNodelist = nodes.Where(r => r.TreeID == _treeID && _PKDict.Contains(r.PartitioningKey)).OrderBy(r => r.NodeDepth).ThenBy(r => r.NodeID).ToList();
            List <TreeNodeEntity> nodeSet     = new List <TreeNodeEntity>();

            if (entryNode > 0)
            {
                TreeNodeEntity thisNode = newNodelist.FirstOrDefault(c => c.NodeID == entryNode);
                if (thisNode == null)
                {
                    errCode = 2;
                    errText = "入口结点无效!";
                    throw new Exception($"{errCode}-{errText}");
                }
                nodeSet = newNodelist.Where(c => c.NodeDepth > thisNode.NodeDepth).OrderBy(r => r.NodeDepth).ThenBy(r => r.NodeID).ToList();
                nodeSet.Insert(0, thisNode);
            }
            else
            {
                nodeSet = newNodelist;
            }

            List <TreeLeafEntity> leafSet = null;

            if (includingLeaves)
            {
                leafSet = leaves.Where(r => r.TreeID == _treeID && _PKDict.Contains(r.PartitioningKey)).OrderBy(r => r.UDFOrdinal).Take(50000).ToList();
            }

            TreeNodeEntity node     = nodeSet.FirstOrDefault();
            IRAPTreeNodes  rootNode = new IRAPTreeNodes();

            if (node != null)
            {
                rootNode.NodeID        = node.NodeID;
                rootNode.NodeCode      = node.Code;
                rootNode.NodeName      = node.NodeName;
                rootNode.NodeDepth     = node.NodeDepth;
                rootNode.NodeStatus    = node.NodeStatus;
                rootNode.NodeType      = 3;
                rootNode.CSTRoot       = node.CSTRoot;
                rootNode.UDFOrdinal    = node.UDFOrdinal;
                rootNode.TreeViewType  = 2;
                rootNode.Parent        = node.Father;
                rootNode.IconFile      = node.IconID.ToString();
                rootNode.Accessibility = 0;
                FindNodeAddToNode(rootNode, nodeSet, leafSet);
            }
            return(rootNode);
        }
        private void FullfillTreeNode(EntityTreeViewItem node, TreeNodeEntity nodeEntity, BitmapImage image)
        {
            foreach (var item in nodeEntity.SubNodes.OrderBy(s => s.Name))
            {
                EntityTreeViewItem directoryNode = new EntityTreeViewItem(item.Name, null, _folderImage);

                node.Items.Add(directoryNode);

                FullfillTreeNode(directoryNode, item, image);
            }

            foreach (var item in nodeEntity.Entities.OrderBy(s => s.Item1))
            {
                string name = item.Item1;

                EntityTreeViewItem tn = new EntityTreeViewItem(name, item.Item2, image);

                StringBuilder result = new StringBuilder();

                if (item.Item2.IsManaged.GetValueOrDefault())
                {
                    if (result.Length > 0)
                    {
                        result.Append(" ");
                    }

                    result.Append("Managed");
                }

                if (item.Item2.IsHidden.Value)
                {
                    if (result.Length > 0)
                    {
                        result.Append("    ");
                    }

                    result.Append("Hidden");
                }

                if (result.Length > 0)
                {
                    tn.Description = result.ToString();
                }

                node.Items.Add(tn);
            }

            if (node.Items.Count > 0)
            {
                node.Description = node.Items.Count.ToString();
            }
        }
        private void LoadWebResources(IEnumerable <WebResource> results)
        {
            ObservableCollection <EntityTreeViewItem> list = new ObservableCollection <EntityTreeViewItem>();

            var groupList = results
                            .GroupBy(a => a.WebResourceType.Value)
                            .OrderBy(a => a.Key);

            foreach (var group in groupList)
            {
                var groupName = group.First().FormattedValues[WebResource.Schema.Attributes.webresourcetype];

                BitmapImage image = null;

                if (_typeImageMapping.ContainsKey(group.Key))
                {
                    image = _typeImageMapping[group.Key];
                }

                var node = new EntityTreeViewItem(groupName, null, image);

                var nodeEntity = TreeNodeEntity.Convert(group);

                FullfillTreeNode(node, nodeEntity, image);

                list.Add(node);
            }

            ExpandNode(list);

            this.trVWebResources.Dispatcher.Invoke(() =>
            {
                this.trVWebResources.BeginInit();

                this.trVWebResources.ItemsSource = list;

                this.trVWebResources.EndInit();
            });
        }
示例#4
0
    private List<TreeNodeEntity> GetDirNode(string dir)
    {
        List<TreeNodeEntity> filesEntities = new List<TreeNodeEntity>();
        string[] dirs = Directory.GetDirectories(dir);
        foreach (string InDir in dirs)
        {
            TreeNodeEntity dirNode = new TreeNodeEntity();
            dirNode.Name = InDir.Substring(InDir.LastIndexOf("\\") + 1, InDir.Length - InDir.LastIndexOf("\\") - 1);
            dirNode.Open = false;
            dirNode.Children = GetDirNode(InDir);
            filesEntities.Add(dirNode);
        }
        string[] files = Directory.GetFiles(dir);
        foreach (string InFile in files)
        {
            TreeNodeEntity fileNode = new TreeNodeEntity();
            CodeEntity ce = CodeOperation.GetCodeFromPath(dir.Replace(
               Server.MapPath(AppConfiger.GetProjectsDir(Server)), "") +
               "\\" + InFile.Substring(InFile.LastIndexOf("\\") + 1, InFile.Length - InFile.LastIndexOf("\\") - 1));
            if (ce != null)
            {
                fileNode.Id = ce.Id;
                fileNode.Name = ce.Path.Substring(ce.Path.LastIndexOf("\\") + 1, ce.Path.Length - ce.Path.LastIndexOf("\\") - 1);
                fileNode.TargetName = "sourceFrame";
                fileNode.UrlFormat = "/Viewer.aspx?id={0}";
                filesEntities.Add(fileNode);
            }
            else
            {
                fileNode.Name = InFile.Substring(InFile.LastIndexOf("\\") + 1, InFile.Length - InFile.LastIndexOf("\\") - 1);
                filesEntities.Add(fileNode);
            }

        }
        return filesEntities;
    }
示例#5
0
    /// <summary>
    /// 获取文件
    /// </summary>
    /// <param name="dir"></param>
    /// <returns></returns>
    private List <TreeNodeEntity> GetDirNode(string dir)
    {
        List <TreeNodeEntity> filesEntities = new List <TreeNodeEntity>();

        string[] dirs = Directory.GetDirectories(dir);
        foreach (string InDir in dirs)
        {
            TreeNodeEntity dirNode = new TreeNodeEntity();
            dirNode.Name     = InDir.Substring(InDir.LastIndexOf("\\") + 1, InDir.Length - InDir.LastIndexOf("\\") - 1);
            dirNode.Open     = false;
            dirNode.Children = GetDirNode(InDir);
            filesEntities.Add(dirNode);
        }
        string[] files = Directory.GetFiles(dir);
        foreach (string InFile in files)
        {
            TreeNodeEntity fileNode = new TreeNodeEntity();
            CodeEntity     ce       = CodeOperation.GetCodeFromPath(dir.Replace(
                                                                        Server.MapPath(AppConfiger.GetProjectsDir(Server)), "") +
                                                                    "\\" + InFile.Substring(InFile.LastIndexOf("\\") + 1, InFile.Length - InFile.LastIndexOf("\\") - 1));
            if (ce != null)
            {
                fileNode.Id         = ce.Id;
                fileNode.Name       = ce.Path.Substring(ce.Path.LastIndexOf("\\") + 1, ce.Path.Length - ce.Path.LastIndexOf("\\") - 1);
                fileNode.TargetName = "sourceFrame";
                fileNode.UrlFormat  = "/Viewer.aspx?id={0}";
                filesEntities.Add(fileNode);
            }
            else
            {
                fileNode.Name = InFile.Substring(InFile.LastIndexOf("\\") + 1, InFile.Length - InFile.LastIndexOf("\\") - 1);
                filesEntities.Add(fileNode);
            }
        }
        return(filesEntities);
    }