2
schangxiang@126.com
2024-08-16 b47c50a2a514def7374b32d7194b2c599cba5625
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
 
 
using iWareCommon.Common.Entity;
using iWareDataCore.DEV.Entity;
using iWareDataCore.DEV.Service;
using iWareDataCore.RBAC.Entity;
using iWareDataCore.RBAC.Service;
using iWareExcel.EXCEL.Entity;
using iWareExcel.EXCEL.Service;
using System.Collections.Generic;
namespace iWareWms.Code.Common.Entity
{
    /// <summary>
    /// 系统缓存类
    /// </summary>
    public class CacheEntity
    {
        private static object FactoryLock = new object();
        private static object WorkShopLock = new object();
        private static object WorkCenterLock = new object();
        private static object CellLock = new object();
        private static object UnitLock = new object();
        private static object OpcWcfServiceLock = new object();
        private static object RedisWcfServiceLock = new object();
        private static object ContentLock = new object();
        private static object ShiftLock = new object();
        private static object ProcessRoutingLock = new object();
        private static object WorkBookLock = new object();
        private static object EquipmentLock = new object();
        private static object ControlCenterWcfServiceLock = new object();
 
        /// <summary>
        /// 菜单
        /// </summary>
        private static Dictionary<int, ContentEntity> contentDict = null;
 
        public static Dictionary<int, ContentEntity> ContentDict
        {
            get
            {
                if (contentDict == null)
                {
                    lock (ContentLock)
                    {
                        if (contentDict == null)
                        {
                            string msg;
                            contentDict = ContentService.GetInstance().ToDictionary(new QueryParam(), out msg);
                        }
                    }
                }
                return contentDict;
            }
            set { CacheEntity.contentDict = value; }
        }
 
 
        /// <summary>
        /// 以工作簿的名称为键,工作簿为值的字典
        /// </summary>
        private static Dictionary<string, WorkBookEntity> workBookDict = null;
 
 
        public static Dictionary<string, WorkBookEntity> WorkBookDict
        {
            get
            {
                if (workBookDict == null)
                {
                    lock (WorkBookLock)
                    {
                        if (workBookDict == null)
                        {
                            string msg;
                            var workBooks = WorkBookService.GetInstance().QueryByParam(new QueryParam(), out msg);
                            workBookDict = new Dictionary<string, WorkBookEntity>();
                            workBooks.ForEach(x => workBookDict.Add(x.Name, x));
                        }
                    }
                }
                return CacheEntity.workBookDict;
            }
            set { CacheEntity.workBookDict = value; }
        }
 
 
        /// <summary>
        /// 设备
        /// </summary>
        private static Dictionary<int, EquipmentEntity> equipmentDict = null;
 
        public static Dictionary<int, EquipmentEntity> EquipmentDict
        {
            get
            {
                if (equipmentDict == null)
                {
                    lock (EquipmentLock)
                    {
                        if (equipmentDict == null)
                        {
                            string msg;
                            equipmentDict = EquipmentService.GetInstance().ToDictionary(new QueryParam(), out msg);
                        }
                    }
                }
                return equipmentDict;
            }
            set { CacheEntity.equipmentDict = value; }
        }
 
 
       
 
    }
}