From 994d438b4b06011eb7656357a367392bb30467c5 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期二, 22 八月 2023 17:33:33 +0800
Subject: [PATCH] 处理数据导入流程-1

---
 DataLoader/MainWindow.xaml.cs |   73 ++++++++++++++++++++++--------------
 1 files changed, 44 insertions(+), 29 deletions(-)

diff --git a/DataLoader/MainWindow.xaml.cs b/DataLoader/MainWindow.xaml.cs
index 6610d73..1e1af95 100644
--- a/DataLoader/MainWindow.xaml.cs
+++ b/DataLoader/MainWindow.xaml.cs
@@ -15,6 +15,8 @@
 {
     public partial class MainWindow : Window
     {
+        private bool isBusy;
+
         public ResWin resWin;
 
         private LoginWin loginWin;
@@ -32,8 +34,6 @@
             CommonProp.Owner = this;
             CommonProp.Init();
 
-            //this.cbMetaType.ItemsSource= GetMetaTypes();
-            //this.cbMetaType.SelectedIndex= 0;
             this.btnLoad.IsEnabled = false;
             this.btnImport.IsEnabled = false;
 
@@ -59,7 +59,7 @@
             return list;
         }
 
-        // 璁剧疆
+        // 鐧诲綍
         private void Login_MouseLeftButtonDown(object sender, RoutedEventArgs e)
         {
             loginWin = new LoginWin();
@@ -67,6 +67,7 @@
             loginWin.Show();
         }
 
+        // 璁剧疆鐧诲綍淇℃伅
         public void SetLoginInfo()
         {
             if (loginWin != null) loginWin.Close();
@@ -88,6 +89,7 @@
             this.resWin.Show();
         }
 
+        // 璁剧疆璧勬簮淇℃伅
         public void SetRes(string dircode, string fullName)
         {
             this.Show();
@@ -126,40 +128,41 @@
         // 鍔犺浇
         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 (isBusy) return;
+            if (string.IsNullOrEmpty(CommonProp.Dircode))
+            {
+                MessageBox.Show("璇烽�夋嫨璧勬簮鐩綍锛�", "鎻愮ず");
+                return;
+            }
+            if (string.IsNullOrEmpty(CommonProp.SourcePath) || !Directory.Exists(CommonProp.SourcePath))
+            {
+                MessageBox.Show("璇烽�夋嫨鏁版嵁鐩綍鎴栨暟鎹洰褰曚笉瀛樺湪锛�", "鎻愮ず");
+                return;
+            }
+            if (string.IsNullOrEmpty(CommonProp.TargetPath) || !Directory.Exists(CommonProp.TargetPath))
+            {
+                MessageBox.Show("璇烽�夋嫨鍏ュ簱鐩綍鎴栧叆搴撶洰褰曚笉瀛樺湪锛�", "鎻愮ず");
+                return;
+            }
+            CommonProp.SensorType = this.tbSensorType.Text.Trim();
+            ContentControl cc = this.cbMetaType.SelectedItem as ContentControl;
+            CommonProp.MetaType = null == cc || "璇烽�夋嫨" == cc.Content.ToString() ? string.Empty : cc.Content.ToString();
+            CommonProp.AcqTime = this.dpAcqTime.SelectedDate;
 
-            //string[] files = Directory.GetFiles(SourcePath);
-            //if (null == files || files.Length == 0)
-            //{
-            //    MessageBox.Show("鏁版嵁鐩綍涓嬫病鏈夋枃浠讹紒", "鎻愮ず");
-            //    return;
-            //}
-
-            //this.viewDatas.Clear();
-            //Importor.GetFiles(viewDatas, SourcePath);
+            this.isBusy = true;
+            this.viewDatas.Clear();
+            Importor.GetFiles(viewDatas);
+            this.isBusy = false;
         }
-
         // 瀵煎叆
         private void Import_MouseLeftButtonDown(object sender, RoutedEventArgs e)
         {
-            if (viewDatas.Count == 0) return;
+            if (isBusy || viewDatas.Count == 0) return;
 
-            //string str = this.tbStart.Text.Trim();
-            //int start = 1;
-            //int.TryParse(str, out start);
-
+            this.isBusy = true;
             Thread thread = new Thread(new ThreadStart(() =>
             {
-                //Importor.ImportFiles(viewDatas, TargetPath, start);
+                Importor.ImportFiles(viewDatas);
 
                 lvView.Dispatcher.BeginInvoke((ThreadStart)delegate
                 {
@@ -167,9 +170,21 @@
                     view.Refresh();
                 });
 
+                isBusy = false;
                 MessageBox.Show("鏁版嵁瀵煎叆瀹屾垚锛�", "鎻愮ず");
             }));
             thread.Start();
         }
+
+        // 绐楀彛鍏抽棴涓簨浠�
+        private void Window_Closing(object sender, CancelEventArgs e)
+        {
+            if (isBusy)
+            {
+                MessageBox.Show("姝e湪瀵煎叆鏁版嵁锛岃绋嶅悗~", "鎻愮ず");
+                e.Cancel = true;
+                return;
+            }
+        }
     }
 }

--
Gitblit v1.9.3