From a3c6000b9c452915e98abc069c4a06c34b2740e1 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期二, 07 二月 2023 09:24:26 +0800
Subject: [PATCH] 1

---
 DataLoader/MainWindow.xaml.cs |   22 +++++++---
 DataLoader/CS/Importor.cs     |   41 ++++++++++++++++++++
 DataLoader/MainWindow.xaml    |    9 +++-
 DataLoader/Model/Tool.cs      |    6 ++-
 4 files changed, 65 insertions(+), 13 deletions(-)

diff --git a/DataLoader/CS/Importor.cs b/DataLoader/CS/Importor.cs
index 464bbc6..55c839e 100644
--- a/DataLoader/CS/Importor.cs
+++ b/DataLoader/CS/Importor.cs
@@ -7,6 +7,7 @@
 using System.IO;
 using System.Linq;
 using System.Reflection;
+using System.Threading.Tasks;
 using System.Windows.Forms;
 
 namespace DataLoader.CS
@@ -77,7 +78,7 @@
 
             vd.Meta = new SysMeta();
             vd.Meta.name = fi.Name;
-            vd.Meta.dirid = 1;
+            vd.Meta.dirid = Tool.DirId;
             vd.Meta.depid = 1;
             vd.Meta.verid = 0;
             vd.Meta.type = fi.Extension.ToLower().Replace(".", "");
@@ -87,6 +88,44 @@
 
         public static void ImportFiles(ObservableCollection<ViewData> viewDatas, string target)
         {
+            Parallel.ForEach(viewDatas, (vd, ParallelLoopState) =>
+            {
+                try
+                {
+                    vd.Status = "鐢熸垚MD5鐮�...";
+                    string guid = MD5Helper.GetMD5Hash(vd.FilePath);
+                    if (IsFileExists(guid))
+                    {
+                        vd.Status = "宸插瓨鍦紒";
+                        return;
+                    }
+
+                    vd.Status = "鎻掑叆鏁版嵁搴�...";
+                    int start = GetSubPath(target, 1);
+                    SysMeta mf = GetMetaFile(vd, start, guid);
+
+                    int metaId = InsertMeta(mf);
+                    if (metaId == 0)
+                    {
+                        vd.Status = "鍏冩暟鎹嚭閿欙紒";
+                        return;
+                    }
+
+                    vd.Status = "澶嶅埗鏂囦欢...";
+                    CopyFile(vd.FilePath, Path.Combine(target, mf.path));
+
+                    vd.Status = "瀹屾垚銆�";
+                }
+                catch (Exception ex)
+                {
+                    LogOut.Error(ex.Message + "\r\n" + ex.StackTrace);
+                    vd.Status = "澶辫触锛�";
+                }
+            });
+        }
+
+        public static void ImportFiles2(ObservableCollection<ViewData> viewDatas, string target)
+        {
             int start = 1;
             foreach (ViewData vd in viewDatas)
             {
diff --git a/DataLoader/MainWindow.xaml b/DataLoader/MainWindow.xaml
index 9b73d3d..1ce46c9 100644
--- a/DataLoader/MainWindow.xaml
+++ b/DataLoader/MainWindow.xaml
@@ -46,10 +46,13 @@
         </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}"/>
-        <Label Grid.Row="0" Grid.Column="2" Content="浠ょ墝锛�" 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"/>-->
+        <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}"/>
diff --git a/DataLoader/MainWindow.xaml.cs b/DataLoader/MainWindow.xaml.cs
index dbda5b5..d2265d2 100644
--- a/DataLoader/MainWindow.xaml.cs
+++ b/DataLoader/MainWindow.xaml.cs
@@ -84,18 +84,26 @@
         // 鐧诲綍
         private void Login_MouseLeftButtonDown(object sender, RoutedEventArgs e)
         {
-            win = new LoginWin();
-            this.Hide();
-            win.Show();
+            //win = new LoginWin();
+            //this.Hide();
+            //win.Show();
+
+            SetLoginInfo();
         }
 
         public void SetLoginInfo()
         {
-            if (win != null) win.Close();
-            this.Show();
+            //if (win != null) win.Close();
+            //this.Show();
 
-            this.tbUid.Text = Tool.UserId.ToString();
-            this.tbToken.Text = Tool.Token;
+            //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 Tool.UserId);
+            int.TryParse(didStr, out Tool.DirId);
 
             this.btnLoad.IsEnabled = true;
             this.btnImport.IsEnabled = true;
diff --git a/DataLoader/Model/Tool.cs b/DataLoader/Model/Tool.cs
index 631f0ed..48cf7f7 100644
--- a/DataLoader/Model/Tool.cs
+++ b/DataLoader/Model/Tool.cs
@@ -19,9 +19,11 @@
 
         public static readonly string BaseDir = AppDomain.CurrentDomain.BaseDirectory;
 
-        public static int UserId = 0;
+        public static int UserId = 1;
 
-        public static string Uname = "";
+        public static string Uname = "admin";
+
+        public static int DirId = 1;
 
         public static string Token = "";
 

--
Gitblit v1.9.3