mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-11-07 18:04:45 +08:00
修复定时任务不能运行
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Threading;
|
||||||
using Infrastructure;
|
using Infrastructure;
|
||||||
using Infrastructure.Cache;
|
using Infrastructure.Cache;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
@@ -37,5 +38,17 @@ namespace OpenAuth.App.Test
|
|||||||
var result = app.QueryLocalHandlers();
|
var result = app.QueryLocalHandlers();
|
||||||
Console.WriteLine(JsonHelper.Instance.Serialize(result));
|
Console.WriteLine(JsonHelper.Instance.Serialize(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ChangeStatus()
|
||||||
|
{
|
||||||
|
var app = _autofacServiceProvider.GetService<OpenJobApp>();
|
||||||
|
app.ChangeJobStatus(new ChangeJobStatusReq
|
||||||
|
{
|
||||||
|
Id = "f40fe48d-71a4-4f47-b324-6178d97abfb9",
|
||||||
|
Status = 1
|
||||||
|
});
|
||||||
|
Thread.Sleep(60000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,22 +40,22 @@ namespace OpenAuth.Repository
|
|||||||
//初始化多租户信息,根据租户id调整数据库
|
//初始化多租户信息,根据租户id调整数据库
|
||||||
private void InitTenant(DbContextOptionsBuilder optionsBuilder)
|
private void InitTenant(DbContextOptionsBuilder optionsBuilder)
|
||||||
{
|
{
|
||||||
if (_httpContextAccessor == null || _httpContextAccessor.HttpContext == null)
|
string tenantId = "OpenAuthDBContext";
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//读取多租户ID
|
if (_httpContextAccessor != null && _httpContextAccessor.HttpContext != null)
|
||||||
string tenantId = _httpContextAccessor.HttpContext.Request.Query[Define.TENANT_ID];
|
|
||||||
if (string.IsNullOrEmpty(tenantId))
|
|
||||||
{
|
{
|
||||||
tenantId = _httpContextAccessor.HttpContext.Request.Headers[Define.TENANT_ID];
|
//读取多租户ID
|
||||||
|
var httpTenantId = _httpContextAccessor.HttpContext.Request.Query[Define.TENANT_ID];
|
||||||
|
if (string.IsNullOrEmpty(httpTenantId))
|
||||||
|
{
|
||||||
|
httpTenantId = _httpContextAccessor.HttpContext.Request.Headers[Define.TENANT_ID];
|
||||||
}
|
}
|
||||||
|
|
||||||
//如果没有租户id,或租户用的是默认的OpenAuthDBContext,则不做任何调整
|
//如果没有租户id,或租户用的是默认的OpenAuthDBContext,则不做任何调整
|
||||||
if (string.IsNullOrEmpty(tenantId))
|
if (!string.IsNullOrEmpty(httpTenantId))
|
||||||
{
|
{
|
||||||
tenantId = "OpenAuthDBContext";
|
tenantId = httpTenantId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string connect = _configuration.GetConnectionString(tenantId);
|
string connect = _configuration.GetConnectionString(tenantId);
|
||||||
|
|||||||
Reference in New Issue
Block a user