private void ExecuteIncrementalSync(SyncParams syncParams, CancellationToken cancellationToken) { _logService.Info($"ExecutePartialSync on candidates collection with LastAuditEventDate: {syncParams.LastAuditEventDate}"); var expectedCreatedCount = _auditRepository.GetAuditItemsCreatedSinceCount(syncParams.LastAuditEventDate, cancellationToken).Result; var createdCursor = _auditRepository.GetAllAuditItemsCreatedSince(syncParams.LastAuditEventDate, cancellationToken).Result; ProcessCandidates(createdCursor, expectedCreatedCount, cancellationToken); }
public void SetAuditEventSyncParams(SyncParams syncParams) { _getOpenConnection.MutatingQuery <int>( @"UPDATE Sync.SyncParams SET LastAuditEventDate = @lastAuditEventDate", new { lastAuditEventDate = syncParams.LastAuditEventDate == DateTime.MinValue ? null : (DateTime?)syncParams.LastAuditEventDate }); }
private void ExecuteFullSync(SyncParams syncParams, CancellationToken cancellationToken) { _logService.Warn($"ExecuteFullSync on audits collection with LastAuditEventDate: {syncParams.LastAuditEventDate}"); var expectedCount = _auditRepository.GetAuditItemsCount(cancellationToken).Result; var auditItems = _auditRepository.GetAllAuditItems(cancellationToken).Result; ProcessCandidates(auditItems, expectedCount, cancellationToken); }
public void SetCandidateSyncParams(SyncParams syncParams) { _getOpenConnection.MutatingQuery <int>( @"UPDATE Sync.SyncParams SET CandidateLastCreatedDate = @candidateLastCreatedDate, CandidateLastUpdatedDate = @candidateLastUpdatedDate", new { candidateLastCreatedDate = syncParams.CandidateLastCreatedDate == DateTime.MinValue ? null : (DateTime?)syncParams.CandidateLastCreatedDate, candidateLastUpdatedDate = syncParams.CandidateLastUpdatedDate == DateTime.MinValue ? null : (DateTime?)syncParams.CandidateLastUpdatedDate }); }
public void SetTraineeshipSyncParams(SyncParams syncParams) { _getOpenConnection.MutatingQuery <int>( @"UPDATE Sync.SyncParams SET TraineeshipLastCreatedDate = @traineeshipLastCreatedDate, TraineeshipLastUpdatedDate = @traineeshipLastUpdatedDate", new { traineeshipLastCreatedDate = syncParams.TraineeshipLastCreatedDate == DateTime.MinValue ? null : (DateTime?)syncParams.TraineeshipLastCreatedDate, traineeshipLastUpdatedDate = syncParams.TraineeshipLastUpdatedDate == DateTime.MinValue ? null : (DateTime?)syncParams.TraineeshipLastUpdatedDate }); }
public void SetApprenticeshipSyncParams(SyncParams syncParams) { _getOpenConnection.MutatingQuery <int>( @"UPDATE Sync.SyncParams SET ApprenticeshipLastCreatedDate = @apprenticeshipLastCreatedDate, ApprenticeshipLastUpdatedDate = @apprenticeshipLastUpdatedDate", new { apprenticeshipLastCreatedDate = syncParams.ApprenticeshipLastCreatedDate == DateTime.MinValue ? null : (DateTime?)syncParams.ApprenticeshipLastCreatedDate, apprenticeshipLastUpdatedDate = syncParams.ApprenticeshipLastUpdatedDate == DateTime.MinValue ? null : (DateTime?)syncParams.ApprenticeshipLastUpdatedDate }); }
private VideoBufferManager() { bool videoBuffering = Utils.Config.StringToBool(ConfigHandler.GetValue <VideoInfoPlugin>("VideoBuffering")); if (videoBuffering) { SyncParams <VideoBuffering> param = new SyncParams <VideoBuffering>("VideoBuffering", TimeSpan.FromSeconds(10), onVideoBufferingUpdate); CCTVInfoManager.Instance.ClientHub.RegisterSynchronizer <VideoBuffering>(param); } //_videoBufSync = new StaticInfoSynchronizer<VideoBuffering>(VideoInfoManager.Instance.WebApiBaseUri, "VideoBuffering", TimeSpan.FromSeconds(10), null, onVideoBufferingUpdate); }
private NodesManager() { string baseAddress = System.Configuration.ConfigurationManager.AppSettings["StaticInfoAddress"]; _hub = new CCTVDefaultInfoSync(baseAddress); _hub.RegisterDefaultWithoutUpdate(CCTVInfoType.HierarchyInfo); SyncParams <StorageSource> param = new SyncParams <StorageSource>("CenterStorage", TimeSpan.FromSeconds(10)); _hub.RegisterSynchronizer(param); }
private void ExecuteFullSync(SyncParams syncParams, CancellationToken cancellationToken) { _logService.Warn($"ExecuteFullSync on candidates collection with LastCreatedDate: {syncParams.CandidateLastCreatedDate} LastUpdatedDate: {syncParams.CandidateLastUpdatedDate}"); //TODO: This delete would have to be done outside of this class as it affects traineeships and apprenticeships at the same time //_genericSyncRespository.DeleteAll(_candidateTable); var expectedCount = _candidateUserRepository.GetCandidatesCount(cancellationToken).Result; var candidateUsers = _candidateUserRepository.GetAllCandidateUsers(cancellationToken).Result; var vacancyLocalAuthorities = _vacancyRepository.GetAllVacancyLocalAuthorities(); var localAuthorityCountyIds = _localAuthorityRepository.GetLocalAuthorityCountyIds(); ProcessCandidates(candidateUsers, expectedCount, vacancyLocalAuthorities, localAuthorityCountyIds, SyncType.Full, cancellationToken); }
public InfoService() { ClientHub = new CCTVDefaultInfoSync(Configurations.Instance.InfoServiceAddress); SyncParams <Gateway> gwSP = new SyncParams <Gateway>("GBT28181/Gateway", Timeout.InfiniteTimeSpan); SyncParams <Platform> platSP = new SyncParams <Platform>("GBT28181/Platform", Timeout.InfiniteTimeSpan); SyncParams <SipIdMap> simSP = new SyncParams <SipIdMap>("GBT28181/DeviceIdMap", Timeout.InfiniteTimeSpan); ClientHub.RegisterSynchronizer <Gateway>(gwSP); ClientHub.RegisterSynchronizer <Platform>(platSP); ClientHub.RegisterSynchronizer <SipIdMap>(simSP); ClientHub.RegisterDefaultWithoutUpdate(CCTVInfoType.StaticInfo); ClientHub.RegisterDefaultWithoutUpdate(CCTVInfoType.ControlConfig); ClientHub.RegisterDefaultWithoutUpdate(CCTVInfoType.UserPrivilege); }
public void RegisterHierarchy(string logicalTreeName, TimeSpan interval, SyncUpdateHandler updateHandler, string savePath) { if (_syncParams.ContainsKey(CCTVInfoType.HierarchyInfo)) { IDisposable dis = _syncParams[CCTVInfoType.HierarchyInfo] as IDisposable; dis.Dispose(); } SyncParams <CCTVHierarchyInfo> sp = new SyncParams <CCTVHierarchyInfo>(HierarchyInfoUtil.CreateSection(logicalTreeName), interval, updateHandler, savePath); StaticInfoSynchronizer <CCTVHierarchyInfo> sync = new StaticInfoSynchronizer <CCTVHierarchyInfo>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate); _syncParams[CCTVInfoType.HierarchyInfo] = new ParamHolder <CCTVHierarchyInfo>() { Sync = sync, Param = sp }; }
public void RegisterSynchronizer <T>(SyncParams <T> param) { Type t = typeof(T); if (_dictSyncs.ContainsKey(t)) { ParamHolder <T> holder = _dictSyncs[t] as ParamHolder <T>; holder.Sync.Dispose(); } StaticInfoSynchronizer <T> newSync = new StaticInfoSynchronizer <T>(_baseAddress, param.Section, param.Interval, param.SavePath, param.OnUpdate); _dictSyncs[t] = new ParamHolder <T>() { Sync = newSync, Param = param }; }
public SyncParams GetSyncParams() { var databaseSyncParams = _getOpenConnection.Query <DatabaseSyncParams>("SELECT LastSyncVersion, ApprenticeshipLastCreatedDate, ApprenticeshipLastUpdatedDate, TraineeshipLastCreatedDate, TraineeshipLastUpdatedDate, CandidateLastCreatedDate, CandidateLastUpdatedDate, LastAuditEventDate FROM Sync.SyncParams").SingleOrDefault() ?? new DatabaseSyncParams(); var syncParams = new SyncParams { LastSyncVersion = databaseSyncParams.LastSyncVersion }; //SQL doesn't store the "kind" property for DateTime and this is required for correct comparison to MongoDB DateTimes if (databaseSyncParams.ApprenticeshipLastCreatedDate.HasValue) { syncParams.ApprenticeshipLastCreatedDate = new DateTime(databaseSyncParams.ApprenticeshipLastCreatedDate.Value.Ticks, DateTimeKind.Utc); } if (databaseSyncParams.ApprenticeshipLastUpdatedDate.HasValue) { syncParams.ApprenticeshipLastUpdatedDate = new DateTime(databaseSyncParams.ApprenticeshipLastUpdatedDate.Value.Ticks, DateTimeKind.Utc); } if (databaseSyncParams.TraineeshipLastCreatedDate.HasValue) { syncParams.TraineeshipLastCreatedDate = new DateTime(databaseSyncParams.TraineeshipLastCreatedDate.Value.Ticks, DateTimeKind.Utc); } if (databaseSyncParams.TraineeshipLastUpdatedDate.HasValue) { syncParams.TraineeshipLastUpdatedDate = new DateTime(databaseSyncParams.TraineeshipLastUpdatedDate.Value.Ticks, DateTimeKind.Utc); } if (databaseSyncParams.CandidateLastCreatedDate.HasValue) { syncParams.CandidateLastCreatedDate = new DateTime(databaseSyncParams.CandidateLastCreatedDate.Value.Ticks, DateTimeKind.Utc); } if (databaseSyncParams.CandidateLastUpdatedDate.HasValue) { syncParams.CandidateLastUpdatedDate = new DateTime(databaseSyncParams.CandidateLastUpdatedDate.Value.Ticks, DateTimeKind.Utc); } if (databaseSyncParams.LastAuditEventDate.HasValue) { syncParams.LastAuditEventDate = new DateTime(databaseSyncParams.LastAuditEventDate.Value.Ticks, DateTimeKind.Utc); } return(syncParams); }
private void ExecuteIncrementalSync(SyncParams syncParams, CancellationToken cancellationToken) { _logService.Info($"ExecutePartialSync on candidates collection with LastCreatedDate: {syncParams.CandidateLastCreatedDate} LastUpdatedDate: {syncParams.CandidateLastUpdatedDate}"); var vacancyLocalAuthorities = _vacancyRepository.GetAllVacancyLocalAuthorities(); var localAuthorityCountyIds = _localAuthorityRepository.GetLocalAuthorityCountyIds(); //Inserts _logService.Info("Processing new candidates"); var expectedCreatedCount = _candidateUserRepository.GetCandidatesCreatedSinceCount(syncParams.CandidateLastCreatedDate, cancellationToken).Result; var createdCursor = _candidateUserRepository.GetAllCandidateUsersCreatedSince(syncParams.CandidateLastCreatedDate, cancellationToken).Result; ProcessCandidates(createdCursor, expectedCreatedCount, vacancyLocalAuthorities, localAuthorityCountyIds, SyncType.PartialByDateCreated, cancellationToken); _logService.Info("Completed processing new candidates"); //Updates _logService.Info("Processing updated candidates"); var expectedUpdatedCount = _candidateUserRepository.GetCandidatesUpdatedSinceCount(syncParams.CandidateLastUpdatedDate, cancellationToken).Result; var updatedCursor = _candidateUserRepository.GetAllCandidateUsersUpdatedSince(syncParams.CandidateLastUpdatedDate, cancellationToken).Result; ProcessCandidates(updatedCursor, expectedUpdatedCount, vacancyLocalAuthorities, localAuthorityCountyIds, SyncType.PartialByDateUpdated, cancellationToken); _logService.Info("Completed processing updated candidates"); }
private void UpdateWebApiUrl(string ip) { string url = $"http://{ip}:{ConfigReader.Instance.WebApiPort}"; if (ClientHub != null) { ClientHub.Dispose(); } if (ThumbnailMgr != null) { ThumbnailMgr.Dispose(); } ClientHub = new CCTVDefaultInfoSync(url); ThumbnailMgr = new ThumbnailManager(url, ConstSettings.ThumbnailPath); //集中存储配置信息获取。 SyncParams <StorageSource> param = new SyncParams <StorageSource>("CenterStorage", Timeout.InfiniteTimeSpan); ClientHub.RegisterDefault(CCTVInfoType.HierarchyInfo, TimeSpan.Zero); ClientHub.RegisterDefault(CCTVInfoType.StaticInfo, TimeSpan.Zero); ClientHub.RegisterDefault(CCTVInfoType.OnlineStatus, TimeSpan.FromSeconds(5)); ClientHub.RegisterDefault(CCTVInfoType.DynamicInfo, TimeSpan.FromSeconds(5)); ClientHub.RegisterSynchronizer(param); }
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; } }