Kaynağa Gözat

rename ConnectionString

Lith 10 ay önce
ebeveyn
işleme
57dab569c6

+ 5 - 5
Sqler/Module/Sqler/Controllers/DbPort/DbPortController.cs

@@ -30,13 +30,13 @@ namespace App.Module.Sqler.Controllers.DbPort
         [HttpGet("Export")]
         public void Export
            ([FromForm] string type,
-            [FromForm] string ConnectionString,
+            [FromForm] string connectionString,
             [FromForm, SsDescription("sqlite/sqlite-NoMemoryCache/excel/csv/txt")] string exportFileType)
         {
             Response.ContentType = "text/html;charset=utf-8";
 
             DbPortLogical.Export(SendMsg,
-                type, ConnectionString,
+                type, connectionString,
                 exportFileType
                 );
         }
@@ -51,7 +51,7 @@ namespace App.Module.Sqler.Controllers.DbPort
         public void Import(
             [FromForm] IList<IFormFile> files,
             [FromForm] string type,
-            [FromForm] string ConnectionString,
+            [FromForm] string connectionString,
             [FromForm, SsDescription("on代表true")] string createTable,
             [FromForm] string delete,
             [FromForm] string truncate
@@ -62,7 +62,7 @@ namespace App.Module.Sqler.Controllers.DbPort
 
 
             //(x.2)连接字符串
-            if (string.IsNullOrWhiteSpace(ConnectionString))
+            if (string.IsNullOrWhiteSpace(connectionString))
             {
                 SendMsg(EMsgType.Err, "import error - invalid arg conn.");
                 return;
@@ -90,7 +90,7 @@ namespace App.Module.Sqler.Controllers.DbPort
 
 
             //(x.5)导入数据
-            DbPortLogical.Import(SendMsg, filePath, type, ConnectionString, createTable == "on", delete == "on", truncate == "on");
+            DbPortLogical.Import(SendMsg, filePath, type, connectionString, createTable == "on", delete == "on", truncate == "on");
 
         }
 

+ 1 - 1
Sqler/Module/Sqler/Controllers/SqlRun/SqlRunController.cs

@@ -224,7 +224,7 @@ namespace App.Module.Sqler.Controllers.SqlRun
 
             var connInfo = SqlerHelp.sqlerConfig.GetByPath<Vit.Db.Util.Data.ConnectionInfo>("SqlRun.Config");
 
-            DbPortLogical.Export(SendMsg, connInfo.type, connInfo.ConnectionString, exportFileType, sql: sql);
+            DbPortLogical.Export(SendMsg, connInfo.type, connInfo.connectionString, exportFileType, sql: sql);
         }
         #endregion
 

+ 2 - 13
Sqler/Module/Sqler/Logical/DbPort/DataOutput.cs

@@ -21,7 +21,7 @@ namespace Sqler.Module.Sqler.Logical.DbPort
         /// mssql、mysql、sqlite
         /// </summary>
         public string type;
-        public string ConnectionString; //数据库连接字符串。亦可从配置文件获取,如 sqler.config:SqlBackup.SqlServerBackup.ConnectionString
+        public string connectionString { get; set; } //数据库连接字符串。亦可从配置文件获取,如 sqler.config:SqlBackup.SqlServerBackup.ConnectionString
         public bool createTable;
         public bool delete;
         public bool truncate;
