Exemplo n.º 1
0
        /// <summary>
        /// Method for blocking seats 
        /// </summary>
        /// <returns></returns>
        public BlockSeatsResponse blockSeatsForBooking(String scheduleId, String travelDate, String fromStationId, String toStationId, String boardingPointId,
                                String emailId, String mobileNbr, String address, String URL, String ConsumerKey, String ConsumerSecret,
                                int noOfSeats, String seatNo, String title, String name, String age, String sex)
        {
            BlockSeatsResponse objBlockSeatsResponse = new BlockSeatsResponse();
            try
            {
                travelDate = travelDate.Replace('-', '/');
                String[] seatNoArray = seatNo.Split(',');
                String[] titleArray = title.Split(',');
                String[] nameArray = name.Split(',');
                String[] ageArray = age.Split(',');
                String[] sexArray = sex.Split(',');

                client = new TGTravelServiceClient("TGSWS", URL);
                PassengerDetailDTO[] PassengerDetailDT = new PassengerDetailDTO[noOfSeats];

                for (int i = 0; i < noOfSeats; i++)
                {
                    PassengerDetailDTO PassengerDetailDTO1 = new PassengerDetailDTO();
                    PassengerDetailDTO1.age = ageArray[i].ToString();
                    PassengerDetailDTO1.name = nameArray[i].ToString();
                    PassengerDetailDTO1.seatNbr = seatNoArray[i].ToString();
                    PassengerDetailDTO1.sex = sexArray[i].ToString();
                    PassengerDetailDT[i] = PassengerDetailDTO1;
                }

                BlockedSeatsForBookingDetails response = client.blockSeatsForBooking(ConsumerKey, ConsumerSecret, scheduleId
                    , travelDate, fromStationId, toStationId, boardingPointId, emailId, mobileNbr, address, PassengerDetailDT);

                DataSet ds = convertJsonStringToDataSet(JsonConvert.SerializeObject(response));

                if (ds != null)
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables["status"].Rows[0]["code"].ToString().Trim().ToLower() == "200")
                        {
                            if (ds.Tables[0].Columns.Contains("bookingId"))
                            {
                                objBlockSeatsResponse.BookingID = ds.Tables[0].Rows[0]["bookingId"].ToString();
                                objBlockSeatsResponse.Status = "SUCCESS";
                            }
                        }
                        else
                        {
                            objBlockSeatsResponse.Status = "FAIL";
                            objBlockSeatsResponse.Message = ds.Tables["status"].Rows[0]["message"].ToString();
                        }
                    }
                }
                else { objBlockSeatsResponse.Status = "FAIL"; }
            }
            catch (Exception ex)
            {
                // to do
            }
            return objBlockSeatsResponse;
        }
        public string BlockTicket(BlockSeats blockSeats, String ConsumerKey, String ConsumerSecret)
        {
            if (ValidateRequest(ConsumerKey, ConsumerSecret))
            {
                ClientAPIList objClientAPIList = new ClientAPIList();

                if (HttpContext.Current.Cache["ClientAPI-" + ConsumerKey] == null)
                    GetAPIProvidersList(ConsumerKey, ConsumerSecret);

                objClientAPIList = (ClientAPIList)HttpContext.Current.Cache["ClientAPI-" + ConsumerKey];
                ClientAPIDetails objClientAPIDetails = objClientAPIList.SingleOrDefault(element => element.ProviderName == blockSeats.ProviderName);
                //BusesSearchFilter objBusesSearchFilter = new BusesSearchFilter();
                //objBusesSearchFilter = GetCityIDsOfProviders(objBusesSearchFilter, objClientAPIDetails, blockSeats.SourceId, blockSeats.DestinationId, blockSeats.JourneyDate);

                BlockSeatsResponse objBlockResponse = new BlockSeatsResponse();
                try
                {
                    switch (blockSeats.ProviderName)
                    {
                        case "BITLA":
                        case "MORNINGSTAR":
                            BitlaAPI clsBitlaAPI = new BitlaAPI();
                            objBlockResponse = clsBitlaAPI.validateTicket(blockSeats.SourceId, blockSeats.DestinationId, blockSeats.TripId,
                                objClientAPIDetails.APIURL, objClientAPIDetails.ConsumerKey, blockSeats.NoOfSeats, blockSeats.BoardingId.ToString(), blockSeats.SeatNo, blockSeats.Title, blockSeats.Name,
                                blockSeats.Age, blockSeats.Sex, blockSeats.Address, blockSeats.BookingRefNo, blockSeats.IdCardType, blockSeats.IdCardNo, blockSeats.IdCardIssuedBy,
                                blockSeats.MobileNo, blockSeats.EmergencyMobileNo, blockSeats.EmailId);
                            break;
                        case "TICKETGOOSE":
                            TicketGooseAPI clsTicketGooseAPI = new TicketGooseAPI();
                            objBlockResponse = clsTicketGooseAPI.blockSeatsForBooking(blockSeats.TripId, blockSeats.JourneyDate, blockSeats.SourceId.ToString(), blockSeats.DestinationId.ToString(), blockSeats.BoardingId,
                                blockSeats.EmailId, blockSeats.MobileNo, blockSeats.Address[0].ToString(), objClientAPIDetails.APIURL, objClientAPIDetails.ConsumerKey, objClientAPIDetails.ConsumerSecret,
                                blockSeats.NoOfSeats, blockSeats.SeatNo, blockSeats.Title, blockSeats.Name, blockSeats.Age, blockSeats.Sex);
                            break;
                        case "ABHIBUS":
                        case "SVR":
                        case "KALLADA":
                        case "KAVERI":
                        case "RAJESH":
                        case "SAIANJANA":
                            AbhibusAPI clsAbhiBusAPI = new AbhibusAPI();
                            objBlockResponse = clsAbhiBusAPI.getBlockTicket(blockSeats.SourceId, blockSeats.DestinationId, blockSeats.JourneyDate, blockSeats.TripId, blockSeats.SeatNo, objClientAPIDetails.APIURL, objClientAPIDetails.ConsumerKey);
                            break;
                        case "EASYBUS":
                            EasybusAPI clsEasyBusAPI = new EasybusAPI();
                            objBlockResponse = clsEasyBusAPI.getBlockTicket(blockSeats.SourceId, blockSeats.DestinationId, blockSeats.JourneyDate, blockSeats.TripId, blockSeats.SeatNo, objClientAPIDetails.APIURL, objClientAPIDetails.ConsumerKey);

                            break;
                        default:
                            break;
                    }
                }
                catch (Exception)
                {
                    //
                }
                return JsonConvert.SerializeObject(objBlockResponse);
            }
            else
            {
                return null;
                //throw new http exception
                //throw new System.Web.Http.HttpResponseException(HttpStatusCode.Forbidden);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Method for validating booked ticket
        /// </summary>
        /// <returns></returns>
        public BlockSeatsResponse validateTicket(int sourceId, int destinationId, String reservationId, String URL, String ConsumerKey
            , int noOfSeats, String boardingPointId, String seatNo, String title, String name, String age, String sex, String address
            , String bookingRefNo, String idCardType, String idCardNo, String idCardIssuedBy, String mobileNo, String emergencyMobileNo
            , String emailId)
        {
            BlockSeatsResponse objBlockSeatsResponse = new BlockSeatsResponse();

            try
            {
                String[] seatNoArray = seatNo.Split(',');
                String[] titleArray = title.Split(',');
                String[] nameArray = name.Split(',');
                String[] ageArray = age.Split(',');
                String[] sexArray = sex.Split(',');

                String requestUrl = URL + "/validate_book_ticket.json?api_key=" + ConsumerKey + "&reservation_id="
                    + reservationId + "&origin_id=" + sourceId + "&destination_id=" + destinationId + "&boarding_at=" + boardingPointId
                        + "&no_of_seats=" + noOfSeats + "&agent_ref_number=" + bookingRefNo;

                #region JsonRequestBody
                string seatDetails = "";

                for (int i = 0; i < noOfSeats; i++)
                {
                    if (seatDetails == "")
                    {
                        seatDetails = "{\"seat_number\":\"" + seatNoArray[i].ToString() + "\",\"title\":\"" + titleArray[i].ToString() + "\",\"name\":\"" + nameArray[i].ToString() + "\",\"age\":\""
                                        + ageArray[i].ToString() + "\",\"sex\":\"" + sexArray[i].ToString() + "\",\"is_primary\":\"" + "true" + "\",\"id_card_type\":\""
                                        + "1" + "\",\"id_card_number\":\"" + idCardNo + "\",\"id_card_issued_by\":\""
                                        + idCardIssuedBy + "\"} ";
                        //1 -> Pan Card, 2 -> D/L, 3 -> Passport, 4 -> Voter, 5 -> Aadhar Card////id_card_type
                    }
                    else
                    {
                        seatDetails = seatDetails + "," + "{\"seat_number\":\"" + seatNoArray[i].ToString() + "\",\"title\":\"" + titleArray[i].ToString() + "\",\"name\":\"" + nameArray[i].ToString() + "\",\"age\":\""
                                        + ageArray[i].ToString() + "\",\"sex\":\"" + sexArray[i].ToString() + "\",\"is_primary\":\"" + "true" + "\",\"id_card_type\":\""
                                        + "1" + "\",\"id_card_number\":\"" + idCardNo + "\",\"id_card_issued_by\":\""
                                        + idCardIssuedBy + "\"} ";
                    }
                }

                String req = "{\"book_ticket\":{\"seat_details\":{\"seat_detail\":[" + seatDetails + "]},";

                req = req + "\"contact_detail\":{\"mobile_number\":\"" + mobileNo + "\",\"emergency_name\":\"" + emergencyMobileNo
                          + "\",\"email\":\"" + emailId + "\"}}}";
                #endregion

                string response = invokePostRequest(requestUrl, req, "application/json");

                DataSet ds = convertJsonStringToDataSet(response);

                if (ds != null)
                {
                    if (ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["code"].ToString().Trim() == "200")
                        {
                            objBlockSeatsResponse.Status = "SUCCESS";
                            objBlockSeatsResponse.Message = ds.Tables[0].Rows[0]["message"].ToString().Trim();
                        }
                        else
                        {
                            objBlockSeatsResponse.Status = "FAIL";
                            objBlockSeatsResponse.Message = ds.Tables[0].Rows[0]["message"].ToString().Trim();
                        }
                    }
                }
                else { objBlockSeatsResponse.Status = "FAIL"; }

            }
            catch (Exception ex)
            {
                // to do
            }
            return objBlockSeatsResponse;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Method for getting the seat selection and blocking based on date, source, destination, and seat numbers
        /// </summary>
        /// <returns></returns>
        public BlockSeatsResponse getBlockTicket(int sourceId, int destinationId, String dateOfJourney, String serviceId,
             String selectedSeats, String URL, String ConsumerKey)
        {
            BlockSeatsResponse objBlockSeatsResponse = new BlockSeatsResponse();

            try
            {

                objBlockSeatsResponse.Status = "SUCCESS";

            }
            catch (Exception ex)
            {
                // to do
            }
            return objBlockSeatsResponse;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Method for getting the seat selection and blocking based on date, source, destination, and seat numbers
        /// </summary>
        /// <returns></returns>
        public BlockSeatsResponse getBlockTicket(int sourceId, int destinationId, String dateOfJourney, String serviceId,
             String selectedSeats, String URL, String ConsumerKey)
        {
            BlockSeatsResponse objBlockSeatsResponse = new BlockSeatsResponse();

            try
            {
                dateOfJourney = dateOfJourney.Split('-')[2] + "-" + dateOfJourney.Split('-')[1] + "-" + dateOfJourney.Split('-')[0];

                requestBody = "<?xml version='1.0'?><methodCall>" +
                "<methodName>index.seatselection</methodName>" +
                "<params><param><value><struct>" +
                "<member><name>jdate</name><value><string>" + dateOfJourney + "</string></value></member>" +
                "<member><name>sourceid</name><value><string>" + sourceId + "</string></value></member>" +
                "<member><name>destinationid</name><value><string>" + destinationId + "</string></value></member>" +
                "<member><name>serviceid</name><value><string>" + serviceId + "</string></value></member>" +
                "<member><name>selected_seats</name><value><string>" + selectedSeats + "</string></value></member>" +
                "</struct></value></param></params></methodCall>";

                xmlNodes = getXmlNodeList(requestBody, URL, ConsumerKey);
                string sel_seats = "", total_fare = "";
                if (xmlNodes != null)
                {
                    foreach (XmlNode xNode in xmlNodes)
                    {
                        XmlNodeList nodeNameList = xNode.SelectNodes("member/name");
                        XmlNodeList nodeValueList = xNode.SelectNodes("member/value");

                        for (int i = 0; i < nodeNameList.Count; i++)
                        {
                            if (nodeNameList.Item(i).InnerText == "sel_seats")
                            {
                                sel_seats = nodeValueList.Item(i).InnerText;
                            }
                            else if (nodeNameList.Item(i).InnerText == "sel_seat_row_cols")
                            {
                                string sel_seat_row_cols = nodeValueList.Item(i).InnerText;
                            }
                            else if (nodeNameList.Item(i).InnerText == "total_fare")
                            {
                                total_fare = nodeValueList.Item(i).InnerText;
                            }
                        }
                    }
                }

                if (sel_seats != "" && total_fare != "")
                {
                    objBlockSeatsResponse.Status = "SUCCESS";
                }
                else
                {
                    objBlockSeatsResponse.Status = "FAIL";
                }
            }
            catch (Exception ex)
            {
                // to do
            }
            return objBlockSeatsResponse;
        }