Example #1
0
 public override bool Load(string versionReuired)
 {
     try
     {
         string             str;
         TrainsCacheStorage storage = new TrainsCacheStorage();
         if (storage.Load(out str, out this.LastError))
         {
             TrainsCache cache = DCSerializer.DeserializeWithDCS(typeof(TrainsCache), str) as TrainsCache;
             base.CacheTime = cache.CacheTime;
             this.Trains    = cache.Trains;
             base.Version   = cache.Version;
             if (!cache.IsValid(versionReuired, out this.LastError))
             {
                 return(false);
             }
             return(true);
         }
     }
     catch (Exception exception)
     {
         base.LastError = exception.Message;
     }
     return(false);
 }
Example #2
0
 private void TISWebService_GetStateCompleted(object sender, GetStateCompletedEventArgs e)
 {
     try
     {
         //if (e.Error != null)
         //{
         //    throw new SLException(e.Error.Message + " DataProvider from server which failed");
         //}
         //if (!e.Result)
         //{
         //    throw new SLException(e.strError + " DataProvider from server");
         //}
         //if (this.OnData != null)
         //{
         TISWebServiceGetStateSupportOUT result               = DCSerializer.DeserializeWithDCS(typeof(TISWebServiceGetStateSupportOUT), e.strOut) as TISWebServiceGetStateSupportOUT;
         List <TrainWebData>             onlineTrains         = DCSerializer.DeserializeWithDCS(typeof(List <TrainWebData>), e.onlineTrainsData) as List <TrainWebData>;
         List <TrainWebData>             offlineTrains        = DCSerializer.DeserializeWithDCS(typeof(List <TrainWebData>), e.offlineTrainsData) as List <TrainWebData>;
         List <TrainWebData>             onlineButNotOnTheMap = DCSerializer.DeserializeWithDCS(typeof(List <TrainWebData>), e.onlineButNotOnTheMapTrainsData) as List <TrainWebData>;
         //this.OnData(result, onlineTrains, offlineTrains, onlineButNotOnTheMap);
         //this.AddLog("DataProvider GetStateCompleted");
         //}
     }
     //catch (SLException exception)
     //{
     //    this.DataError(exception.Message);
     //    this.AddLog("DataProvider GetState error custom: " + exception.Message);
     //}
     catch (Exception exception2)
     {
         //this.DataError(exception2.Message);
         //this.AddLog("DataProvider GetState error: " + exception2.Message);
     }
 }
Example #3
0
        private StateDataViewModel GetStateData(GetStateResponseBody webResponse)
        {
            var model = new StateDataViewModel();

            model.StateResult          = webResponse.GetStateResult;
            model.strOut               = DCSerializer.DeserializeWithDCS <TISWebServiceGetStateSupportOUT>(webResponse.strOut);
            model.onlineTrains         = DCSerializer.DeserializeWithDCS <List <TrainWebData> >(webResponse.onlineTrainsData);
            model.offlineTrains        = DCSerializer.DeserializeWithDCS <List <TrainWebData> >(webResponse.offlineTrainsData);
            model.onlineButNotOnTheMap = DCSerializer.DeserializeWithDCS <List <TrainWebData> >(webResponse.onlineButNotOnTheMapTrainsData);
            model.trainGraphData       = DCSerializer.DeserializeWithDCS <TrainGraphData>(webResponse.trainGraphData);
            model.Error = webResponse.strError;

            return(model);
        }
Example #4
0
 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;
 }