From d633d8200bacc4a05996ba367d81e1dc6e60d572 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期二, 17 一月 2023 10:45:59 +0800
Subject: [PATCH] 1

---
 DataLoader/CS/Importor.cs |   49 ++++++++++++++++++-------------------------------
 1 files changed, 18 insertions(+), 31 deletions(-)

diff --git a/DataLoader/CS/Importor.cs b/DataLoader/CS/Importor.cs
index b860aba..0520b40 100644
--- a/DataLoader/CS/Importor.cs
+++ b/DataLoader/CS/Importor.cs
@@ -25,9 +25,7 @@
             }
         }
 
-        private static readonly string insertMeta = "insert into lf.sys_meta (name, dirid, depid, verid, type, sizes, cs, scale, resolution, gather, batch, descr, create_user) values (@name, @dirid, @depid, @verid, @type, @sizes, @cs, @scale, @resolution, @gather, @batch, @descr, @create_user) returning id";
-
-        private static readonly string insertMetaFile = "insert into lf.sys_meta_file (name, metaid, fileid, guid, path, sizes, create_user) values (@name, @metaid, @fileid, @guid, @path, @sizes, @create_user)";
+        private static readonly string insertMeta = "insert into lf.sys_meta (eventid, metaid, dirid, depid, verid, name, type, guid, path, sizes, tab, rows, create_user, create_time) values (@eventid, @metaid, @dirid, @depid, @verid, @name, @type, @guid, @path, @sizes, @tab, @rows, @create_user, now()) returning id";
 
         public static string GetFilePathByGuid(string guid)
         {
@@ -51,19 +49,9 @@
 
         public static int InsertMeta(SysMeta meta)
         {
-            // string sql = "INSERT INTO public.data_files(mid, guid, name, ext, path, subs, remark) VALUES (@mid, @guid, @name, @ext, @path, @subs, @remark) returning id";
             List<DbParameter> list = Tool.GetParams<SysMeta>(insertMeta, meta);
 
             object obj = Helper.GetScalar(insertMeta, list.ToArray());
-
-            return obj == null ? 0 : Convert.ToInt32(obj);
-        }
-
-        public static int InsertMetaFile(SysMetaFile metaFile)
-        {
-            List<DbParameter> list = Tool.GetParams<SysMetaFile>(insertMetaFile, metaFile);
-
-            object obj = Helper.ExecuteNonQuery(insertMetaFile, list.ToArray());
 
             return obj == null ? 0 : Convert.ToInt32(obj);
         }
@@ -89,17 +77,11 @@
 
             vd.Meta = new SysMeta();
             vd.Meta.name = fi.Name;
-            vd.Meta.dirid = 0;
-            vd.Meta.depid = 0;
+            vd.Meta.dirid = 1;
+            vd.Meta.depid = 1;
             vd.Meta.verid = 0;
-            vd.Meta.type = "file";
+            vd.Meta.type = fi.Extension.ToLower().Replace(".", "");
             vd.Meta.sizes = Tool.SizeToMb(fi.Length);
-            vd.Meta.cs = null;
-            vd.Meta.scale = null;
-            vd.Meta.resolution = null;
-            vd.Meta.gather = DateTime.Now;
-            vd.Meta.batch = null;
-            vd.Meta.descr = null;
             vd.Meta.create_user = Tool.UserId;
         }
 
@@ -119,16 +101,15 @@
                     }
 
                     vd.Status = "鎻掑叆鏁版嵁搴�...";
-                    int metaId = InsertMeta(vd.Meta);
+                    start = GetSubPath(target, start);
+                    SysMeta mf = GetMetaFile(vd, start, guid);
+
+                    int metaId = InsertMeta(mf);
                     if (metaId == 0)
                     {
                         vd.Status = "鍏冩暟鎹嚭閿欙紒";
                         continue;
                     }
-
-                    start = GetSubPath(target, start);
-                    SysMetaFile mf = GetMetaFile(vd, metaId, start, guid);
-                    InsertMetaFile(mf);
 
                     vd.Status = "澶嶅埗鏂囦欢...";
                     CopyFile(vd.FilePath, Path.Combine(target, mf.path));
@@ -163,15 +144,21 @@
             }
         }
 
-        private static SysMetaFile GetMetaFile(ViewData vd, int metaId, int subPath, string guid)
+        private static SysMeta GetMetaFile(ViewData vd, int subPath, string guid)
         {
-            SysMetaFile mf = new SysMetaFile();
+            SysMeta mf = new SysMeta();
+            mf.eventid = Guid.NewGuid().ToString();
+            mf.metaid = 0;
+            mf.dirid = vd.Meta.dirid;
+            mf.depid = vd.Meta.depid;
+            mf.verid = vd.Meta.verid;
             mf.name = vd.Meta.name;
-            mf.metaid = metaId;
-            mf.fileid = 0;
+            mf.type = vd.Meta.type;
             mf.guid = guid;
             mf.path = subPath + "\\" + mf.name;
             mf.sizes = vd.Meta.sizes;
+            mf.tab = null;
+            mf.rows = 0;
             mf.create_user = vd.Meta.create_user;
 
             return mf;

--
Gitblit v1.9.3