IW4M-Admin/SharedLibrary/Database/Repair.cs
RaidMax e974de8e63 vpn check updates, fixed some issues,
"masked" status is now sensitive
discord link in webfront if configured
2018-03-13 16:30:22 -05:00

29 lines
811 B
C#

using SharedLibrary.Interfaces;
using System;
using System.Data.SqlServerCe;
namespace SharedLibrary.Database
{
public class Repair
{
public static void Run(ILogger log)
{
if (!System.IO.File.Exists($"{Utilities.OperatingDirectory}Database.sdf"))
return;
SqlCeEngine engine = new SqlCeEngine(@"Data Source=|DataDirectory|\Database.sdf");
if (false == engine.Verify())
{
log.WriteWarning("Database is corrupted.");
try
{
engine.Repair(null, RepairOption.DeleteCorruptedRows);
}
catch (SqlCeException ex)
{
log.WriteError(ex.Message);
}
}
}
}
}