parent
624f584072
commit
9a8df6679a
|
@ -1,4 +1,5 @@
|
|||
using Longbow.Tasks;
|
||||
using Bootstrap.DataAccess;
|
||||
using Longbow.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Collections.Generic;
|
||||
|
@ -34,6 +35,13 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
{
|
||||
var sche = TaskServicesManager.Get(scheName);
|
||||
if (sche != null) sche.Status = operType == "pause" ? SchedulerStatus.Disabled : SchedulerStatus.Running;
|
||||
|
||||
// SQL 日志任务特殊处理
|
||||
if (scheName == "SQL日志")
|
||||
{
|
||||
if (operType == "pause") LogHelper.Pause();
|
||||
else LogHelper.Run();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,12 +49,23 @@ namespace Bootstrap.DataAccess
|
|||
/// <param name="log"></param>
|
||||
public static System.Threading.Tasks.Task AddDBLog(DBLog log) => System.Threading.Tasks.Task.Run(() =>
|
||||
{
|
||||
if (!_messageQueue.IsAddingCompleted)
|
||||
if (!_messageQueue.IsAddingCompleted && !_pause)
|
||||
{
|
||||
_messageQueue.Add(log);
|
||||
}
|
||||
});
|
||||
|
||||
private static bool _pause;
|
||||
/// <summary>
|
||||
/// 暂停接收脚本执行日志
|
||||
/// </summary>
|
||||
public static void Pause() => _pause = true;
|
||||
|
||||
/// <summary>
|
||||
/// 开始接收脚本执行日志
|
||||
/// </summary>
|
||||
public static void Run() => _pause = false;
|
||||
|
||||
/// <summary>
|
||||
/// 查询所有SQL日志信息
|
||||
/// </summary>
|
||||
|
@ -80,7 +91,8 @@ namespace Bootstrap.DataAccess
|
|||
var logs = new List<DBLog>();
|
||||
while (_messageQueue.TryTake(out var log))
|
||||
{
|
||||
logs.Add(log);
|
||||
if (log != null) logs.Add(log);
|
||||
if (logs.Count >= 100) break;
|
||||
}
|
||||
if (logs.Any())
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue