Просмотр исходного кода

mainserver区分正式和开发,库名不同

lcl 2 лет назад
Родитель
Сommit
ae01448abb
1 измененных файлов с 15 добавлено и 8 удалено
  1. 15 8
      Startup.cs

+ 15 - 8
Startup.cs

@@ -90,11 +90,6 @@ namespace MySystem
                 };
             });
             MySystemLib.SystemPublicFuction.appcheck = "success";
-            initMainServer();
-            initBsServer();
-            initCashServer();
-            initSpServer();
-            initOperateServer();
 
             RedisDbconn.csredis = new CSRedis.CSRedisClient(Configuration["Setting:RedisConnStr"]);
             // TendisDbconn.csredis = new CSRedis.CSRedisClient(Configuration["Setting:TendisConnStr"]);
@@ -137,6 +132,13 @@ namespace MySystem
                     name: "default",
                     pattern: "{controller=Home}/{action=Index}/{Id?}");
             });
+            
+            initMainServer(Env);
+            initBsServer();
+            initCashServer();
+            initSpServer();
+            initOperateServer();
+
             if(Env == "Develop")
             {
             }
@@ -162,15 +164,20 @@ namespace MySystem
 
 
         //初始化数据结构
-        private void initMainServer()
+        private void initMainServer(string Env)
         {
+            string dbName = "KxsMainServer";
+            if(Env == "Production")
+            {
+                dbName = "KxsProfitServer";
+            }
             Dictionary<string, Dictionary<string, string>> tables = new Dictionary<string, Dictionary<string, string>>();
             Library.OtherMySqlConn.connstr = Configuration["Setting:SqlConnStr"];
-            System.Data.DataTable tablecollection = Library.OtherMySqlConn.dtable("select DISTINCT TABLE_NAME from information_schema.columns where table_schema = 'KxsProfitServer'");
+            System.Data.DataTable tablecollection = Library.OtherMySqlConn.dtable("select DISTINCT TABLE_NAME from information_schema.columns where table_schema = '" + dbName + "'");
             foreach (System.Data.DataRow subtable in tablecollection.Rows)
             {
                 Dictionary<string, string> Columns = new Dictionary<string, string>();
-                System.Data.DataTable columncollection = Library.OtherMySqlConn.dtable("select COLUMN_NAME,DATA_TYPE from information_schema.columns where table_schema = 'KxsProfitServer' and TABLE_NAME='" + subtable["TABLE_NAME"].ToString() + "'");
+                System.Data.DataTable columncollection = Library.OtherMySqlConn.dtable("select COLUMN_NAME,DATA_TYPE from information_schema.columns where table_schema = '" + dbName + "' and TABLE_NAME='" + subtable["TABLE_NAME"].ToString() + "'");
                 foreach (System.Data.DataRow column in columncollection.Rows)
                 {
                     string datatype = column["DATA_TYPE"].ToString();