|
@@ -1,5 +1,5 @@
|
|
|
-using YSAI.Model.data;
|
|
|
|
|
-using YSAI.Log;
|
|
|
|
|
|
|
+using YSAI.Log;
|
|
|
|
|
+using YSAI.Model.data;
|
|
|
using YSAI.Unility;
|
|
using YSAI.Unility;
|
|
|
|
|
|
|
|
namespace YSAI.Model.@interface
|
|
namespace YSAI.Model.@interface
|
|
@@ -56,12 +56,13 @@ namespace YSAI.Model.@interface
|
|
|
/// <param name="Message">消息</param>
|
|
/// <param name="Message">消息</param>
|
|
|
/// <param name="RData">结果值</param>
|
|
/// <param name="RData">结果值</param>
|
|
|
/// <param name="Exception">异常对象</param>
|
|
/// <param name="Exception">异常对象</param>
|
|
|
|
|
+ /// <param name="ConsoleShow">控制台显示</param>
|
|
|
/// <returns>统一结果</returns>
|
|
/// <returns>统一结果</returns>
|
|
|
- protected Task<OperateResult> BreakAsync(string MethodName, bool State, string? Message = null, object? RData = null, @enum.ResultType RType = @enum.ResultType.Null, Exception? Exception = null)
|
|
|
|
|
|
|
+ protected Task<OperateResult> BreakAsync(string MethodName, bool State, string? Message = null, object? RData = null, @enum.ResultType RType = @enum.ResultType.Null, Exception? Exception = null, bool ConsoleShow = true)
|
|
|
{
|
|
{
|
|
|
return Task.Run(() =>
|
|
return Task.Run(() =>
|
|
|
{
|
|
{
|
|
|
- return Break(MethodName, State, Message, RData, RType, Exception);
|
|
|
|
|
|
|
+ return Break(MethodName, State, Message, RData, RType, Exception, ConsoleShow);
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -73,15 +74,16 @@ namespace YSAI.Model.@interface
|
|
|
/// <param name="Message">消息</param>
|
|
/// <param name="Message">消息</param>
|
|
|
/// <param name="RData">结果值</param>
|
|
/// <param name="RData">结果值</param>
|
|
|
/// <param name="Exception">异常对象</param>
|
|
/// <param name="Exception">异常对象</param>
|
|
|
|
|
+ /// <param name="ConsoleShow">控制台显示</param>
|
|
|
/// <returns>统一结果</returns>
|
|
/// <returns>统一结果</returns>
|
|
|
- protected OperateResult Break(string MethodName, bool State, string? Message = null, object? RData = null, @enum.ResultType RType = @enum.ResultType.Null, Exception? Exception = null)
|
|
|
|
|
|
|
+ protected OperateResult Break(string MethodName, bool State, string? Message = null, object? RData = null, @enum.ResultType RType = @enum.ResultType.Null, Exception? Exception = null, bool ConsoleShow = true)
|
|
|
{
|
|
{
|
|
|
//返回运行时间(毫秒)
|
|
//返回运行时间(毫秒)
|
|
|
int runTime = TimeTool.Instance($"{TAG}.{MethodName}").StopRecord().milliseconds;
|
|
int runTime = TimeTool.Instance($"{TAG}.{MethodName}").StopRecord().milliseconds;
|
|
|
//消息数据组织
|
|
//消息数据组织
|
|
|
string message = $"[ {TAG} ]( {MethodName} {(State ? "成功" : "异常")} ){(string.IsNullOrEmpty(Message) ? string.Empty : $" : {Message}")}";
|
|
string message = $"[ {TAG} ]( {MethodName} {(State ? "成功" : "异常")} ){(string.IsNullOrEmpty(Message) ? string.Empty : $" : {Message}")}";
|
|
|
//异常则输出日志
|
|
//异常则输出日志
|
|
|
- if (!State) { LogHelper.Error(message, $"{TAG}/{MethodName}.log", Exception); }
|
|
|
|
|
|
|
+ if (!State) { LogHelper.Error(message, $"{TAG}/{MethodName}.log", Exception, ConsoleShow); }
|
|
|
//返回状态
|
|
//返回状态
|
|
|
return new OperateResult(State, message, runTime, RData, RType);
|
|
return new OperateResult(State, message, runTime, RData, RType);
|
|
|
}
|
|
}
|
|
@@ -91,12 +93,13 @@ namespace YSAI.Model.@interface
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
/// <param name="MethodName">方法名</param>
|
|
/// <param name="MethodName">方法名</param>
|
|
|
/// <param name="result">结果</param>
|
|
/// <param name="result">结果</param>
|
|
|
|
|
+ /// <param name="ConsoleShow">控制台显示</param>
|
|
|
/// <returns>统一结果</returns>
|
|
/// <returns>统一结果</returns>
|
|
|
- protected Task<OperateResult> BreakAsync(string MethodName, OperateResult result)
|
|
|
|
|
|
|
+ protected Task<OperateResult> BreakAsync(string MethodName, OperateResult result, bool ConsoleShow = true)
|
|
|
{
|
|
{
|
|
|
return Task.Run(() =>
|
|
return Task.Run(() =>
|
|
|
{
|
|
{
|
|
|
- return Break(MethodName, result);
|
|
|
|
|
|
|
+ return Break(MethodName, result, ConsoleShow);
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -105,15 +108,16 @@ namespace YSAI.Model.@interface
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
/// <param name="MethodName">方法名</param>
|
|
/// <param name="MethodName">方法名</param>
|
|
|
/// <param name="result">结果</param>
|
|
/// <param name="result">结果</param>
|
|
|
|
|
+ /// <param name="ConsoleShow">控制台显示</param>
|
|
|
/// <returns>统一结果</returns>
|
|
/// <returns>统一结果</returns>
|
|
|
- protected OperateResult Break(string MethodName, OperateResult result)
|
|
|
|
|
|
|
+ protected OperateResult Break(string MethodName, OperateResult result, bool ConsoleShow = true)
|
|
|
{
|
|
{
|
|
|
//返回运行时间(毫秒)
|
|
//返回运行时间(毫秒)
|
|
|
int runTime = TimeTool.Instance($"{TAG}.{MethodName}").StopRecord().milliseconds;
|
|
int runTime = TimeTool.Instance($"{TAG}.{MethodName}").StopRecord().milliseconds;
|
|
|
//消息数据组织
|
|
//消息数据组织
|
|
|
string message = $"[ {TAG} ]( {MethodName} {(result.State ? "成功" : "异常")} ){(string.IsNullOrEmpty(result.Message) ? string.Empty : $" : {result.Message}")}";
|
|
string message = $"[ {TAG} ]( {MethodName} {(result.State ? "成功" : "异常")} ){(string.IsNullOrEmpty(result.Message) ? string.Empty : $" : {result.Message}")}";
|
|
|
//异常则输出日志
|
|
//异常则输出日志
|
|
|
- if (!result.State) { LogHelper.Error(message, $"{TAG}/{MethodName}.log"); }
|
|
|
|
|
|
|
+ if (!result.State) { LogHelper.Error(message, $"{TAG}/{MethodName}.log", consoleShow: ConsoleShow); }
|
|
|
//返回状态
|
|
//返回状态
|
|
|
return new OperateResult(result.State, message, runTime, result.RData, result.RType);
|
|
return new OperateResult(result.State, message, runTime, result.RData, result.RType);
|
|
|
}
|
|
}
|