Exemplo n.º 1
0
        /// <summary>
        /// 初始化缓存
        /// </summary>
        /// <returns>设备集合</returns>
        private List <FlowDevice> InitCache()
        {
            _logger.LogInformation((int)LogEvent.系统, "初始化缓存");

            IMemoryCache memoryCache = _serviceProvider.GetRequiredService <IMemoryCache>();

            using (IServiceScope serviceScope = _serviceProvider.CreateScope())
            {
                CodesManager codesManager = serviceScope.ServiceProvider.GetRequiredService <CodesManager>();
                memoryCache.InitSystemCache(codesManager.GetList());
                DevicesManager    devicesManager = serviceScope.ServiceProvider.GetRequiredService <DevicesManager>();
                List <FlowDevice> devices        = devicesManager.GetList(null, 0, 0, null, null, null, 0, 0).Datas;
                memoryCache.InitDeviceCache(devices);
                RoadCrossingsManager roadCrossingsManager = serviceScope.ServiceProvider.GetRequiredService <RoadCrossingsManager>();
                memoryCache.InitCrossingCache(roadCrossingsManager.GetList(null, 0, 0).Datas);
                RoadSectionsManager roadSectionsManager = serviceScope.ServiceProvider.GetRequiredService <RoadSectionsManager>();
                memoryCache.InitSectionCache(roadSectionsManager.GetList(null, 0, 0, 0).Datas);
                return(devices);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="manager">路段数据库操作实例</param>
 public RoadSectionsController(RoadSectionsManager manager)
 {
     _manager = manager;
 }