/// <summary> /// Method to get available trips for given provider /// </summary> /// <param name="ProviderName"></param> /// <param name="objClientAPIDetails"></param> /// <returns>Returns JSON string with list of available trips</returns> private SeatsInfo GetTripDetailsByProviderName(ClientAPIDetails objClientAPIDetails, BusesSearchFilter objBusesSearchFilter, String tripId, String markUpFare, String SeatLayoutId) { SeatsInfo objSeatsInfo = new SeatsInfo(); try { switch (objClientAPIDetails.ProviderName) { case "ABHIBUS": case "SVR": case "KALLADA": case "KAVERI": case "RAJESH": case "SAIANJANA": AbhibusAPI clsAbhibusAPI = new AbhibusAPI(); objSeatsInfo = clsAbhibusAPI.getBusSeatLayout(objBusesSearchFilter.SourceID , objBusesSearchFilter.DestinationID , objBusesSearchFilter.JourneyDate , tripId , "0" , objClientAPIDetails.APIURL , objClientAPIDetails.ConsumerKey); break; case "BITLA": case "MORNINGSTAR": BitlaAPI clsBitlaAPI = new BitlaAPI(); objSeatsInfo = clsBitlaAPI.getServiceDetails(tripId , objClientAPIDetails.APIURL , objClientAPIDetails.ConsumerKey); break; case "TICKETGOOSE": TicketGooseAPI clsTicketGooseAPI = new TicketGooseAPI(); objSeatsInfo = clsTicketGooseAPI.getTripDetailsV2(objBusesSearchFilter.SourceID , objBusesSearchFilter.DestinationID , objBusesSearchFilter.JourneyDate , tripId , objClientAPIDetails.APIURL , objClientAPIDetails.ConsumerKey , objClientAPIDetails.ConsumerSecret); break; //easy bus 18-05-2013 case "EASYBUS": EasybusAPI clsEasyBusAPI = new EasybusAPI(); objSeatsInfo = clsEasyBusAPI.getLayoutDetails(objBusesSearchFilter.SourceID , objBusesSearchFilter.DestinationID , objBusesSearchFilter.JourneyDate , tripId , SeatLayoutId , markUpFare , "0" , objClientAPIDetails.APIURL , objClientAPIDetails.ConsumerKey); break; default: break; } objSeatsInfo.providerName = objClientAPIDetails.ProviderName; } catch (Exception ex) { //to do //Log Exception } return objSeatsInfo; }
private SeatsInfo TestGetSeatLayout(SeatsInfo objSeatsInfo) { SeatsInfo objSeatsInfoResponse = new SeatsInfo(); objSeatsInfoResponse = objSeatsInfo; BusesBaseClass _ = new BusesBaseClass(); //Convert it to string and then to dataset //Supposed to use objSeatsInfo.Seats as it is. DataSet dsMain = _.convertJsonStringToDataSet(JsonConvert.SerializeObject(objSeatsInfo)); if (dsMain != null) { DataTable dtMain = dsMain.Tables["seats"]; StringBuilder sbSeatLayout = new StringBuilder(); String[] response = new String[3]; try { if (dtMain.Rows.Count > 0) { #region Code to convert "Row" & "Column" columns to integer datatype //create a copy of main table DataTable dt = dtMain.Clone(); //set column datatypes for int values dt.Columns["row"].DataType = Type.GetType("System.Int16"); dt.Columns["column"].DataType = Type.GetType("System.Int16"); dt.Columns["zIndex"].DataType = Type.GetType("System.Int16"); var lengthCount1 = (from dr in dtMain.AsEnumerable() select dr["length"]).Distinct().ToList(); drArray1 = dtMain.Select(String.Empty, "row DESC, column ASC, zIndex DESC"); if (drArray1.Length > 0) { foreach (DataRow dr in drArray1) dt.ImportRow(dr); } dt.AcceptChanges(); #endregion var zIndexCount = (from dr in dt.AsEnumerable() select dr["zIndex"]).Distinct().ToList(); var RowCount = (from dr in dt.AsEnumerable() select dr["row"]).Distinct().ToList(); var ColumnCount = (from dr in dt.AsEnumerable() select dr["column"]).Distinct().ToList(); //Used in exceptional cases where a bus has both seats and sleeper coaches //int maxLength = Convert.ToInt32(dt.Compute("max(Length)", string.Empty)); int maxLength = (from dr in dt.AsEnumerable() select dr["length"]).Distinct().Count(); int maxWidth = (from dr in dt.AsEnumerable() select dr["width"]).Distinct().Count(); String strSeatType = String.Empty; String strSeatCssSuffix = String.Empty; if (zIndexCount.Count > 1) //sbSeatLayout.Append("<table align=\"center\"><tr><td colspan=\"2\">"); if (lengthCount1.Count() != 2) { sbSeatLayout.Append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\"><tr><td colspan=\"2\">"); } else { if (ColumnCount.Count() != 22 && ColumnCount.Count() != 10 && ColumnCount.Count() != 8 && ColumnCount.Count() != 11 && ColumnCount.Count() != 6 && ColumnCount.Count() != 9 && ColumnCount.Count() != 7 && ColumnCount.Count() != 13 && ColumnCount.Count() != 10 && ColumnCount.Count() != 12) { sbSeatLayout.Append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"680\" align=\"left\"><tr><td colspan=\"2\">"); } else { if (RowCount.Count() == 2 && zIndexCount.Count() == 2) { sbSeatLayout.Append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"680\" align=\"left\"><tr><td colspan=\"2\">"); } else { sbSeatLayout.Append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\"><tr><td colspan=\"2\">"); } } } else sbSeatLayout.Append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\" style=\"border: 1px solid #D3D3D3; border-radius: 2px; padding: 1px; margin: 0px; \"><tr><td colspan=\"2\">"); foreach (Int16 index in zIndexCount) { if (zIndexCount.Count > 1) { //div tag is added to show border with same size for upper and lower decks sbSeatLayout.Append("<div style=\"border: 1px solid #D3D3D3; border-radius: 2px; padding: 2px; margin: 2px;margin-top:3px; \">"); //add steering image only once if (zIndexCount.IndexOf(index) > 0) { sbSeatLayout.Append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><span />");//class=\"lowerLabel\" style=\"float:left;height:55px;\" } else { sbSeatLayout.Append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><span >");//class=\"upperLabel\" style=\"height:50px;\" } } else sbSeatLayout.Append("<div><span class=\"steering\"/> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" >");//<span class=\"steering\"/> foreach (Int16 row in RowCount) { #region Create datarow array //Get the actual row count to drArrayMain drArrayMain = dt.Select("row = " + row + " AND zIndex = " + index, "column ASC"); //Create another array which is based on ColumnCount //This array will be used in below code DataRow[] drArray = new DataRow[ColumnCount.Count]; // drArray = drArrayMain; #endregion //check if bus has different seat layouts. If so, do not float seats right if (maxLength == 2 && maxWidth == 2) sbSeatLayout.Append("<tr><td>"); else sbSeatLayout.Append("<tr><td style=\"float: right\">");//style=\"float: right\" sbSeatLayout.Append("<ul class=\"seat_map\">"); #region loop array and add seats foreach (DataRow dr in drArrayMain) { #region Set seat type seat/sleeper_v/sleeper_h // dr["length"] or dr["width"] will be empty strings only if there is no seat in dr of drArray if (dr["length"].ToString() != String.Empty && dr["width"].ToString() != String.Empty) { if (int.Parse(dr["width"].ToString()) == 1 && int.Parse(dr["length"].ToString()) == 1) { strSeatType = "Seat"; strSeatCssSuffix = "seat"; } else if (int.Parse(dr["width"].ToString()) == 2) { strSeatType = "Sleeper_v"; strSeatCssSuffix = "sleeper_v"; } else if (int.Parse(dr["length"].ToString()) == 2) { strSeatType = "Sleeper_h"; strSeatCssSuffix = "sleeper_h"; } } #endregion //Check if datarow has empty seats, if so add empty spaces if (dr["isAvailableSeat"] != null && dr["isAvailableSeat"].ToString() != String.Empty) { //set appropriate class based on seat availability if (dr["isAvailableSeat"].ToString().ToUpper() == "FALSE") { sbSeatLayout.Append("<li id=\"li" + dr["number"].ToString() + "\" class=\"booked_" + strSeatCssSuffix + "\" title='Booked'> "); } else { if (dr["isLadiesSeat"].ToString().ToUpper() == "TRUE") sbSeatLayout.Append("<li id=\"li" + dr["number"].ToString().Replace("(", String.Empty).Replace(")", String.Empty).Replace(" ", String.Empty) + "\" class=\"availableladies_" + strSeatCssSuffix + "\" "); else sbSeatLayout.Append("<li id=\"li" + dr["number"].ToString().Replace("(", String.Empty).Replace(")", String.Empty).Replace(" ", String.Empty) + "\" class=\"available_" + strSeatCssSuffix + "\" "); sbSeatLayout.Append("onclick=\"doUndoSelect('" + dr["number"].ToString() + "', '" + dr["fare"].ToString() + "," + strSeatType + ",0', 'available')\" "); sbSeatLayout.Append("onmouseout=\"fnClosePanel('seat_info');\" "); sbSeatLayout.Append("onmouseover=\"fnShowPanel(event,'seat_info','" + dr["number"].ToString() + "," + dr["fare"].ToString() + "," + strSeatType + "');\">"); } //Seat number is properly displayed in Chrome and Firefox except IE. //check with designer. If it doesn't work, uncomment below line and comment the line next to it. sbSeatLayout.Append("<a id='seat" + dr["number"].ToString() + "'>" + "" + "</a></li>"); sbSeatLayout.Append("<input id=\"isSelected" + dr["number"].ToString().Replace("(", String.Empty).Replace(")", String.Empty).Replace(" ", String.Empty) + "\" type=\"hidden\" name=\"isSelected" + dr["number"].ToString().Replace("(", String.Empty).Replace(")", String.Empty) + "\" />"); sbSeatLayout.Append("<input id=\"isSelectedRet" + dr["number"].ToString().Replace("(", String.Empty).Replace(")", String.Empty).Replace(" ", String.Empty) + "\" type=\"hidden\" name=\"isSelectedRet" + dr["number"].ToString().Replace("(", String.Empty).Replace(")", String.Empty) + "\" />"); } else { //check if drArray has no seats. If so, add li element to create walking bay //if (drArray.Where(p => p.RowState == DataRowState.Detached).Count() == drArray.Count()) // sbSeatLayout.Append("<li> </li>"); } } #endregion sbSeatLayout.Append("</ul>"); sbSeatLayout.Append("</td></tr>"); } sbSeatLayout.Append("</table></div>"); } sbSeatLayout.Append("</td></tr></table>"); } } catch (Exception ex) { // only for development purpose } objSeatsInfoResponse.SeatsScript = sbSeatLayout.ToString(); return objSeatsInfoResponse; } else return null; }
public DataSet GetcallBack(string Resrvation_Id, string url, string ConsumerKey, string ConsumerSecret, string doj) { DataSet ds = new DataSet(); ClientAPIList objClientAPIList = new ClientAPIList(); GetAPIProvidersList(ConsumerKey, ConsumerSecret); objClientAPIList = (ClientAPIList)HttpContext.Current.Cache["ClientAPI-" + ConsumerKey]; //Check if atleast one provider is accessible if (objClientAPIList != null && objClientAPIList.Count > 0) { objClientAPIList.Where(e => e.ProviderName == Convert.ToString("BITLA")); BitlaAPI bitla = new BitlaAPI(); SeatsInfo seat = new SeatsInfo(); seat = bitla.getServiceDetails(Resrvation_Id, objClientAPIList[0].APIURL, objClientAPIList[0].ConsumerKey); ds = convertJsonStringToDataSet(JsonConvert.SerializeObject(seat)); } return ds; }
/// <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; }
/// <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; }
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; }
SeatsInfo SeatLayout(String tot_availableseat_num, string tot_Seat_num, String bookedseats, String gendertype, String lowerdeck_seat_nos, String upperdeck_seat_nos, String seat_fare, String layoutid, int length, int width, int zIdnex) { try { SeatsInfo objSeatsLayout = new SeatsInfo(); objSeatsLayout.Seats = new List<SeatLayout>(); //string[] seatLayoutStringArray = tot_availableseat_num.Split(';'); //string[] Bookedseats = tot_Seat_num.Split(';'); string[] seatLayoutStringArray = lowerdeck_seat_nos.Split(';'); string[] Bookedseats = upperdeck_seat_nos.Split(';'); string[] BSeats = bookedseats.Split(';'); foreach (string bseat in BSeats) { if (bseat != "" && bseat != "#*#-") { string[] star = new string[1]; star[0] = "#*#"; string[] st = bseat.Split(star, StringSplitOptions.None); if (Convert.ToString(strbseats) == "") { strbseats = st[0].ToString(); } else { strbseats = strbseats + ";" + st[0].ToString(); } } } string[] strseatarr = strbseats.ToString().Split(';'); foreach (string femaleseat in strseatarr) { foreach (string seat in seatLayoutStringArray) { if (seat != "" && seat != "#*#-") { //R3 #*# 1-2 #*# S #*# B #*# F string[] star = new string[1]; star[0] = "#*#"; string[] st = seat.Split(star, StringSplitOptions.None); if (Convert.ToString(st[0]).Trim() != "") { if (Convert.ToString(st[2]).Trim() != "B") { if (st.Count() > 4) { if (Convert.ToString(st[4]).Trim() == "F") { if (Convert.ToString(st[0]).Trim() == Convert.ToString(femaleseat).Trim()) { if (femaleseat.Contains('L')) { if (femaleseat.ToString().Split('L')[1] != "") { if (Convert.ToInt32(femaleseat.ToString().Split('L')[1]) % 2 == 0) { if (Convert.ToString(feseat) == "") { //even feseat ="L"+ Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('L')[1]) - 1) ; } else { feseat = feseat + ";" + "L" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('L')[1]) - 1); } } else { if (Convert.ToString(feseat) == "") { //odd feseat = "L" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('L')[1]) + 1); } else { feseat = feseat + ";" + "L" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('L')[1]) + 1); } } } } else if (femaleseat.Contains('R')) { if (femaleseat.ToString().Split('R')[1] != "") { if (Convert.ToInt32(femaleseat.ToString().Split('R')[1]) % 2 == 0) { if (Convert.ToString(feseat) == "") { feseat = "R" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('R')[1]) - 1); } else { feseat = feseat + ";" + "R" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('R')[1]) - 1); } } else { if (Convert.ToString(feseat) == "") { //odd feseat = "R" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('R')[1]) + 1); } else { feseat = feseat + ";" + "R" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('R')[1]) + 1); } } } } else if (femaleseat.Contains('A')) { if (femaleseat.ToString().Split('A')[1] != "") { if (Convert.ToInt32(femaleseat.ToString().Split('A')[1]) % 2 == 0) { if (Convert.ToString(feseat) == "") { //even feseat = "A" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('A')[1]) - 1); } else { feseat = feseat + ";" + "A" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('A')[1]) - 1); } } else { if (Convert.ToString(feseat) == "") { //odd feseat = "A" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('A')[1]) + 1); } else { feseat = feseat + ";" + "A" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('A')[1]) + 1); } } } } else if (femaleseat.Contains('B')) { if (femaleseat.ToString().Split('B')[1] != "") { if (Convert.ToInt32(femaleseat.ToString().Split('B')[1]) % 2 == 0) { if (Convert.ToString(feseat) == "") { //even feseat = "B" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('B')[1]) - 1); } else { feseat = feseat + ";" + "B" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('B')[1]) - 1); } } else { if (Convert.ToString(feseat) == "") { //odd feseat = "B" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('B')[1]) + 1); } else { feseat = feseat + ";" + "B" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('B')[1]) + 1); } } } } else if (femaleseat.Contains('C')) { if (femaleseat.ToString().Split('C')[1] != "") { if (Convert.ToInt32(femaleseat.ToString().Split('C')[1]) % 2 == 0) { if (Convert.ToString(feseat) == "") { //even feseat = "C" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('C')[1]) - 1); } else { feseat = feseat + ";" + "C" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('C')[1]) - 1); } } else { if (Convert.ToString(feseat) == "") { //odd feseat = "C" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('C')[1]) + 1); } else { feseat = feseat + ";" + "C" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('C')[1]) + 1); } } } } else if (femaleseat.Contains('D')) { if (femaleseat.ToString().Split('D')[1] != "") { if (Convert.ToInt32(femaleseat.ToString().Split('D')[1]) % 2 == 0) { if (Convert.ToString(feseat) == "") { //even feseat = "D" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('D')[1]) - 1); } else { feseat = feseat + ";" + "D" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('D')[1]) - 1); } } else { if (Convert.ToString(feseat) == "") { //odd feseat = "D" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('D')[1]) + 1); } else { feseat = feseat + ";" + "D" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('D')[1]) + 1); } } } } else if (femaleseat.Contains('E')) { if (femaleseat.ToString().Split('E')[1] != "") { if (Convert.ToInt32(femaleseat.ToString().Split('E')[1]) % 2 == 0) { if (Convert.ToString(feseat) == "") { //even feseat = "E" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('E')[1]) - 1); } else { feseat = feseat + ";" + "E" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('E')[1]) - 1); } } else { if (Convert.ToString(feseat) == "") { //odd feseat = "E" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('E')[1]) + 1); } else { feseat = feseat + ";" + "E" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('E')[1]) + 1); } } } } else if (femaleseat.Contains('F')) { if (femaleseat.ToString().Split('F')[1] != "") { if (Convert.ToInt32(femaleseat.ToString().Split('F')[1]) % 2 == 0) { if (Convert.ToString(feseat) == "") { //even feseat = "F" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('F')[1]) - 1); } else { feseat = feseat + ";" + "F" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('F')[1]) - 1); } } else { if (Convert.ToString(feseat) == "") { //odd feseat = "F" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('F')[1]) + 1); } else { feseat = feseat + ";" + "F" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('F')[1]) + 1); } } } } else if (femaleseat.Contains('G')) { if (femaleseat.ToString().Split('G')[1] != "") { if (Convert.ToInt32(femaleseat.ToString().Split('G')[1]) % 2 == 0) { if (Convert.ToString(feseat) == "") { //even feseat = "G" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('G')[1]) - 1); } else { feseat = feseat + ";" + "G" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('G')[1]) - 1); } } else { if (Convert.ToString(feseat) == "") { //odd feseat = "G" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('G')[1]) + 1); } else { feseat = feseat + ";" + "G" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('G')[1]) + 1); } } } } else if (femaleseat.Contains('H')) { if (femaleseat.ToString().Split('H')[1] != "") { if (Convert.ToInt32(femaleseat.ToString().Split('H')[1]) % 2 == 0) { if (Convert.ToString(feseat) == "") { //even feseat = "H" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('H')[1]) - 1); } else { feseat = feseat + ";" + "H" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('H')[1]) - 1); } } else { if (Convert.ToString(feseat) == "") { //odd feseat = "H" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('H')[1]) + 1); } else { feseat = feseat + ";" + "H" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('H')[1]) + 1); } } } } else if (femaleseat.Contains('I')) { if (femaleseat.ToString().Split('I')[1] != "") { if (Convert.ToInt32(femaleseat.ToString().Split('I')[1]) % 2 == 0) { if (Convert.ToString(feseat) == "") { //even feseat = "I" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('I')[1]) - 1); } else { feseat = feseat + ";" + "I" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('I')[1]) - 1); } } else { if (Convert.ToString(feseat) == "") { //odd feseat = "I" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('I')[1]) + 1); } else { feseat = feseat + ";" + "I" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('I')[1]) + 1); } } } } else if (femaleseat.Contains('J')) { if (femaleseat.ToString().Split('J')[1] != "") { if (Convert.ToInt32(femaleseat.ToString().Split('J')[1]) % 2 == 0) { if (Convert.ToString(feseat) == "") { //even feseat = "J" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('J')[1]) - 1); } else { feseat = feseat + ";" + "J" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('J')[1]) - 1); } } else { if (Convert.ToString(feseat) == "") { //odd feseat = "J" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('J')[1]) + 1); } else { feseat = feseat + ";" + "J" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('J')[1]) + 1); } } } } else if (femaleseat.Contains('K')) { if (femaleseat.ToString().Split('K')[1] != "") { if (Convert.ToInt32(femaleseat.ToString().Split('K')[1]) % 2 == 0) { if (Convert.ToString(feseat) == "") { //even feseat = "K" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('K')[1]) - 1); } else { feseat = feseat + ";" + "K" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('K')[1]) - 1); } } else { if (Convert.ToString(feseat) == "") { //odd feseat = "K" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('K')[1]) + 1); } else { feseat = feseat + ";" + "K" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('K')[1]) + 1); } } } } else if (femaleseat.Contains('V')) { if (femaleseat.ToString().Split('V')[1] != "") { if (Convert.ToInt32(femaleseat.ToString().Split('V')[1]) % 2 == 0) { if (Convert.ToString(feseat) == "") { //even feseat = "V" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('V')[1]) - 1); } else { feseat = feseat + ";" + "V" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('V')[1]) - 1); } } else { if (Convert.ToString(feseat) == "") { //odd feseat = "V" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('V')[1]) + 1); } else { feseat = feseat + ";" + "V" + Convert.ToString(Convert.ToInt32(femaleseat.ToString().Split('V')[1]) + 1); } } } } else { if (Convert.ToInt32(femaleseat) % 2 == 0) { if (Convert.ToString(feseat) == "") { //even feseat = Convert.ToString(Convert.ToInt32(femaleseat) - 1); } else { feseat = feseat + ";" + Convert.ToString(Convert.ToInt32(femaleseat) - 1); } } else { if (Convert.ToString(feseat) == "") { //odd feseat = Convert.ToString(Convert.ToInt32(femaleseat) + 1); } else { feseat = feseat + ";" + Convert.ToString(Convert.ToInt32(femaleseat) + 1); } } } } } } } } } } } foreach (string seat in seatLayoutStringArray) { if (seat != "" && seat != "#*#-") { //R3 #*# 1-2 #*# S #*# B #*# F string[] star = new string[1]; star[0] = "#*#"; string[] st = seat.Split(star, StringSplitOptions.None); if (Convert.ToString(st[0]).Trim() != "") { string[] stRowColumn = st[1].ToString().Split('-'); string strseat2 = st[0].ToString().Trim(); SeatLayout objSeat = new SeatLayout(); objSeat.column = Convert.ToInt32(stRowColumn[1].ToString().Trim()); objSeat.fare = seat_fare; objSeat.id = layoutid; if (Convert.ToString(st[3]).Trim() == "A") { objSeat.isAvailableSeat = "true"; } else { objSeat.isAvailableSeat = "false"; } if (Convert.ToString(st[2]).Trim() == "B") { if (st.Count() > 4) { if (Convert.ToString(st[4]).Trim() == "F") { objSeat.isLadiesSeat = "true"; } else { objSeat.isLadiesSeat = null; } } } else { if (Convert.ToString(st[3]).Trim() == "A") { string[] seatstr = feseat.ToString().Split(';'); if (seatstr.Length >= 1) { foreach (string f in seatstr) { if (f.Contains('L')) { if (Convert.ToString(st[0]).Trim() == Convert.ToString(f)) { objSeat.isLadiesSeat = "true"; break; } else { objSeat.isLadiesSeat = "false"; } } else if (f.Contains('R')) { if (Convert.ToString(st[0]).Trim() == Convert.ToString(f)) { objSeat.isLadiesSeat = "true"; break; } else { objSeat.isLadiesSeat = "false"; } } else if (Convert.ToString(st[0]).Trim() == Convert.ToString(f)) { objSeat.isLadiesSeat = "true"; break; } else { objSeat.isLadiesSeat = "false"; } } } } else { objSeat.isLadiesSeat = "false"; } } //} //else //{ // objSeat.isLadiesSeat = null; //} objSeat.length = length; objSeat.number = Convert.ToString(st[0]).Trim(); objSeat.row = Convert.ToInt32(Convert.ToString(stRowColumn[0]).Trim()); objSeat.width = width; objSeat.zIndex = zIdnex; objSeatsLayout.Seats.Add(objSeat); } } } #region comment code // tot_Seat_num = tot_Seat_num + ";"; // string[] Bookedseats = tot_Seat_num.Split(';'); //SeatLayout objSeat1 = new SeatLayout(); //foreach (string seat2 in seatLayoutStringArray)//available seats //{ // string[] star = new string[1]; // star[0] = "#*#"; // string[] st = seat2.Split(star, StringSplitOptions.None); // string strseat2 = st[0].ToString().Trim(); // string[] stRowColumn = st[1].ToString().Split('-'); // foreach (string seat3 in Bookedseats) // { // string[] star1 = new string[1]; // star1[0] = "#*#"; // string[] st1 = seat3.Split(star, StringSplitOptions.None); // string strseat3 = st1[0].ToString().Trim(); // tot = ""; // if (strseat2 == strseat3) // { // tot_Seat_num = tot_Seat_num.Replace(seat3 + ";", ""); // break; // } // } //} //tot_Seat_num = tot_Seat_num.Replace("L5 #*# 5-12", ""); //string[] Bookedseats1 = tot_Seat_num.Split(';'); //foreach (string seat5 in Bookedseats1) //{ // string[] star1 = new string[1]; // star1[0] = "#*#"; // string[] st1 = seat5.Split(star1, StringSplitOptions.None); // string strseat3 = st1[0].ToString().Trim(); // string[] seatLayoutStringArray4 = bookedseats.Split(';'); // foreach (string seat4 in seatLayoutStringArray4) // { // if (seat4 != "" && seat4 != "#*#-") // { // string[] star4 = new string[1]; // star4[0] = "#*#"; // string[] st4 = seat4.Split(star4, StringSplitOptions.None); // string strseat4 = st4[0].ToString(); // if (strseat3 == strseat4) // { // tot_Seat_num = tot_Seat_num.Replace(seat5 + ";", ""); // } // } // } //} //bookedseats = bookedseats + ";" + tot_Seat_num; #endregion string[] seatLayoutStringArray1 = upperdeck_seat_nos.Split(';'); string[] seatLayoutStringArray2 = gendertype.Split(';'); //int k = 0; foreach (string seat1 in seatLayoutStringArray1) { if (seat1 != "" && seat1 != "#*#-") { string[] star = new string[1]; star[0] = "#*#"; string[] st = seat1.Split(star, StringSplitOptions.None); if (Convert.ToString(st[0]).Trim() != "") { string[] stRowColumn = st[1].ToString().Split('-'); SeatLayout objSeat = new SeatLayout(); objSeat.column = Convert.ToInt32(stRowColumn[1].ToString().Trim()); objSeat.fare = seat_fare; objSeat.id = layoutid; if (Convert.ToString(st[3]).Trim() == "A") { objSeat.isAvailableSeat = "true"; } else { objSeat.isAvailableSeat = "false"; } if (st.Count() > 4) { if (Convert.ToString(st[4]).Trim() == "F") { objSeat.isLadiesSeat = "true"; } else { objSeat.isLadiesSeat = null; } } else { objSeat.isLadiesSeat = null; } objSeat.length = length; objSeat.number = Convert.ToString(st[0]).Trim(); objSeat.row = Convert.ToInt32(Convert.ToString(stRowColumn[0]).Trim()); objSeat.width = width; objSeat.zIndex = zIdnex; objSeatsLayout.Seats.Add(objSeat); } } //k += 1; } objSeatsLayout.boardingTimes = null; return objSeatsLayout; } catch (Exception ex) { return null; } }