1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
| using DataLoader.Model;
| using Npgsql;
| using System;
| using System.Collections.Generic;
| using System.Collections.ObjectModel;
| using System.Data.Common;
| using System.IO;
| using System.Linq;
| using System.Reflection;
|
| namespace DataLoader.CS
| {
| public class Importor
| {
| private static PostgreHelper _ph = null;
|
| public static PostgreHelper Helper
| {
| get
| {
| if (_ph == null) _ph = new PostgreHelper(DbEnum.langfang);
|
| return _ph;
| }
| }
|
| 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)";
|
| public static int CountFilesByGuid(string guid)
| {
| string sql = "select count(*) from lf.sys_meta_file where guid=@guid";
| DbParameter dp = new NpgsqlParameter("@guid", guid);
|
| int rows = Helper.GetCount(sql, dp);
|
| return rows;
| }
|
| 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);
| }
|
| public static void Import(ObservableCollection<ViewData> viewDatas, string source, string target)
| {
| string[] files = Directory.GetFiles(source);
| }
| }
| }
|
|