public string BookTicket(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);
                BookSeatsResponse objBookResponse = new BookSeatsResponse();
                if (objClientAPIDetails != null)
                {
                    try
                    {
                        switch (blockSeats.ProviderName)
                        {
                            case "BITLA":
                            case "MORNINGSTAR":
                                BitlaAPI clsBitlaAPI = new BitlaAPI();
                                objBookResponse = clsBitlaAPI.bookTicket(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();
                                objBookResponse = clsTicketGooseAPI.BookTicket(blockSeats.BookingId, objClientAPIDetails.APIURL, objClientAPIDetails.ConsumerKey, objClientAPIDetails.ConsumerSecret);
                                break;
                            case "ABHIBUS":
                            case "SVR":
                            case "KALLADA":
                            case "KAVERI":
                            case "RAJESH":
                            case "SAIANJANA":
                                AbhibusAPI clsAbhiBusAPI = new AbhibusAPI();
                                objBookResponse = clsAbhiBusAPI.bookSeats(blockSeats.SourceId, blockSeats.DestinationId, blockSeats.JourneyDate
                                    , blockSeats.TripId, blockSeats.SeatNo, blockSeats.Title, blockSeats.Name, blockSeats.BoardingId, blockSeats.Address
                                    , blockSeats.Name, blockSeats.MobileNo, blockSeats.EmailId, blockSeats.BookingRefNo, objClientAPIDetails.APIURL
                                    , objClientAPIDetails.ConsumerKey);

                                objBookResponse.extraseatinfo = blockSeats.SourceId + "," + blockSeats.DestinationId + "," + blockSeats.JourneyDate
                              + "," + blockSeats.TripId + "," + blockSeats.SeatNo + "," + blockSeats.Title + "," + blockSeats.Name + "," + blockSeats.BoardingId + "," + blockSeats.Address
                              + "," + blockSeats.Name + "," + blockSeats.MobileNo + "," + blockSeats.EmailId + "," + blockSeats.BookingRefNo;
                                break;

                            case "EASYBUS":
                                EasybusAPI clsEasyBusAPI = new EasybusAPI();
                                objBookResponse = clsEasyBusAPI.bookSeats(blockSeats.SourceId, blockSeats.DestinationId, blockSeats.JourneyDate
                                    , blockSeats.TripId, blockSeats.SeatNo, blockSeats.Sex, blockSeats.Name, blockSeats.BoardingId, blockSeats.Address
                                    , blockSeats.Name, blockSeats.MobileNo, blockSeats.EmailId, blockSeats.BookingRefNo, objClientAPIDetails.APIURL
                                    , objClientAPIDetails.ConsumerKey);

                                objBookResponse.extraseatinfo = blockSeats.SourceId + "," + blockSeats.DestinationId + "," + blockSeats.JourneyDate
                              + "," + blockSeats.TripId + "," + blockSeats.SeatNo + "," + blockSeats.Title + "," + blockSeats.Name + "," + blockSeats.BoardingId + "," + blockSeats.Address
                              + "," + blockSeats.Name + "," + blockSeats.MobileNo + "," + blockSeats.EmailId + "," + blockSeats.BookingRefNo;

                                break;
                            default:
                                break;
                        }
                    }
                    catch (Exception ex)
                    {
                        objBookResponse.Message = ex.ToString();
                    }
                }
                else
                {
                    objBookResponse.Message = "no api found";
                }
                return JsonConvert.SerializeObject(objBookResponse);
            }
            else
            {
                return null;
                //throw new http exception
                //throw new System.Web.Http.HttpResponseException(HttpStatusCode.Forbidden);

            }
        }
