public override void Load() { var response = emergencyLinkageConfigService.GetEmergencyLinkageConfigAllList(new GetAllEmergencyLinkageConfigRequest()); if (response.IsSuccess && response.Data != null) { _cache.Clear(); _cache = response.Data; } }
protected override void DoWork() { /*检查报警通知-start*/ try { DateTime alarmNotificationServerSideTime = DateTime.MinValue; BasicResponse <string> alarmNotificationLastChangedTimeResponse = largeDataAnalysisLastChangedService.GetAlarmNotificationLastChangedTime(new LargeDataAnalysisLastChangedRequest()); if (alarmNotificationLastChangedTimeResponse.IsSuccess && !string.IsNullOrEmpty(alarmNotificationLastChangedTimeResponse.Data)) { alarmNotificationServerSideTime = DateTime.Parse(alarmNotificationLastChangedTimeResponse.Data); } if (alarmNotificationServerSideTime > alarmNotificationLastChangedTime || alarmConfigCache.Count == 0) { var alarmNotificationPersonnelResponse = alarmNotificationPersonnelConfigService.GetAlarmNotificationPersonnelConfigAllList(new GetAllAlarmNotificationRequest()); if (alarmNotificationPersonnelResponse.IsSuccess && alarmNotificationPersonnelResponse.Data != null) { var cachedAlarmNotificationItems = alarmConfigCache.Query(); foreach (var item in alarmNotificationPersonnelResponse.Data) { var oldAlarmConfig = cachedAlarmNotificationItems.FirstOrDefault(q => q.Id == item.Id); if (null == oldAlarmConfig) { alarmConfigCache.AddItem(item); } else { alarmConfigCache.UpdateItem(item); } } int alarmConfigCount = cachedAlarmNotificationItems.Count; for (int i = alarmConfigCount - 1; i >= 0; i--) { if (!alarmNotificationPersonnelResponse.Data.Any(q => q.Id == cachedAlarmNotificationItems[i].Id)) { alarmConfigCache.DeleteItem(cachedAlarmNotificationItems[i]); } } } alarmNotificationLastChangedTime = alarmNotificationServerSideTime; } } catch (Exception ex) { LogHelper.Error(string.Format("检查报警通知时出错:{0}", ex.StackTrace)); } /*检查报警通知-end*/ /*检查应急联动-start*/ try { DateTime emergencyLinkageServerSideTime = DateTime.MinValue; BasicResponse <string> emergencyLinkageLastChangedTimeResponse = largeDataAnalysisLastChangedService.GetEmergencyLinkageLastChangedTime(new LargeDataAnalysisLastChangedRequest()); if (emergencyLinkageLastChangedTimeResponse.IsSuccess && !string.IsNullOrEmpty(emergencyLinkageLastChangedTimeResponse.Data)) { emergencyLinkageServerSideTime = DateTime.Parse(emergencyLinkageLastChangedTimeResponse.Data); } if (emergencyLinkageServerSideTime > emergencyLinkageLastChangedTime || emergencyLinkageConfigCache.Count == 0) { var emergencyLinkageResponse = emergencyLinkageConfigService.GetEmergencyLinkageConfigAllList(new GetAllEmergencyLinkageConfigRequest()); if (emergencyLinkageResponse.IsSuccess && emergencyLinkageResponse.Data != null) { var cachedEmergencyLinkageItems = emergencyLinkageConfigCache.Query(); foreach (var item in emergencyLinkageResponse.Data) { var oldEmergencyLinkageConfig = cachedEmergencyLinkageItems.FirstOrDefault(q => q.Id == item.Id); if (null == oldEmergencyLinkageConfig) { emergencyLinkageConfigCache.AddItem(item); } else { emergencyLinkageConfigCache.UpdateItem(item); } } int emergencyLinkageCount = cachedEmergencyLinkageItems.Count; for (int i = emergencyLinkageCount - 1; i >= 0; i--) { if (!emergencyLinkageResponse.Data.Any(q => q.Id == cachedEmergencyLinkageItems[i].Id)) { emergencyLinkageConfigCache.DeleteItem(cachedEmergencyLinkageItems[i]); } } } emergencyLinkageLastChangedTime = emergencyLinkageServerSideTime; } } catch (Exception ex) { LogHelper.Error(string.Format("检查应急联动时出错:{0}", ex.StackTrace)); } /*检查应急联动-end*/ /*检查区域断电-start RegionOutageConfigCacheList*/ try { DateTime regionOutageServerSideTime = DateTime.MinValue; BasicResponse <string> regionOutageLastChangedTimeResponse = largeDataAnalysisLastChangedService.GetRegionOutageLastChangedTime(new LargeDataAnalysisLastChangedRequest()); if (regionOutageLastChangedTimeResponse.IsSuccess && !string.IsNullOrEmpty(regionOutageLastChangedTimeResponse.Data)) { regionOutageServerSideTime = DateTime.Parse(regionOutageLastChangedTimeResponse.Data); } if (regionOutageServerSideTime > regionOutageLastChangedTime || regionOutageConfigCache.Count == 0) { var regionOutageResponse = regionOutageConfigService.GetRegionOutageConfigAllList(new GetAllRegionOutageConfigRequest()); if (regionOutageResponse.IsSuccess && regionOutageResponse.Data != null) { var cachedRegionOutageItems = regionOutageConfigCache.Query(); foreach (var item in regionOutageResponse.Data) { var oldRegionOutageConfig = cachedRegionOutageItems.FirstOrDefault(q => q.Id == item.Id); if (null == oldRegionOutageConfig) { regionOutageConfigCache.AddItem(item); } else { regionOutageConfigCache.UpdateItem(item); } } int regionOutageCount = cachedRegionOutageItems.Count; for (int i = regionOutageCount - 1; i >= 0; i--) { if (!regionOutageResponse.Data.Any(q => q.Id == cachedRegionOutageItems[i].Id)) { regionOutageConfigCache.DeleteItem(cachedRegionOutageItems[i]); } } } regionOutageLastChangedTime = regionOutageServerSideTime; } } catch (Exception ex) { LogHelper.Error(string.Format("检查区域断电时出错:{0}", ex.StackTrace)); } /*检查区域断电-end*/ base.DoWork(); }
public BasicResponse <List <JC_EmergencyLinkageConfigInfo> > GetEmergencyLinkageConfigAllList(GetAllEmergencyLinkageConfigRequest getAllEmergencyLinkageConfigRequest) { return(_EmergencyLinkageConfigService.GetEmergencyLinkageConfigAllList(getAllEmergencyLinkageConfigRequest)); }