管道基础大数据平台系统开发-【CS】-ExportMap
13693261870
2023-08-21 48c18a96f8c8022ec43691117f2472073895af71
修改入库工具的界面
已添加1个文件
已修改6个文件
已删除1个文件
384 ■■■■■ 文件已修改
DataLoader/App.config 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/CS/Importor.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/CS/NtstWeb.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/DataLoader.csproj 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/MainWindow.xaml 46 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/MainWindow.xaml.cs 133 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/Model/Common.cs 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/Model/CommonProp.cs 142 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/App.config
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="StartPath" value="1"/>
    <add key="SourcePath" value="D:\LF\import"/>
    <add key="TargetPath" value="D:\LF\upload"/>
    <!--<add key="pgConn" value="Server=127.0.0.1;Port=5433;Database=langfang;User Id=postgres;Password=postgres;"/>-->
    <add key="pgConn" value="Server=192.168.20.83;Port=5433;Database=moon;User Id=postgres;Password=Postgres!_14_moon;"/>
  </appSettings>
DataLoader/CS/Importor.cs
@@ -87,12 +87,12 @@
            vd.Meta = new SysMeta();
            vd.Meta.name = fi.Name;
            vd.Meta.dirid = Common.DirId;
            //vd.Meta.dirid = Common.DirId;
            vd.Meta.depid = 1;
            vd.Meta.verid = 0;
            vd.Meta.type = fi.Extension.ToLower().Replace(".", "");
            vd.Meta.sizes = Tools.SizeToMb(fi.Length);
            vd.Meta.create_user = Common.UserId;
            vd.Meta.create_user = CommonProp.UserId;
        }
        public static void ImportFiles(ObservableCollection<ViewData> viewDatas, string target, int start)
DataLoader/CS/NtstWeb.cs
@@ -21,13 +21,13 @@
        {
            if (uid > 0 && !string.IsNullOrEmpty(token))
            {
                Common.UserId = uid;
                Common.Uname = uname;
                Common.Token = token;
                CommonProp.UserId = uid;
                CommonProp.Uname = uname;
                CommonProp.Token = token;
                owner.Dispatcher.Invoke(new Action(delegate
                {
                    Common.Owner.SetLoginInfo();
                    CommonProp.Owner.SetLoginInfo();
                }));
            }
        }
DataLoader/DataLoader.csproj
@@ -138,7 +138,7 @@
    <Compile Include="CS\MetaHelper.cs" />
    <Compile Include="CS\StaticData.cs" />
    <Compile Include="CS\Tools.cs" />
    <Compile Include="Model\Common.cs" />
    <Compile Include="Model\CommonProp.cs" />
    <Compile Include="CS\ModelHandler.cs" />
    <Compile Include="CS\NtstWeb.cs" />
    <Compile Include="CS\PostgreHelper.cs" />
DataLoader/MainWindow.xaml
@@ -1,9 +1,9 @@
<Window x:Class="DataLoader.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Height="500" Width="750"
        Height="700" Width="900"
        Loaded="Window_Loaded"
        Title="数据入库 v1.4" WindowStartupLocation="CenterScreen">
        Title="影像数据入库 v1.5" WindowStartupLocation="CenterScreen">
    <Window.Resources>
        <Style x:Key="btn" TargetType="Button">
            <Setter Property="Background" Value="#005699"/>
