Files
server/src/Infrastructure.Dapper/Repositories/MaintenanceRepository.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

67 lines
2.3 KiB
C#
Raw Normal View History

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);
}
}
2019-02-03 22:39:53 -05:00
public async Task DisableCipherAutoStatsAsync()
{
using (var connection = new SqlConnection(ConnectionString))
2019-02-03 22:39:53 -05:00
{
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);
}
}
2018-10-09 10:23:52 -04:00
public async Task DeleteExpiredGrantsAsync()
{
using (var connection = new SqlConnection(ConnectionString))
2018-10-09 10:23:52 -04:00
{
await connection.ExecuteAsync(
"[dbo].[Grant_DeleteExpired]",
commandType: CommandType.StoredProcedure,
commandTimeout: 172800);
2018-10-09 10:23:52 -04:00
}
}
}
}