@@ -74,18 +74,7 @@ namespace Sqler.Module.Sqler.Logical.DbPort
 
         public void Output()
         {
-
-            //if (type == "sqlite-NoMemoryCache")
-            //{
-            //    using (var conn = ConnectionFactory.Sqlite_GetOpenConnectionByFilePath())
-            //    using (new Vit.Orm.Dapper.Data.Sqlite.SQLiteBackup(conn, ConnectionString: ConnectionString))
-            //    {
-            //        BatchImport(conn);
-            //    }
-            //    return;
-            //}
-
-            using (var conn = ConnectionFactory.GetConnection(new Vit.Db.Util.Data.ConnectionInfo { type = type, ConnectionString = ConnectionString }))
+            using (var conn = ConnectionFactory.GetConnection(new Vit.Db.Util.Data.ConnectionInfo { type = type, connectionString = connectionString }))
             {
                 BatchImport(conn);
             }

+ 19 - 19
Sqler/Module/Sqler/Logical/DbPort/DbPortLogical.cs

@@ -88,7 +88,7 @@ namespace Sqler.Module.Sqler.Logical.DbPort
         /// </summary>
         /// <param name="SendMsg"></param>
         /// <param name="type"></param>
-        /// <param name="ConnectionString"></param>
+        /// <param name="connectionString"></param>
         /// <param name="exportFileType"></param>
         /// <param name="sql"></param>
         /// <param name="inTableNames"></param>
@@ -99,7 +99,7 @@ namespace Sqler.Module.Sqler.Logical.DbPort
            (
             Action<EMsgType, string> SendMsg,
             string type,
-            string ConnectionString,
+            string connectionString,
             [SsDescription("sqlite/sqlite-NoMemoryCache/excel/csv/txt")] string exportFileType,
             string sql = null, List<string> inTableNames = null, //指定一个即可,若均不指定,则返回所有表
             string outFilePath = null, string outFileName = null, //指定一个即可
@@ -111,26 +111,26 @@ namespace Sqler.Module.Sqler.Logical.DbPort
 
             #region (x.1)连接字符串
 
-            if (string.IsNullOrWhiteSpace(ConnectionString))
+            if (string.IsNullOrWhiteSpace(connectionString))
             {
                 SendMsg(EMsgType.Err, "Export error - invalid arg conn.");
                 return;
             }
 
             //解析ConnectionString
-            if (ConnectionString.StartsWith("sqler.json::"))
+            if (connectionString.StartsWith("sqler.json::"))
             {
-                ConnectionString = SqlerHelp.sqlerConfig.GetStringByPath(ConnectionString.Substring("sqler.json::".Length));
+                connectionString = SqlerHelp.sqlerConfig.GetStringByPath(connectionString.Substring("sqler.json::".Length));
             }
 
 
             if (type == "mysql")
             {
-                ConnectionString = SqlerHelp.MySql_FormatConnectionString(ConnectionString);
+                connectionString = SqlerHelp.MySql_FormatConnectionString(connectionString);
             }
             else if (type == "mssql")
             {
-                ConnectionString = SqlerHelp.SqlServer_FormatConnectionString(ConnectionString);
+                connectionString = SqlerHelp.SqlServer_FormatConnectionString(connectionString);
             }
             #endregion
 
@@ -433,7 +433,7 @@ namespace Sqler.Module.Sqler.Logical.DbPort
             try
             {
                 using (new Disposable(onDispose))
-                using (var conn = ConnectionFactory.GetConnection(new Vit.Db.Util.Data.ConnectionInfo { type = type, ConnectionString = ConnectionString }))
+                using (var conn = ConnectionFactory.GetConnection(new Vit.Db.Util.Data.ConnectionInfo { type = type, connectionString = connectionString }))
                 {
                     var startTime = DateTime.Now;
 
@@ -561,7 +561,7 @@ namespace Sqler.Module.Sqler.Logical.DbPort
         /// <param name="SendMsg"></param>
         /// <param name="filePath"></param>
         /// <param name="type"></param>
-        /// <param name="ConnectionString"></param>
+        /// <param name="connectionString"></param>
         /// <param name="createTable"></param>
         /// <param name="delete"></param>
         /// <param name="truncate"></param>
@@ -569,7 +569,7 @@ namespace Sqler.Module.Sqler.Logical.DbPort
              Action<EMsgType, string> SendMsg,
              string filePath,
              string type,
-             string ConnectionString,
+             string connectionString,
              bool createTable,
              bool delete,
              bool truncate
@@ -581,26 +581,26 @@ namespace Sqler.Module.Sqler.Logical.DbPort
 
             #region (x.2)连接字符串
 
-            if (string.IsNullOrWhiteSpace(ConnectionString))
+            if (string.IsNullOrWhiteSpace(connectionString))
             {
                 SendMsg(EMsgType.Err, "Export error - invalid arg conn.");
                 return;
             }
 
             //解析ConnectionString
-            if (ConnectionString.StartsWith("sqler.json::"))
+            if (connectionString.StartsWith("sqler.json::"))
             {
-                ConnectionString = SqlerHelp.sqlerConfig.GetStringByPath(ConnectionString.Substring("sqler.json::".Length));
+                connectionString = SqlerHelp.sqlerConfig.GetStringByPath(connectionString.Substring("sqler.json::".Length));
             }
 
 
             if (type == "mysql")
             {
-                ConnectionString = SqlerHelp.MySql_FormatConnectionString(ConnectionString);
+                connectionString = SqlerHelp.MySql_FormatConnectionString(connectionString);
             }
             else if (type == "mssql")
             {
-                ConnectionString = SqlerHelp.SqlServer_FormatConnectionString(ConnectionString);
+                connectionString = SqlerHelp.SqlServer_FormatConnectionString(connectionString);
             }
             #endregion
 
@@ -693,7 +693,7 @@ namespace Sqler.Module.Sqler.Logical.DbPort
                 var output = new DataOutput();
                 output.SendMsg = SendMsg;
                 output.type = type;
-                output.ConnectionString = ConnectionString;
+                output.connectionString = connectionString;
                 output.createTable = createTable;
                 output.delete = delete;
                 output.truncate = truncate;
@@ -794,7 +794,7 @@ namespace Sqler.Module.Sqler.Logical.DbPort
                 #region (x.2)init from_data
                 SendMsg(EMsgType.Title, "   init from_data");
                 using (var conn = ConnectionFactory.GetConnection(new Vit.Db.Util.Data.ConnectionInfo
-                { type = from_type, ConnectionString = from_ConnectionString }))
+                { type = from_type, connectionString = from_ConnectionString }))
                 {
                     if (string.IsNullOrWhiteSpace(from_sql))
                     {
@@ -821,7 +821,7 @@ namespace Sqler.Module.Sqler.Logical.DbPort
                     (tableName, curTbIndex) =>
                     {
                         var conn = ConnectionFactory.GetConnection(new Vit.Db.Util.Data.ConnectionInfo
-                        { type = from_type, ConnectionString = from_ConnectionString });
+                        { type = from_type, connectionString = from_ConnectionString });
                         var dataReader = conn.ExecuteReader(from_sql, commandTimeout: DbPortLogical.commandTimeout);
                         int tableIndex = 0;
 
@@ -855,7 +855,7 @@ namespace Sqler.Module.Sqler.Logical.DbPort
                 var output = new DataOutput();
                 output.SendMsg = SendMsg;
                 output.type = to_type;
-                output.ConnectionString = to_ConnectionString;
+                output.connectionString = to_ConnectionString;
                 output.createTable = createTable;
                 output.delete = delete;
                 output.truncate = truncate;

+ 5 - 5
Sqler/wwwroot/sqler/DbPort/DataTransfer.html

@@ -29,10 +29,10 @@
                         <input type='radio' name='from_type' value="sqlite" />sqlite
                     </td>
                 </tr>
-                <tr><td>ConnectionString</td><td><textarea name='from_ConnectionString' cols="100" rows="2"></textarea></td></tr>
+                <tr><td>connectionString</td><td><textarea name='from_ConnectionString' cols="100" rows="2"></textarea></td></tr>
                 <tr><td>sql(若不指定则复制所有表数据)</td><td><textarea name='from_sql' cols="100" rows="8">
-/* <SqlRunConfig>                
-<tableNames>["aaa","bbb"]</tableNames>                  
+/* <SqlRunConfig>
+<tableNames>["aaa","bbb"]</tableNames>
 </SqlRunConfig> */
 </textarea></td></tr>
                 <tr><td colspan="2" style="text-align:left;padding-top:40px;"><b>目标配置</b> 指定要将数据复制到何处:</td></tr>
@@ -41,10 +41,10 @@
                     <td>
                         <input type='radio' name='to_type' value="mssql" checked="checked" />mssql
                         <input type='radio' name='to_type' value="mysql" />mysql
-                        <input type='radio' name='to_type' value="sqlite" />sqlite                  
+                        <input type='radio' name='to_type' value="sqlite" />sqlite
                     </td>
                 </tr>
-                <tr><td>ConnectionString</td><td><textarea name='to_ConnectionString' cols="100" rows="2"></textarea></td></tr>
+                <tr><td>connectionString</td><td><textarea name='to_ConnectionString' cols="100" rows="2"></textarea></td></tr>
 
                 <tr><td>createTable</td><td><input type='checkbox' name='createTable' /></td></tr>
                 <tr><td>delete</td><td><input type='checkbox' name='delete' /></td></tr>

+ 4 - 4
Sqler/wwwroot/sqler/DbPort/DbPort.html

@@ -25,7 +25,7 @@
                         <input type='radio' name='type' value="sqlite" />sqlite
                     </td>
                 </tr>
-                <tr><td>ConnectionString</td><td><textarea name='ConnectionString' cols="100" rows="2"></textarea></td></tr>
+                <tr><td>connectionString</td><td><textarea name='connectionString' cols="100" rows="2"></textarea></td></tr>
                 <tr>
                     <td>导出类型</td>
                     <td>
@@ -41,7 +41,7 @@
         <pre>
             <code>
                 type:              数据库类型,可为 mssql、mysql、sqlite
-                ConnectionString:  数据库连接字符串
+                connectionString:  数据库连接字符串
             </code>
     </pre>
     </fieldset>
@@ -59,7 +59,7 @@
                         <input type='radio' name='type' value="sqlite" />sqlite
                     </td>
                 </tr>
-                <tr><td><label title="数据导入到何处">ConnectionString</label></td><td><textarea name='ConnectionString' cols="100" rows="2"></textarea></td></tr>
+                <tr><td><label title="数据导入到何处">connectionString</label></td><td><textarea name='connectionString' cols="100" rows="2"></textarea></td></tr>
 
                 <tr><td>createTable</td><td><input type='checkbox' name='createTable' /></td></tr>
                 <tr><td>delete</td><td><input type='checkbox' name='delete' /></td></tr>
@@ -72,7 +72,7 @@
             <code>
                 file:               从哪里导入数据。导入文件可为 sqlite、xls、xlsx等
                 type:               数据导入到何处。数据库类型,可为 mssql、mysql、sqlite
-                ConnectionString:   数据导入到何处。数据库连接字符串
+                connectionString:   数据导入到何处。数据库连接字符串
                 createTable:        若指定(on),则在导入数据前自动创建表结构
                 delete:             若指定(on),则在导入数据前使用delete语句清空待操作的表
                 truncate:           若指定(on),则在导入数据前使用truncate语句清空待操作的表

+ 0 - 193
Vit.AutoTemp/Controllers/AutoTempController.cs

@@ -1,193 +0,0 @@
-using Microsoft.AspNetCore.Mvc;
-
-using Newtonsoft.Json.Linq;
-
-using System.Collections.Generic;
-
-using Vit.AutoTemp.DataProvider;
-using Vit.Core.Util.ComponentModel.Data;
-using Vit.Core.Util.ComponentModel.Query;
-using Vit.Core.Util.ComponentModel.SsError;
-using Vit.Extensions;
-using Vit.Linq.Query;
-
-namespace App.Module.AutoTemp.Controllers
-{
-    // apiRoute=/autoTemp/data/{template}/{action}
-    [Route("autoTemp/data")]
-    [ApiController]
-    public class AutoTempController : ControllerBase
-    {
-
-
-        static AutoTempController()
-        {
-            #region init demo        
-
-            IDataProvider dataProvider;
-
-            dataProvider = new Vit.AutoTemp.Demo.DemoDataProvider { isTree = true, template = "demo_tree" };
-            Vit.AutoTemp.AutoTempHelp.RegistDataProvider(dataProvider);
-
-
-            dataProvider = new Vit.AutoTemp.Demo.DemoDataProvider { isTree = false, template = "demo_list" };
-            Vit.AutoTemp.AutoTempHelp.RegistDataProvider(dataProvider);
-
-
-            dataProvider = new Vit.AutoTemp.Demo.DemoRepository().ToDataProvider("demo_repository_list");
-            Vit.AutoTemp.AutoTempHelp.RegistDataProvider(dataProvider);
-
-            #endregion
-
-        }
-
-
-
-
-
-        #region (x.1) getConfig
-        /// <summary>
-        /// GET autoTemp/getConfig
-        /// </summary>
-        /// <returns></returns>
-        [HttpGet("{template}/getConfig")]
-        public ApiReturn getConfig(string template)
-        {
-            try
-            {
-                var dataProvider = Vit.AutoTemp.AutoTempHelp.GetDataProvider(template);
-                if (dataProvider == null) return new SsError { errorMessage = "模板不存在" };
-
-                return dataProvider.getControllerConfig(this);
-            }
-            catch (System.Exception ex)
-            {
-                return (SsError)ex.GetBaseException();
-            }
-        }
-
-        #endregion
-
-        #region (x.2) getList
-        /// <summary>
-        /// GET autoTemp/getList
-        /// </summary>
-        /// <returns></returns>
-        [HttpGet("{template}/getList")]
-        public ApiReturn getList(string template, [FromQuery] string filter, [FromQuery] string sort, [FromQuery] string page, [FromQuery] string arg)
-        {
-            try
-            {
-                var page_ = page.Deserialize<PageInfo>();
-                var filter_ = filter.Deserialize<List<DataFilter>>() ?? new List<DataFilter>();
-                var sort_ = sort.Deserialize<SortItem[]>();
-                //{ isRoot: true,pid: 5}
-                var arg_ = arg.Deserialize<JObject>() ?? new JObject();
-
-                var dataProvider = Vit.AutoTemp.AutoTempHelp.GetDataProvider(template);
-                if (dataProvider == null) return new SsError { errorMessage = "模板不存在" };
-
-                return dataProvider.getList(this, filter_, sort_, page_, arg_);
-            }
-            catch (System.Exception ex)
-            {
-                return (SsError)ex.GetBaseException();
-            }
-        }
-
-        #endregion
-
-        #region (x.3) getModel
-        /// <summary>
-        /// GET autoTemp/getModel
-        /// </summary>
-        /// <returns></returns>
-        [HttpGet("{template}/getModel")]
-        public ApiReturn getModel(string template, [FromQuery] string id)
-        {
-            try
-            {
-                var dataProvider = Vit.AutoTemp.AutoTempHelp.GetDataProvider(template);
-                if (dataProvider == null) return new SsError { errorMessage = "模板不存在" };
-
-                return dataProvider.getModel(this, id);
-            }
-            catch (System.Exception ex)
-            {
-                return (SsError)ex.GetBaseException();
-            }
-        }
-        #endregion
-
-
-
-        #region (x.4) insert
-        /// <summary>
-        /// POST autoTemp/insert
-        /// </summary>
-        /// <returns></returns>
-        [HttpPost("{template}/insert")]
-        public ApiReturn insert(string template, [FromBody] JObject model)
-        {
-            try
-            {
-                var dataProvider = Vit.AutoTemp.AutoTempHelp.GetDataProvider(template);
-                if (dataProvider == null) return new SsError { errorMessage = "模板不存在" };
-
-                return dataProvider.insert(this, model);
-            }
-            catch (System.Exception ex)
-            {
-                return (SsError)ex.GetBaseException();
-            }
-        }
-        #endregion
-
-
-
-        #region (x.5) update
-        /// <summary>
-        /// PUT autoTemp/update
-        /// </summary>
-        /// <returns></returns>
-        [HttpPut("{template}/update")]
-        public ApiReturn update(string template, [FromBody] JObject model)
-        {
-            try
-            {
-                var dataProvider = Vit.AutoTemp.AutoTempHelp.GetDataProvider(template);
-                if (dataProvider == null) return new SsError { errorMessage = "模板不存在" };
-
-                return dataProvider.update(this, model);
-            }
-            catch (System.Exception ex)
-            {
-                return (SsError)ex.GetBaseException();
-            }
-        }
-        #endregion
-
-
-        #region (x.6) delete
-        /// <summary>
-        /// DELETE autoTemp/delete
-        /// </summary>
-        /// <returns></returns>
-        [HttpDelete("{template}/delete")]
-        public ApiReturn delete(string template, [FromBody] JObject arg)
-        {
-            try
-            {
-                var dataProvider = Vit.AutoTemp.AutoTempHelp.GetDataProvider(template);
-                if (dataProvider == null) return new SsError { errorMessage = "模板不存在" };
-
-                return dataProvider.delete(this, arg);
-            }
-            catch (System.Exception ex)
-            {
-                return (SsError)ex.GetBaseException();
-            }
-        }
-        #endregion 
-    }
-}

+ 0 - 12
Vit.AutoTemp/Vit.AutoTemp.csproj

@@ -13,18 +13,6 @@
     </PropertyGroup>
 
 
-    <ItemGroup>
-        <Compile Remove="Controllers\**" />
-        <Compile Remove="DataProvider\Ef\**" />
-        <EmbeddedResource Remove="Controllers\**" />
-        <EmbeddedResource Remove="DataProvider\Ef\**" />
-        <None Remove="Controllers\**" />
-        <None Remove="DataProvider\Ef\**" />
-    </ItemGroup>
-
-
-
-
     <ItemGroup>
         <ProjectReference Include="..\..\Vit.Db\src\Vit.Db\Vit.Db\Vit.Db.csproj" />
         <ProjectReference Include="..\..\VitormLib\Vitorm\src\Vitorm\Vitorm.csproj" />