Exemplo n.º 1
0
        //展开选中项的子项
        private void item_Expand(object sender, RoutedEventArgs e)
        {
            TreeViewItem treeItem = memberTreeView.SelectedItem as TreeViewItem;

            if (treeItem != null)
            {
                MenuItem   menu     = sender as MenuItem;
                int        expLevel = int.Parse(menu.Tag.ToString());
                MyTreeNode node     = treeItem.Tag as MyTreeNode;
                if (expLevel > 1000 && node.ChildrenCountAll > 10000)
                {
                    string           warnTxt = "你确定要一次性展开全部子节点吗?\n展开层级过大可能会由于数据量太大而造成程序卡死。";
                    MessageBoxResult result  = MessageBox.Show(warnTxt, "警告", MessageBoxButton.YesNo);
                    if (result == MessageBoxResult.No)
                    {
                        return;
                    }
                }

                levels = 0;
                TimingUtil.StartTiming();
                MyTrees.OpenDB();
                WindowView.notify.SetProcessBarVisible(true);
                ExpandNode(treeItem, expLevel);
                WindowView.notify.SetProcessBarVisible(false);
                MyTrees.CloseDB();
                WindowView.notify.SetStatusMessage(TimingUtil.EndTiming());
            }
        }
Exemplo n.º 2
0
 public void ExpandRootNode(int maxLevel)
 {
     levels = 0;
     MyTrees.OpenDB();
     ExpandNode(memberTreeView.Items[0] as TreeViewItem, maxLevel);
     MyTrees.CloseDB();
 }
Exemplo n.º 3
0
        public void SetRootNode(MyTreeNode rootNode)
        {
            pager.Visibility = Visibility.Hidden;
            memberTreeView.Items.Clear();
            ringNodeIds.Clear();

            if (rootNode != null)
            {
                TreeViewItem rootItem = NewTreeViewItem(rootNode);

                memberTreeView.Items.Add(rootItem);

                //如果还有子节点,则添加一个节点,使该节点具有折叠的"+"
                if (rootNode.ChildrenCount > 0)
                {
                    rootItem.Items.Add(NewTreeViewItem(null));
                }

                MyTrees.OpenDB();
                //判断当前根节点是否存在父节点
                if (MyTrees.GetNodeBySysId(rootNode.TopId) != null)
                {
                    btnUpLevelNode.IsEnabled = true;
                    btnUpRootNode.IsEnabled  = true;
                }
                else
                {
                    btnUpLevelNode.IsEnabled = false;
                    btnUpRootNode.IsEnabled  = false;
                }
                MyTrees.CloseDB();
            }
        }
Exemplo n.º 4
0
        //节点太多,点击加载更多未显示的节点
        void moreNode_Load(object sender, RoutedEventArgs e)
        {
            TreeViewItem moreItem   = sender as TreeViewItem;
            MyTreeNode   node       = moreItem.Tag as MyTreeNode;
            TreeViewItem parentItem = moreItem.Parent as TreeViewItem;

            if (parentItem != null)
            {
                parentItem.Items.Remove(moreItem);

                MyTrees.OpenDB();
                List <MyTreeNode> childrenNodes = MyTrees.GetNodesByTopIdPage(node.TopId, node.ChildrenCount);
                MyTrees.CloseDB();
                foreach (MyTreeNode subNode in childrenNodes)
                {
                    TreeViewItem subItem = NewTreeViewItem(subNode);
                    parentItem.Items.Add(subItem);

                    //如果子节点还有孙子节点,则添加一个虚假的孙节点,使该子节点具有折叠的"+"
                    if (subNode.ChildrenCount > 0)
                    {
                        subItem.Items.Add(NewTreeViewItem(null));
                    }

                    WindowView.notify.SetStatusMessage("正在展开节点" + subItem.Header);
                }

                //表示分页加载更多的节点
                node.ChildrenCount = node.ChildrenCount + MyTrees.getNodePageSize;
                if (node.ChildrenCount < node.ChildrenCountAll)
                {
                    parentItem.Items.Add(NewTreeViewItem(node));
                }
            }
        }
Exemplo n.º 5
0
        internal static int GetIdConflictNodesCount()
        {
            MyTrees.OpenDB();
            string sql = "select count(*) from "
                         + treeDB.TableName + "_calc where sysid in (select v from "
                         + treeDB.TableName + "_profile where k='Conflict')";
            int count = treeDB.SearchCount(sql);

            MyTrees.CloseDB();
            return(count);
        }
Exemplo n.º 6
0
        internal static List <string> GetIdConflictNodes(int pageNo, int pageSize)
        {
            MyTrees.OpenDB();
            string sql = "select * from "
                         + treeDB.TableName + "_calc where sysid in (select v from "
                         + treeDB.TableName + "_profile where k='Conflict') limit "
                         + (pageNo * pageSize) + ", " + pageSize;
            List <string> conflictNodes = treeDB.SearchString(sql);

            MyTrees.CloseDB();
            return(conflictNodes);
        }