예제 #2
0
        /// <summary>
        /// Method for booking ticket
        /// </summary>
        /// <returns></returns>
        public BookSeatsResponse bookTicket(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)
        {
            BookSeatsResponse objBookSeatsResponse = new BookSeatsResponse();
            try
            {
                String[] seatNoArray = seatNo.Split(',');
                String[] titleArray = title.Split(',');
                String[] nameArray = name.Split(',');
                String[] ageArray = age.Split(',');
                String[] sexArray = sex.Split(',');

                String requestUrl = URL + "/book_ticket.json?api_key=" + ConsumerKey +
                    "&reservation_id=" + reservationId + "&origin_id=" + sourceId + "&destination_id=" + destinationId
                    + "&boarding_at=" + boardingPointId + "&no_of_seats=" + noOfSeats.ToString() + "&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 str = invokePostRequest(requestUrl, req, "application/json");

                DataSet ds = convertJsonStringToDataSet(str);

                if (ds != null)
                {
                    if (ds.Tables["ticket_details"] != null)
                    {
                        if (ds.Tables["ticket_details"].Rows[0]["ticket_status"].ToString().Trim().ToLower() == "confirmed"
                            && ds.Tables["ticket_details"].Rows[0]["ticket_number"].ToString().Trim() != "")
                        {
                            objBookSeatsResponse.Status = "SUCCESS";
                            objBookSeatsResponse.APIPNR = ds.Tables["ticket_details"].Rows[0]["ticket_number"].ToString().Trim();
                            objBookSeatsResponse.OperatorPNR = ds.Tables["ticket_details"].Rows[0]["travel_operator_pnr"].ToString().Trim();
                        }
                        else
                        {
                            objBookSeatsResponse.Status = "FAIL";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //to do
            }
            return objBookSeatsResponse;
        }
예제 #3
0
        /// <summary>
        /// Method for booking a seat by passing the required information like date, source, destination etc.......
        /// </summary>
        /// <returns></returns>
        public BookSeatsResponse bookSeats(int sourceId, int destinationId, String dateOfJourney, String serviceId, String selectedSeats, String gender,
                String passengerName, String boardingPointId, String custAddress, String custName, String custPhoneNo,
                String custEmailId, String referenceNo, String URL, String ConsumerKey)
        {
            BookSeatsResponse objBookSeatsResponse = new BookSeatsResponse();
            try
            {
                String Gender = null;
                String Emails = null;
                String Phones = null;
                string g;
                string email;
                string phone;
                string[] gen = gender.ToString().Split(',');
                int k = gen.Count();
                if (k != 1)
                {
                    for (int i = 0; i < k; i++)
                    {
                        if (Convert.ToString(gen[i]).Trim() == "MALE")
                        {
                            g = "M";
                            email = custEmailId;
                            phone = custPhoneNo;
                        }
                        else
                        {
                            g = "F";
                            email = custEmailId;
                            phone = custPhoneNo;
                        }
                        Gender = Gender + "," + g;
                        Emails = Emails + "," + email;
                        Phones = Phones + "," + phone;

                    }
                }
                else
                {
                    if (gender == "MALE")
                    {
                        Gender = "M";
                        Emails = custEmailId;
                        Phones = custPhoneNo;
                    }
                    else
                    {
                        Gender = "F";
                        Emails = custEmailId;
                        Phones = custPhoneNo;
                    }
                }
                if (Gender.StartsWith(","))
                {
                    Gender = Gender.Substring(1);
                }
                if (Emails.StartsWith(","))
                {
                    Emails = Emails.Substring(1);
                }
                if (Phones.StartsWith(","))
                {
                    Phones = Phones.Substring(1);
                }

                //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=BookTicket&SorceStationid=" + sourceId + "&DestinationStationid=" + destinationId + "&DateofJourney=" + dateOfJourney + "&ServiceId=" + serviceId + "&Seats=" + selectedSeats + "&PassName=" + passengerName + "&Email=" + custEmailId + "&ContactNo=" + custPhoneNo + "&Gender=" + gender + "&Address=" + custAddress + "&SeatFare=550" + "&BoardingId="+boardingPointId + "&Key=" + ConsumerKey;
                requestBody = URL + "/server.aspx?Method=BookTicket&SorceStationid=" + sourceId + "&DestinationStationid=" + destinationId + "&DateofJourney=" + dateOfJourney + "&ServiceId=" + serviceId + "&Seats=" + selectedSeats + "&PassName=" + passengerName + "&Email=" + Emails + "&ContactNo=" + Phones + "&Gender=" + Gender + "&Address=" + custAddress + "&SeatFare=550" + "&BoardingId=" + boardingPointId + "&Key=" + ConsumerKey;

                DataSet ds = convertXMLtoDataset(getJSONReponse(requestBody));
                DataTable dtBookTicket = new DataTable();
                dtBookTicket = ds.Tables[0];
                if (dtBookTicket != null)
                {
                    objBookSeatsResponse.Status = "Success";
                    objBookSeatsResponse.APIPNR = dtBookTicket.Rows[0]["PNRNumber"].ToString();
                    objBookSeatsResponse.OperatorPNR = dtBookTicket.Rows[0]["PNRNumber"].ToString();
                    objBookSeatsResponse.Message = dtBookTicket.Rows[0]["Message"].ToString();
                }

                objBookSeatsResponse.OperaterNo = "AfterResponse";
            }
            catch (Exception ex)
            {
                // to do
            }
            return objBookSeatsResponse;
            //return null;
        }
예제 #4
0
        /// <summary>
        /// Method for booking a ticket using userid,password,bookingid
        /// </summary>
        /// <param name="bookingId"></param>
        /// <returns></returns>
        public BookSeatsResponse BookTicket(String bookingId, String URL, String ConsumerKey, String ConsumerSecret)
        {
            BookSeatsResponse objBookSeatsResponse = new BookSeatsResponse();
            try
            {
                client = new TGTravelServiceClient("TGSWS", URL);
                BookingDetails response = client.bookTicket(ConsumerKey, ConsumerSecret, bookingId);

                string strTicketGooseBookingResponse = JsonConvert.SerializeObject(response);

                DataSet ds = convertJsonStringToDataSet(strTicketGooseBookingResponse);

                if (ds != null && ds.Tables["status"] != null)
                {
                    if (ds.Tables["status"].Rows[0]["code"].ToString().Trim() == "200"
                        && ds.Tables["status"].Rows[0]["message"].ToString().Trim().ToLower() == "success")
                    {
                        objBookSeatsResponse.Status = "SUCCESS";
                        foreach (DataRow item in ds.Tables["extraSeatInfoList"].Rows)
                        {
                            objBookSeatsResponse.OperatorPNR = item["extraSeatInfo"].ToString();
                                //(objBookSeatsResponse.OperatorPNR == "") ?
                                    //                            item["extraSeatInfo"].ToString() :
                                   //                             objBookSeatsResponse.OperatorPNR + "," + item["extraSeatInfo"].ToString();
                            objBookSeatsResponse.OperaterNo = item["extraSeatInfo"].ToString();
                            objBookSeatsResponse.extraseatinfo = item["extraSeatInfo"].ToString();
                        }
                    }
                    else
                    {
                        objBookSeatsResponse.Status = "FAIL"; objBookSeatsResponse.Message = ds.Tables["status"].Rows[0]["message"].ToString().Trim();
                    }
                }
                else
                    objBookSeatsResponse.Status = "FAIL";

                objBookSeatsResponse.APIPNR = (objBookSeatsResponse.Status == "SUCCESS") ? bookingId : "";
            }
            catch (Exception ex)
            {
                // to do
            }
            return objBookSeatsResponse;
        }
예제 #5
0
        /// <summary>
        /// Method for booking a seat by passing the required information like date, source, destination etc.......
        /// </summary>
        /// <returns></returns>
        public BookSeatsResponse bookSeats(int sourceId, int destinationId, String dateOfJourney, String serviceId, String selectedSeats, String gender,
                String passengerName, String boardingPointId, String custAddress, String custName, String custPhoneNo,
                String custEmailId, String referenceNo, String URL, String ConsumerKey)
        {
            BookSeatsResponse objBookSeatsResponse = new BookSeatsResponse();
            try
            {
                //dateOfJourney = "5/2/2013";
                //yyyy-MM-dd
                if (dateOfJourney.Contains('/'))
                {
                    if (dateOfJourney.Split('/')[0].Length == 1 && dateOfJourney.Split('/')[1].Length == 1)
                    {
                        dateOfJourney = dateOfJourney.Split('/')[2] + "-" + "0" + dateOfJourney.Split('/')[0] + "-" + "0" + dateOfJourney.Split('/')[1];
                    }
                    else if (dateOfJourney.Split('/')[0].Length == 1)
                    {
                        dateOfJourney = dateOfJourney.Split('/')[2] + "-" + "0" + dateOfJourney.Split('/')[0] + "-" + dateOfJourney.Split('/')[1];
                    }
                    else if (dateOfJourney.Split('/')[1].Length == 1)
                    {
                        dateOfJourney = dateOfJourney.Split('/')[2] + "-" + dateOfJourney.Split('/')[0] + "-" + "0" + dateOfJourney.Split('/')[1];
                    }
                    else
                    {
                        dateOfJourney = dateOfJourney.Split('/')[2] + "-" + dateOfJourney.Split('/')[0] + "-" + dateOfJourney.Split('/')[1];
                    }
                }
                else
                {
                    dateOfJourney = dateOfJourney.Split('-')[2] + "-" + dateOfJourney.Split('-')[1] + "-" + dateOfJourney.Split('-')[0];
                }
                requestBody = "<?xml version='1.0'?><methodCall>" +
                    "<methodName>index.seatbooking</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>" +
                    "<member><name>psgr_gender_type</name><value><string>" + gender + "</string></value></member>" +
                    "<member><name>psgr_name</name><value><string>" + passengerName + "</string></value></member>" +
                    "<member><name>boardingpoint_id</name><value><string>" + boardingPointId + "</string></value></member>" +
                    "<member><name>customer_address</name><value><string> " + custAddress + " </string></value></member>" +
                    "<member><name>customer_name</name><value><string>" + custName + "</string></value></member>" +
                    "<member><name>customer_phoneno</name><value><string>" + custPhoneNo + "</string></value></member>" +
                    "<member><name>customer_email</name><value><string>" + custEmailId + "</string></value></member>" +
                    "<member><name>booking_ref_num</name><value><string>" + referenceNo + "</string></value></member>" +
                    "</struct></value></param></params></methodCall>";

                xmlNodes = getXmlNodeList(requestBody, URL, ConsumerKey);

                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++)
                        {
                            switch (nodeNameList.Item(i).InnerText.ToLower())
                            {
                                case "status":
                                    objBookSeatsResponse.Status = nodeValueList.Item(i).InnerText;
                                    break;
                                case "ticket_num":
                                    objBookSeatsResponse.APIPNR = nodeValueList.Item(i).InnerText;
                                    break;
                                case "service_number":
                                    objBookSeatsResponse.OperatorPNR = nodeValueList.Item(i).InnerText;
                                    break;
                                case "message":
                                    objBookSeatsResponse.Message = nodeValueList.Item(i).InnerText;
                                    break;
                                //case "total_fare":
                                //    //total_fare = nodeValueList.Item(i).InnerText;
                                //    break;
                                default:
                                    break;
                            }
                        }
                    }
                }
                objBookSeatsResponse.OperaterNo = "AfterResponse";
            }
            catch (Exception ex)
            {
                // to do
            }
            return objBookSeatsResponse;
        }