From 9f300514a23b1e008a3314c0b782ef67f190e7af Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期二, 22 八月 2023 18:08:52 +0800 Subject: [PATCH] 修改“加载”功能 --- DataLoader/App.config | 2 DataLoader/MainWindow.xaml.cs | 2 + DataLoader/CS/Importor.cs | 64 +++++++++++++++++++++++-------- DataLoader/CS/DBHelper.cs | 2 4 files changed, 51 insertions(+), 19 deletions(-) diff --git a/DataLoader/App.config b/DataLoader/App.config index 642558f..50a0c79 100644 --- a/DataLoader/App.config +++ b/DataLoader/App.config @@ -2,7 +2,7 @@ <configuration> <appSettings> <add key="StartPath" value="1"/> - <add key="SourcePath" value="D:\LF\import"/> + <add key="SourcePath" value="D:\Moon\data"/> <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;"/> diff --git a/DataLoader/CS/DBHelper.cs b/DataLoader/CS/DBHelper.cs index 6d4fcbd..a51056b 100644 --- a/DataLoader/CS/DBHelper.cs +++ b/DataLoader/CS/DBHelper.cs @@ -76,7 +76,7 @@ /// </summary> public static List<SysDir> GetDirList() { - string sql = "select a.*, fn_get_fullname(a.code, 2) fullName from lf.sys_dir a"; + string sql = "select a.*, fn_get_fullname(a.code, 2) fullName from lf.sys_dir a order by pid, order_num, id"; DataTable dt = Tools.DBHelper.GetDataTable(sql); if (null == dt || dt.Rows.Count == 0) return null; diff --git a/DataLoader/CS/Importor.cs b/DataLoader/CS/Importor.cs index 0b5fd01..217d165 100644 --- a/DataLoader/CS/Importor.cs +++ b/DataLoader/CS/Importor.cs @@ -15,18 +15,62 @@ /// </summary> public static void GetFiles(ObservableCollection<ViewData> viewDatas) { - string[] files = Directory.GetFiles(CommonProp.SourcePath); + string[] files = Directory.GetFiles(CommonProp.SourcePath, "*", SearchOption.AllDirectories); for (int i = 0, c = files.Length; i < c; i++) { + string file = files[i]; + string ext = Path.GetExtension(file).ToLower(); + if (!StaticData.ALL_EXTENSION.Contains(ext) || IsExcludFile(file)) + { + continue; + } + ViewData vd = new ViewData(); vd.ID = i + 1; - vd.FilePath = files[i]; - vd.Ext = System.IO.Path.GetExtension(files[i]); + vd.FilePath = file; + vd.Ext = ext; vd.Status = "鍑嗗"; viewDatas.Add(vd); SetSysMeta(vd); } + } + + /// <summary> + /// 璁剧疆鍏冩暟鎹� + /// </summary> + private static void SetSysMeta(ViewData vd) + { + FileInfo fi = new FileInfo(vd.FilePath); + + vd.Meta = new SysMeta(); + vd.Meta.name = fi.Name; + //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 = CommonProp.UserId; + } + + /// <summary> + /// 鏄�/鍚︿负鎺掗櫎鏂囦欢 + /// </summary> + private static bool IsExcludFile(string file) + { + bool isExclud = false; + + string name = Path.GetFileName(file).ToLower(); + foreach (string ss in StaticData.MAPPER_EXCLUDE_EXT) + { + if (name.EndsWith(ss)) + { + isExclud = true; + break; + } + } + + return isExclud; } /// <summary> @@ -79,20 +123,6 @@ SetSysMeta(vd); } - } - - private static void SetSysMeta(ViewData vd) - { - FileInfo fi = new FileInfo(vd.FilePath); - - vd.Meta = new SysMeta(); - vd.Meta.name = fi.Name; - //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 = CommonProp.UserId; } public static void ImportFiles(ObservableCollection<ViewData> viewDatas, string target, int start) diff --git a/DataLoader/MainWindow.xaml.cs b/DataLoader/MainWindow.xaml.cs index 1e1af95..1fdbeb3 100644 --- a/DataLoader/MainWindow.xaml.cs +++ b/DataLoader/MainWindow.xaml.cs @@ -134,11 +134,13 @@ MessageBox.Show("璇烽�夋嫨璧勬簮鐩綍锛�", "鎻愮ず"); return; } + CommonProp.SourcePath = this.tbSource.Text.Trim(); if (string.IsNullOrEmpty(CommonProp.SourcePath) || !Directory.Exists(CommonProp.SourcePath)) { MessageBox.Show("璇烽�夋嫨鏁版嵁鐩綍鎴栨暟鎹洰褰曚笉瀛樺湪锛�", "鎻愮ず"); return; } + CommonProp.TargetPath = this.tbTarget.Text.Trim(); if (string.IsNullOrEmpty(CommonProp.TargetPath) || !Directory.Exists(CommonProp.TargetPath)) { MessageBox.Show("璇烽�夋嫨鍏ュ簱鐩綍鎴栧叆搴撶洰褰曚笉瀛樺湪锛�", "鎻愮ず"); -- Gitblit v1.9.3