Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ae72d2e6b | ||
|
|
afea9c82bd | ||
|
|
e53048a980 |
@@ -1,14 +1,16 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using SimApi.Attributes;
|
using SimApi.Attributes;
|
||||||
using SimApi.CoceSdk;
|
|
||||||
using SimApi.Communications;
|
using SimApi.Communications;
|
||||||
|
using SimApi.Controllers;
|
||||||
using SimApi.Helpers;
|
using SimApi.Helpers;
|
||||||
|
|
||||||
namespace SimApi.Controllers;
|
namespace SimApi.CoceSdk;
|
||||||
|
|
||||||
public class SimApiCoceController(CoceApp coce,SimApiAuth auth) : SimApiBaseController
|
public class CoceController(CoceApp coce, SimApiAuth auth, IServiceProvider sp) : SimApiBaseController
|
||||||
{
|
{
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public SimApiBaseResponse<ConfigResponse> GetConfig()
|
public SimApiBaseResponse<ConfigResponse> GetConfig()
|
||||||
@@ -33,8 +35,9 @@ public class SimApiCoceController(CoceApp coce,SimApiAuth auth) : SimApiBaseCont
|
|||||||
{
|
{
|
||||||
Id = data.UserId,
|
Id = data.UserId,
|
||||||
Meta = meta,
|
Meta = meta,
|
||||||
Extra = groups
|
|
||||||
};
|
};
|
||||||
|
var processor = sp.GetService<ICoceLoginProcessor>();
|
||||||
|
processor?.Process(loginItem, groups.ToArray());
|
||||||
return new SimApiBaseResponse<string>(auth.Login(loginItem));
|
return new SimApiBaseResponse<string>(auth.Login(loginItem));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using SimApi.Communications;
|
||||||
|
|
||||||
|
namespace SimApi.CoceSdk;
|
||||||
|
|
||||||
|
public interface ICoceLoginProcessor
|
||||||
|
{
|
||||||
|
SimApiLoginItem Process(SimApiLoginItem loginItem, GroupInfo[] groups);
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
namespace SimApi.Configurations;
|
||||||
|
|
||||||
|
public class SimApiJobOptions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// WebUi地址,设置为null表示不启用
|
||||||
|
/// </summary>
|
||||||
|
public string? DashboardUrl { get; set; } = "/jobs";
|
||||||
|
|
||||||
|
public string DashboardAuthUser { get; set; } = "admin";
|
||||||
|
public string DashboardAuthPass { get; set; } = "Admin@123!";
|
||||||
|
public string? RedisConfiguration { get; set; }
|
||||||
|
|
||||||
|
public int? Database { get; set; } = null;
|
||||||
|
public SimApiJobServerConfig[] Servers { get; set; } = [new()];
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SimApiJobServerConfig()
|
||||||
|
{
|
||||||
|
public string[] Queues { get; set; } = ["default"];
|
||||||
|
public int WorkerNum { get; set; } = 50;
|
||||||
|
}
|
||||||
@@ -5,11 +5,12 @@ namespace SimApi.Configurations;
|
|||||||
|
|
||||||
public class SimApiOptions
|
public class SimApiOptions
|
||||||
{
|
{
|
||||||
|
public string? RedisConfiguration { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 启用全部Cors,对于开发前后分离的时候很有用。
|
/// 是否启用后台任务系统 *基于Hangfire
|
||||||
/// default: true
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableCors { get; set; } = true;
|
public bool EnableJob { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 启用SimApiAuth,一个简单的基于Header Token的认证方式。
|
/// 启用SimApiAuth,一个简单的基于Header Token的认证方式。
|
||||||
@@ -17,13 +18,16 @@ public class SimApiOptions
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableSimApiAuth { get; set; }
|
public bool EnableSimApiAuth { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否使用CoceSdk
|
/// 是否使用CoceSdk
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableCoceSdk { get; set; }
|
public bool EnableCoceSdk { get; set; }
|
||||||
|
|
||||||
public CoceAppSdkOption CoceSdkOptions { get; set; } = new();
|
/// <summary>
|
||||||
|
/// 开启S3兼容的存储系统。
|
||||||
|
/// default: false
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableSimApiStorage { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 启用在线文档,启用后 访问 /swagger 可以查看对应的api文档。
|
/// 启用在线文档,启用后 访问 /swagger 可以查看对应的api文档。
|
||||||
@@ -31,6 +35,20 @@ public class SimApiOptions
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableSimApiDoc { get; set; }
|
public bool EnableSimApiDoc { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否启用Synapse
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableSynapse { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 启用全部Cors,对于开发前后分离的时候很有用。
|
||||||
|
/// default: true
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableCors { get; set; } = true;
|
||||||
|
|
||||||
|
|
||||||
|
public CoceAppSdkOption CoceSdkOptions { get; set; } = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 启用异常拦截,启用后,所有的异常将被通过json反馈。
|
/// 启用异常拦截,启用后,所有的异常将被通过json反馈。
|
||||||
/// default: true
|
/// default: true
|
||||||
@@ -42,11 +60,6 @@ public class SimApiOptions
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableSimApiResponseFilter { get; set; } = true;
|
public bool EnableSimApiResponseFilter { get; set; } = true;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 开启S3兼容的存储系统。
|
|
||||||
/// default: false
|
|
||||||
/// </summary>
|
|
||||||
public bool EnableSimApiStorage { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 开启ForwardHeaders,开启后可以透传负载均衡的Headers
|
/// 开启ForwardHeaders,开启后可以透传负载均衡的Headers
|
||||||
@@ -60,17 +73,18 @@ public class SimApiOptions
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableLowerUrl { get; set; } = true;
|
public bool EnableLowerUrl { get; set; } = true;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 启用格式化的 Console Logger
|
/// 启用格式化的 Console Logger
|
||||||
/// default: false
|
/// default: false
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableLogger { get; set; }
|
public bool EnableLogger { get; set; } = true;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否启用Synapse
|
/// 配置Job
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableSynapse { get; set; }
|
public SimApiJobOptions SimApiJobOptions { get; set; } = new();
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Swagger文档相关配置,需要启用 EnableSimApiDoc
|
/// Swagger文档相关配置,需要启用 EnableSimApiDoc
|
||||||
@@ -103,4 +117,9 @@ public class SimApiOptions
|
|||||||
{
|
{
|
||||||
options?.Invoke(SimApiStorageOptions);
|
options?.Invoke(SimApiStorageOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ConfigureSimApiJob(Action<SimApiJobOptions>? options = null)
|
||||||
|
{
|
||||||
|
options?.Invoke(SimApiJobOptions);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using Microsoft.Extensions.Caching.Distributed;
|
||||||
|
|
||||||
|
namespace SimApi.Helpers;
|
||||||
|
|
||||||
|
public class SimApiCache(IDistributedCache cache)
|
||||||
|
{
|
||||||
|
private const string Prefix = "SimApi:Cache";
|
||||||
|
|
||||||
|
public void Set(string key, object value, DistributedCacheEntryOptions? options = null)
|
||||||
|
{
|
||||||
|
if (options is not null)
|
||||||
|
{
|
||||||
|
cache.SetString(Prefix + key, SimApiUtil.Json(value), options);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cache.SetString(Prefix + key, SimApiUtil.Json(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? Get(string key)
|
||||||
|
{
|
||||||
|
return cache.GetString(Prefix + key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T? Get<T>(string key)
|
||||||
|
{
|
||||||
|
var data = cache.GetString(Prefix + key);
|
||||||
|
return data == null ? default : JsonSerializer.Deserialize<T>(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Hangfire.Dashboard;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
|
namespace SimApi.Helpers;
|
||||||
|
|
||||||
|
public class SimApiJobWebAuth(string user, string pass) : IDashboardAuthorizationFilter
|
||||||
|
{
|
||||||
|
public bool Authorize(DashboardContext context)
|
||||||
|
{
|
||||||
|
var httpContext = context.GetHttpContext();
|
||||||
|
var authHeader = httpContext.Request.Headers["Authorization"].FirstOrDefault();
|
||||||
|
if (authHeader != null && authHeader.StartsWith("Basic "))
|
||||||
|
{
|
||||||
|
var encodedUsernamePassword = authHeader.Split(' ', 2, StringSplitOptions.RemoveEmptyEntries)[1]?.Trim();
|
||||||
|
var decodedUsernamePassword = Encoding.UTF8.GetString(Convert.FromBase64String(encodedUsernamePassword));
|
||||||
|
var username = decodedUsernamePassword.Split(':', 2)[0];
|
||||||
|
var password = decodedUsernamePassword.Split(':', 2)[1];
|
||||||
|
|
||||||
|
if (username == user && password == pass)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
httpContext.Response.StatusCode = 401;
|
||||||
|
httpContext.Response.Headers.WWWAuthenticate = "Basic realm=\"SimApiBasicAuth\"";
|
||||||
|
httpContext.Response.WriteAsync("").Wait();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
+8
-4
@@ -23,10 +23,14 @@
|
|||||||
<Folder Include="Exceptions\"/>
|
<Folder Include="Exceptions\"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Minio" Version="6.0.3" />
|
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.17" />
|
||||||
<PackageReference Include="MQTTnet" Version="4.3.6.1152" />
|
<PackageReference Include="Hangfire.Console" Version="1.4.3" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.7.1" />
|
<PackageReference Include="Hangfire.Redis.StackExchange" Version="1.9.4" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.7.1" />
|
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="9.0.1" />
|
||||||
|
<PackageReference Include="Minio" Version="6.0.4" />
|
||||||
|
<PackageReference Include="MQTTnet" Version="5.0.1.1416" />
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="7.2.0" />
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="7.2.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ProjectExtensions>
|
<ProjectExtensions>
|
||||||
<MonoDevelop>
|
<MonoDevelop>
|
||||||
|
|||||||
+65
-22
@@ -3,6 +3,9 @@ using System.Diagnostics;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using Hangfire;
|
||||||
|
using Hangfire.Console;
|
||||||
|
using Hangfire.Redis.StackExchange;
|
||||||
using SimApi.Helpers;
|
using SimApi.Helpers;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
@@ -29,6 +32,12 @@ public static class SimApiExtensions
|
|||||||
{
|
{
|
||||||
var simApiOptions = new SimApiOptions();
|
var simApiOptions = new SimApiOptions();
|
||||||
options?.Invoke(simApiOptions);
|
options?.Invoke(simApiOptions);
|
||||||
|
if (simApiOptions.RedisConfiguration != null)
|
||||||
|
{
|
||||||
|
builder.AddStackExchangeRedisCache(x => x.Configuration = simApiOptions.RedisConfiguration);
|
||||||
|
builder.AddSingleton<SimApiCache>();
|
||||||
|
}
|
||||||
|
|
||||||
if (simApiOptions.EnableLogger)
|
if (simApiOptions.EnableLogger)
|
||||||
{
|
{
|
||||||
builder.AddLogging(logger =>
|
builder.AddLogging(logger =>
|
||||||
@@ -49,6 +58,30 @@ public static class SimApiExtensions
|
|||||||
builder.AddSingleton<CoceApp>();
|
builder.AddSingleton<CoceApp>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (simApiOptions.EnableJob)
|
||||||
|
{
|
||||||
|
builder.AddHangfire(x =>
|
||||||
|
{
|
||||||
|
var redisOption = new RedisStorageOptions();
|
||||||
|
if (simApiOptions.SimApiJobOptions.Database.HasValue)
|
||||||
|
{
|
||||||
|
redisOption.Db = simApiOptions.SimApiJobOptions.Database.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
x.UseRedisStorage(simApiOptions.SimApiJobOptions.RedisConfiguration ??
|
||||||
|
simApiOptions.RedisConfiguration, redisOption);
|
||||||
|
x.UseConsole();
|
||||||
|
});
|
||||||
|
foreach (var server in simApiOptions.SimApiJobOptions.Servers)
|
||||||
|
{
|
||||||
|
builder.AddHangfireServer(hfs =>
|
||||||
|
{
|
||||||
|
hfs.Queues = server.Queues;
|
||||||
|
hfs.WorkerCount = server.WorkerNum;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (simApiOptions.EnableCors)
|
if (simApiOptions.EnableCors)
|
||||||
{
|
{
|
||||||
builder.AddCors(cors => cors.AddPolicy("any",
|
builder.AddCors(cors => cors.AddPolicy("any",
|
||||||
@@ -210,9 +243,10 @@ public static class SimApiExtensions
|
|||||||
builder.AddSingleton<SimApiStorage>();
|
builder.AddSingleton<SimApiStorage>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (simApiOptions.EnableSimApiException)
|
if (simApiOptions.EnableSimApiResponseFilter)
|
||||||
{
|
{
|
||||||
builder.AddControllers(opt => opt.Filters.Add<SimApiResponseFilter>())
|
builder.AddControllers(opt => opt.Filters.Add<SimApiResponseFilter>())
|
||||||
|
.AddXmlSerializerFormatters()
|
||||||
.AddJsonOptions(opt => opt.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase);
|
.AddJsonOptions(opt => opt.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,6 +262,11 @@ public static class SimApiExtensions
|
|||||||
|
|
||||||
logger.LogInformation("当前时区: {LocalId}", TimeZoneInfo.Local.Id);
|
logger.LogInformation("当前时区: {LocalId}", TimeZoneInfo.Local.Id);
|
||||||
|
|
||||||
|
if (options.RedisConfiguration != null)
|
||||||
|
{
|
||||||
|
logger.LogInformation("开始配置 RedisCache ...");
|
||||||
|
}
|
||||||
|
|
||||||
//请求一下检测存储错误
|
//请求一下检测存储错误
|
||||||
if (options.EnableSimApiStorage)
|
if (options.EnableSimApiStorage)
|
||||||
{
|
{
|
||||||
@@ -242,17 +281,17 @@ public static class SimApiExtensions
|
|||||||
options.CoceSdkOptions.AppId);
|
options.CoceSdkOptions.AppId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.EnableLowerUrl)
|
|
||||||
{
|
|
||||||
logger.LogInformation("开始配置使用URL小写...");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.EnableSynapse)
|
if (options.EnableSynapse)
|
||||||
{
|
{
|
||||||
var synapse = builder.Services.GetRequiredService<Synapse>();
|
var synapse = builder.Services.GetRequiredService<Synapse>();
|
||||||
synapse.Init();
|
synapse.Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.EnableJob)
|
||||||
|
{
|
||||||
|
logger.LogInformation("开始配置 SimApiJob ...");
|
||||||
|
}
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,10 +303,8 @@ public static class SimApiExtensions
|
|||||||
public static WebApplication UseSimApi(this WebApplication builder)
|
public static WebApplication UseSimApi(this WebApplication builder)
|
||||||
{
|
{
|
||||||
var options = builder.Services.GetRequiredService<SimApiOptions>();
|
var options = builder.Services.GetRequiredService<SimApiOptions>();
|
||||||
|
|
||||||
var logger = builder.Services.GetRequiredService<ILogger<SimApiOptions>>();
|
var logger = builder.Services.GetRequiredService<ILogger<SimApiOptions>>();
|
||||||
|
UseSimApi((IHost)builder);
|
||||||
logger.LogInformation("当前时区: {LocalId}", TimeZoneInfo.Local.Id);
|
|
||||||
if (options.EnableForwardHeaders)
|
if (options.EnableForwardHeaders)
|
||||||
{
|
{
|
||||||
logger.LogInformation("开始配置ForwardedHeaders...");
|
logger.LogInformation("开始配置ForwardedHeaders...");
|
||||||
@@ -280,6 +317,12 @@ public static class SimApiExtensions
|
|||||||
builder.UseCors("any");
|
builder.UseCors("any");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.EnableSimApiResponseFilter)
|
||||||
|
{
|
||||||
|
logger.LogInformation("开始配置SimApiResponseFilter...");
|
||||||
|
builder.MapControllers();
|
||||||
|
}
|
||||||
|
|
||||||
if (options.EnableSimApiAuth)
|
if (options.EnableSimApiAuth)
|
||||||
{
|
{
|
||||||
logger.LogInformation("开始配置SimApiAuth...");
|
logger.LogInformation("开始配置SimApiAuth...");
|
||||||
@@ -296,11 +339,11 @@ public static class SimApiExtensions
|
|||||||
options.CoceSdkOptions.ApiEndpoint, options.CoceSdkOptions.AuthEndpoint,
|
options.CoceSdkOptions.ApiEndpoint, options.CoceSdkOptions.AuthEndpoint,
|
||||||
options.CoceSdkOptions.AppId);
|
options.CoceSdkOptions.AppId);
|
||||||
builder.MapControllerRoute(name: "LoginUseCoce", pattern: "/auth/login",
|
builder.MapControllerRoute(name: "LoginUseCoce", pattern: "/auth/login",
|
||||||
defaults: new { controller = "SimApiCoce", action = "Login" });
|
defaults: new { controller = "Coce", action = "Login" });
|
||||||
builder.MapControllerRoute(name: "LoginUseCoce", pattern: "/user/groups",
|
builder.MapControllerRoute(name: "LoginUseCoce", pattern: "/user/groups",
|
||||||
defaults: new { controller = "SimApiCoce", action = "ListGroups" });
|
defaults: new { controller = "Coce", action = "ListGroups" });
|
||||||
builder.MapControllerRoute(name: "LoginUseCoce", pattern: "/auth/config",
|
builder.MapControllerRoute(name: "LoginUseCoce", pattern: "/auth/config",
|
||||||
defaults: new { controller = "SimApiCoce", action = "GetConfig" });
|
defaults: new { controller = "Coce", action = "GetConfig" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,22 +371,22 @@ public static class SimApiExtensions
|
|||||||
builder.UseMiddleware<SimApiExceptionMiddleware>();
|
builder.UseMiddleware<SimApiExceptionMiddleware>();
|
||||||
}
|
}
|
||||||
|
|
||||||
//请求一下检测存储错误
|
|
||||||
if (options.EnableSimApiStorage)
|
|
||||||
{
|
|
||||||
logger.LogInformation("开始配置SimApiStorage...");
|
|
||||||
builder.Services.GetService<SimApiStorage>();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.EnableLowerUrl)
|
if (options.EnableLowerUrl)
|
||||||
{
|
{
|
||||||
logger.LogInformation("开始配置使用URL小写...");
|
logger.LogInformation("开始配置使用URL小写...");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.EnableSynapse)
|
if (options is { EnableJob: true, SimApiJobOptions.DashboardUrl: not null })
|
||||||
{
|
{
|
||||||
var synapse = builder.Services.GetRequiredService<Synapse>();
|
logger.LogInformation("开始配置 SimApiJob Web控制台...");
|
||||||
synapse.Init();
|
builder.UseHangfireDashboard(options.SimApiJobOptions.DashboardUrl, new DashboardOptions
|
||||||
|
{
|
||||||
|
Authorization =
|
||||||
|
[
|
||||||
|
new SimApiJobWebAuth(options.SimApiJobOptions.DashboardAuthUser,
|
||||||
|
options.SimApiJobOptions.DashboardAuthPass)
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
|
|||||||
+1
-2
@@ -8,7 +8,6 @@ using System.Threading.Tasks;
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using MQTTnet;
|
using MQTTnet;
|
||||||
using MQTTnet.Client;
|
|
||||||
using MQTTnet.Formatter;
|
using MQTTnet.Formatter;
|
||||||
using SimApi.Attributes;
|
using SimApi.Attributes;
|
||||||
using SimApi.Communications;
|
using SimApi.Communications;
|
||||||
@@ -22,7 +21,7 @@ public partial class Synapse(SimApiOptions simApiOptions, ILogger<Synapse> logge
|
|||||||
{
|
{
|
||||||
private SimApiSynapseOptions Options { get; } = simApiOptions.SimApiSynapseOptions;
|
private SimApiSynapseOptions Options { get; } = simApiOptions.SimApiSynapseOptions;
|
||||||
|
|
||||||
private MqttFactory MqttFactory { get; } = new();
|
private MqttClientFactory MqttFactory { get; } = new();
|
||||||
public IMqttClient? Client { get; set; }
|
public IMqttClient? Client { get; set; }
|
||||||
|
|
||||||
private List<RegisterItem> EventRegistry { get; set; } = new();
|
private List<RegisterItem> EventRegistry { get; set; } = new();
|
||||||
|
|||||||
Reference in New Issue
Block a user