From 8482a6fef58c0d699795435ef525a8f188e502a1 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期一, 21 八月 2023 13:44:11 +0800
Subject: [PATCH] 修改Postgres数据库帮助类

---
 ExportMap/cs/Tools.cs          |    2 
 DataLoader/CS/PostgreHelper.cs |   35 +++++++++--
 DataLoader/CS/Importor.cs      |    2 
 DataLoader/CS/ModelHandler.cs  |    6 +
 ExportMap/db/ModelHandler.cs   |    2 
 DataLoader/CS/StaticData.cs    |  110 ++++++++++++++++++++++++++----------
 ExportMap/db/PostgreHelper.cs  |    8 +-
 7 files changed, 119 insertions(+), 46 deletions(-)

diff --git a/DataLoader/CS/Importor.cs b/DataLoader/CS/Importor.cs
index b454147..0ff7069 100644
--- a/DataLoader/CS/Importor.cs
+++ b/DataLoader/CS/Importor.cs
@@ -28,7 +28,7 @@
         {
             get
             {
-                if (_ph == null) _ph = new PostgreHelper(DbEnum.langfang);
+                if (_ph == null) _ph = new PostgreHelper();
 
                 return _ph;
             }
diff --git a/DataLoader/CS/ModelHandler.cs b/DataLoader/CS/ModelHandler.cs
index 07bdb41..197f1b3 100644
--- a/DataLoader/CS/ModelHandler.cs
+++ b/DataLoader/CS/ModelHandler.cs
@@ -3,11 +3,13 @@
 using System.Data;
 using System.Linq;
 using System.Reflection;
-using System.Text;
-using System.Threading.Tasks;
+using System.Web;
 
 namespace DataLoader.CS
 {
+    /// <summary>
+    /// DataTable涓庡疄浣撶被鐩镐簰杞崲
+    /// </summary>
     public class ModelHandler
     {
         /// <summary>
diff --git a/DataLoader/CS/PostgreHelper.cs b/DataLoader/CS/PostgreHelper.cs
index 7b99a94..11f4ead 100644
--- a/DataLoader/CS/PostgreHelper.cs
+++ b/DataLoader/CS/PostgreHelper.cs
@@ -5,9 +5,8 @@
 using System.Data;
 using System.Data.Common;
 using System.Linq;
-using System.Text;
 using System.Text.RegularExpressions;
-using System.Threading.Tasks;
+using System.Web;
 
 namespace DataLoader.CS
 {
@@ -29,11 +28,9 @@
 
         private string conStr = null;
 
-        public PostgreHelper(DbEnum db)
+        public PostgreHelper()
         {
-            string str = ConfigurationManager.AppSettings["pgConn"];
-
-            this.conStr = string.Format(str, db.ToString());
+            this.conStr = ConfigurationManager.AppSettings["pgConn"];
         }
 
         /// <summary>
@@ -135,6 +132,32 @@
             }
         }
 
+        public int GetIntScalar(string sql, params DbParameter[] args)
+        {
+            using (NpgsqlConnection con = new NpgsqlConnection(ConStr))
+            {
+                if (con.State != ConnectionState.Open)
+                {
+                    con.Open();
+                }
+
+                using (NpgsqlCommand cmd = new NpgsqlCommand(sql, con))
+                {
+                    if (args != null)
+                    {
+                        foreach (DbParameter arg in args)
+                        {
+                            cmd.Parameters.Add(arg);
+                        }
+                    }
+
+                    object obj = cmd.ExecuteScalar();
+
+                    return null == obj ? 0 : Convert.ToInt32(obj);
+                }
+            }
+        }
+
         /// <summary>
         /// 鎵цSQL锛岃繑鍥炲奖鍝嶈鏁�
         /// </summary>
diff --git a/DataLoader/CS/StaticData.cs b/DataLoader/CS/StaticData.cs
index 5fa5089..07e157c 100644
--- a/DataLoader/CS/StaticData.cs
+++ b/DataLoader/CS/StaticData.cs
@@ -1,8 +1,6 @@
 锘縰sing System;
 using System.Collections.Generic;
 using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 
 namespace DataLoader.CS
 {
@@ -10,39 +8,91 @@
     {
         public static String BasePath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
 
-        /**
-         * JP2鏂囦欢鎵╁睍鍚�
-         */
-        public static List<String> JP2_EXT = new List<String> { "jp2.aux.xml" };
+        public static String ADMIN = "admin";
 
-        /**
-         * MPT鏂囦欢鎵╁睍鍚�
-         */
-        public static List<String> MPT_EXT = new List<String> { ".midx", ".strmi" };
+        public readonly static String ZIP = ".zip";
 
-        /**
-         * IMG鏂囦欢鎵╁睍鍚�
-         */
-        public static List<String> IMG_EXT = new List<String> { ".rrd", ".img.aux.xml", ".hdr", ".img.enp", ".img.xml" };
+        public readonly static String XLS = ".xls";
 
-        /**
-         * TIF鏂囦欢鎵╁睍鍚�
-         */
-        public static List<String> TIF_EXT = new List<String> { ".prj", ".tfw", ".tif.ovr", ".tif.aux.xml", ".tif.enp", ".tif.xml" };
+        public readonly static String XLSX = ".xlsx";
 
-        /**
-         * TIFF鏂囦欢鎵╁睍鍚�
-         */
-        public static List<String> TIFF_EXT = new List<String> { ".prj", ".tfw", ".tiff.ovr", ".tiff.aux.xml", ".tiff.enp", ".tiff.xml" };
+        public readonly static String MDB = ".mdb";
 
-        /**
-         * SHP鏂囦欢鎵╁睍鍚�
-         */
-        public static List<String> SHP_EXT = new List<String> { ".shx", ".dbf", ".prj", ".cpg" };
+        public readonly static String SHP = ".shp";
 
-        /**
-         * 鎵�鏈夋枃浠舵墿灞曞悕
-         */
-        public static List<String> ALL_EXTENSION = new List<String> { ".pdf", ".xls", ".xlsx", ".doc", ".docx", ".ppt", ".pptx", ".shp", ".gdb", ".mdb", ".dwg", ".las", ".laz", ".cpt", ".mpt", ".fly", ".efb", ".g3d", ".fbx", ".obj", ".3dm", ".3dml", ".osgb", ".rvt", ".ifc", ".jpg", ".png", ".img", ".tif", ".tiff", ".bmp", ".gif", ".rmvb", ".rm", ".mp3", ".mp4", ".avi", ".wma", ".wmv", ".7z", ".rar", ".zip", ".db", ".jp2", ".txt", ".xml" };
+        public readonly static String NGDB = "gdb";
+
+        public readonly static String GDB = ".gdb";
+
+        public readonly static String JPG = ".jpg";
+
+        public readonly static String IMG = ".img";
+
+        public readonly static String MPT = ".mpt";
+
+        public readonly static String D3DML = ".3dml";
+
+        public readonly static String TIF = ".tif";
+
+        public readonly static String TIFF = ".tiff";
+
+        public readonly static String LAS = ".las";
+
+        public readonly static String OSGB = ".osgb";
+
+        /// <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' };
+
+        /// <summary>
+        /// 瀵嗙爜姝e垯琛ㄨ揪寮�
+        /// </summary>
+        public readonly static String PWD_REG = "^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\\W!@#$%^&*`~()\\-_+=,.?;<>]+$)(?![a-z0-9]+$)(?![a-z\\W!@#$%^&*`~()\\-_+=,.?;<>]+$)(?![0-9\\W!@#$%^&*`~()\\-_+=,.?;<>]+$)[a-zA-Z0-9\\W!@#$%^&*`~()\\-_+=,.?;<>]{12,20}$";
+
+        /// <summary>
+        /// MPT鏂囦欢鎵╁睍鍚�
+        /// </summary>
+        public readonly static List<String> MPT_EXT = new List<String> { ".midx", ".strmi", ".ei.midx", ".ei.mpt", ".ei.strmi" };
+
+        /// <summary>
+        /// JPG鏂囦欢鎵╁睍鍚�
+        /// </summary>
+        public readonly static List<String> JPG_EXT = new List<String> { ".jpg.aux.xml", ".jpg.ovr", ".jpg.xml", ".jgw", ".prj" };
+
+        /// <summary>
+        /// JP2鏂囦欢鎵╁睍鍚�
+        /// </summary>
+        public readonly static List<String> JP2_EXT = new List<String> { ".jp2.aux.xml", ".jp2.ovr", ".jp2.xml", ".jgw", ".prj", ".jp2.html", ".jp2.txt" };
+
+        /// <summary>
+        /// IMG鏂囦欢鎵╁睍鍚�
+        /// </summary>
+        public readonly static List<String> IMG_EXT = new List<String> { ".rrd", ".img.aux.xml", ".hdr", ".img.enp", ".img.xml" };
+
+        /// <summary>
+        /// TIF鏂囦欢鎵╁睍鍚�
+        /// </summary>
+        public readonly static List<String> TIF_EXT = new List<String> { ".prj", ".tfw", ".aux", ".tif.ovr", ".tif.aux.xml", ".tif.xml" };
+
+        /// <summary>
+        /// TIFF鏂囦欢鎵╁睍鍚�
+        /// </summary>
+        public readonly static List<String> TIFF_EXT = new List<String> { ".prj", ".tfw", ".aux", ".tiff.ovr", ".tiff.aux.xml", ".tiff.xml" };
+
+        /// <summary>
+        /// SHP鏂囦欢鎵╁睍鍚�
+        /// </summary>
+        public readonly static List<String> SHP_EXT = new List<String> { ".shx", ".dbf", ".prj", ".cpg" };
+
+        /// <summary>
+        /// Mapper鎺掗櫎鎵╁睍鍚�
+        /// </summary>
+        public readonly static List<String> MAPPER_EXCLUDE_EXT = new List<String> { ".jpg.aux.xml", ".jpg.xml", ".jp2.aux.xml", ".jp2.xml", ".jp2.html", ".jp2.txt", ".img.aux.xml", ".img.xml", ".tif.aux.xml", ".tif.xml", ".tiff.aux.xml", ".tiff.xml", ".shp.xml" };
+
+        /// <summary>
+        /// 鎵�鏈夋枃浠舵墿灞曞悕
+        /// </summary>
+        public readonly static List<String> ALL_EXTENSION = new List<String> { ".txt", ".xml", ".pdf", ".xls", ".xlsx", ".doc", ".docx", ".ppt", ".pptx", ".shp", ".gdb", ".mdb", ".dwg", ".las", ".laz", ".cpt", ".mpt", ".ei.mpt", ".fly", ".efb", ".g3d", ".fbx", ".obj", ".3dm", ".3dml", ".osgb", ".rvt", ".ifc", ".jpg", ".jp2", ".png", ".img", ".tif", ".tiff", ".dem", ".bmp", ".gif", ".rmvb", ".rm", ".mp3", ".mp4", ".avi", ".wma", ".wmv", ".7z", ".rar", ".zip" };
     }
 }
diff --git a/ExportMap/cs/Tools.cs b/ExportMap/cs/Tools.cs
index c681121..814e34a 100644
--- a/ExportMap/cs/Tools.cs
+++ b/ExportMap/cs/Tools.cs
@@ -60,7 +60,7 @@
             {
                 if (null == _dbHelper)
                 {
-                    _dbHelper = new PostgreHelper(DbEnum.langfang);
+                    _dbHelper = new PostgreHelper();
                 }
 
                 return _dbHelper;
diff --git a/ExportMap/db/ModelHandler.cs b/ExportMap/db/ModelHandler.cs
index 7f1a8be..f6ca700 100644
--- a/ExportMap/db/ModelHandler.cs
+++ b/ExportMap/db/ModelHandler.cs
@@ -82,4 +82,4 @@
             return dt;
         }
     }
-}
\ No newline at end of file
+}
diff --git a/ExportMap/db/PostgreHelper.cs b/ExportMap/db/PostgreHelper.cs
index 8659d6d..66bd605 100644
--- a/ExportMap/db/PostgreHelper.cs
+++ b/ExportMap/db/PostgreHelper.cs
@@ -28,11 +28,9 @@
 
         private string conStr = null;
 
-        public PostgreHelper(DbEnum db)
+        public PostgreHelper()
         {
-            string str = ConfigurationManager.AppSettings["pgConn"];
-
-            this.conStr = string.Format(str, db.ToString());
+            this.conStr = ConfigurationManager.AppSettings["pgConn"];
         }
 
         /// <summary>
@@ -196,4 +194,4 @@
             return Regex.IsMatch(input, StrRegex, RegexOptions.IgnoreCase);
         }
     }
-}
\ No newline at end of file
+}

--
Gitblit v1.9.3