管道基础大数据平台系统开发-【CS】-ExportMap
1
13693261870
2023-08-22 1e45582d78413ae5696e0b0bc971fad7e9d64c49
1
已添加3个文件
已修改6个文件
336 ■■■■■ 文件已修改
DataLoader/CS/DBHelper.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/DataLoader.csproj 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/LoginWin.xaml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/MainWindow.xaml 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/MainWindow.xaml.cs 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/Model/SysDir.cs 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/Model/TreeItem.cs 115 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/ResWin.xaml 67 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/ResWin.xaml.cs 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/CS/DBHelper.cs
@@ -66,7 +66,7 @@
        /// </summary>
        public static List<SysDir> GetDirList()
        {
            string sql = "select * from lf.sys_dir";
            string sql = "select a.*, fn_get_fullname(a.code, 2) fullName from lf.sys_dir a";
            DataTable dt = Tools.DBHelper.GetDataTable(sql);
            if (null == dt || dt.Rows.Count == 0) return null;
DataLoader/DataLoader.csproj
@@ -119,6 +119,10 @@
      <Generator>MSBuild:Compile</Generator>
      <SubType>Designer</SubType>
    </ApplicationDefinition>
    <Compile Include="Model\TreeItem.cs" />
    <Compile Include="ResWin.xaml.cs">
      <DependentUpon>ResWin.xaml</DependentUpon>
    </Compile>
    <Page Include="LoginWin.xaml">
      <SubType>Designer</SubType>
      <Generator>MSBuild:Compile</Generator>
@@ -152,6 +156,10 @@
      <DependentUpon>MainWindow.xaml</DependentUpon>
      <SubType>Code</SubType>
    </Compile>
    <Page Include="ResWin.xaml">
      <Generator>MSBuild:Compile</Generator>
      <SubType>Designer</SubType>
    </Page>
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Model\SysMeta.cs" />
DataLoader/LoginWin.xaml
@@ -2,7 +2,7 @@
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Chrome="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
        Loaded="Window_Loaded" Title="登录窗口"
        Loaded="Window_Loaded" Title="登录窗口" ShowInTaskbar="False" WindowStyle="None"
        Height="500" Width="750" WindowStartupLocation="CenterScreen">
    <Grid>
        <Chrome:ChromiumWebBrowser x:Name="web" Margin="1" Grid.Row="1" />
DataLoader/MainWindow.xaml
@@ -1,8 +1,7 @@
<Window x:Class="DataLoader.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Height="700" Width="900"
        Loaded="Window_Loaded"
        Height="700" Width="900" Loaded="Window_Loaded"
        Title="数据入库 v1.5" WindowStartupLocation="CenterScreen">
    <Window.Resources>
        <Style x:Key="btn" TargetType="Button">
@@ -23,8 +22,9 @@
        <Style x:Key="tb" TargetType="TextBox">
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="HorizontalAlignment" Value="Stretch"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Height" Value="30"/>
            <Setter Property="FontSize" Value="20"/>
            <Setter Property="FontSize" Value="16"/>
        </Style>
        <!--Combox-->
@@ -127,7 +127,7 @@
            <Setter Property="BorderThickness" Value="0"/>
        </Style>
        <!--<Style TargetType="DatePickerTextBox">
        <Style TargetType="DatePickerTextBox">
            <Setter Property="ItemsControl.Template">
                <Setter.Value>
                    <ControlTemplate>
@@ -135,7 +135,7 @@
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>-->
        </Style>
    </Window.Resources>
    <Grid x:Name="gMain">
        <Grid.RowDefinitions>
@@ -164,7 +164,7 @@
        <Button Grid.Row="0" Grid.Column="4" Content="登 å½•" Style="{StaticResource btn}" Click="Login_MouseLeftButtonDown"/>
        <Label Grid.Row="1" Grid.Column="0" Content="令牌:" VerticalAlignment="Center" HorizontalAlignment="Right" />
        <TextBox Grid.Row="1" Grid.Column="1"  Style="{StaticResource tb}" IsReadOnly="True" x:Name="tbToken"/>
        <TextBox Grid.Row="1" Grid.Column="1" Style="{StaticResource tb}" IsReadOnly="True" x:Name="tbToken"/>
        <Label Grid.Row="1" Grid.Column="2" Content="元数据类型:" VerticalAlignment="Center" HorizontalAlignment="Right" />
        <!--<TextBox Grid.Row="1" Grid.Column="3" Style="{StaticResource tb}" x:Name="tbAcqTim2e"/>-->
        <!--<ComboBox Grid.Row="1" Grid.Column="3" IsReadOnly="True" DisplayMemberPath="Name" Style="{StaticResource ComboBoxStyle}" Width="320" Height="30" HorizontalAlignment="Left" x:Name="cbMetaType"></ComboBox>-->
@@ -187,7 +187,7 @@
        <Label Grid.Row="3" Grid.Column="0" Content="资源目录:" VerticalAlignment="Center" HorizontalAlignment="Right" />
        <TextBox Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="3" Style="{StaticResource tb}" x:Name="tbDir"/>
        <TextBox Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="3" Style="{StaticResource tb}" IsReadOnly="True" x:Name="tbDir"/>
        <Button Grid.Row="3" Grid.Column="4" Content="选 æ‹©" Style="{StaticResource btn}" Click="Dir_MouseLeftButtonDown" x:Name="btnDir"/>
        <Label Grid.Row="4" Grid.Column="0" Content="数据目录:" VerticalAlignment="Center" HorizontalAlignment="Right" />
DataLoader/MainWindow.xaml.cs
@@ -15,9 +15,11 @@
{
    public partial class MainWindow : Window
    {
        private ObservableCollection<ViewData> viewDatas = new ObservableCollection<ViewData>();
        public ResWin resWin;
        private LoginWin win;
        private LoginWin loginWin;
        private ObservableCollection<ViewData> viewDatas = new ObservableCollection<ViewData>();
        public MainWindow()
        {
@@ -60,24 +62,19 @@
        // è®¾ç½®
        private void Login_MouseLeftButtonDown(object sender, RoutedEventArgs e)
        {
            win = new LoginWin();
            loginWin = new LoginWin();
            this.Hide();
            win.Show();
            loginWin.Show();
        }
        public void SetLoginInfo()
        {
            if (win != null) win.Close();
            if (loginWin != null) loginWin.Close();
            this.Show();
            //this.tbUid.Text = Tool.UserId.ToString();
            //this.tbToken.Text = Tool.Token;
            //string uidStr = this.tbUid.Text.Trim();
            //string didStr = this.tbDir.Text.Trim();
            //int.TryParse(uidStr, out Common.UserId);
            //int.TryParse(didStr, out Common.DirId);
            this.tbUid.Text = CommonProp.UserId.ToString();
            this.tbUname.Text = CommonProp.Uname;
            this.tbToken.Text = CommonProp.Token;
            this.btnLoad.IsEnabled = true;
            this.btnImport.IsEnabled = true;
@@ -86,7 +83,21 @@
        // èµ„源目录
        private void Dir_MouseLeftButtonDown(object sender, RoutedEventArgs e)
        {
            resWin = new ResWin();
            this.Hide();
            resWin.Show();
        }
        public void SetRes(string dircode, string fullName)
        {
            if (resWin != null) resWin.Close();
            this.Show();
            if (!string.IsNullOrEmpty(dircode))
            {
                CommonProp.Dircode = dircode;
                this.tbDir.Text = fullName;
            }
        }
        // æ•°æ®ç›®å½•
DataLoader/Model/SysDir.cs
@@ -86,5 +86,10 @@
        /// ç¼–码
        /// </summary>
        public string code { set; get; }
        /// <summary>
        /// å®Œå…¨åç§°
        /// </summary>
        public string fullName { set; get; }
    }
}
DataLoader/Model/TreeItem.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,115 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataLoader.Model
{
    public class TreeItem : INotifyPropertyChanged
    {
        private int id;
        private string name;
        private bool isChecked;
        private bool isExpanded;
        private ObservableCollection<TreeItem> child;
        public event PropertyChangedEventHandler PropertyChanged;
        public TreeItem()
        {
        }
        public TreeItem(int id, string name, string fullName)
        {
            this.id = id;
            this.name = name;
            this.FullName = fullName;
        }
        public int ID
        {
            set
            {
                this.id = value;
                ChangProperty("ID");
            }
            get
            {
                return this.id;
            }
        }
        public string Name
        {
            set
            {
                this.name = value;
                ChangProperty("Name");
            }
            get
            {
                return this.name;
            }
        }
        public bool IsChecked
        {
            set
            {
                isChecked = value;
                ChangProperty("IsChecked");
            }
            get
            {
                return this.isChecked;
            }
        }
        public bool IsExpanded
        {
            set
            {
                isExpanded = value;
                ChangProperty("IsExpanded");
            }
            get
            {
                return isExpanded;
            }
        }
        public string FullName
        {
            set;
            get;
        }
        public ObservableCollection<TreeItem> Child
        {
            set
            {
                child = value;
                ChangProperty("Child");
            }
            get
            {
                return child;
            }
        }
        private void ChangProperty(string propName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
            }
        }
    }
}
DataLoader/ResWin.xaml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,67 @@
<Window x:Class="DataLoader.ResWin"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        ShowInTaskbar="False" Loaded="Window_Loaded" Closing="Window_Closing"
        xmlns:model="clr-namespace:DataLoader.Model" Background="Transparent"
        Title="请选择资源" Height="750" Width="600" WindowStartupLocation="CenterScreen">
    <Window.Resources>
        <Style x:Key="CheckBoxStyle" TargetType="{x:Type CheckBox}">
            <Setter Property="SnapsToDevicePixels" Value="true" />
            <Setter Property="OverridesDefaultStyle" Value="False" />
            <Setter Property="Height" Value="52"/>
            <Setter Property="IsChecked" Value="False"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="CheckBox">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Grid Height="{TemplateBinding Height}" Width="{TemplateBinding Height}">
                                <Rectangle x:Name="CheckBoxRectangle" Fill="#00446F" Opacity="1" RadiusY="0" RadiusX="0"/>
                                <Rectangle x:Name="CheckBoxRectangleOut" Stroke="#00A0E9" StrokeThickness="1" RadiusY="0" RadiusX="0"/>
                                <Grid x:Name="CheckedMark" Height="{TemplateBinding Height}" Width="{TemplateBinding Height}" Visibility="Collapsed" >
                                    <Viewbox>
                                        <Grid>
                                            <Path SnapsToDevicePixels="True" StrokeThickness="4" Data="M1,9 L10,17" Stroke="#F6A411"/>
                                            <Path SnapsToDevicePixels="True" StrokeThickness="4" Data="M8,17 L20,4" Stroke="#F6A411"/>
                                        </Grid>
                                    </Viewbox>
                                </Grid>
                            </Grid>
                            <ContentPresenter Grid.Column="1" VerticalAlignment="Center" Margin="8,0,0,0"/>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsChecked" Value="True">
                                <Setter TargetName="CheckedMark" Property="Visibility" Value="Visible"></Setter>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
    <Grid>
        <Grid.Background>
            <SolidColorBrush Color="#0B498F" Opacity="0.3"/>
        </Grid.Background>
        <ScrollViewer Grid.Row="0" Grid.Column="0" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Margin="5" Background="Transparent">
            <TreeView x:Name="tvResTree" FontSize="13" Background="Transparent" Foreground="White" BorderThickness="0">
                <TreeView.ItemTemplate>
                    <HierarchicalDataTemplate DataType="{x:Type model:TreeItem}" ItemsSource="{Binding Path=Child}">
                        <StackPanel Orientation="Horizontal" Margin="0 10" Background="Transparent">
                            <CheckBox IsChecked="{Binding IsChecked}" Tag="{Binding ID}" Style="{StaticResource CheckBoxStyle}" Click="CheckBox_Click" Cursor="Hand" Margin="0 0 10 0" VerticalAlignment="Center" BorderBrush="#00A0E9" BorderThickness="1" Background="#00446F" Width="20" Height="20" VerticalContentAlignment='Center'/>
                            <Border Tag="{Binding ID}" Height="32" VerticalAlignment="Center" BorderBrush="#1A63B5" BorderThickness="1" Padding="15 2 15 0" Cursor="Hand" MouseLeftButtonDown="Border_MouseLeftButtonDown">
                                <Border.Background>
                                    <SolidColorBrush Color="#0B498F" Opacity="0.3"/>
                                </Border.Background>
                                <TextBlock VerticalAlignment="Center" Text="{Binding Name}" FontSize="16" FontFamily="MicrosoftYaHei" Foreground="White" HorizontalAlignment="Center"/>
                            </Border>
                        </StackPanel>
                    </HierarchicalDataTemplate>
                </TreeView.ItemTemplate>
            </TreeView>
        </ScrollViewer>
    </Grid>
</Window>
DataLoader/ResWin.xaml.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,86 @@
using DataLoader.CS;
using DataLoader.Model;
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace DataLoader
{
    public partial class ResWin : Window
    {
        private TreeItem items = new TreeItem();
        private List<SysDir> dirs;
        private CheckBox cbLast;
        public ResWin()
        {
            InitializeComponent();
        }
        private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            //
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            dirs = DBHelper.GetDirList();
            if (null == dirs || 0 == dirs.Count) return;
            FindTreeItems(dirs, items, 0);
            this.tvResTree.ItemsSource = items.Child;
        }
        private void FindTreeItems(List<SysDir> list, TreeItem ti, int pid)
        {
            if (ti.Child == null) ti.Child = new ObservableCollection<TreeItem>();
            foreach (SysDir dir in list)
            {
                if (pid == dir.pid)
                {
                    TreeItem item = new TreeItem();
                    item.ID = dir.id;
                    item.Name = dir.name;
                    item.FullName = dir.fullName;
                    item.IsExpanded = true;
                    ti.Child.Add(item);
                    FindTreeItems(list, item, dir.id);
                }
            }
        }
        private void CheckBox_Click(object sender, RoutedEventArgs e)
        {
            CheckBox cb = sender as CheckBox;
            if (cb.IsChecked == true)
            {
                if (null != this.cbLast) this.cbLast.IsChecked = false;
                this.cbLast = cb;
            }
            else
            {
                this.cbLast = null;
            }
        }
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            SysDir dir = null;
            if (this.cbLast != null)
            {
                int id = int.Parse(this.cbLast.Tag.ToString());
                dir = (from d in dirs where d.id == id select d).First<SysDir>();
            }
            CommonProp.Owner.resWin = null;
            CommonProp.Owner.SetRes(null == dir ? null : dir.code, null == dir ? null : dir.fullName);
        }
    }
}