Example #1
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();
        }
Example #2
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);
        }