コード例 #1
0
        /// <summary>
        /// Method for checking the whether the service is available or not based on the reservation id
        /// </summary>
        /// <returns></returns>
        public SeatsInfo getServiceDetails(String reservationId, String URL, String ConsumerKey)
        {
            SeatsInfo objSeatsLayout = null;
            try
            {
                requestBody = URL + "/service_details/" + reservationId + ".json?api_key=" + ConsumerKey;
                String strResponse = getJSONReponse(requestBody);
                DataSet ds = convertJsonStringToDataSet(strResponse);
                BoardingDroppingPoints bpList = new BoardingDroppingPoints();
                BoardingDroppingPoints dpList = new BoardingDroppingPoints();
                if (ds != null && ds.Tables.Count > 0 && ds.Tables["seat"].Rows.Count > 0)
                {
                    objSeatsLayout = new SeatsInfo();
                    objSeatsLayout.Seats = new List<SeatLayout>();
                    #region Loop each seat and add seat details to objSeatsLayout
                    foreach (DataRow item in ds.Tables["seat"].Rows)
                    {
                        SeatLayout objSeat = new SeatLayout();
                        objSeat.fare = item["fare"].ToString();
                        objSeat.id = reservationId;
                        objSeat.number = item["number"].ToString();

                        if (!Boolean.Parse(item["is_gangway"].ToString()))
                        {
                            objSeat.isAvailableSeat = item["available"].ToString();
                            objSeat.isLadiesSeat = item["is_reserved_for_ladies"].ToString();
                        }
                        else
                        {
                            objSeat.isAvailableSeat = null;
                            objSeat.isLadiesSeat = null;
                        }

                        objSeat.row = Int16.Parse(item["col_id"].ToString());
                        objSeat.column = Int16.Parse(item["row_id"].ToString());

                        #region set length, width and zindex

                        switch (item["type"].ToString())
                        {
                            case "UB":
                            case "SUB":
                                objSeat.length = 2;
                                objSeat.width = 1;
                                objSeat.zIndex = 1;
                                break;

                            //objSeat.length = 2;
                            //objSeat.width = 1;
                            //objSeat.zIndex = 1;
                            //break;
                            case "LB":
                            case "SLB":
                                objSeat.length = 2;
                                objSeat.width = 1;
                                objSeat.zIndex = 0;
                                break;

                            //objSeat.length = 2;
                            //objSeat.width = 1;
                            //objSeat.zIndex = 0;
                            //break;
                            case "SS":
                                objSeat.length = 1;
                                objSeat.width = 1;
                                objSeat.zIndex = 0;
                                break;
                            case "GY":
                                objSeat.length = 1;
                                objSeat.width = 1;
                                objSeat.zIndex = 0;
                                break;
                            default:
                                break;
                        }

                        #endregion

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

                    #region Loop all boarding and dropping points
                    foreach (DataRow point in ds.Tables["stage"].Rows)
                    {
                        if (point["type"] != null)
                        {
                            if (point["type"].ToString().ToUpper().Contains("BOARDING"))
                            {
                                bpList.Add(new BoardingDroppingDetails((String)point["address"], (String)point["contact_numbers"], (String)point["contact_persons"],
                                    (String)point["id"], (String)point["landmark"], (String)point["name"], (String)point["name"], (String)point["time"]));
                            }
                            else
                            {
                                dpList.Add(new BoardingDroppingDetails((String)point["address"], (String)point["contact_numbers"], (String)point["contact_persons"],
                                    (String)point["id"], (String)point["landmark"], (String)point["name"], (String)point["name"], (String)point["time"]));
                            }
                            //id,name,type,time,address,city_id,city,state(empty),contact_numbers,contact_persons,pin_code,landmark,ref_stage_id,ref_stage_name,stages_id
                        }
                    }
                    #endregion

                    if (bpList.Count > 0)
                        objSeatsLayout.boardingTimes = bpList;
                    if (dpList.Count > 0)
                        objSeatsLayout.droppingTimes = dpList;

                    if (ds.Tables["service_details"] != null &&
                        ds.Tables["service_details"].Rows.Count > 0 &&
                        ds.Tables["service_details"].Rows[0]["available_Seats"] != null)
                        objSeatsLayout.availableSeatsCount = ds.Tables["service_details"].Rows[0]["available_Seats"].ToString();
                }
            }
            catch (Exception ex)
            {
                // to do
            }
            return objSeatsLayout;
        }
コード例 #2
0
        public SeatsInfo getLayoutDetails(int sourceId, int destinationId, String dateOfJourney, String serviceId, String markUpFare, String SeatLayoutId,
              String seatType, String URL, String ConsumerKey)
        {
            SeatsInfo objSeatsLayout = null;

            try
            {
                //Convert mm-dd-yyyy format to API compatible format dd-mm-yyyy
                dateOfJourney = dateOfJourney.Split('-')[1] + "/" + dateOfJourney.Split('-')[0] + "/" + dateOfJourney.Split('-')[2];

                // requestBody = URL + "/server.aspx?Method=GetLayoutDetails&ServiceId=" + serviceId + "&DateofJourney=" + dateOfJourney + "&SorceStationid="+sourceId + "&DestinationStationid=" + destinationId + "&DateofJourney=" + dateOfJourney + "&DateOfReturn=" + dateOfJourney + "&Key=" + ConsumerKey;
                string str = URL + "/Server.aspx?Method=GetLayoutDetails&ServiceId=" + serviceId + "&DateofJourney=" + dateOfJourney + "&LayoutId=" + SeatLayoutId + "&BreathFare=" + markUpFare + "&SeatFare=" + markUpFare + "&Key=" + ConsumerKey;
                requestBody = str;

                DataSet ds = convertXMLtoDataset(getJSONReponse(requestBody));
                DataTable dtBuses = new DataTable();
                dtBuses = ds.Tables[0];

                objSeatsLayout = new SeatsInfo();
                objSeatsLayout.Seats = new List<SeatLayout>();
                if (dtBuses != null)
                {

                    for (int i = 0; i < dtBuses.Rows.Count; i++)
                    {
                        for (int j = 0; j < dtBuses.Columns.Count; j++)
                        {
                            SeatLayout objSeat = new SeatLayout();

                            string seat;
                            //string[] arr = new string[1];
                            seat = dtBuses.Rows[i][j].ToString();
                            if (seat != null && seat != "" && seat != "$")
                            {
                                string[] seatstr = seat.ToString().Split('_');

                                if (seatstr[0].StartsWith("U") || seatstr[0].StartsWith("L"))
                                {

                                    if (Convert.ToString(seatstr[0]).Trim() != "")
                                    {
                                        objSeat.number = seatstr[0].ToString();
                                    }

                                    if (Convert.ToString(seatstr[1]).Trim() != "")
                                    {
                                        if (Convert.ToString(seatstr[1]).Trim() == "1")
                                        {
                                            objSeat.isAvailableSeat = "true";
                                        }
                                        else if (Convert.ToString(seatstr[1]).Trim() == "0")
                                        {
                                            objSeat.isAvailableSeat = "false";
                                            if (Convert.ToString(seatstr[3]).Trim() != "")
                                            {
                                                if (Convert.ToString(seatstr[3]).Trim() == "S")
                                                {
                                                    objSeat.length = 2;
                                                    objSeat.width = 1;
                                                    objSeat.zIndex = 0;
                                                }
                                                else if (Convert.ToString(seatstr[3]).Trim() == "B")
                                                {
                                                    objSeat.length = 2;
                                                    objSeat.width = 1;
                                                    objSeat.zIndex = 0;
                                                }
                                            }
                                        }
                                        if (Convert.ToString(seatstr[2]).Trim() != "")
                                        {
                                            if (Convert.ToString(seatstr[2]).Trim() == "S")
                                            {
                                                objSeat.length = 2;
                                                objSeat.width = 1;
                                                objSeat.zIndex = 0;
                                            }
                                            else if (Convert.ToString(seatstr[2]).Trim() == "B")
                                            {
                                                objSeat.length = 2;
                                                objSeat.width = 1;
                                                objSeat.zIndex = 0;
                                            }
                                        }

                                        if (Convert.ToString(seatstr[3]).Trim() != "")
                                        {
                                            objSeat.fare = seatstr[3].ToString();
                                        }
                                    }
                                }
                                else
                                {

                                    if (Convert.ToString(seatstr[0]).Trim() != "")
                                    {
                                        objSeat.number = seatstr[0].ToString();
                                    }
                                    if (Convert.ToString(seatstr[1]).Trim() != "")
                                    {
                                        if (Convert.ToString(seatstr[1]).Trim() == "1")
                                        {
                                            objSeat.isAvailableSeat = "true";
                                        }
                                        else if (Convert.ToString(seatstr[1]).Trim() == "0")
                                        {
                                            objSeat.isAvailableSeat = "false";
                                            if (Convert.ToString(seatstr[3]).Trim() != "")
                                            {
                                                if (Convert.ToString(seatstr[3]).Trim() == "S")
                                                {
                                                    objSeat.length = 1;
                                                    objSeat.width = 1;
                                                    objSeat.zIndex = 0;
                                                }
                                                else if (Convert.ToString(seatstr[3]).Trim() == "B")
                                                {
                                                    objSeat.length = 2;
                                                    objSeat.width = 1;
                                                    objSeat.zIndex = 0;
                                                }
                                            }

                                        }
                                    }
                                    if (Convert.ToString(seatstr[2]).Trim() != "")
                                    {
                                        if (Convert.ToString(seatstr[2]).Trim() == "S")
                                        {
                                            objSeat.length = 1;
                                            objSeat.width = 1;
                                            objSeat.zIndex = 0;
                                        }
                                        else if (Convert.ToString(seatstr[2]).Trim() == "B")
                                        {
                                            objSeat.length = 2;
                                            objSeat.width = 1;
                                            objSeat.zIndex = 0;
                                        }
                                    }

                                    if (Convert.ToString(seatstr[3]).Trim() != "")
                                    {
                                        objSeat.fare = seatstr[3].ToString();
                                    }
                                }

                                objSeat.row = i + 1;
                                objSeat.column = j + 1;
                                objSeat.id = serviceId;
                                objSeat.isLadiesSeat = "false";
                                objSeatsLayout.Seats.Add(objSeat);
                            }

                        }
                    }

                    #region boarding and dropping points

                    BoardingDroppingPoints bpList = new BoardingDroppingPoints();
                    string strb = URL + "/Server.aspx?Method=GetBoardingPoints&ServiceId=" + serviceId + "&SorceStationid=" + sourceId + "&Key=" + ConsumerKey;
                    DataSet dsb = convertXMLtoDataset(getJSONReponse(strb));
                    DataTable dtBoarding = new DataTable();
                    dtBoarding = dsb.Tables[0];
                    if (dtBoarding != null && dtBoarding.TableName == "BoardingPoints")
                    {

                        for (int i = 0; i < dtBoarding.Rows.Count; i++)
                        {

                            string strBoarding;
                            string strBoardingAddress;
                            strBoarding = dtBoarding.Rows[i]["BoardindPointID"].ToString();
                            strBoardingAddress = dtBoarding.Rows[i]["BoardindPointName"].ToString();
                            if (strBoardingAddress != null && strBoardingAddress != "")
                            {
                                string[] BoardingId = strBoarding.ToString().Split('-');
                                string[] BoardingAddress = strBoardingAddress.ToString().Split('-');
                                BoardingDroppingDetails point = new BoardingDroppingDetails();
                                if (Convert.ToString(BoardingId[0]).Trim() != "")
                                {
                                    point.pointId = BoardingId[0].ToString();
                                }
                                if (Convert.ToString(BoardingAddress[0]).Trim() != "")
                                {
                                    point.location = BoardingId[1].ToString() + "," + BoardingAddress[0].ToString();
                                }
                                if (Convert.ToString(BoardingAddress[1]).Trim() != "")
                                {
                                    point.time = BoardingAddress[1].ToString();
                                }

                                bpList.Add(point);

                            }
                        }
                        if (bpList.Count > 0)
                            objSeatsLayout.boardingTimes = bpList;
                    }
                    else
                    {
                        BoardingDroppingDetails point = new BoardingDroppingDetails();
                        point.pointId = "0";
                        point.location = "No Boarding Points";
                        point.time = "00.00";
                        bpList.Add(point);
                        if (bpList.Count > 0)
                            objSeatsLayout.boardingTimes = bpList;
                    }
                    #endregion
                }

            }
            catch (Exception)
            {

                throw;
            }

            return objSeatsLayout;
        }
コード例 #3
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;
        }
