Beispiel #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);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 初始化缓存
        /// </summary>
        /// <returns>设备集合</returns>
        private List <DensityDevice> InitCache()
        {
            _logger.LogInformation((int)LogEvent.系统, "初始化缓存");

            DensityCache.DensitiesCache.Clear();
            EventCache.LastEventsCache.Clear();
            WebSocketMiddleware.ClearUrl();

            WebSocketMiddleware.AddUrl(EventWebSocketBlock.EventUrl);

            DateTime now       = DateTime.Now;
            DateTime yesterday = now.Date.AddDays(-1);

            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 <DensityDevice> devices        = devicesManager.GetList(null, 0, 0, null, null, 0, 0).Datas;
                memoryCache.InitDeviceCache(devices);
                RoadCrossingsManager roadCrossingsManager = serviceScope.ServiceProvider.GetRequiredService <RoadCrossingsManager>();
                memoryCache.InitCrossingCache(roadCrossingsManager.GetList(null, 0, 0).Datas);

                DensitiesManager densitiesManager = serviceScope.ServiceProvider.GetRequiredService <DensitiesManager>();
                foreach (DensityDevice device in devices)
                {
                    foreach (var relation in device.DensityDevice_DensityChannels)
                    {
                        foreach (TrafficRegion region in relation.Channel.Regions)
                        {
                            DensityCache.DensitiesCache.TryAdd(region.DataId, new ConcurrentQueue <TrafficDensity>(densitiesManager.QueryList(region.DataId, DateTimeLevel.Minute, yesterday, now)));
                            WebSocketMiddleware.AddUrl($"{DensityWebSocketBlock.DensityUrl}{region.DataId}");
                        }
                    }
                }
                return(devices);
            }
        }
Beispiel #3
0
 public PageModel <DensityDevice> GetList([FromQuery] string deviceName, [FromQuery] int deviceModel, [FromQuery] int deviceStatus, [FromQuery] string ip, [FromQuery] string order, [FromQuery] int pageNum, [FromQuery] int pageSize)
 {
     return(_manager.GetList(deviceName, deviceModel, deviceStatus, ip, order,
                             pageNum, pageSize));
 }