Esempio n. 1
0
        private void deleteAndUpdate <T>(StaticInfoSynchronizer <T> sync, IEnumerable <string> allKeys, Dictionary <string, T> newValues, Func <T, string> keyInEle)
        {
            var delKeyDict = allKeys.Where(x => !newValues.ContainsKey(x)).ToDictionary(x => x);
            var delValues  = sync.Values.Where(x => delKeyDict.ContainsKey(keyInEle(x)));
            var delDict    = delValues.ToDictionary(x => keyInEle(x));

            sync.PutUpdate(toObjectItems(delDict, true));
            sync.PutUpdate(toObjectItems(newValues, false));
        }
Esempio n. 2
0
        private void _info_RealtimeInfoEvent(VideoParser.Camera camera, VideoParser.GPS gps)
        {
            CCTVDynamicInfo dynamicInfo = getCameraInfo(camera);

            if (dynamicInfo == null)
            {
                dynamicInfo = getGpsInfo(gps);
            }
            if (dynamicInfo != null)
            {
                ObjectItem <CCTVDynamicInfo> item = new ObjectItem <CCTVDynamicInfo>()
                {
                    Key       = dynamicInfo.VideoId,
                    IsDeleted = false,
                    Item      = dynamicInfo,
                };
                _dynamicItemList.Add(item);
                if (DateTime.Now - _lastUpdateTime > TimeSpan.FromSeconds(0.5))
                {
                    _lastUpdateTime = DateTime.Now;
                    _dynamicSync.PutUpdate(_dynamicItemList);
                    _dynamicItemList.Clear();
                }
            }
        }