From c194f352aa673fc8467ea78807ff07f22e8af034 Mon Sep 17 00:00:00 2001 From: d4ilys <963922242@com> Date: Sat, 30 Nov 2024 11:22:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86CoreErrorStrings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FreeSql/FreeSqlBuilder.cs | 5 +++++ .../Curd/TDengineDelete.cs | 4 ++-- .../TDengineAdo/TDengineAdo.cs | 8 ++++---- .../TDengineAdo/TDengineConnectionPool.cs | 10 +++++----- .../TDengineCodeFirst.cs | 4 ++-- .../TDengineDbFirst.cs | 20 +++++++++---------- .../TDengineExpression.cs | 2 +- .../TDengineProvider.cs | 4 ++-- 8 files changed, 31 insertions(+), 26 deletions(-) diff --git a/FreeSql/FreeSqlBuilder.cs b/FreeSql/FreeSqlBuilder.cs index 6f5afd90a..90f626dcb 100644 --- a/FreeSql/FreeSqlBuilder.cs +++ b/FreeSql/FreeSqlBuilder.cs @@ -385,6 +385,11 @@ namespace FreeSql if (type == null) throwNotFind("FreeSql.Provider.Duckdb.dll", "FreeSql.Duckdb.DuckdbProvider<>"); break; + case DataType.TDengine: + type = Type.GetType("FreeSql.TDengine.TDengineProvider`1,FreeSql.Provider.TDengine")?.MakeGenericType(typeof(TMark)); + if (type == null) throwNotFind("FreeSql.Provider.TDengine.dll", "FreeSql.TDengine.TDengineProvider<>"); + break; + default: throw new Exception(CoreErrorStrings.NotSpecified_UseConnectionString_UseConnectionFactory); } } diff --git a/Providers/FreeSql.Provider.TDengine/Curd/TDengineDelete.cs b/Providers/FreeSql.Provider.TDengine/Curd/TDengineDelete.cs index 41dc35451..b1acc558c 100644 --- a/Providers/FreeSql.Provider.TDengine/Curd/TDengineDelete.cs +++ b/Providers/FreeSql.Provider.TDengine/Curd/TDengineDelete.cs @@ -16,11 +16,11 @@ namespace FreeSql.TDengine.Curd { } - public override List ExecuteDeleted() => throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreStrings.S_Not_Implemented_Feature}"); + public override List ExecuteDeleted() => throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}"); #if net40 #else - public override Task> ExecuteDeletedAsync(CancellationToken cancellationToken = default) => throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreStrings.S_Not_Implemented_Feature}"); + public override Task> ExecuteDeletedAsync(CancellationToken cancellationToken = default) => throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}"); #endif } } diff --git a/Providers/FreeSql.Provider.TDengine/TDengineAdo/TDengineAdo.cs b/Providers/FreeSql.Provider.TDengine/TDengineAdo/TDengineAdo.cs index bdc5f213c..1dcf404b9 100644 --- a/Providers/FreeSql.Provider.TDengine/TDengineAdo/TDengineAdo.cs +++ b/Providers/FreeSql.Provider.TDengine/TDengineAdo/TDengineAdo.cs @@ -32,16 +32,16 @@ namespace FreeSql.TDengine if (isAdoPool) masterConnectionString = masterConnectionString.Substring("AdoConnectionPool,".Length); if (!string.IsNullOrEmpty(masterConnectionString)) MasterPool = isAdoPool - ? new DbConnectionStringPool(base.DataType, CoreStrings.S_MasterDatabase, + ? new DbConnectionStringPool(base.DataType, CoreErrorStrings.S_MasterDatabase, () => new TDengineConnection(masterConnectionString)) as IObjectPool - : new TDengineConnectionPool(CoreStrings.S_MasterDatabase, masterConnectionString, null, null); + : new TDengineConnectionPool(CoreErrorStrings.S_MasterDatabase, masterConnectionString, null, null); slaveConnectionStrings?.ToList().ForEach(slaveConnectionString => { var slavePool = isAdoPool - ? new DbConnectionStringPool(base.DataType, $"{CoreStrings.S_SlaveDatabase}{SlavePools.Count + 1}", + ? new DbConnectionStringPool(base.DataType, $"{CoreErrorStrings.S_SlaveDatabase}{SlavePools.Count + 1}", () => new TDengineConnection(slaveConnectionString)) as IObjectPool - : new TDengineConnectionPool($"{CoreStrings.S_SlaveDatabase}{SlavePools.Count + 1}", + : new TDengineConnectionPool($"{CoreErrorStrings.S_SlaveDatabase}{SlavePools.Count + 1}", slaveConnectionString, () => Interlocked.Decrement(ref slaveUnavailables), () => Interlocked.Increment(ref slaveUnavailables)); SlavePools.Add(slavePool); diff --git a/Providers/FreeSql.Provider.TDengine/TDengineAdo/TDengineConnectionPool.cs b/Providers/FreeSql.Provider.TDengine/TDengineAdo/TDengineConnectionPool.cs index 4741555d6..15042e265 100644 --- a/Providers/FreeSql.Provider.TDengine/TDengineAdo/TDengineConnectionPool.cs +++ b/Providers/FreeSql.Provider.TDengine/TDengineAdo/TDengineConnectionPool.cs @@ -40,7 +40,7 @@ namespace FreeSql.TDengine internal class TDengineConnectionPoolPolicy : IPolicy { internal TDengineConnectionPool InternalPool; - public string Name { get; set; } = $"TDengine Connection {CoreStrings.S_ObjectPool}"; + public string Name { get; set; } = $"TDengine Connection {CoreErrorStrings.S_ObjectPool}"; public int PoolSize { get; set; } = 50; public TimeSpan SyncGetTimeout { get; set; } = TimeSpan.FromSeconds(10); public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(20); @@ -117,9 +117,9 @@ namespace FreeSql.TDengine { if (obj.Value == null) { - InternalPool.SetUnavailable(new Exception(CoreStrings.S_ConnectionStringError), + InternalPool.SetUnavailable(new Exception(CoreErrorStrings.S_ConnectionStringError), obj.LastGetTimeCopy); - throw new Exception(CoreStrings.S_ConnectionStringError_Check(this.Name)); + throw new Exception(CoreErrorStrings.S_ConnectionStringError_Check(this.Name)); } if (obj.Value.State != ConnectionState.Open || @@ -147,9 +147,9 @@ namespace FreeSql.TDengine { if (obj.Value == null) { - InternalPool.SetUnavailable(new Exception(CoreStrings.S_ConnectionStringError), + InternalPool.SetUnavailable(new Exception(CoreErrorStrings.S_ConnectionStringError), obj.LastGetTimeCopy); - throw new Exception(CoreStrings.S_ConnectionStringError_Check(this.Name)); + throw new Exception(CoreErrorStrings.S_ConnectionStringError_Check(this.Name)); } if (obj.Value.State != ConnectionState.Open || diff --git a/Providers/FreeSql.Provider.TDengine/TDengineCodeFirst.cs b/Providers/FreeSql.Provider.TDengine/TDengineCodeFirst.cs index 2ddd56365..981d0715b 100644 --- a/Providers/FreeSql.Provider.TDengine/TDengineCodeFirst.cs +++ b/Providers/FreeSql.Provider.TDengine/TDengineCodeFirst.cs @@ -86,10 +86,10 @@ namespace FreeSql.TDengine if (sb.Length > 0) sb.Append(Environment.NewLine); var tb = obj.tableSchema; if (tb == null) - throw new Exception(CoreStrings.S_Type_IsNot_Migrable(obj.tableSchema.Type.FullName)); + throw new Exception(CoreErrorStrings.S_Type_IsNot_Migrable(obj.tableSchema.Type.FullName)); if (tb.Columns.Any() == false) throw new Exception( - CoreStrings.S_Type_IsNot_Migrable_0Attributes(obj.tableSchema.Type.FullName)); + CoreErrorStrings.S_Type_IsNot_Migrable_0Attributes(obj.tableSchema.Type.FullName)); var tbName = _commonUtils.SplitTableName(tb.DbName).First(); diff --git a/Providers/FreeSql.Provider.TDengine/TDengineDbFirst.cs b/Providers/FreeSql.Provider.TDengine/TDengineDbFirst.cs index 5151899b7..d9d1f9c35 100644 --- a/Providers/FreeSql.Provider.TDengine/TDengineDbFirst.cs +++ b/Providers/FreeSql.Provider.TDengine/TDengineDbFirst.cs @@ -32,12 +32,12 @@ namespace FreeSql.TDengine public List GetTablesByDatabase(params string[] database) { - throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreStrings.S_Not_Implemented_Feature}"); + throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}"); } public DbTableInfo GetTableByName(string name, bool ignoreCase = true) { - throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreStrings.S_Not_Implemented_Feature}"); + throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}"); } public bool ExistsTable(string name, bool ignoreCase = true) @@ -80,7 +80,7 @@ namespace FreeSql.TDengine public string GetCsConvert(DbColumnInfo column) { - throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreStrings.S_Not_Implemented_Feature}"); + throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}"); //return _dicDbToCs.TryGetValue(column.DbType, out var trydc) // ? (column.IsNullable ? trydc.csConvert : trydc.csConvert.Replace("?", "")) // : null; @@ -88,20 +88,20 @@ namespace FreeSql.TDengine public string GetCsParse(DbColumnInfo column) { - throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreStrings.S_Not_Implemented_Feature}"); + throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}"); //return _dicDbToCs.TryGetValue(column.DbType, out var trydc) ? trydc.csParse : null; } public string GetCsStringify(DbColumnInfo column) { - throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreStrings.S_Not_Implemented_Feature}"); + throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}"); //return _dicDbToCs.TryGetValue(column.DbType, out var trydc) ? trydc.csStringify : null; } public string GetCsType(DbColumnInfo column) { - throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreStrings.S_Not_Implemented_Feature}"); + throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}"); //return _dicDbToCs.TryGetValue(column.DbType, out var trydc) // ? (column.IsNullable ? trydc.csType : trydc.csType.Replace("?", "")) // : null; @@ -109,26 +109,26 @@ namespace FreeSql.TDengine public Type GetCsTypeInfo(DbColumnInfo column) { - throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreStrings.S_Not_Implemented_Feature}"); + throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}"); //return _dicDbToCs.TryGetValue(column.DbType, out var trydc) ? trydc.csTypeInfo : null; } public string GetCsTypeValue(DbColumnInfo column) { - throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreStrings.S_Not_Implemented_Feature}"); + throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}"); //return _dicDbToCs.TryGetValue(column.DbType, out var trydc) ? trydc.csTypeValue : null; } public string GetDataReaderMethod(DbColumnInfo column) { - throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreStrings.S_Not_Implemented_Feature}"); + throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}"); //return _dicDbToCs.TryGetValue(column.DbType, out var trydc) ? trydc.dataReaderMethod : null; } public List GetEnumsByDatabase(params string[] database) { - throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreStrings.S_Not_Implemented_Feature}"); + throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}"); } } } \ No newline at end of file diff --git a/Providers/FreeSql.Provider.TDengine/TDengineExpression.cs b/Providers/FreeSql.Provider.TDengine/TDengineExpression.cs index 8b0167fc3..4207dd431 100644 --- a/Providers/FreeSql.Provider.TDengine/TDengineExpression.cs +++ b/Providers/FreeSql.Provider.TDengine/TDengineExpression.cs @@ -314,7 +314,7 @@ namespace FreeSql.TDengine return _common.StringConcat(concatNewArrExp.Expressions.Select(a => getExp(a)).ToArray(), null); return _common.StringConcat(exp.Arguments.Select(a => getExp(a)).ToArray(), null); case "Format": - if (exp.Arguments[0].NodeType != ExpressionType.Constant) throw new Exception(CoreStrings.Not_Implemented_Expression_ParameterUseConstant(exp, exp.Arguments[0])); + if (exp.Arguments[0].NodeType != ExpressionType.Constant) throw new Exception(CoreErrorStrings.Not_Implemented_Expression_ParameterUseConstant(exp, exp.Arguments[0])); var expArgsHack = exp.Arguments.Count == 2 && exp.Arguments[1].NodeType == ExpressionType.NewArrayInit ? (exp.Arguments[1] as NewArrayExpression).Expressions : exp.Arguments.Where((a, z) => z > 0); //3个 {} 时,Arguments 解析出来是分开的 diff --git a/Providers/FreeSql.Provider.TDengine/TDengineProvider.cs b/Providers/FreeSql.Provider.TDengine/TDengineProvider.cs index 185214091..ddb8c64fc 100644 --- a/Providers/FreeSql.Provider.TDengine/TDengineProvider.cs +++ b/Providers/FreeSql.Provider.TDengine/TDengineProvider.cs @@ -75,7 +75,7 @@ namespace FreeSql.TDengine public override IUpdate CreateUpdateProvider(object dywhere) { - throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreStrings.S_Not_Implemented_Feature}"); + throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}"); } public override IDelete CreateDeleteProvider(object dywhere) @@ -85,7 +85,7 @@ namespace FreeSql.TDengine public override IInsertOrUpdate CreateInsertOrUpdateProvider() { - throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreStrings.S_Not_Implemented_Feature}"); + throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}"); } ~TDengineProvider() => this.Dispose();