73 lines
1.6 KiB
C#
73 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using _0_Framework.InfraStructure;
|
|
using AccountManagement.Application.Contracts.Account;
|
|
using AccountManagement.Domain.AccountAgg;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace AccountMangement.Infrastructure.EFCore.Repository;
|
|
|
|
public class Worker : RepositoryBase<long, Account>, IWorker
|
|
{
|
|
|
|
|
|
//private readonly IServiceScopeFactory _serviceScopeFactory;
|
|
private readonly AccountContext _context;
|
|
|
|
|
|
public Worker(AccountContext context) : base(context)
|
|
{
|
|
|
|
_context = context;
|
|
}
|
|
|
|
public async Task RemoveVerfy(long id)
|
|
{
|
|
|
|
var ress = Get(id);
|
|
|
|
|
|
TimeSpan delay = TimeSpan.FromSeconds(10);
|
|
await Task.Delay(delay);
|
|
ress.VerifyCode = "";
|
|
await _context.SaveChangesAsync();
|
|
|
|
|
|
}
|
|
|
|
public async Task CreateVerifyCode(long id, string code)
|
|
{
|
|
|
|
try
|
|
{
|
|
await CreateCode(id,code);
|
|
}
|
|
finally
|
|
{
|
|
await RemoveVerifyCode(id);
|
|
}
|
|
|
|
}
|
|
|
|
public async Task RemoveVerifyCode(long id)
|
|
{
|
|
TimeSpan delay = TimeSpan.FromSeconds(30);
|
|
await Task.Delay(delay);
|
|
//await Thread.Sleep(20000);
|
|
var account = Get(id);
|
|
account.VerifyCode = "";
|
|
await _context.SaveChangesAsync();
|
|
}
|
|
|
|
public async Task CreateCode(long id, string code)
|
|
{
|
|
|
|
var account = Get(id);
|
|
account.SetVerifyCode(code);
|
|
await _context.SaveChangesAsync();
|
|
}
|
|
} |