@@ -38,31 +38,30 @@
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="5*" />
            <ColumnDefinition Width="18*" />
            <ColumnDefinition Width="4*" />
            <ColumnDefinition Width="18*" />
            <ColumnDefinition Width="7*" />
            <ColumnDefinition Width="20*" />
            <ColumnDefinition Width="4*" />
            <ColumnDefinition Width="20*" />
            <ColumnDefinition Width="5*" />
        </Grid.ColumnDefinitions>
        <Label Grid.Row="0" Grid.Column="0" Content="用户ID:" VerticalAlignment="Center" HorizontalAlignment="Right" />
        <TextBox x:Name="tbUid" Grid.Row="0" Grid.Column="1" Style="{StaticResource tb}" Text="1"/>
        <Label Grid.Row="0" Grid.Column="2" Content="目录ID:" VerticalAlignment="Center" HorizontalAlignment="Right" />
        <TextBox x:Name="tbDir" Grid.Row="0" Grid.Column="3"  Style="{StaticResource tb}" Text="1"/>
        <!--<Label Grid.Row="0" Grid.Column="2" Content="令牌:" VerticalAlignment="Center" HorizontalAlignment="Right" />
        <TextBox x:Name="tbToken" Grid.Row="0" Grid.Column="3"  Style="{StaticResource tb}"/>
        <Button Grid.Row="0" Grid.Column="4" Content="登 å½•" Style="{StaticResource btn}" Click="Login_MouseLeftButtonDown"/>-->
        <Button Grid.Row="0" Grid.Column="4" Content="设 ç½®" Style="{StaticResource btn}" Click="Login_MouseLeftButtonDown"/>
        <Label Grid.Row="0" Grid.Column="0" Content="用户名:" VerticalAlignment="Center" HorizontalAlignment="Right" />
        <TextBox Grid.Row="0" Grid.Column="1" Style="{StaticResource tb}" IsReadOnly="True" x:Name="tbUname"/>
        <Label Grid.Row="0" Grid.Column="2" Content="令牌:" VerticalAlignment="Center" HorizontalAlignment="Right" />
        <TextBox Grid.Row="0" Grid.Column="3"  Style="{StaticResource tb}" IsReadOnly="True" x:Name="tbToken"/>
        <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 x:Name="tbSource" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" Style="{StaticResource tb}" Text="{Binding Path=SourcePath, Mode=TwoWay}"/>
        <Button x:Name="btnSource" Grid.Row="1" Grid.Column="4" Content="选 æ‹©" Style="{StaticResource btn}" Click="Source_MouseLeftButtonDown"/>
        <Label Grid.Row="1" Grid.Column="0" Content="资源目录:" VerticalAlignment="Center" HorizontalAlignment="Right" />
        <TextBox Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" Style="{StaticResource tb}" x:Name="tbDir"/>
        <Button Grid.Row="1" Grid.Column="4" Content="选 æ‹©" Style="{StaticResource btn}" Click="Dir_MouseLeftButtonDown" x:Name="btnDir"/>
        <Label Grid.Row="2" Grid.Column="0" Content="入库目录:" VerticalAlignment="Center" HorizontalAlignment="Right" />
        <TextBox x:Name="tbTarget" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" Style="{StaticResource tb}" Text="{Binding Path=TargetPath, Mode=TwoWay}"/>
        <Label Grid.Row="2" Grid.Column="0" Content="数据目录:" VerticalAlignment="Center" HorizontalAlignment="Right" />
        <TextBox Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" Style="{StaticResource tb}" x:Name="tbSource"/>
        <Button Grid.Row="2" Grid.Column="4" Content="选 æ‹©" Style="{StaticResource btn}" Click="Source_MouseLeftButtonDown" x:Name="btnSource"/>
        <Label Grid.Row="3" Grid.Column="0" Content="起始编号:" VerticalAlignment="Center" HorizontalAlignment="Right" />
        <TextBox x:Name="tbStart" Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="3" Style="{StaticResource tb}" Text="1"/>
        <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="tbTarget"/>
        <Button Grid.Row="3" Grid.Column="4" Content="选 æ‹©" Style="{StaticResource btn}" Click="Target_MouseLeftButtonDown" x:Name="btnTarget"/>
        <ScrollViewer Grid.Row="4" Grid.RowSpan="3" Grid.Column="0" Grid.ColumnSpan="4" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Margin="2">
            <ListView x:Name="lvView">
@@ -85,8 +84,7 @@
            </ListView>
        </ScrollViewer>
        <Button x:Name="btnTarget" Grid.Row="2" Grid.Column="4" Content="选 æ‹©" Style="{StaticResource btn}" Click="Target_MouseLeftButtonDown"/>
        <Button x:Name="btnLoad" Grid.Row="3" Grid.Column="4" Content="加 è½½" Style="{StaticResource btn}" Click="Load_MouseLeftButtonDown"/>
        <Button x:Name="btnImport" Grid.Row="4" Grid.Column="4" Content="导 å…¥" Style="{StaticResource btn}" Click="Import_MouseLeftButtonDown"/>
        <Button x:Name="btnLoad" Grid.Row="4" Grid.Column="4" Content="加 è½½" Style="{StaticResource btn}" Click="Load_MouseLeftButtonDown"/>
        <Button x:Name="btnImport" Grid.Row="5" Grid.Column="4" Content="导 å…¥" Style="{StaticResource btn}" VerticalAlignment="Top" Click="Import_MouseLeftButtonDown"/>
    </Grid>
</Window>
DataLoader/MainWindow.xaml.cs
@@ -7,52 +7,17 @@
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Forms.VisualStyles;
using System.Windows.Threading;
namespace DataLoader
{
    public partial class MainWindow : Window, INotifyPropertyChanged
    public partial class MainWindow : Window
    {
        private ObservableCollection<ViewData> viewDatas = new ObservableCollection<ViewData>();
        public event PropertyChangedEventHandler PropertyChanged;
        private string _sourcePath = @"D:\LF\data\mdb";
        private string _targetPath = @"\\LAPTOP-DRTGLTU2\share";
        private LoginWin win;
        public string SourcePath
        {
            get { return _sourcePath; }
            set
            {
                if (!String.IsNullOrEmpty(value) && Directory.Exists(value))
                {
                    _sourcePath = value;
                    PropertyChanged(this, new PropertyChangedEventArgs("SourcePath"));
                }
            }
        }
        public string TargetPath
        {
            get { return _targetPath; }
            set
            {
                if (!String.IsNullOrEmpty(value) && Directory.Exists(value))
                {
                    _targetPath = value;
                    PropertyChanged(this, new PropertyChangedEventArgs("TargetPath"));
                }
            }
        }
        public MainWindow()
        {
@@ -60,15 +25,10 @@
            this.DataContext = this;
        }
        protected virtual void OnPropertyChanged(string propertyName = null)
        {
            //PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
            if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Common.Owner = this;
            CommonProp.Owner = this;
            CommonProp.Init();
            this.btnLoad.IsEnabled = false;
            this.btnImport.IsEnabled = false;
@@ -76,8 +36,7 @@
            lvView.DataContext = viewDatas;
            lvView.SetBinding(ListView.ItemsSourceProperty, new Binding());
            //String file = "E:\\data\\mpt\\A4mpt20131125.mpt";
            //string md5 = MD5Helper.GetMD5Hash(file);
            // string md5 = MD5Helper.GetMD5Hash("E:\\data\\mpt\\A4mpt20131125.mpt");
            LogOut.Info("************  åº”用程序启动成功! ************");
        }
@@ -87,9 +46,6 @@
            win = new LoginWin();
            this.Hide();
            win.Show();
            //SetLoginInfo();
            //GdalHelper.Instance.ReadTiff();
        }
        public void SetLoginInfo()
@@ -100,69 +56,69 @@
            //this.tbUid.Text = Tool.UserId.ToString();
            //this.tbToken.Text = Tool.Token;
            string uidStr = this.tbUid.Text.Trim();
            string didStr = this.tbDir.Text.Trim();
            //string uidStr = this.tbUid.Text.Trim();
            //string didStr = this.tbDir.Text.Trim();
            int.TryParse(uidStr, out Common.UserId);
            int.TryParse(didStr, out Common.DirId);
            //int.TryParse(uidStr, out Common.UserId);
            //int.TryParse(didStr, out Common.DirId);
            this.btnLoad.IsEnabled = true;
            this.btnImport.IsEnabled = true;
        }
        // æºç›®å½•
        // èµ„源目录
        private void Dir_MouseLeftButtonDown(object sender, RoutedEventArgs e)
        {
        }
        // æ•°æ®ç›®å½•
        private void Source_MouseLeftButtonDown(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog();
            if (!String.IsNullOrEmpty(SourcePath) && Directory.Exists(SourcePath)) dialog.SelectedPath = SourcePath;
            if (!String.IsNullOrEmpty(CommonProp.SourcePath) && Directory.Exists(CommonProp.SourcePath)) dialog.SelectedPath = CommonProp.SourcePath;
            System.Windows.Forms.DialogResult result = dialog.ShowDialog();
            if (result == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }
            if (result == System.Windows.Forms.DialogResult.Cancel) return;
            this.SourcePath = dialog.SelectedPath.Trim();
            this.tbSource.Text = CommonProp.SourcePath = dialog.SelectedPath.Trim();
        }
        // ç›®æ ‡ç›®å½•
        private void Target_MouseLeftButtonDown(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog();
            if (!String.IsNullOrEmpty(TargetPath) && Directory.Exists(TargetPath)) dialog.SelectedPath = TargetPath;
            if (!String.IsNullOrEmpty(CommonProp.TargetPath) && Directory.Exists(CommonProp.TargetPath)) dialog.SelectedPath = CommonProp.TargetPath;
            System.Windows.Forms.DialogResult result = dialog.ShowDialog();
            if (result == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }
            if (result == System.Windows.Forms.DialogResult.Cancel) return;
            this.TargetPath = dialog.SelectedPath.Trim();
            this.tbTarget.Text = CommonProp.TargetPath = dialog.SelectedPath.Trim();
        }
        // åŠ è½½
        private void Load_MouseLeftButtonDown(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(SourcePath) || !Directory.Exists(SourcePath))
            {
                MessageBox.Show("请选择数据目录!", "提示");
                return;
            }
            if (string.IsNullOrEmpty(TargetPath) || !Directory.Exists(TargetPath))
            {
                MessageBox.Show("请选择入库目录!", "提示");
                return;
            }
            //if (string.IsNullOrEmpty(SourcePath) || !Directory.Exists(SourcePath))
            //{
            //    MessageBox.Show("请选择数据目录!", "提示");
            //    return;
            //}
            //if (string.IsNullOrEmpty(TargetPath) || !Directory.Exists(TargetPath))
            //{
            //    MessageBox.Show("请选择入库目录!", "提示");
            //    return;
            //}
            string[] files = Directory.GetFiles(SourcePath);
            if (null == files || files.Length == 0)
            {
                MessageBox.Show("数据目录下没有文件!", "提示");
                return;
            }
            //string[] files = Directory.GetFiles(SourcePath);
            //if (null == files || files.Length == 0)
            //{
            //    MessageBox.Show("数据目录下没有文件!", "提示");
            //    return;
            //}
            this.viewDatas.Clear();
            Importor.GetFiles(viewDatas, SourcePath);
            //this.viewDatas.Clear();
            //Importor.GetFiles(viewDatas, SourcePath);
        }
        // å¯¼å…¥
