forked from yubaolee/OpenAuth.Core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ÂëÉñ
committed
Apr 24, 2020
1 parent
3f087aa
commit 74333cf
Showing
8 changed files
with
192 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System.Threading.Tasks; | ||
using OpenAuth.Repository.Domain; | ||
using Quartz; | ||
|
||
namespace OpenAuth.App.Jobs | ||
{ | ||
public class SysLogJob : IJob | ||
{ | ||
private SysLogApp _sysLogApp; | ||
|
||
public SysLogJob(SysLogApp sysLogApp) | ||
{ | ||
_sysLogApp = sysLogApp; | ||
} | ||
|
||
public Task Execute(IJobExecutionContext context) | ||
{ | ||
_sysLogApp.Add(new SysLog | ||
{ | ||
Content = "这是一个定时任务" | ||
}); | ||
return Task.CompletedTask; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace OpenAuth.App.Request | ||
{ | ||
public class ChangeJobStatusReq | ||
{ | ||
/// <summary> | ||
/// 任务ID | ||
/// </summary> | ||
public string Id { get; set; } | ||
|
||
/// <summary> | ||
/// 改变任务状态 | ||
/// 0:停止;1:启动(任务变成正在运行) | ||
/// </summary> | ||
public int Status { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using Infrastructure; | ||
using Infrastructure.Cache; | ||
using Microsoft.AspNetCore.Http; | ||
using NUnit.Framework; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Moq; | ||
using OpenAuth.App.Request; | ||
using OpenAuth.App.SSO; | ||
|
||
namespace OpenAuth.App.Test | ||
{ | ||
[TestFixture] | ||
public class TestJob :TestBase | ||
{ | ||
public override ServiceCollection GetService() | ||
{ | ||
var services = new ServiceCollection(); | ||
|
||
var cachemock = new Mock<ICacheContext>(); | ||
cachemock.Setup(x => x.Get<UserAuthSession>("tokentest")).Returns(new UserAuthSession { Account = "admin" }); | ||
services.AddScoped(x => cachemock.Object); | ||
|
||
var httpContextAccessorMock = new Mock<IHttpContextAccessor>(); | ||
httpContextAccessorMock.Setup(x => x.HttpContext.Request.Query[Define.TOKEN_NAME]).Returns("tokentest"); | ||
|
||
services.AddScoped(x => httpContextAccessorMock.Object); | ||
|
||
return services; | ||
} | ||
|
||
|
||
[Test] | ||
public void GetSysJobs() | ||
{ | ||
var app = _autofacServiceProvider.GetService<OpenJobApp>(); | ||
var result = app.QueryLocalHandlers(); | ||
Console.WriteLine(JsonHelper.Instance.Serialize(result)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters