56 lines
1.3 KiB
C#
56 lines
1.3 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using NLog;
|
|
using System;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MagMan.Data.Tenant
|
|
{
|
|
public class DbAdmin : IDisposable
|
|
{
|
|
#region Private Fields
|
|
|
|
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Public Constructors
|
|
|
|
public DbAdmin()
|
|
{
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Methods
|
|
|
|
public static async Task<bool> migrateDbMain(string connString)
|
|
{
|
|
bool answ = false;
|
|
using (MagManContext dbCtx = new MagManContext(connString))
|
|
{
|
|
await dbCtx.Database.MigrateAsync();
|
|
answ = true;
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
public static bool resetPlantLogTable()
|
|
{
|
|
bool answ = false;
|
|
using (MagManContext dbCtx = new MagManContext())
|
|
{
|
|
string sqlCommand = "TRUNCATE TABLE PlantLog;";
|
|
dbCtx.Database.ExecuteSqlRaw(sqlCommand);
|
|
answ = true;
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
} |