public DataSet GetTripDetails(string FromStationId, string ToStationId, string TravelDate, string scheduleId)
        {
            try
            {
                TGTravelServiceClient o = new TGTravelServiceClient();
                o.Open();
                DataSet ds1 = new DataSet("dataset");
                TripDetails TripDt = o.getTripDetailsV2(UserId, Password, FromStationId, ToStationId, TravelDate, scheduleId);
                DataTable dataTable = new DataTable();
                dataTable.TableName = "BusLayoutList";
                if (TripDt.status.message.ToString() == "success")
                {
                    dataTable.Columns.Add("level");
                    dataTable.Columns.Add("noOfRows");
                    dataTable.Columns.Add("noOfColumns");
                    dataTable.Columns.Add("rowNbr");
                    dataTable.Columns.Add("columnNbr");
                    dataTable.Columns.Add("seatNbr");
                    dataTable.Columns.Add("cellType");

                    TripDetailsDTO dd = TripDt.tripDetails;
                    foreach (BusLayoutDTO Bdt in dd.busLayoutList)
                    {
                        foreach (SeatDetailsDTO sdt in Bdt.seatDetailsList)
                        {
                            DataRow dr = dataTable.NewRow();
                            dr["level"] = Bdt.level;
                            dr["noOfRows"] = Bdt.nbrOfRows;
                            dr["noOfColumns"] = Bdt.nbrOfColumns;
                            dr["rowNbr"] = sdt.rowNbr;
                            dr["columnNbr"] = sdt.columnNbr;
                            dr["seatNbr"] = sdt.seatNbr;
                            dr["cellType"] = sdt.cellType;
                            dataTable.Rows.Add(dr);
                        }
                    }
                    DataTable dtseatdetails = new DataTable();
                    dtseatdetails.TableName = "SeatDetails";
                    dtseatdetails.Columns.Add("SeatseatNbr");
                    dtseatdetails.Columns.Add("seatType");
                    dtseatdetails.Columns.Add("fare");
                    dtseatdetails.Columns.Add("seatStatus");
                    foreach (SeatDetailDTO SDt in dd.seatDetailList)
                    {
                        DataRow drseat = dtseatdetails.NewRow();
                        drseat["SeatseatNbr"] = SDt.seatNbr;
                        drseat["seatType"] = SDt.seatType;
                        drseat["fare"] = SDt.fare;
                        drseat["seatStatus"] = SDt.seatStatus;
                        dtseatdetails.Rows.Add(drseat);
                    }
                    DataTable dtBoarding = new DataTable();
                    dtBoarding.TableName = "BoardingPoints";
                    dtBoarding.Columns.Add("boardingPointId");
                    dtBoarding.Columns.Add("boardingPointName");
                    dtBoarding.Columns.Add("time");

                    foreach (BoardingPointDTO BPdt in dd.boardingPointList)
                    {
                        DataRow drboarding = dtBoarding.NewRow();
                        drboarding["boardingPointId"] = BPdt.boardingPointId;
                        drboarding["boardingPointName"] = BPdt.boardingPointName;
                        drboarding["time"] = BPdt.time;
                        dtBoarding.Rows.Add(drboarding);
                    }

                    ds1.Tables.Add(dtseatdetails);
                    ds1.Tables.Add(dtBoarding);
                    ds1.Tables.Add(dataTable);
                }
                o.Close();
                return ds1;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Method for getting all the tripdetails of V2
        /// </summary>
        /// <returns></returns>
        public SeatsInfo getTripDetailsV2(int sourceId, int destinationId, String dateOfJourney, String scheduleId, String URL,
                        String ConsumerKey, String ConsumerSecret)
        {
            SeatsInfo objSeatsLayout = null;
            try
            {
                //Convert dd-mm-yyyy format to API compatible format dd/mm/yyyy
                dateOfJourney = dateOfJourney.Replace('-', '/');
                client = new TGTravelServiceClient("TGSWS", URL);
                TripDetails response = client.getTripDetailsV2(ConsumerKey, ConsumerSecret, sourceId.ToString(), destinationId.ToString(), dateOfJourney, scheduleId);

                BoardingDroppingPoints bpList = new BoardingDroppingPoints();

                if (response != null && response.tripDetails != null)
                {
                    objSeatsLayout = new SeatsInfo();
                    objSeatsLayout.Seats = new List<SeatLayout>();
                    #region Loop each seat and add seat details to objSeatsLayout
                    //.OrderByDescending(element => element.level)
                    foreach (BusLayoutDTO busLayout in response.tripDetails.busLayoutList)
                    {
                        foreach (SeatDetailsDTO item in busLayout.seatDetailsList)
                        {
                            SeatLayout objSeat = new SeatLayout();
                            //set default values
                            objSeat.length = 1;
                            objSeat.width = 1;
                            objSeat.zIndex = busLayout.level - 1;
                            objSeat.row = item.columnNbr;
                            objSeat.column = item.rowNbr;
                            objSeat.id = scheduleId;
                            objSeat.number = item.seatNbr;

                            switch (item.cellType.ToUpper())
                            {
                                case "AISLE":
                                    break;
                                case "SEAT":
                                    objSeat.isAvailableSeat = "false";
                                    break;
                                case "BERTH":
                                    objSeat.isAvailableSeat = "false";
                                    objSeat.length = 2;
                                    objSeat.width = 1;
                                    break;
                                default:
                                    break;
                            }

                            //only available seats are fetched in response.tripDetails.seatDetailList
                            SeatDetailDTO seatInfo = response.tripDetails.seatDetailList.SingleOrDefault(seat => seat.seatNbr == item.seatNbr);

                            if (item.seatNbr != null && seatInfo != null)
                            {
                                objSeat.fare = seatInfo.fare;
                                if (seatInfo.seatStatus.Equals("A") || seatInfo.seatStatus.Equals("F") || seatInfo.seatStatus.Equals("M"))
                                {
                                    objSeat.isAvailableSeat = "true";
                                    if (seatInfo.seatStatus.Equals("F"))
                                        objSeat.isLadiesSeat = "true";
                                }
                            }

                            objSeatsLayout.Seats.Add(objSeat);
                        }
                    }
                    #endregion

                    #region Loop all boarding and dropping points
                    foreach (BoardingPointDTO point in response.tripDetails.boardingPointList)
                    {
                        bpList.Add(new BoardingDroppingDetails(point.boardingPointId, point.boardingPointName, point.time));
                    }
                    #endregion

                    if (bpList.Count > 0)
                        objSeatsLayout.boardingTimes = bpList;
                }
            }
            catch (Exception)
            {
                // to do
            }
            return objSeatsLayout;
        }