WeddingPlatform.Web
1.0.0.0
지도, 갤러리, 방명록, 계좌 안내와 배경음악을 링크 하나에 담는 무료 모바일 청첩장 서비스입니다.
Toggle main menu visibility
로딩중...
검색중...
일치하는것 없음
GhostAccountCleanupService.cs
이 파일의 문서화 페이지로 가기
1
using
Microsoft.Extensions.Hosting;
2
using
Microsoft.Extensions.Logging;
3
4
namespace
WeddingPlatform.Services
;
5
14
public
sealed
class
GhostAccountCleanupService
: BackgroundService
15
{
24
private
readonly
ITenantStore
_tenants
;
33
private
readonly ILogger<GhostAccountCleanupService>
_logger
;
42
private
static
readonly TimeSpan
Interval
= TimeSpan.FromHours(1);
51
private
static
readonly TimeSpan
GracePeriod
= TimeSpan.FromHours(24);
52
77
public
GhostAccountCleanupService
(
ITenantStore
tenants, ILogger<GhostAccountCleanupService> logger)
78
{
79
_tenants
= tenants;
80
_logger
= logger;
81
}
82
107
protected
override
async Task
ExecuteAsync
(CancellationToken stoppingToken)
108
{
109
while
(!stoppingToken.IsCancellationRequested)
110
{
111
await Task.Delay(
Interval
, stoppingToken).ConfigureAwait(
false
);
112
await
RunCleanupAsync
(stoppingToken).ConfigureAwait(
false
);
113
}
114
}
115
140
private
async Task
RunCleanupAsync
(CancellationToken ct)
141
{
142
try
143
{
144
var all = await
_tenants
.GetAllAsync(ct).ConfigureAwait(
false
);
145
var cutoff = DateTime.Now -
GracePeriod
;
146
147
foreach
(var t
in
all)
148
{
149
if
(t.GalleryFileNames.Count > 0)
continue
;
150
if
(t.CreatedAt > cutoff)
continue
;
151
152
await
_tenants
.DeleteAsync(t.Slug, ct).ConfigureAwait(
false
);
153
_logger
.LogInformation(
"고스트 계정 자동 삭제: {Slug} (생성: {CreatedAt:g}, 사진 0장)"
, t.Slug, t.CreatedAt);
154
}
155
}
156
catch
(Exception ex) when (ex is not OperationCanceledException)
157
{
158
_logger
.LogError(ex,
"고스트 계정 정리 중 오류 발생"
);
159
}
160
}
161
}
WeddingPlatform.Services
Definition
CsvGuestbookStorage.cs:6
WeddingPlatform.Services.GhostAccountCleanupService.RunCleanupAsync
async Task RunCleanupAsync(CancellationToken ct)
Definition
GhostAccountCleanupService.cs:140
WeddingPlatform.Services.GhostAccountCleanupService.Interval
static readonly TimeSpan Interval
Definition
GhostAccountCleanupService.cs:42
WeddingPlatform.Services.GhostAccountCleanupService._logger
readonly ILogger< GhostAccountCleanupService > _logger
Definition
GhostAccountCleanupService.cs:33
WeddingPlatform.Services.GhostAccountCleanupService.GhostAccountCleanupService
GhostAccountCleanupService(ITenantStore tenants, ILogger< GhostAccountCleanupService > logger)
Definition
GhostAccountCleanupService.cs:77
WeddingPlatform.Services.GhostAccountCleanupService.ExecuteAsync
override async Task ExecuteAsync(CancellationToken stoppingToken)
Definition
GhostAccountCleanupService.cs:107
WeddingPlatform.Services.GhostAccountCleanupService.GracePeriod
static readonly TimeSpan GracePeriod
Definition
GhostAccountCleanupService.cs:51
WeddingPlatform.Services.GhostAccountCleanupService._tenants
readonly ITenantStore _tenants
Definition
GhostAccountCleanupService.cs:24
WeddingPlatform.Services.ITenantStore
Definition
ITenantStore.cs:14
Services
GhostAccountCleanupService.cs
다음에 의해 생성됨 :
1.17.0