From 2d2cfdcbf7714d1f78f5c084e74b0e84b4e74f76 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期一, 21 八月 2023 14:29:17 +0800 Subject: [PATCH] 合并通用的方法 --- DataLoader/Model/Tool.cs | 65 -------------------------------- 1 files changed, 0 insertions(+), 65 deletions(-) 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