private void checkRegister(CCTVInfoType type) { if (!_syncParams.ContainsKey(type)) { throw new InvalidOperationException("未注册此种类型的信息同步刷新服务:" + type); } }
private T[] GetDefaultInfoFull <T>(CCTVInfoType type) { checkRegister(type); ParamHolder <T> ph = _syncParams[type] as ParamHolder <T>; checkUpdate(ph); return(ph.Sync.Values.ToArray()); }
public void RemoveUpdateHandler(CCTVInfoType type, SyncUpdateHandler updateHandler) { if (_syncParams.ContainsKey(type) && updateHandler != null) { IUpdate iu = _syncParams[type] as IUpdate; iu.UpdateHandler -= updateHandler; } }
public void UpdateDefault(CCTVInfoType type) { if (_syncParams.ContainsKey(type)) { IUpdate pd = _syncParams[type] as IUpdate; pd.Update(); } }
public void UnregisterDefault(CCTVInfoType type) { if (_syncParams.ContainsKey(type)) { IDisposable dis = _syncParams[type] as IDisposable; dis.Dispose(); _syncParams.Remove(type); } }
private T GetDefaultInfo <T>(CCTVInfoType type, string key) { checkRegister(type); ParamHolder <T> ph = _syncParams[type] as ParamHolder <T>; checkUpdate(ph); T value; ph.Sync.TryGetValue(key, out value); return(value); }
private void PutDefaultInfo <T>(CCTVInfoType type, string key, T info, bool isDeleted) { checkRegister(type); ParamHolder <T> ph = _syncParams[type] as ParamHolder <T>; ph.Sync.PutUpdate(new List <ObjectItem <T> >() { new ObjectItem <T>() { Key = key, IsDeleted = isDeleted, Item = info } }); }
public void RegisterDefault(CCTVInfoType type, TimeSpan interval, SyncUpdateHandler updateHandler, string savePath) { if (_syncParams.ContainsKey(type)) { IDisposable dis = _syncParams[type] as IDisposable; dis.Dispose(); } switch (type) { case CCTVInfoType.TargetTrackInfo: { SyncParams <CCTVTargetTrack> sp = new SyncParams <CCTVTargetTrack>(DefaultSections.TargetTrackInfo, interval, updateHandler, savePath); StaticInfoSynchronizer <CCTVTargetTrack> sync = new StaticInfoSynchronizer <CCTVTargetTrack>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate); _syncParams[type] = new ParamHolder <CCTVTargetTrack>() { Sync = sync, Param = sp }; } break; case CCTVInfoType.VideoAnalyzeInfo: { SyncParams <CCTVVideoAnalyze> sp = new SyncParams <CCTVVideoAnalyze>(DefaultSections.VideoAnalyzeInfo, interval, updateHandler, savePath); StaticInfoSynchronizer <CCTVVideoAnalyze> sync = new StaticInfoSynchronizer <CCTVVideoAnalyze>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate); _syncParams[type] = new ParamHolder <CCTVVideoAnalyze>() { Sync = sync, Param = sp }; } break; case CCTVInfoType.VideoTrackInfo: { SyncParams <CCTVVideoTrack> sp = new SyncParams <CCTVVideoTrack>(DefaultSections.VideoTrackInfo, interval, updateHandler, savePath); StaticInfoSynchronizer <CCTVVideoTrack> sync = new StaticInfoSynchronizer <CCTVVideoTrack>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate); _syncParams[type] = new ParamHolder <CCTVVideoTrack>() { Sync = sync, Param = sp }; } break; case CCTVInfoType.CameraLimitsInfo: { SyncParams <CCTVCameraLimits> sp = new SyncParams <CCTVCameraLimits>(DefaultSections.CameraLimitsInfo, interval, updateHandler, savePath); StaticInfoSynchronizer <CCTVCameraLimits> sync = new StaticInfoSynchronizer <CCTVCameraLimits>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate); _syncParams[type] = new ParamHolder <CCTVCameraLimits>() { Sync = sync, Param = sp }; } break; case CCTVInfoType.DynamicInfo: { SyncParams <CCTVDynamicInfo> sp = new SyncParams <CCTVDynamicInfo>(DefaultSections.DynamicInfo, interval, updateHandler, savePath); StaticInfoSynchronizer <CCTVDynamicInfo> sync = new StaticInfoSynchronizer <CCTVDynamicInfo>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate); _syncParams[type] = new ParamHolder <CCTVDynamicInfo>() { Sync = sync, Param = sp }; } break; case CCTVInfoType.GlobalInfo: { SyncParams <CCTVGlobalInfo> sp = new SyncParams <CCTVGlobalInfo>(DefaultSections.GlobalInfo, interval, updateHandler, savePath); StaticInfoSynchronizer <CCTVGlobalInfo> sync = new StaticInfoSynchronizer <CCTVGlobalInfo>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate); _syncParams[type] = new ParamHolder <CCTVGlobalInfo>() { Sync = sync, Param = sp }; } break; case CCTVInfoType.HierarchyInfo: { SyncParams <CCTVHierarchyInfo> sp = new SyncParams <CCTVHierarchyInfo>(HierarchyInfoUtil.CreateSection("Default"), interval, updateHandler, savePath); StaticInfoSynchronizer <CCTVHierarchyInfo> sync = new StaticInfoSynchronizer <CCTVHierarchyInfo>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate); _syncParams[type] = new ParamHolder <CCTVHierarchyInfo>() { Sync = sync, Param = sp }; } break; case CCTVInfoType.LogicalTree: { SyncParams <CCTVLogicalTree> sp = new SyncParams <CCTVLogicalTree>(DefaultSections.LogicalTree, interval, updateHandler, savePath); StaticInfoSynchronizer <CCTVLogicalTree> sync = new StaticInfoSynchronizer <CCTVLogicalTree>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate); _syncParams[type] = new ParamHolder <CCTVLogicalTree>() { Sync = sync, Param = sp }; } break; case CCTVInfoType.OnlineStatus: { SyncParams <CCTVOnlineStatus> sp = new SyncParams <CCTVOnlineStatus>(DefaultSections.OnlineStatus, interval, updateHandler, savePath); StaticInfoSynchronizer <CCTVOnlineStatus> sync = new StaticInfoSynchronizer <CCTVOnlineStatus>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate); _syncParams[type] = new ParamHolder <CCTVOnlineStatus>() { Sync = sync, Param = sp }; } break; case CCTVInfoType.ServerInfo: { SyncParams <CCTVServerInfo> sp = new SyncParams <CCTVServerInfo>(DefaultSections.ServerInfo, interval, updateHandler, savePath); StaticInfoSynchronizer <CCTVServerInfo> sync = new StaticInfoSynchronizer <CCTVServerInfo>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate); _syncParams[type] = new ParamHolder <CCTVServerInfo>() { Sync = sync, Param = sp }; } break; case CCTVInfoType.StaticInfo: { SyncParams <CCTVStaticInfo> sp = new SyncParams <CCTVStaticInfo>(DefaultSections.StaticInfo, interval, updateHandler, savePath); StaticInfoSynchronizer <CCTVStaticInfo> sync = new StaticInfoSynchronizer <CCTVStaticInfo>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate); _syncParams[type] = new ParamHolder <CCTVStaticInfo>() { Sync = sync, Param = sp }; } break; case CCTVInfoType.ControlConfig: { SyncParams <CCTVControlConfig> sp = new SyncParams <CCTVControlConfig>(DefaultSections.ControlConfig, interval, updateHandler, savePath); StaticInfoSynchronizer <CCTVControlConfig> sync = new StaticInfoSynchronizer <CCTVControlConfig>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate); _syncParams[type] = new ParamHolder <CCTVControlConfig>() { Sync = sync, Param = sp }; } break; case CCTVInfoType.DeviceInfo: { SyncParams <CCTVDeviceInfo> sp = new SyncParams <CCTVDeviceInfo>(DefaultSections.DeviceInfo, interval, updateHandler, savePath); StaticInfoSynchronizer <CCTVDeviceInfo> sync = new StaticInfoSynchronizer <CCTVDeviceInfo>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate); _syncParams[type] = new ParamHolder <CCTVDeviceInfo>() { Sync = sync, Param = sp }; } break; case CCTVInfoType.UserInfo: { SyncParams <CCTVUserInfo> sp = new SyncParams <CCTVUserInfo>(DefaultSections.UserInfo, interval, updateHandler, savePath); StaticInfoSynchronizer <CCTVUserInfo> sync = new StaticInfoSynchronizer <CCTVUserInfo>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate); _syncParams[type] = new ParamHolder <CCTVUserInfo>() { Sync = sync, Param = sp }; } break; case CCTVInfoType.Privilege: { SyncParams <CCTVPrivilege> sp = new SyncParams <CCTVPrivilege>(DefaultSections.Privilege, interval, updateHandler, savePath); StaticInfoSynchronizer <CCTVPrivilege> sync = new StaticInfoSynchronizer <CCTVPrivilege>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate); _syncParams[type] = new ParamHolder <CCTVPrivilege>() { Sync = sync, Param = sp }; } break; case CCTVInfoType.UserPrivilege: { { SyncParams <CCTVUserPrivilege> sp = new SyncParams <CCTVUserPrivilege>(DefaultSections.UserPrivilege, interval, updateHandler, savePath); StaticInfoSynchronizer <CCTVUserPrivilege> sync = new StaticInfoSynchronizer <CCTVUserPrivilege>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate); _syncParams[type] = new ParamHolder <CCTVUserPrivilege>() { Sync = sync, Param = sp }; } } break; default: break; } }
public void RegisterDefault(CCTVInfoType type, TimeSpan interval, SyncUpdateHandler updateHandler) { RegisterDefault(type, interval, updateHandler, null); }
public void RegisterDefault(CCTVInfoType type, TimeSpan interval) { RegisterDefault(type, interval, null, null); }
public void RegisterDefaultWithoutUpdate(CCTVInfoType type) { RegisterDefault(type, TimeSpan.Zero, null, null); }
public bool HasRegisteredDefault(CCTVInfoType type) { return(_syncParams.ContainsKey(type)); }