コード例 #4
0
        private BoardingDroppingPoints Points(string points,string Travel)
        {
            BoardingDroppingPoints bdPoints = new BoardingDroppingPoints();

            try
            {
                if (points != "")
                {
                    string[] str = new string[1];
                    str[0] = "%&&&%";
                    string[] ssstr = points.Split(str, StringSplitOptions.None);
                    foreach (string st in ssstr)
                    {
                        if (st != "")
                        {
                            //6 - Ameerpet^^Kaveri Travels Near Hotel Imrose,Towards Begumpet (Ph No:9246462060) - 10:15PM
                            string[] strsplit = st.Split('^');
                            string[] strArr = strsplit[0].Split('-');
                            string[] strtime = strsplit[2].Split('-');
                            BoardingDroppingDetails details = new BoardingDroppingDetails();
                            details.pointId = strArr[0].ToString();
                            details.time = strtime[strtime.Length - 1].ToString().Trim().ToString();
                            //string[] strphone = strtime[0].Split('(');
                            details.address = strsplit[2].ToString().Trim().ToString();
                            //details.contactNumbers = strphone[1].ToString().Split(')')[0].Trim().ToString();
                            //for (int i = 1; i < strArr.Length - 1; i++)
                            if (Travel != "Kaveri Kamakshi Travels")
                            {
                                details.name = strArr[1].ToString();
                            }
                            else
                            {
                                details.name = strArr[2].ToString();
                            }
                            // details.name = details.name + strArr[i].ToString();
                            bdPoints.Add(details);

                        }
                    }
                }
            }
            catch (Exception ex)
            {
                // to do
            }
            return bdPoints;
        }