mirror of
https://github.com/bitwarden/server
synced 2025-12-28 06:03:29 +00:00
Split out repositories to Infrastructure.Dapper / EntityFramework (#1759)
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.Core.Repositories;
|
||||
using Bit.Core.Settings;
|
||||
using Dapper;
|
||||
|
||||
namespace Bit.Infrastructure.Dapper.Repositories
|
||||
{
|
||||
public class MaintenanceRepository : BaseRepository, IMaintenanceRepository
|
||||
{
|
||||
public MaintenanceRepository(GlobalSettings globalSettings)
|
||||
: this(globalSettings.SqlServer.ConnectionString, globalSettings.SqlServer.ReadOnlyConnectionString)
|
||||
{ }
|
||||
|
||||
public MaintenanceRepository(string connectionString, string readOnlyConnectionString)
|
||||
: base(connectionString, readOnlyConnectionString)
|
||||
{ }
|
||||
|
||||
public async Task UpdateStatisticsAsync()
|
||||
{
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
await connection.ExecuteAsync(
|
||||
"[dbo].[AzureSQLMaintenance]",
|
||||
new { operation = "statistics", mode = "smart", LogToTable = true },
|
||||
commandType: CommandType.StoredProcedure,
|
||||
commandTimeout: 172800);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task DisableCipherAutoStatsAsync()
|
||||
{
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
await connection.ExecuteAsync(
|
||||
"sp_autostats",
|
||||
new { tblname = "[dbo].[Cipher]", flagc = "OFF" },
|
||||
commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task RebuildIndexesAsync()
|
||||
{
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
await connection.ExecuteAsync(
|
||||
"[dbo].[AzureSQLMaintenance]",
|
||||
new { operation = "index", mode = "smart", LogToTable = true },
|
||||
commandType: CommandType.StoredProcedure,
|
||||
commandTimeout: 172800);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task DeleteExpiredGrantsAsync()
|
||||
{
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
await connection.ExecuteAsync(
|
||||
"[dbo].[Grant_DeleteExpired]",
|
||||
commandType: CommandType.StoredProcedure,
|
||||
commandTimeout: 172800);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user