@@ -170,15 +126,16 @@
        {
            if (viewDatas.Count == 0) return;
            string str = this.tbStart.Text.Trim();
            int start = 1;
            int.TryParse(str, out start);
            //string str = this.tbStart.Text.Trim();
            //int start = 1;
            //int.TryParse(str, out start);
            Thread thread = new Thread(new ThreadStart(() =>
            {
                Importor.ImportFiles(viewDatas, TargetPath, start);
                //Importor.ImportFiles(viewDatas, TargetPath, start);
                lvView.Dispatcher.BeginInvoke((ThreadStart)delegate {
                lvView.Dispatcher.BeginInvoke((ThreadStart)delegate
                {
                    ICollectionView view = CollectionViewSource.GetDefaultView(viewDatas);
                    view.Refresh();
                });
DataLoader/Model/Common.cs
ÎļþÒÑɾ³ý
DataLoader/Model/CommonProp.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,142 @@
using DataLoader.CS;
using System;
using System.ComponentModel;
using System.IO;
namespace DataLoader.Model
{
    /// <summary>
    /// é€šç”¨å±žæ€§ç±»
    /// </summary>
    public class CommonProp // : INotifyPropertyChanged
    {
        /// <summary>
        /// åˆå§‹åŒ–
        /// </summary>
        public static void Init()
        {
            string startPath = Tools.GetSetting("StartPath");
            int.TryParse(startPath, out StartPath);
            SourcePath = Tools.GetSetting("SourcePath");
            TargetPath = Tools.GetSetting("TargetPath");
            Owner.tbSource.Text = SourcePath;
            Owner.tbTarget.Text = TargetPath;
        }
        /// <summary>
        /// æ‰€æœ‰è€…
        /// </summary>
        public static MainWindow Owner;
        /// <summary>
        /// å¼€å§‹ç›®å½•
        /// </summary>
        public static int StartPath;
        /// <summary>
        /// ç”¨æˆ·ID
        /// </summary>
        public static int UserId = 1;
        /// <summary>
        /// ç”¨æˆ·å
        /// </summary>
        public static string Uname = "admin";
        /// <summary>
        /// ä»¤ç‰Œ
        /// </summary>
        public static string Token;
        /// <summary>
        /// å•位编码
        /// </summary>
        public static string Depcode;
        /// <summary>
        /// å•位名称
        /// </summary>
        public static string Depname;
        /// <summary>
        /// ç›®å½•编码
        /// </summary>
        public static string Dircode;
        /// <summary>
        /// ç›®å½•名称
        /// </summary>
        public static string Dirname;
        /// <summary>
        /// ä¼ æ„Ÿå™¨ç±»åž‹
        /// </summary>
        public static string sensortype;
        /// <summary>
        /// é‡‡é›†æ—¶é—´
        /// </summary>
        public static DateTime acq_time = DateTime.Now;
        /// <summary>
        /// å…ƒæ•°æ®ç±»åž‹
        /// </summary>
        public static string MetaType;
        /// <summary>
        /// æ•°æ®ç›®å½•
        /// </summary>
        public static string SourcePath;
        /// <summary>
        /// å…¥åº“目录
        /// </summary>
        public static string TargetPath;
        /*private string _sourcePath;
        /// <summary>
        /// æ•°æ®æºç›®å½•
        /// </summary>
        public string SourcePath
        {
            get { return _sourcePath; }
            set
            {
                if (!String.IsNullOrEmpty(value) && Directory.Exists(value))
                {
                    _sourcePath = value;
                    PropertyChanged(this, new PropertyChangedEventArgs("SourcePath"));
                }
            }
        }
        private string _targetPath;
        /// <summary>
        /// ç›®æ ‡ç›®å½•
        /// </summary>
        public string TargetPath
        {
            get { return _targetPath; }
            set
            {
                if (!String.IsNullOrEmpty(value) && Directory.Exists(value))
                {
                    _targetPath = value;
                    PropertyChanged(this, new PropertyChangedEventArgs("TargetPath"));
                }
            }
        }
        public event PropertyChangedEventHandler PropertyChanged;
        protected virtual void OnPropertyChanged(string propertyName)
        {
            //PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
            if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }*/
    }
}