Exemplo n.º 7
0
        internal static List <MyTreeNode> GetTreeRootNodes(int pageNo, int pageSize)
        {
            MyTrees.OpenDB();
            string sql = "select sysid,topid,name,level,sublevel,subcount,subcountall from "
                         + treeDB.TableName + "_calc where sysid in (select v from "
                         + treeDB.TableName + "_profile where k='Tree') order by subcountall desc limit "
                         + (pageNo * pageSize) + ", " + pageSize;
            List <MyTreeNode> treeRootNodes = treeDB.SearchNode(sql);

            MyTrees.CloseDB();
            return(treeRootNodes);
        }
Exemplo n.º 8
0
 internal static List <string> GetRingNodeIds()
 {
     if (ringNodes == null)
     {
         ringNodes = new List <string>();
         MyTrees.OpenDB();
         string sql = "select v from " + treeDB.TableName + "_profile where k='Ring'";
         ringNodes = treeDB.SearchString(sql);
         MyTrees.CloseDB();
     }
     return(ringNodes);
 }
Exemplo n.º 9
0
 internal static List <string> GetLeafAloneNodeIds()
 {
     if (leafAloneNodeIds == null)
     {
         leafAloneNodeIds = new List <string>();
         MyTrees.OpenDB();
         string sql = "select v from " + treeDB.TableName + "_profile where k='Leaf'";
         leafAloneNodeIds = treeDB.SearchString(sql);
         MyTrees.CloseDB();
     }
     return(leafAloneNodeIds);
 }
Exemplo n.º 10
0
 private static void ExportAllImgs(MyTreeView mytreeview, MyTreeNode node)
 {
     mytreeview.BeginExportImg();
     exportNodes.Clear();
     exportNodes.Add(node);
     MyTrees.OpenDB();
     while (exportNodes.Count > 0)
     {
         ExportImg(mytreeview, exportNodes[0]);
     }
     mytreeview.EndExportImg();
     MyTrees.CloseDB();
 }
Exemplo n.º 11
0
 internal static List <string> GetTableOptCols()
 {
     if (tableOptCols == null)
     {
         MyTrees.OpenDB();
         string sql = "select v from "
                      + treeDB.TableName
                      + "_profile where k='TableOptCol'";
         tableOptCols = treeDB.SearchString(sql);
         MyTrees.CloseDB();
     }
     return(tableOptCols);
 }
Exemplo n.º 12
0
        void item_Expanded(object sender, RoutedEventArgs e)
        {
            TreeViewItem item = e.Source as TreeViewItem;

            if (item.HasItems && (item.Items[0] as TreeViewItem).Header.ToString() == "none")
            {
                //先移除为使该节点具有折叠的"+"而添加的虚假的子节点
                item.Items.Clear();

                if ((e.Source as TreeViewItem).IsSelected)
                {
                    MyTrees.OpenDB();
                }

                MyTreeNode        node          = item.Tag as MyTreeNode;
                List <MyTreeNode> childrenNodes = MyTrees.GetNodesByTopIdPage(node.SysId, 0);

                foreach (MyTreeNode subNode in childrenNodes)
                {
                    TreeViewItem subItem = NewTreeViewItem(subNode);
                    item.Items.Add(subItem);

                    //如果子节点还有孙子节点,则添加一个虚假的孙节点,使该子节点具有折叠的"+"
                    if (subNode.ChildrenCount > 0)
                    {
                        subItem.Items.Add(NewTreeViewItem(null));
                    }

                    WindowView.notify.SetStatusMessage("正在展开节点" + subItem.Header);
                }

                //表示分页加载更多的节点
                if (node.ChildrenCount > MyTrees.getNodePageSize)
                {
                    MyTreeNode moreNode = new MyTreeNode();
                    moreNode.SysId            = "moreNode";
                    moreNode.Name             = node.Name;
                    moreNode.TopId            = node.SysId;
                    moreNode.ChildrenCount    = MyTrees.getNodePageSize;
                    moreNode.ChildrenCountAll = node.ChildrenCount;
                    item.Items.Add(NewTreeViewItem(moreNode));
                }

                if ((e.Source as TreeViewItem).IsSelected)
                {
                    MyTrees.CloseDB();
                }
            }
        }
Exemplo n.º 13
0
        void item_SelectedChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            TreeViewItem selectedItem = e.NewValue as TreeViewItem;

            if (selectedItem != null)
            {
                MyTreeNode node = selectedItem.Tag as MyTreeNode;
                if (node != null)
                {
                    MyTrees.OpenDB();
                    string nodeDB = MyTrees.GetStringBySysId(node.SysId);
                    MyTrees.CloseDB();
                    if (nodeDB != null)
                    {
                        myNodeInfo.SetNode(nodeDB);
                    }
                }
            }
            WindowView.Refresh_Online_time();
        }
