예제 #1
0
 public static DarwinDepartureBoard GetGetEntireBoard(string crs, int offset, int window)
 {
     try
     {
         Darwin.LDBServiceSoapClient client = new LDBServiceSoapClient();
         StationBoardWithDetails board = client.GetDepBoardWithDetails(DarwinToken.TheAccessToken, 0, crs, string.Empty, FilterType.from, offset, window);
         return DarwinDepartureBoardFactory.CreateDepartureBoard(board);
     }
     catch (Exception ex)
     {
         Logging.LogError(ex, "Whilst getting Departure Board", 1);
         return null;
     }
 }
예제 #2
0
 public static DarwinDepartureBoard GetGetEntireBoard(string crs, int offset, int window)
 {
     try
     {
         Darwin.LDBServiceSoapClient client = new LDBServiceSoapClient();
         StationBoardWithDetails     board  = client.GetDepBoardWithDetails(DarwinToken.TheAccessToken, 0, crs, string.Empty, FilterType.from, offset, window);
         return(DarwinDepartureBoardFactory.CreateDepartureBoard(board));
     }
     catch (Exception ex)
     {
         Logging.LogError(ex, "Whilst getting Departure Board", 1);
         return(null);
     }
 }
예제 #3
0
        //process of getting the Train rows.
        public List <DepartureBoardRowDTO> GetTrainDepartureBoards(String stationCode)
        {
            List <DepartureBoardRowDTO> rows = new List <DepartureBoardRowDTO>();

            try
            {
                //connectiong to Train api.
                var nrServiceClient            = new LDBServiceSoapClient();
                StationBoardWithDetails2 board = nrServiceClient.GetDepBoardWithDetails(
                    new AccessToken {
                    TokenValue = "94e96b3b-ee5d-43cb-ac3b-d49b5520579c"
                },
                    100,
                    stationCode,
                    String.Empty,
                    FilterType.to,
                    0,
                    120);
                //process of adding to the list rows.
                foreach (var s in board.trainServices)
                {
                    //remove what is gonna be set as Destination(since it is not to be included in via later)
                    var k = s.subsequentCallingPoints.FirstOrDefault().callingPoint.ToList();
                    k.Reverse();
                    k.Remove(k.First());
                    k.Reverse();

                    //Test of doing it through editing strings, was replaced with Reversing and removing.

                    /*string.join(string,array)
                     * for(int i = 0; i<s.subsequentCallingPoints.FirstOrDefault().callingPoint.Length-2; i++)
                     * {
                     *  points = points + s.subsequentCallingPoints.FirstOrDefault().callingPoint[i].locationName;
                     *  points = points + ", ";
                     * }
                     * points = points + s.subsequentCallingPoints.FirstOrDefault().callingPoint[s.subsequentCallingPoints.FirstOrDefault().callingPoint.Length - 2].locationName;
                     */

                    //figure out the time to give it.
                    var      now    = board.generatedAt;
                    var      sched  = s.std;
                    TimeSpan ts     = TimeSpan.Parse(sched);
                    var      expect = now.Date + ts;

                    //create flatened object and add to list of rows.
                    DepartureBoardRowDTO dep = new DepartureBoardRowDTO
                    {
                        StationName   = board.locationName,
                        Destination   = s.subsequentCallingPoints.LastOrDefault().callingPoint.LastOrDefault().locationName,
                        Via           = String.Join(", ", k.Select(name => name.locationName)),
                        ScheduledTime = expect.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss"),
                        Expected      = s.etd,
                        Platform      = s.platform
                    };
                    rows.Add(dep);
                }
            }
            catch
            {
                rows.Add(Error("TRAIN"));
            }
            return(rows);
        }