mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-13 18:04:16 +01:00
dispose db context from services
This commit is contained in:
parent
ffe24b0e71
commit
f29edbd1c3
3 changed files with 4 additions and 4 deletions
|
|
@ -51,7 +51,7 @@ namespace MareSynchronosServer
|
|||
try
|
||||
{
|
||||
using var scope = _services.CreateScope();
|
||||
var dbContext = scope.ServiceProvider.GetService<MareDbContext>()!;
|
||||
using var dbContext = scope.ServiceProvider.GetService<MareDbContext>()!;
|
||||
|
||||
var prevTime = DateTime.Now.Subtract(TimeSpan.FromDays(filesOlderThanDays));
|
||||
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ namespace MareSynchronosServer.Discord
|
|||
|
||||
var hashedLodestoneId = BitConverter.ToString(sha256.ComputeHash(Encoding.UTF8.GetBytes(lodestoneId.ToString()))).Replace("-", "");
|
||||
|
||||
var db = scope.ServiceProvider.GetService<MareDbContext>();
|
||||
using var db = scope.ServiceProvider.GetService<MareDbContext>();
|
||||
|
||||
// check if discord id or lodestone id is banned
|
||||
if (db.BannedRegistrations.Any(a => a.DiscordIdOrLodestoneAuth == arg.User.Id.ToString() || a.DiscordIdOrLodestoneAuth == hashedLodestoneId))
|
||||
|
|
@ -408,7 +408,7 @@ namespace MareSynchronosServer.Discord
|
|||
private void UpdateStatus(object state)
|
||||
{
|
||||
using var scope = services.CreateScope();
|
||||
var db = scope.ServiceProvider.GetService<MareDbContext>();
|
||||
using var db = scope.ServiceProvider.GetService<MareDbContext>();
|
||||
|
||||
var users = db.Users.Count(c => c.CharacterIdentification != null);
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public class SystemInfoService : IHostedService, IDisposable
|
|||
MareMetrics.AvailableIOWorkerThreads.Set(ioThreads);
|
||||
|
||||
using var scope = _services.CreateScope();
|
||||
var db = scope.ServiceProvider.GetService<MareDbContext>();
|
||||
using var db = scope.ServiceProvider.GetService<MareDbContext>();
|
||||
|
||||
var users = db.Users.Count(c => c.CharacterIdentification != null);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue