From e1b6f5052ae50ac9507f6f3f6a06e2c2f574d0cd Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期日, 01 一月 2023 21:13:29 +0800 Subject: [PATCH] 1 --- DataLoader/MainWindow.xaml.cs | 46 +++++++++++++++++++++++++++++++++------------- 1 files changed, 33 insertions(+), 13 deletions(-) diff --git a/DataLoader/MainWindow.xaml.cs b/DataLoader/MainWindow.xaml.cs index 8fb9b4a..20a6f18 100644 --- a/DataLoader/MainWindow.xaml.cs +++ b/DataLoader/MainWindow.xaml.cs @@ -6,10 +6,13 @@ using System.ComponentModel; 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 { @@ -19,9 +22,9 @@ public event PropertyChangedEventHandler PropertyChanged; - private string _sourcePath= "D:\\LF\\data\\mdb"; + private string _sourcePath = "D:\\opting\\寰楁枃鏁版嵁"; // "D:\\LF\\data\\mdb"; - private string _targetPath= "D:\\LF\\upload"; + private string _targetPath = "D:\\LF\\upload"; private LoginWin win; @@ -66,7 +69,9 @@ { Tool.Owner = this; + this.btnLoad.IsEnabled = false; this.btnImport.IsEnabled = false; + lvView.DataContext = viewDatas; lvView.SetBinding(ListView.ItemsSourceProperty, new Binding()); @@ -87,8 +92,10 @@ if (win != null) win.Close(); this.Show(); - this.tbUid.Text = Tool.UserId.ToString() + "锛�" + Tool.Uname; + this.tbUid.Text = Tool.UserId.ToString() + "-" + Tool.Uname; this.tbToken.Text = Tool.Token; + + this.btnLoad.IsEnabled = true; this.btnImport.IsEnabled = true; } @@ -122,34 +129,47 @@ this.TargetPath = dialog.SelectedPath.Trim(); } - // 瀵煎叆 - private void Import_MouseLeftButtonDown(object sender, RoutedEventArgs e) + // 鍔犺浇 + private void Load_MouseLeftButtonDown(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(SourcePath) || !Directory.Exists(SourcePath)) { - MessageBox.Show("璇烽�夋嫨鏁版嵁鐩綍锛�"); + MessageBox.Show("璇烽�夋嫨鏁版嵁鐩綍锛�", "鎻愮ず"); return; } if (string.IsNullOrEmpty(TargetPath) || !Directory.Exists(TargetPath)) { - MessageBox.Show("璇烽�夋嫨鍏ュ簱鐩綍锛�"); + MessageBox.Show("璇烽�夋嫨鍏ュ簱鐩綍锛�", "鎻愮ず"); return; } string[] files = Directory.GetFiles(SourcePath); if (null == files || files.Length == 0) { - MessageBox.Show("鏁版嵁鐩綍涓嬫病鏈夋枃浠讹紒"); + MessageBox.Show("鏁版嵁鐩綍涓嬫病鏈夋枃浠讹紒", "鎻愮ず"); return; } - viewDatas.Clear(); + this.viewDatas.Clear(); + Importor.GetFiles(viewDatas, SourcePath); + } - Dispatcher.Invoke(new Action(delegate + // 瀵煎叆 + private void Import_MouseLeftButtonDown(object sender, RoutedEventArgs e) + { + if (viewDatas.Count == 0) return; + + Thread thread = new Thread(new ThreadStart(() => { - this.btnImport.IsEnabled = false; - Importor.Import(viewDatas, SourcePath, TargetPath); - this.btnImport.IsEnabled = true; + Importor.ImportFiles(viewDatas, TargetPath); + + lvView.Dispatcher.BeginInvoke((ThreadStart)delegate { + ICollectionView view = CollectionViewSource.GetDefaultView(viewDatas); + view.Refresh(); + }); + + MessageBox.Show("鏁版嵁瀵煎叆瀹屾垚锛�", "鎻愮ず"); })); + thread.Start(); } } } -- Gitblit v1.9.3