DuGuYang 3 лет назад
Родитель
Сommit
909f1c6b8b
1 измененных файлов с 26 добавлено и 0 удалено
  1. 26 0
      Startup.cs

+ 26 - 0
Startup.cs

@@ -93,8 +93,10 @@ namespace MySystem
             initMainServer();
             initBsServer();
             initCashServer();
+            initSpServer();
 
             RedisDbconn.csredis = new CSRedis.CSRedisClient(Configuration["Setting:RedisConnStr"]);
+            // TendisDbconn.csredis = new CSRedis.CSRedisClient(Configuration["Setting:TendisConnStr"]);
         }
 
         // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@@ -217,5 +219,29 @@ namespace MySystem
             Library.OtherMySqlConn.connstr = "";
             PublicFunction.CashTables = tables;
         }
+
+        private void initSpServer()
+        {
+            Dictionary<string, Dictionary<string, string>> tables = new Dictionary<string, Dictionary<string, string>>();
+            Library.OtherMySqlConn.connstr = Configuration["Setting:SpSqlConnStr"];
+            System.Data.DataTable tablecollection = Library.OtherMySqlConn.dtable("select DISTINCT TABLE_NAME from information_schema.columns where table_schema = 'KxsSpServer'");
+            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 = 'KxsSpServer' and TABLE_NAME='" + subtable["TABLE_NAME"].ToString() + "'");
+                foreach (System.Data.DataRow column in columncollection.Rows)
+                {
+                    string datatype = column["DATA_TYPE"].ToString();
+                    if (datatype == "decimal")
+                    {
+                        datatype = "numeric";
+                    }
+                    Columns.Add(column["COLUMN_NAME"].ToString(), datatype);
+                }
+                tables.Add(subtable["TABLE_NAME"].ToString(), Columns);
+            }
+            Library.OtherMySqlConn.connstr = "";
+            PublicFunction.SpTables = tables;
+        }
     }
 }