服务端的TigerApi 框架,基于.NET6 2024 版本
Rodney Chen
2025-04-15 ba08e05138d882a2a5bc603a166b07af071cc1a1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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
    }
}