From 2d2cfdcbf7714d1f78f5c084e74b0e84b4e74f76 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期一, 21 八月 2023 14:29:17 +0800 Subject: [PATCH] 合并通用的方法 --- DataLoader/CS/Importor.cs | 4 +- DataLoader/CS/NtstWeb.cs | 0 DataLoader/CS/Tools.cs | 17 ++++++++ DataLoader/DataLoader.csproj | 3 + DataLoader/LoginWin.xaml.cs | 3 + DataLoader/CS/StaticData.cs | 5 ++ DataLoader/CS/MetaHelper.cs | 13 ++++++ DataLoader/Model/Tool.cs | 65 -------------------------------- 8 files changed, 41 insertions(+), 69 deletions(-) diff --git a/DataLoader/CS/Importor.cs b/DataLoader/CS/Importor.cs index 0ff7069..4a3960f 100644 --- a/DataLoader/CS/Importor.cs +++ b/DataLoader/CS/Importor.cs @@ -58,7 +58,7 @@ public static int InsertMeta(SysMeta meta) { - List<DbParameter> list = Tool.GetParams<SysMeta>(insertMeta, meta); + List<DbParameter> list = Tools.GetParams<SysMeta>(insertMeta, meta); object obj = Helper.GetScalar(insertMeta, list.ToArray()); @@ -91,7 +91,7 @@ vd.Meta.depid = 1; vd.Meta.verid = 0; vd.Meta.type = fi.Extension.ToLower().Replace(".", ""); - vd.Meta.sizes = Tool.SizeToMb(fi.Length); + vd.Meta.sizes = Tools.SizeToMb(fi.Length); vd.Meta.create_user = Tool.UserId; } diff --git a/DataLoader/CS/MetaHelper.cs b/DataLoader/CS/MetaHelper.cs new file mode 100644 index 0000000..31427cc --- /dev/null +++ b/DataLoader/CS/MetaHelper.cs @@ -0,0 +1,13 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataLoader.CS +{ + public class MetaHelper + { + + } +} diff --git a/DataLoader/Model/NtstWeb.cs b/DataLoader/CS/NtstWeb.cs similarity index 100% rename from DataLoader/Model/NtstWeb.cs rename to DataLoader/CS/NtstWeb.cs diff --git a/DataLoader/CS/StaticData.cs b/DataLoader/CS/StaticData.cs index 25a11e9..8b7764f 100644 --- a/DataLoader/CS/StaticData.cs +++ b/DataLoader/CS/StaticData.cs @@ -39,6 +39,11 @@ public readonly static String OSGB = ".osgb"; /// <summary> + /// 鏍呮牸鏁版嵁鎵╁睍鍚� + /// </summary> + public static readonly List<String> RASTER_EXT = new List<String> { ".img", ".tif", ".tiff", "jpg", "jp2" }; + + /// <summary> /// 16杩涘埗 /// </summary> public static readonly char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; diff --git a/DataLoader/CS/Tools.cs b/DataLoader/CS/Tools.cs index d03b1c4..365e538 100644 --- a/DataLoader/CS/Tools.cs +++ b/DataLoader/CS/Tools.cs @@ -59,10 +59,27 @@ } /// <summary> + /// 鎹㈢畻涓篗B + /// </summary> + public static double SizeToMb(long size) + { + if (size < 1050) + { + return 0.001; + } + + String str = string.Format("{0:F3}", size / 1024.0 / 1024.0); + + return Double.Parse(str); + } + + /// <summary> /// 鑾峰彇璁剧疆 /// </summary> public static string GetSetting(string key) { + if (!ConfigurationManager.AppSettings.AllKeys.Contains(key)) return null; + return ConfigurationManager.AppSettings[key]; } diff --git a/DataLoader/DataLoader.csproj b/DataLoader/DataLoader.csproj index 5750e0f..ca386db 100644 --- a/DataLoader/DataLoader.csproj +++ b/DataLoader/DataLoader.csproj @@ -135,11 +135,12 @@ <Compile Include="CS\Importor.cs" /> <Compile Include="CS\LogOut.cs" /> <Compile Include="CS\MD5Helper.cs" /> + <Compile Include="CS\MetaHelper.cs" /> <Compile Include="CS\StaticData.cs" /> <Compile Include="CS\Tools.cs" /> <Compile Include="Model\Tool.cs" /> <Compile Include="CS\ModelHandler.cs" /> - <Compile Include="Model\NtstWeb.cs" /> + <Compile Include="CS\NtstWeb.cs" /> <Compile Include="CS\PostgreHelper.cs" /> <Compile Include="Model\ViewData.cs" /> <Compile Include="LoginWin.xaml.cs"> diff --git a/DataLoader/LoginWin.xaml.cs b/DataLoader/LoginWin.xaml.cs index a34d869..f56831a 100644 --- a/DataLoader/LoginWin.xaml.cs +++ b/DataLoader/LoginWin.xaml.cs @@ -1,4 +1,5 @@ 锘縰sing CefSharp; +using DataLoader.CS; using DataLoader.Model; using System; using System.Collections.Generic; @@ -32,7 +33,7 @@ private void Window_Loaded(object sender, RoutedEventArgs e) { - web.Address = Tool.BaseDir + "htmls\\login.html"; + web.Address = Tools.BaseDir + "htmls\\login.html"; } } } diff --git a/DataLoader/Model/Tool.cs b/DataLoader/Model/Tool.cs index 48cf7f7..b4432e9 100644 --- a/DataLoader/Model/Tool.cs +++ b/DataLoader/Model/Tool.cs @@ -27,70 +27,5 @@ public static string Token = ""; - public static char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; - - public static string FormatBytes(long bytes) - { - string[] Suffix = { "Byte", "KB", "MB", "GB", "TB" }; - - int i = 0; - double dblSByte = bytes; - if (bytes > 1024) - for (i = 0; (bytes / 1024) > 0; i++, bytes /= 1024) - dblSByte = bytes / 1024.0; - - return String.Format("{0:0.##}{1}", dblSByte, Suffix[i]); - } - - public static string GetSetting(string key) - { - if (!ConfigurationManager.AppSettings.AllKeys.Contains(key)) - { - return null; - } - - return ConfigurationManager.AppSettings[key]; - } - - public static List<DbParameter> GetParams<T>(string sql, T t) - { - List<DbParameter> list = new List<DbParameter>(); - Type tType = typeof(T); - BindingFlags flags = BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.Instance; - - int start = sql.IndexOf("@"); - while (start != -1) - { - int end = sql.IndexOf(",", start); - if (end == -1) end = sql.IndexOf(")", start); - if (end == -1) end = sql.IndexOf(" ", start); - if (end == -1) end = sql.Length; - - string name = sql.Substring(start + 1, end - start - 1); - PropertyInfo pi = tType.GetProperty(name, flags); - if (pi != null) - { - object value = pi.GetValue(t, null); - DbParameter dp = new NpgsqlParameter("@" + name, value); - list.Add(dp); - } - - start = sql.IndexOf("@", end); - } - - return list; - } - - public static double SizeToMb(long size) - { - if (size < 1050) - { - return 0.001; - } - - String str = string.Format("{0:F3}", size / 1024.0 / 1024.0); - - return Double.Parse(str); - } } } -- Gitblit v1.9.3