using Rhea.Common;
|
using Rhea.Common.Interface;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading;
|
using System.Threading.Tasks;
|
|
namespace Tiger.Business
|
{
|
/// <summary>
|
/// DB监控线程
|
/// </summary>
|
public class DbMonitor : ITigerMonitor
|
{
|
#region Variables
|
private WhileThread DbMonitorThread;
|
#endregion
|
|
#region Propertys
|
public string Id { get; set; } = Guid.NewGuid().ToString("N");
|
public string Tag { get; set; } = "DbMonitor";
|
public string Name { get; set; } = "DbMonitor";
|
public bool IsRunning { get; set; }
|
#endregion
|
|
#region Functions
|
public void Start()
|
{
|
try
|
{
|
DbMonitorThread = new(DbMonitoring);
|
DbMonitorThread.Start();
|
Logger.Default.Info("Start Db Monitoring Thread");
|
}
|
catch (System.Exception ex)
|
{
|
Logger.Default.Fatal(ex, "Start Db Monitoring Thread Exception");
|
}
|
}
|
|
public void Stop()
|
{
|
try
|
{
|
DbMonitorThread?.Stop();
|
Logger.Console.Info("Stop Db Monitoring Thread");
|
}
|
catch (System.Exception ex)
|
{
|
Logger.Console.Fatal(ex, "Stop Db Monitoring Thread Exception");
|
}
|
}
|
|
private void DbMonitoring()
|
{
|
try
|
{
|
//switch (BizConfig.Configuration["CurrentProject"])
|
//{
|
// case "JXAH2021_M10"://奥海10线
|
// {
|
// //按计划删除WIP_SN旧数据
|
// Biz.WIP_SN_DeleteOldData(1).Wait();
|
// }
|
// break;
|
// case "GZhGB2021_01"://项目GZhGB2021_01
|
// {
|
// //按计划删除WIP_SN旧数据
|
// Biz.WIP_SN_DeleteOldData(3).Wait();
|
// }
|
// break;
|
// case "GXSALCOMP2021_93":
|
// {
|
// //按计划删除WIP_SN旧数据
|
// Biz.WIP_SN_DeleteOldData(5).Wait();
|
// //按计划备份WIP_SN旧数据
|
// //Biz.WIP_SN_BackupOldData(5).Wait();
|
// }
|
// break;
|
// default:
|
// {
|
// //按计划删除10天前的SNData旧数据
|
// Biz.ScheduledDeletion().Wait();
|
// //按计划删除WIP_SN旧数据
|
// Biz.WIP_SN_DeleteOldData(2).Wait();
|
// }
|
// break;
|
//}
|
}
|
catch (System.Exception ex)
|
{
|
Logger.Console.Fatal(ex, "DbMonitoring Exception");
|
}
|
|
//休眠24小时
|
Thread.Sleep(24 * 60 * 60 * 1000);
|
}
|
#endregion
|
}
|
}
|