commit
b112e5ab6e
|
@ -330,6 +330,12 @@
|
|||
"Code": "0",
|
||||
"Define": NumberInt(0)
|
||||
},
|
||||
{
|
||||
"Category": "网站设置",
|
||||
"Name": "健康检查",
|
||||
"Code": "0",
|
||||
"Define": NumberInt(0)
|
||||
},
|
||||
{
|
||||
"Category": "网站设置",
|
||||
"Name": "默认应用程序",
|
||||
|
|
|
@ -45,6 +45,9 @@ INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('网站设置', '自动
|
|||
-- 是否启用 Blazor 默认为 0 未启用
|
||||
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('网站设置', 'Blazor', '0', 0);
|
||||
|
||||
-- 是否启用 健康检查 默认为 0 未启用 1 启用
|
||||
INSERT INTO Dicts (Category, Name, Code, Define) Values ('网站设置', '健康检查', '1', 0);
|
||||
|
||||
-- 时长单位 月
|
||||
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('网站设置', '程序异常保留时长', '1', 0);
|
||||
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('网站设置', '操作日志保留时长', '12', 0);
|
||||
|
|
|
@ -45,6 +45,9 @@ INSERT INTO Dicts (Id, Category, Name, Code, Define) Values (SEQ_DICTS_ID.NEXTVA
|
|||
-- 是否启用 Blazor 默认为 0 未启用
|
||||
INSERT INTO Dicts (Id, Category, Name, Code, Define) Values (SEQ_DICTS_ID.NEXTVAL, '网站设置', 'Blazor', '0', 0);
|
||||
|
||||
-- 是否启用 健康检查 默认为 0 未启用 1 启用
|
||||
INSERT INTO Dicts (Id, Category, Name, Code, Define) Values (SEQ_DICTS_ID.NEXTVAL, '网站设置', '健康检查', '1', 0);
|
||||
|
||||
-- 时长单位 月
|
||||
INSERT INTO Dicts (Id, Category, Name, Code, Define) Values (SEQ_DICTS_ID.NEXTVAL, '网站设置', '程序异常保留时长', '1', 0);
|
||||
INSERT INTO Dicts (Id, Category, Name, Code, Define) Values (SEQ_DICTS_ID.NEXTVAL, '网站设置', '操作日志保留时长', '12', 0);
|
||||
|
|
|
@ -45,6 +45,9 @@ INSERT INTO [Dicts] ([Category], [Name], [Code], [Define]) VALUES ('网站设置
|
|||
-- 是否启用 Blazor 默认为 0 未启用
|
||||
INSERT INTO [Dicts] ([Category], [Name], [Code], [Define]) VALUES ('网站设置', 'Blazor', '0', 0);
|
||||
|
||||
-- 是否启用 健康检查 默认为 0 未启用 1 启用
|
||||
INSERT INTO [Dicts] ([Category], [Name], [Code], [Define]) VALUES ('网站设置', '健康检查', '1', 0);
|
||||
|
||||
-- 时长单位 月
|
||||
INSERT INTO [Dicts] ([Category], [Name], [Code], [Define]) VALUES ('网站设置', '程序异常保留时长', '1', 0);
|
||||
INSERT INTO [Dicts] ([Category], [Name], [Code], [Define]) VALUES ('网站设置', '操作日志保留时长', '12', 0);
|
||||
|
|
|
@ -48,6 +48,9 @@ INSERT [dbo].[Dicts] ([Category], [Name], [Code], [Define]) VALUES (N'网站设
|
|||
-- 是否启用 Blazor 默认为 0 未启用
|
||||
INSERT [dbo].[Dicts] ([Category], [Name], [Code], [Define]) VALUES (N'网站设置', N'Blazor', N'0', 0)
|
||||
|
||||
-- 是否启用 健康检查 默认为 0 未启用 1 启用
|
||||
INSERT [dbo].[Dicts] ([Category], [Name], [Code], [Define]) VALUES (N'网站设置', N'健康检查', N'1', 0);
|
||||
|
||||
-- 时长单位 月
|
||||
INSERT [dbo].[Dicts] ([Category], [Name], [Code], [Define]) VALUES (N'网站设置', N'程序异常保留时长', '1', 0)
|
||||
INSERT [dbo].[Dicts] ([Category], [Name], [Code], [Define]) VALUES (N'网站设置', N'操作日志保留时长', '12', 0)
|
||||
|
|
Binary file not shown.
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.AspNetCore.Authorization;
|
||||
using Bootstrap.DataAccess;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System.Net.Http;
|
||||
|
@ -26,7 +27,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
{
|
||||
var ret = false;
|
||||
var url = config.GetValue("HealthsCloudUrl", "");
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
if (!string.IsNullOrEmpty(url) && DictHelper.RetrieveHealth())
|
||||
{
|
||||
await httpClient.HttpClient.PostAsJsonAsync(url, message);
|
||||
ret = true;
|
||||
|
|
|
@ -79,7 +79,8 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
"超时任务",
|
||||
"取消任务",
|
||||
"禁用任务",
|
||||
"SQL日志"
|
||||
"SQL日志",
|
||||
"健康检查"
|
||||
};
|
||||
/// <summary>
|
||||
/// 删除任务方法
|
||||
|
|
|
@ -31,6 +31,7 @@ namespace Bootstrap.Admin.Models
|
|||
IPCachePeriod = DictHelper.RetrieveLocaleIPSvrCachePeriod();
|
||||
EnableDemo = DictHelper.RetrieveSystemModel();
|
||||
AdminPathBase = DictHelper.RetrievePathBase();
|
||||
EnableHealth = DictHelper.RetrieveHealth();
|
||||
|
||||
var dicts = DictHelper.RetrieveDicts();
|
||||
Apps = DictHelper.RetrieveApps().Where(d => !d.Key.Equals("BA", StringComparison.OrdinalIgnoreCase)).Select(k =>
|
||||
|
@ -109,5 +110,10 @@ namespace Bootstrap.Admin.Models
|
|||
/// 获得/设置 系统应用程序集合
|
||||
/// </summary>
|
||||
public IEnumerable<(string Key, string Name, string Url)> Apps { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 是否开启健康检查
|
||||
/// </summary>
|
||||
public bool EnableHealth { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Mvc.Versioning;
|
|||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System;
|
||||
|
||||
|
@ -129,7 +130,10 @@ namespace Bootstrap.Admin
|
|||
{
|
||||
endpoints.MapHub<SignalRHub>("/NotiHub");
|
||||
endpoints.MapHub<TaskLogHub>("/TaskLogHub");
|
||||
endpoints.MapBootstrapHealthChecks();
|
||||
endpoints.MapBootstrapHealthChecks("/Healths", configure: op =>
|
||||
{
|
||||
op.Predicate = new Func<HealthCheckRegistration, bool>(reg => DictHelper.RetrieveHealth());
|
||||
});
|
||||
endpoints.MapBlazorHub();
|
||||
endpoints.MapFallbackToPage("/_Host");
|
||||
endpoints.MapDefaultControllerRoute();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Bootstrap.DataAccess;
|
||||
using Bootstrap.Security;
|
||||
using Longbow.Tasks;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System.Linq;
|
||||
|
@ -52,6 +53,16 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
|
||||
// 真实任务负责批次写入数据执行脚本到日志中
|
||||
TaskServicesManager.GetOrAdd<DBLogTask>("SQL日志", TriggerBuilder.Build(Cron.Minutely()));
|
||||
|
||||
// 真实人物负责周期性设置健康检查结果开关为开启
|
||||
TaskServicesManager.GetOrAdd("健康检查", token => Task.FromResult(DictHelper.SaveSettings(new BootstrapDict[] {
|
||||
new BootstrapDict() {
|
||||
Category = "网站设置",
|
||||
Name = "健康检查",
|
||||
Code = "1",
|
||||
Define = 0
|
||||
}
|
||||
})), TriggerBuilder.Build(Cron.Minutely(10)));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,6 +113,10 @@
|
|||
<label class="control-label" for="tableHeader">固定表头</label>
|
||||
<input id="tableHeader" hidden type="checkbox" data-default-val="@Model.FixedTableHeader" data-toggle="toggle" data-width="120" data-onstyle="success" data-on="固定" data-off="跟随" />
|
||||
</div>
|
||||
<div class="form-group col-6">
|
||||
<label class="control-label" for="health">健康检查</label>
|
||||
<input id="health" hidden type="checkbox" data-default-val="@Model.EnableHealth" data-toggle="toggle" data-width="120" data-onstyle="success" data-on="开启" data-off="关闭" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer text-right">
|
||||
|
|
|
@ -59,11 +59,13 @@ $(function () {
|
|||
var uiSettings = $('#sider').prop('checked') ? "1" : "0";
|
||||
var cardTitle = $('#cardTitle').prop('checked') ? "1" : "0";
|
||||
var fixedTableHeader = $('#tableHeader').prop('checked') ? "1" : "0";
|
||||
var enableHealth = $('#health').prop('checked') ? "1" : "0";
|
||||
$.bc({
|
||||
url: Settings.url, data: [
|
||||
{ name: 'ShowCardTitle', code: cardTitle },
|
||||
{ name: 'ShowSideBar', code: uiSettings },
|
||||
{ name: 'FixedTableHeader', code: fixedTableHeader }
|
||||
{ name: 'FixedTableHeader', code: fixedTableHeader },
|
||||
{ name: 'EnableHealth', code: enableHealth }
|
||||
], title: '保存网站设置', method: "post",
|
||||
callback: function (result) {
|
||||
if (result) {
|
||||
|
|
|
@ -319,5 +319,11 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string RetrievePathBase() => DictHelper.RetrieveDicts().FirstOrDefault(d => d.Category == "网站设置" && d.Name == "后台地址" && d.Define == 0)?.Code ?? "";
|
||||
|
||||
/// <summary>
|
||||
/// 获得字典表健康检查是否开启
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool RetrieveHealth() => (DictHelper.RetrieveDicts().FirstOrDefault(d => d.Category == "网站设置" && d.Name == "健康检查" && d.Define == 0)?.Code ?? "0") == "1";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -164,7 +164,8 @@ namespace Bootstrap.DataAccess
|
|||
["TraceLog"] = "访问日志保留时长",
|
||||
["CookiePeriod"] = "Cookie保留时长",
|
||||
["IPCachePeriod"] = "IP请求缓存时长",
|
||||
["AppPath"] = "后台地址"
|
||||
["AppPath"] = "后台地址",
|
||||
["EnableHealth"] = "健康检查"
|
||||
};
|
||||
var ret = SaveSettings(items.Where(i => cache.Any(c => c.Key == i.Name)).Select(i => new BootstrapDict()
|
||||
{
|
||||
|
@ -384,6 +385,12 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
public static string RetrievePathBase() => DbContextManager.Create<Dict>()?.RetrievePathBase() ?? "";
|
||||
|
||||
/// <summary>
|
||||
/// 获得字典表健康检查是否开启
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static bool RetrieveHealth() => DbContextManager.Create<Dict>()?.RetrieveHealth() ?? true;
|
||||
|
||||
/// <summary>
|
||||
/// 保存前台应用配置信息
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue