private void TrainGraphStateLoadFromCache(string version) { TrainGraphCache cache = new TrainGraphCache(); if (cache.Load(version)) { TrainGraphCache cache2 = cache; if (cache2 == null) { this.AddLog("TrainGraphCache was not loaded: Points.Cout == 0"); } else { this.m_needToFillTrainGraph = false; this.m_tgd = new TrainGraphData(); this.m_tgd.TimeStart = cache2.TimeStart; this.m_tgd.TimeStop = cache2.TimeStop; this.m_serverInfo.OperationDate = cache2.OperationDate; this.m_serverInfo.ServerTime = cache2.ServerTime; this.m_serverInfo.LastTrainGraphTime = cache2.LastTrainGraphTime; this.m_firstTrainGraphCache = cache2; } } else { this.AddLog("TrainGraphCache was not loaded: " + cache.LastError); } }
public override bool Load(string versionReuired) { try { byte[] buffer; TrainGraphCacheStorage storage = new TrainGraphCacheStorage(); if (storage.Load(out buffer, out this.LastError)) { TrainGraphCache cache = DCSerializer.DeserializeWithDCSMS(typeof(TrainGraphCache), buffer) as TrainGraphCache; base.CacheTime = cache.CacheTime; base.Curves = cache.Curves; base.Markers = cache.Markers; this.LastTrainGraphTime = cache.LastTrainGraphTime; this.OperationDate = cache.OperationDate; this.ServerTime = cache.ServerTime; base.TimeStart = cache.TimeStart; base.TimeStop = cache.TimeStop; base.Version = cache.Version; if (!cache.IsValid(versionReuired, out this.LastError)) { return(false); } return(true); } } catch (Exception exception) { base.LastError = exception.Message; } return(false); }
public TrainGraphCache Clone() { TrainGraphCache cache = new TrainGraphCache { CacheTime = base.CacheTime, LastTrainGraphTime = this.LastTrainGraphTime, OperationDate = this.OperationDate, ServerTime = this.ServerTime, Version = base.Version, TimeStart = base.TimeStart, TimeStop = base.TimeStop }; foreach (MarkerData data in base.Markers) { cache.Markers.Add(data.Clone()); } foreach (CurveData data2 in base.Curves) { cache.Curves.Add(data2.Clone()); } return cache; }
public TrainGraphCache Clone() { TrainGraphCache cache = new TrainGraphCache { CacheTime = base.CacheTime, LastTrainGraphTime = this.LastTrainGraphTime, OperationDate = this.OperationDate, ServerTime = this.ServerTime, Version = base.Version, TimeStart = base.TimeStart, TimeStop = base.TimeStop }; foreach (MarkerData data in base.Markers) { cache.Markers.Add(data.Clone()); } foreach (CurveData data2 in base.Curves) { cache.Curves.Add(data2.Clone()); } return(cache); }
private void TISWebService_GetStateCompleted(object sender, GetStateCompletedEventArgs e) { try { if (e.Error != null) { throw new SLException(e.Error.Message + " TISMonitor from server which failed"); } if (!e.Result) { throw new SLException(e.strError + " TISMonitor from server"); } TISWebServiceGetStateSupportOUT tout = DCSerializer.DeserializeWithDCS(typeof(TISWebServiceGetStateSupportOUT), e.strOut) as TISWebServiceGetStateSupportOUT; this.m_serverInfo.LastTrainGraphTime = tout.actualRealTimeTrainGraphTime; this.m_serverInfo.ServerTime = tout.ServerTime; List <TrainWebData> onlineTrains = DCSerializer.DeserializeWithDCS(typeof(List <TrainWebData>), e.onlineTrainsData) as List <TrainWebData>; List <TrainWebData> onlineButOnTheMapTrains = DCSerializer.DeserializeWithDCS(typeof(List <TrainWebData>), e.onlineButNotOnTheMapTrainsData) as List <TrainWebData>; List <TrainWebData> offlineTrains = DCSerializer.DeserializeWithDCS(typeof(List <TrainWebData>), e.offlineTrainsData) as List <TrainWebData>; this.DrawTrains(onlineTrains, offlineTrains, onlineButOnTheMapTrains); TrainGraphData data = DCSerializer.DeserializeWithDCS(typeof(TrainGraphData), e.trainGraphData) as TrainGraphData; if (this.m_needToFillTrainGraph) { this.trainGraphControl.ResetData(); } bool needToFillTrainGraph = this.m_needToFillTrainGraph; bool flag2 = false; if (this.m_firstTrainGraphCache != null) { flag2 = true; needToFillTrainGraph = true; data.Curves = this.MergeCachedAndRealTimesCurves(this.m_firstTrainGraphCache.Curves, data.Curves); data.Markers.Clear(); data.Markers.AddRange(this.m_firstTrainGraphCache.Markers); this.m_firstTrainGraphCache = null; } this.m_tgd = data; this.trainGraphControl.TrainGraphData = this.m_tgd; this.trainGraphControl.ActualTime = this.m_serverInfo.ServerTime; this.trainGraphControl.Draw(needToFillTrainGraph); if (this.m_needToFillTrainGraph) { this.m_needToFillTrainGraph = false; } this.UpdateTrainGraphCache(this.m_tgd, this.m_serverInfo); this.UpdateTrainsCache(onlineTrains); this.SetOperationDate(tout.ServerOperationDate, !this.m_isFirstIteration || flag2); this.m_isFirstIteration = false; ErrorDlg.HelperClose(); } catch (SLException exception) { this.AddLog("TISMonitor GetState error custom: " + exception.Message); ErrorDlg.HelperShow("", exception.Message); } catch (Exception exception2) { this.AddLog("TISMonitor GetState error: " + exception2.Message); ErrorDlg.HelperShow("", exception2.Message); this.ResetTrainGraph(); } this.busyIndicator.IsBusy = false; this.m_bInsideTimerForTrains = false; }
private void ResetTrainGraphCache() { this.m_trainGraphCache = new TrainGraphCache(); this.m_trainGraphCache.Version = this.CacheVersion; this.m_firstTrainGraphCache = null; }
private void TISWebService_GetStateCompleted(object sender, GetStateCompletedEventArgs e) { try { if (e.Error != null) { throw new SLException(e.Error.Message + " TISMonitor from server which failed"); } if (!e.Result) { throw new SLException(e.strError + " TISMonitor from server"); } TISWebServiceGetStateSupportOUT tout = DCSerializer.DeserializeWithDCS(typeof(TISWebServiceGetStateSupportOUT), e.strOut) as TISWebServiceGetStateSupportOUT; this.m_serverInfo.LastTrainGraphTime = tout.actualRealTimeTrainGraphTime; this.m_serverInfo.ServerTime = tout.ServerTime; List<TrainWebData> onlineTrains = DCSerializer.DeserializeWithDCS(typeof(List<TrainWebData>), e.onlineTrainsData) as List<TrainWebData>; List<TrainWebData> onlineButOnTheMapTrains = DCSerializer.DeserializeWithDCS(typeof(List<TrainWebData>), e.onlineButNotOnTheMapTrainsData) as List<TrainWebData>; List<TrainWebData> offlineTrains = DCSerializer.DeserializeWithDCS(typeof(List<TrainWebData>), e.offlineTrainsData) as List<TrainWebData>; this.DrawTrains(onlineTrains, offlineTrains, onlineButOnTheMapTrains); TrainGraphData data = DCSerializer.DeserializeWithDCS(typeof(TrainGraphData), e.trainGraphData) as TrainGraphData; if (this.m_needToFillTrainGraph) { this.trainGraphControl.ResetData(); } bool needToFillTrainGraph = this.m_needToFillTrainGraph; bool flag2 = false; if (this.m_firstTrainGraphCache != null) { flag2 = true; needToFillTrainGraph = true; data.Curves = this.MergeCachedAndRealTimesCurves(this.m_firstTrainGraphCache.Curves, data.Curves); data.Markers.Clear(); data.Markers.AddRange(this.m_firstTrainGraphCache.Markers); this.m_firstTrainGraphCache = null; } this.m_tgd = data; this.trainGraphControl.TrainGraphData = this.m_tgd; this.trainGraphControl.ActualTime = this.m_serverInfo.ServerTime; this.trainGraphControl.Draw(needToFillTrainGraph); if (this.m_needToFillTrainGraph) { this.m_needToFillTrainGraph = false; } this.UpdateTrainGraphCache(this.m_tgd, this.m_serverInfo); this.UpdateTrainsCache(onlineTrains); this.SetOperationDate(tout.ServerOperationDate, !this.m_isFirstIteration || flag2); this.m_isFirstIteration = false; ErrorDlg.HelperClose(); } catch (SLException exception) { this.AddLog("TISMonitor GetState error custom: " + exception.Message); ErrorDlg.HelperShow("", exception.Message); } catch (Exception exception2) { this.AddLog("TISMonitor GetState error: " + exception2.Message); ErrorDlg.HelperShow("", exception2.Message); this.ResetTrainGraph(); } this.busyIndicator.IsBusy = false; this.m_bInsideTimerForTrains = false; }