-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
Develop
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Nerosoft.Starfish.Application; | ||
|
||
internal class UserInitializeService : BackgroundService | ||
{ | ||
private readonly IUserApplicationService _service; | ||
private readonly ILogger<UserInitializeService> _logger; | ||
|
||
public UserInitializeService(IUserApplicationService service, ILoggerFactory logger) | ||
{ | ||
_service = service; | ||
_logger = logger.CreateLogger<UserInitializeService>(); | ||
} | ||
|
||
protected override async Task ExecuteAsync(CancellationToken stoppingToken) | ||
{ | ||
try | ||
{ | ||
await _service.InitializeAsync(stoppingToken); | ||
} | ||
catch (Exception exception) | ||
{ | ||
_logger.LogError(exception, exception.Message); | ||
} | ||
} | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Nerosoft.Starfish.Service; | ||
|
||
internal static class ServiceProviderExtensions | ||
{ | ||
public static T GetServiceOrCreateInstance<T>(this IServiceProvider provider) | ||
{ | ||
return ActivatorUtilities.GetServiceOrCreateInstance<T>(provider); | ||
} | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Microsoft.Extensions.Configuration; | ||
using Nerosoft.Euonia.Application; | ||
using Nerosoft.Euonia.Bus; | ||
using Nerosoft.Starfish.Application; | ||
using Nerosoft.Starfish.Domain; | ||
|
||
namespace Nerosoft.Starfish.UseCases; | ||
|
||
internal interface IUserInitializeUseCase : IParameterlessUseCase; | ||
|
||
internal class UserInitializeUseCase : IUserInitializeUseCase | ||
{ | ||
private readonly IBus _bus; | ||
private readonly IUserRepository _repository; | ||
private readonly IConfiguration _configuration; | ||
|
||
public UserInitializeUseCase(IBus bus, IUserRepository repository, IConfiguration configuration) | ||
{ | ||
_bus = bus; | ||
_repository = repository; | ||
_configuration = configuration; | ||
} | ||
|
||
public async Task ExecuteAsync(CancellationToken cancellationToken = default) | ||
{ | ||
var username = _configuration["InitializeUser:UserName"]; | ||
|
||
if (string.IsNullOrWhiteSpace(username)) | ||
{ | ||
return; | ||
} | ||
|
||
var exists = await _repository.CheckUserNameExistsAsync(username, cancellationToken); | ||
if (exists) | ||
{ | ||
return; | ||
} | ||
|
||
var command = new UserCreateCommand | ||
{ | ||
UserName = _configuration["InitializeUser:UserName"], | ||
Password = _configuration["InitializeUser:Password"], | ||
IsAdmin = true, | ||
Reserved = true | ||
}; | ||
await _bus.SendAsync<UserCreateCommand, string>(command, cancellationToken).ContinueWith(task => task.WaitAndUnwrapException()); | ||
} | ||
} |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
namespace Nerosoft.Starfish.Transit; | ||
|
||
/// <summary> | ||
/// 连接信息传输对象 | ||
/// </summary> | ||
public class ConnectionInfoDto | ||
{ | ||
/// <summary> | ||
/// 配置Id | ||
/// </summary> | ||
public string ConfigurationId { get; set; } | ||
|
||
/// <summary> | ||
/// 配置名称 | ||
/// </summary> | ||
public string ConfigurationName { get; set; } | ||
|
||
/// <summary> | ||
/// 连接Id | ||
/// </summary> | ||
public string ConnectionId { get; set; } | ||
|
||
/// <summary> | ||
/// 连接类型 | ||
/// </summary> | ||
public string ConnectionType { get; set; } | ||
|
||
/// <summary> | ||
/// 连接时间 | ||
/// </summary> | ||
public DateTime ConnectedTime { get; set; } | ||
} |
This file was deleted.
This file was deleted.