服务端的TigerApi 框架,基于.NET6 2024 版本
Rodney Chen
2024-12-08 006c12987d7dc7c2081fbf6715ebea98b93fdca0
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
using Rhea.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Tiger.IBusiness;
 
namespace Tiger.Api.DbCache
{
    public partial class Cache
    {
        /// <summary>
        /// 获取条码规则缓存
        /// </summary>
        public static ICodeRuleCache CodeRule => DI.Resolve<ICodeRuleCache>();
        /// <summary>
        /// 获取系统参数缓存
        /// </summary>
        public static ISysParamCache SysParam => DI.Resolve<ISysParamCache>();
        /// <summary>
        /// 获取不良代码缓存
        /// </summary>
        public static IMesDefectCache MesDefect => DI.Resolve<IMesDefectCache>();
        /// <summary>
        /// 获取岗位缓存
        /// </summary>
        public static IMesPositionCache MesPosition => DI.Resolve<IMesPositionCache>();
        /// <summary>
        /// 获取工单池缓存
        /// </summary>
        public static IWoContext WorkBatch => DI.Resolve<IWoContext>();
    }//endClass
 
    /// <summary>
    /// 监控总控
    /// </summary>
    public class DbCacheBus
    {
        
        #region Functions
        public static void StartAutoUpdate()
        {
            if (BizConfig.Configuration["IsUseDbCache"]?.ToLower() == "true")
            {
                //开启系统参数缓存
                Cache.SysParam.Start();
                ConsoleExt.WriteLine("Start SysParam Cache Auto Update Thread..........", ConsoleColor.Yellow);
                //开启系统参数缓存
                Cache.CodeRule.Start();
                ConsoleExt.WriteLine("Start CodeRule Cache Auto Update Thread..........", ConsoleColor.Yellow);
                //开启不良代码缓存
                Cache.MesDefect.Start();
                ConsoleExt.WriteLine("Start MesDefect Cache Auto Update Thread..........", ConsoleColor.Yellow);
                //开启岗位缓存
                Cache.MesPosition.Start();
                ConsoleExt.WriteLine("Start MesPosition Cache Auto Update Thread..........", ConsoleColor.Yellow);
            }
        }
 
        public static void StopAutoUpdate()
        {
            if (BizConfig.Configuration["IsUseDbCache"]?.ToLower() == "true")
            {
                //关闭系统参数缓存
                Cache.SysParam.Stop();
                //关闭系统参数缓存
                Cache.CodeRule.Stop();
                //关闭不良代码缓存
                Cache.MesDefect.Stop();
                //关闭岗位缓存
                Cache.MesPosition.Stop();
            }
        }
        #endregion
    }
}