From 48c18a96f8c8022ec43691117f2472073895af71 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期一, 21 八月 2023 16:16:02 +0800 Subject: [PATCH] 修改入库工具的界面 --- /dev/null | 46 ------ DataLoader/App.config | 3 DataLoader/MainWindow.xaml.cs | 133 ++++++------------ DataLoader/CS/Importor.cs | 4 DataLoader/CS/NtstWeb.cs | 8 DataLoader/MainWindow.xaml | 46 +++--- DataLoader/DataLoader.csproj | 2 DataLoader/Model/CommonProp.cs | 142 ++++++++++++++++++++ 8 files changed, 219 insertions(+), 165 deletions(-) diff --git a/DataLoader/App.config b/DataLoader/App.config index 91e34a9..642558f 100644 --- a/DataLoader/App.config +++ b/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> diff --git a/DataLoader/CS/Importor.cs b/DataLoader/CS/Importor.cs index 0a2b319..eaec35c 100644 --- a/DataLoader/CS/Importor.cs +++ b/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) diff --git a/DataLoader/CS/NtstWeb.cs b/DataLoader/CS/NtstWeb.cs index 8affa3c..4bc8e13 100644 --- a/DataLoader/CS/NtstWeb.cs +++ b/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(); })); } } diff --git a/DataLoader/DataLoader.csproj b/DataLoader/DataLoader.csproj index 12b9fa7..0114832 100644 --- a/DataLoader/DataLoader.csproj +++ b/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" /> diff --git a/DataLoader/MainWindow.xaml b/DataLoader/MainWindow.xaml index 8c06ecc..3db6420 100644 --- a/DataLoader/MainWindow.xaml +++ b/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> diff --git a/DataLoader/MainWindow.xaml.cs b/DataLoader/MainWindow.xaml.cs index b061622..e5dd13f 100644 --- a/DataLoader/MainWindow.xaml.cs +++ b/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(); }); diff --git a/DataLoader/Model/Common.cs b/DataLoader/Model/Common.cs deleted file mode 100644 index 846a624..0000000 --- a/DataLoader/Model/Common.cs +++ /dev/null @@ -1,46 +0,0 @@ -锘縰sing Npgsql; -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Data.Common; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Runtime.InteropServices.ComTypes; -using System.Text; -using System.Threading.Tasks; -using System.Windows; - -namespace DataLoader.Model -{ - /// <summary> - /// 閫氱敤绫� - /// </summary> - public class Common - { - /// <summary> - /// 鎵�鏈夎�� - /// </summary> - public static MainWindow Owner = null; - - /// <summary> - /// 鐢ㄦ埛ID - /// </summary> - public static int UserId = 1; - - /// <summary> - /// 鐢ㄦ埛鍚� - /// </summary> - public static string Uname = "admin"; - - /// <summary> - /// - /// </summary> - public static int DirId = 1; - - /// <summary> - /// 浠ょ墝 - /// </summary> - public static string Token = null; - } -} diff --git a/DataLoader/Model/CommonProp.cs b/DataLoader/Model/CommonProp.cs new file mode 100644 index 0000000..cd55397 --- /dev/null +++ b/DataLoader/Model/CommonProp.cs @@ -0,0 +1,142 @@ +锘縰sing 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)); + }*/ + } +} -- Gitblit v1.9.3