-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
570 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
148 changes: 148 additions & 0 deletions
148
SQLBuilder.Diagnostics/Diagnostics/SqlBuilderDiagnosticMessage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
#region License | ||
/*** | ||
* Copyright © 2018-2025, 张强 (943620963@qq.com). | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* without warranties or conditions of any kind, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#endregion | ||
|
||
using SQLBuilder.Enums; | ||
using System; | ||
using System.Data.Common; | ||
|
||
namespace SQLBuilder.Diagnostics.Diagnostics | ||
{ | ||
/// <summary> | ||
/// SqlBuilder日志诊断执行前消息 | ||
/// </summary> | ||
public class SqlBuilderDiagnosticBeforeMessage | ||
{ | ||
/// <summary> | ||
/// sql语句 | ||
/// </summary> | ||
public string Sql { get; set; } | ||
|
||
/// <summary> | ||
/// json参数 | ||
/// </summary> | ||
public string ParameterJson { get; set; } | ||
|
||
/// <summary> | ||
/// 数据库类型 | ||
/// </summary> | ||
public DatabaseType DatabaseType { get; set; } | ||
|
||
/// <summary> | ||
/// 数据源 | ||
/// </summary> | ||
public string DataSource { get; set; } | ||
|
||
/// <summary> | ||
/// 时间戳 | ||
/// </summary> | ||
public long? Timespan { get; set; } | ||
|
||
/// <summary> | ||
/// 操作id | ||
/// </summary> | ||
public string OperationId { get; set; } | ||
|
||
/// <summary> | ||
/// 执行时间 | ||
/// </summary> | ||
public DateTime ExecuteBefore { get; set; } | ||
} | ||
|
||
/// <summary> | ||
/// SqlBuilder日志诊断执行后消息 | ||
/// </summary> | ||
public class SqlBuilderDiagnosticAfterMessage | ||
{ | ||
/// <summary> | ||
/// sql语句 | ||
/// </summary> | ||
public string Sql { get; set; } | ||
|
||
/// <summary> | ||
/// json参数 | ||
/// </summary> | ||
public string ParameterJson { get; set; } | ||
|
||
/// <summary> | ||
/// 数据源 | ||
/// </summary> | ||
public string DataSource { get; set; } | ||
|
||
/// <summary> | ||
/// 操作id | ||
/// </summary> | ||
public string OperationId { get; set; } | ||
|
||
/// <summary> | ||
/// 耗时(ms) | ||
/// </summary> | ||
public long? ElapsedMilliseconds { get; set; } | ||
|
||
/// <summary> | ||
/// 执行时间 | ||
/// </summary> | ||
public DateTime ExecuteAfter { get; set; } | ||
} | ||
|
||
/// <summary> | ||
/// SqlBuilder日志诊断执行异常消息 | ||
/// </summary> | ||
public class SqlBuilderDiagnosticErrorMessage | ||
{ | ||
/// <summary> | ||
/// 异常 | ||
/// </summary> | ||
public Exception Exception { get; set; } | ||
|
||
/// <summary> | ||
/// 操作id | ||
/// </summary> | ||
public string OperationId { get; set; } | ||
|
||
/// <summary> | ||
/// 耗时(ms) | ||
/// </summary> | ||
public long? ElapsedMilliseconds { get; set; } | ||
|
||
/// <summary> | ||
/// 执行时间 | ||
/// </summary> | ||
public DateTime ExecuteError { get; set; } | ||
} | ||
|
||
/// <summary> | ||
/// SqlBuilder日志诊断执行数据库连接释放消息 | ||
/// </summary> | ||
public class SqlBuilderDiagnosticDisposeMessage | ||
{ | ||
/// <summary> | ||
/// 主库数据库连接对象 | ||
/// </summary> | ||
public DbConnection MasterConnection { get; set; } | ||
|
||
/// <summary> | ||
/// 从库数据库连接对象 | ||
/// </summary> | ||
public DbConnection SalveConnection { get; set; } | ||
|
||
/// <summary> | ||
/// 执行时间 | ||
/// </summary> | ||
public DateTime ExecuteDispose { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#region License | ||
/*** | ||
* Copyright © 2018-2025, 张强 (943620963@qq.com). | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* without warranties or conditions of any kind, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#endregion | ||
|
||
using System; | ||
|
||
namespace SQLBuilder.Diagnostics.Diagnostics | ||
{ | ||
/// <summary> | ||
/// IObserver泛型实现类 | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
public class SqlBuilderObserver<T> : IObserver<T> | ||
{ | ||
private readonly Action<T> _next; | ||
|
||
/// <summary> | ||
/// 构造函数 | ||
/// </summary> | ||
/// <param name="next"></param> | ||
public SqlBuilderObserver(Action<T> next) | ||
{ | ||
_next = next; | ||
} | ||
|
||
/// <summary> | ||
/// 完成 | ||
/// </summary> | ||
public void OnCompleted() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// 出错 | ||
/// </summary> | ||
/// <param name="error"></param> | ||
public void OnError(Exception error) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// 下一步 | ||
/// </summary> | ||
/// <param name="value"></param> | ||
public void OnNext(T value) => _next(value); | ||
} | ||
} |
Oops, something went wrong.