Exemplo n.º 14
0
        public static void Export2CSV(MyTreeNode node, string outputfile)
        {
            ringNodeIds.Clear();
            WindowView.notify.SetProcessBarVisible(true);
            WindowView.notify.SetStatusMessage("开始导出文件......");
            TimingUtil.StartTiming();

            StreamWriter mysw = new StreamWriter(outputfile, true, Encoding.Default);

            List <string> optCols = MyTrees.GetTableOptCols();
            string        header  = string.Join(",", optCols.ToArray());

            header = "会员ID,父级ID,会员姓名,所在层级,下级层数,直接下级会员数,下级会员总数," + header;
            mysw.WriteLine(header);

            StringBuilder allLines = new StringBuilder();

            MyTrees.OpenDB();

            row    = 2;
            allRow = node.ChildrenCountAll + 1;

            //导出所有父节点
            ExportAllParents2CSV(mysw, allLines, node);

            //导出该节点
            string nodestr = MyTrees.GetStringBySysId(node.SysId);

            mysw.WriteLine(nodestr);

            //导出该节点所有子节点
            ExportAllChildren2CSV(mysw, allLines, node);

            MyTrees.CloseDB();
            mysw.Close();

            WindowView.notify.SetStatusMessage(TimingUtil.EndTiming());
            WindowView.notify.SetProcessBarVisible(false);
        }
Exemplo n.º 15
0
        internal static Dictionary <string, string> GetRingNodes(int pageNo, int pageSize)
        {
            MyTrees.OpenDB();
            string sql = "select * from "
                         + treeDB.TableName + "_calc where sysid in (select v from "
                         + treeDB.TableName + "_profile where k='Ring') limit "
                         + (pageNo * pageSize) + ", " + pageSize;
            List <string> nodes = treeDB.SearchString(sql);

            MyTrees.CloseDB();

            Dictionary <string, string> ringNodes = new Dictionary <string, string>();

            foreach (string node in nodes)
            {
                string sysid = node.Substring(0, node.IndexOf(","));
                if (!ringNodes.ContainsKey(sysid))
                {
                    ringNodes.Add(sysid, node);
                }
            }
            return(ringNodes);
        }
Exemplo n.º 16
0
        //显示上一级节点
        private void btnUpLevelNode_Click(object sender, RoutedEventArgs e)
        {
            MyTrees.OpenDB();
            TreeViewItem oldRootItem = memberTreeView.Items[0] as TreeViewItem;
            MyTreeNode   oldRootNode = oldRootItem.Tag as MyTreeNode;
            MyTreeNode   newRootNode = MyTrees.GetNodeBySysId(oldRootNode.TopId);

            if (isRingClose(newRootNode.SysId))
            {
                return;
            }

            //先移除旧的根节点
            memberTreeView.Items.Remove(oldRootItem);

            //添加新的根节点
            TreeViewItem newRootItem = NewTreeViewItem(newRootNode);

            memberTreeView.Items.Add(newRootItem);
            newRootItem.IsExpanded = true;

            //新的根节点添加子节点
            List <MyTreeNode> childrenNodes = MyTrees.GetNodesByTopIdPage(newRootNode.SysId, 0);
            bool hasNotAdded = true;

            foreach (MyTreeNode subNode in childrenNodes)
            {
                if (hasNotAdded)
                {
                    if (oldRootNode.SysId == subNode.SysId)
                    {
                        newRootItem.Items.Add(oldRootItem);
                        hasNotAdded = false;
                        continue;
                    }
                }
                TreeViewItem subItem = NewTreeViewItem(subNode);
                newRootItem.Items.Add(subItem);

                //如果子节点还有孙子节点,则添加一个虚假的孙节点,使该子节点具有折叠的"+"
                if (subNode.ChildrenCount > 0)
                {
                    subItem.Items.Add(NewTreeViewItem(null));
                }
            }

            //表示分页加载更多的节点
            if (newRootNode.ChildrenCount > MyTrees.getNodePageSize)
            {
                MyTreeNode moreNode = new MyTreeNode();
                moreNode.SysId            = "moreNode";
                moreNode.Name             = newRootNode.Name;
                moreNode.TopId            = newRootNode.SysId;
                moreNode.ChildrenCount    = MyTrees.getNodePageSize;
                moreNode.ChildrenCountAll = newRootNode.ChildrenCount;
                newRootItem.Items.Add(NewTreeViewItem(moreNode));
            }

            //判断当前根节点是否存在父节点
            if (MyTrees.GetNodeBySysId(newRootNode.TopId) != null)
            {
                btnUpLevelNode.IsEnabled = true;
                btnUpRootNode.IsEnabled  = true;
            }
            else
            {
                btnUpLevelNode.IsEnabled = false;
                btnUpRootNode.IsEnabled  = false;
            }
            MyTrees.CloseDB();
        }