public override void Register(FlightRegisterParameters param) { if (param.BookingType == "oneway") { OneWayRegister(param); } else if (param.BookingType == "roundtrip") { RoundTripResgister(param); } }
private void GetPostData(string fileName, FlightRegisterParameters param) { HtmlDocument document = new HtmlDocument(); document.Load(fileName); _market1 = GetComboboxValue(document, param.DepartFlightNo, "availabilityTable0"); _market2 = ""; if (param.BookingType == "roundtrip") { _market2 = GetComboboxValue(document, param.ReturnFlightNo, "availabilityTable1"); } }
private void OneWayRegister(FlightRegisterParameters param) { _result = null; string fileName = Path.GetTempFileName(); string cookie = "ASP.NET_SessionId=maebhn55333a1unuwov03z45; CONTROLGROUPCONTACT_ContactInputView_dsadsadsada=CONTROLGROUPCONTACT_ContactInputView_DropDownListTitle=MR&CONTROLGROUPCONTACT_ContactInputView_DropDownListSuffix=&CONTROLGROUPCONTACT_ContactInputView_DropDownListStateProvince=VN|BMV&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine1=dasdasd&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine2=&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine3=&CONTROLGROUPCONTACT_ContactInputView_TextBoxCity=&CONTROLGROUPCONTACT_ContactInputView_TextBoxPostalCode=&CONTROLGROUPCONTACT_ContactInputView_DropDownListCountry=VN&CONTROLGROUPCONTACT_ContactInputView_TextBoxHomePhone=dsada&CONTROLGROUPCONTACT_ContactInputView_TextBoxWorkPhone=&CONTROLGROUPCONTACT_ContactInputView_TextBoxOtherPhone=&CONTROLGROUPCONTACT_ContactInputView_TextBoxFax=7631296&CONTROLGROUPCONTACT_ContactInputView_TextBoxEmailAddress=abnc%40gmail.com; CONTROLGROUPCONTACT_ContactInputView_fdsfsdfdf=CONTROLGROUPCONTACT_ContactInputView_DropDownListTitle=MR&CONTROLGROUPCONTACT_ContactInputView_DropDownListSuffix=&CONTROLGROUPCONTACT_ContactInputView_DropDownListStateProvince=VN|DLI&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine1=fsfdsf&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine2=&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine3=&CONTROLGROUPCONTACT_ContactInputView_TextBoxCity=&CONTROLGROUPCONTACT_ContactInputView_TextBoxPostalCode=&CONTROLGROUPCONTACT_ContactInputView_DropDownListCountry=VN&CONTROLGROUPCONTACT_ContactInputView_TextBoxHomePhone=34242&CONTROLGROUPCONTACT_ContactInputView_TextBoxWorkPhone=&CONTROLGROUPCONTACT_ContactInputView_TextBoxOtherPhone=&CONTROLGROUPCONTACT_ContactInputView_TextBoxFax=1761619&CONTROLGROUPCONTACT_ContactInputView_TextBoxEmailAddress=thienan289%40gmail.com; __utma=187758136.1032547902.1356189845.1356195522.1356225069.3; __utmb=187758136.1.10.1356225069; __utmc=187758136; __utmz=187758136.1356225069.3.3.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided)"; WebScraping webScraping = new AirMekongWebSraping(); IWebScrapingDelegate webScrapingDelegate = webScraping.GetWebScrapingDelegate(param.BookingType); webScrapingDelegate.DownloadWebPage(param, fileName, cookie); GetPostData(fileName, param); string postData = string.Format("__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwUBMGRk77h9CNekodLMZhdJu3riPx9ebN8%3D&pageToken=&AvailabilitySearchInputScheduleSelectView%24RadioButtonMarketStructure=OneWay&originStation1=HAN&AvailabilitySearchInputScheduleSelectView%24TextBoxMarketOrigin1=HAN&destinationStation1=SGN&AvailabilitySearchInputScheduleSelectView%24TextBoxMarketDestination1=SGN&AvailabilitySearchInputScheduleSelectView%24DropDownListMarketDay1=25&AvailabilitySearchInputScheduleSelectView%24DropDownListMarketMonth1=2012-12&AvailabilitySearchInputScheduleSelectView%24DropDownListMarketDateRange1=0%7C4&date_picker=2012-12-25&originStation2=&AvailabilitySearchInputScheduleSelectView%24TextBoxMarketOrigin2=%C4%90i%E1%BB%83m+%C4%91i...&destinationStation2=&AvailabilitySearchInputScheduleSelectView%24TextBoxMarketDestination2=%C4%90i%E1%BB%83m+%C4%91%E1%BA%BFn...&AvailabilitySearchInputScheduleSelectView%24DropDownListMarketDay2=30&AvailabilitySearchInputScheduleSelectView%24DropDownListMarketMonth2=2012-12&AvailabilitySearchInputScheduleSelectView%24DropDownListMarketDateRange2=0%7C4&date_picker=2012-12-30&AvailabilitySearchInputScheduleSelectView%24DropDownListPassengerType_ADT=1&AvailabilitySearchInputScheduleSelectView%24DropDownListPassengerType_CHD=0&AvailabilitySearchInputScheduleSelectView%24DropDownListPassengerType_INFANT=0&AvailabilitySearchInputScheduleSelectView%24DropDownListSearchBy=columnView&ControlGroupScheduleSelectView%24AvailabilityInputScheduleSelectView%24HiddenFieldTabIndex1=3&ControlGroupScheduleSelectView%24AvailabilityInputScheduleSelectView%24market1={0}&ControlGroupScheduleSelectView%24AgreementInputScheduleSelectView%24CheckBoxAgreement=on&ControlGroupScheduleSelectView%24ButtonSubmit=Ti%E1%BA%BFp+t%E1%BB%A5c", _market1); WebClientEx webClient = WebClientEx.CreateMekongAirWebClient("https://booking.airmekong.com.vn/ScheduleSelect.aspx"); webClient.Headers["Cookie"] = "ASP.NET_SessionId=maebhn55333a1unuwov03z45; CONTROLGROUPCONTACT_ContactInputView_dsadsadsada=CONTROLGROUPCONTACT_ContactInputView_DropDownListTitle=MR&CONTROLGROUPCONTACT_ContactInputView_DropDownListSuffix=&CONTROLGROUPCONTACT_ContactInputView_DropDownListStateProvince=VN|BMV&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine1=dasdasd&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine2=&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine3=&CONTROLGROUPCONTACT_ContactInputView_TextBoxCity=&CONTROLGROUPCONTACT_ContactInputView_TextBoxPostalCode=&CONTROLGROUPCONTACT_ContactInputView_DropDownListCountry=VN&CONTROLGROUPCONTACT_ContactInputView_TextBoxHomePhone=dsada&CONTROLGROUPCONTACT_ContactInputView_TextBoxWorkPhone=&CONTROLGROUPCONTACT_ContactInputView_TextBoxOtherPhone=&CONTROLGROUPCONTACT_ContactInputView_TextBoxFax=7631296&CONTROLGROUPCONTACT_ContactInputView_TextBoxEmailAddress=abnc%40gmail.com; CONTROLGROUPCONTACT_ContactInputView_fdsfsdfdf=CONTROLGROUPCONTACT_ContactInputView_DropDownListTitle=MR&CONTROLGROUPCONTACT_ContactInputView_DropDownListSuffix=&CONTROLGROUPCONTACT_ContactInputView_DropDownListStateProvince=VN|DLI&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine1=fsfdsf&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine2=&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine3=&CONTROLGROUPCONTACT_ContactInputView_TextBoxCity=&CONTROLGROUPCONTACT_ContactInputView_TextBoxPostalCode=&CONTROLGROUPCONTACT_ContactInputView_DropDownListCountry=VN&CONTROLGROUPCONTACT_ContactInputView_TextBoxHomePhone=34242&CONTROLGROUPCONTACT_ContactInputView_TextBoxWorkPhone=&CONTROLGROUPCONTACT_ContactInputView_TextBoxOtherPhone=&CONTROLGROUPCONTACT_ContactInputView_TextBoxFax=1761619&CONTROLGROUPCONTACT_ContactInputView_TextBoxEmailAddress=thienan289%40gmail.com; __utma=187758136.1032547902.1356189845.1356195522.1356225069.3; __utmb=187758136.1.10.1356225069; __utmc=187758136; __utmz=187758136.1356225069.3.3.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided)"; webClient.DownloadFileEx(postData, fileName); postData = string.Format( "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwUBMGRk77h9CNekodLMZhdJu3riPx9ebN8%3D&pageToken=&AvailabilitySearchInputContactView%24RadioButtonMarketStructure=OneWay&originStation1=HAN&AvailabilitySearchInputContactView%24TextBoxMarketOrigin1=HAN&destinationStation1=SGN&AvailabilitySearchInputContactView%24TextBoxMarketDestination1=SGN&AvailabilitySearchInputContactView%24DropDownListMarketDay1=25&AvailabilitySearchInputContactView%24DropDownListMarketMonth1=2012-12&AvailabilitySearchInputContactView%24DropDownListMarketDateRange1=0%7C4&date_picker=2012-12-25&originStation2=&AvailabilitySearchInputContactView%24TextBoxMarketOrigin2=%C4%90i%E1%BB%83m+%C4%91i...&destinationStation2=&AvailabilitySearchInputContactView%24TextBoxMarketDestination2=%C4%90i%E1%BB%83m+%C4%91%E1%BA%BFn...&AvailabilitySearchInputContactView%24DropDownListMarketDay2=30&AvailabilitySearchInputContactView%24DropDownListMarketMonth2=2012-12&AvailabilitySearchInputContactView%24DropDownListMarketDateRange2=0%7C4&date_picker=2012-12-30&AvailabilitySearchInputContactView%24DropDownListPassengerType_ADT=1&AvailabilitySearchInputContactView%24DropDownListPassengerType_CHD=0&AvailabilitySearchInputContactView%24DropDownListPassengerType_INFANT=0&AvailabilitySearchInputContactView%24DropDownListSearchBy=columnView&CONTROLGROUPCONTACT%24ContactInputView%24DropDownListTitle=MR&CONTROLGROUPCONTACT%24ContactInputView%24TextBoxLastName={1}&CONTROLGROUPCONTACT%24ContactInputView%24TextBoxFirstName={0}&CONTROLGROUPCONTACT%24ContactInputView%24TextBoxAddressLine1=ttt&CONTROLGROUPCONTACT%24ContactInputView%24DropDownListStateProvince=VN%7CSGN&CONTROLGROUPCONTACT%24ContactInputView%24DropDownListCountry=VN&CONTROLGROUPCONTACT%24ContactInputView%24TextBoxHomePhone={2}&CONTROLGROUPCONTACT%24ContactInputView%24TextBoxEmailAddress={3}&CONTROLGROUPCONTACT%24ContactInputView%24TextBoxFax=7633849&CONTROLGROUPCONTACT%24ItineraryDistributionInputView%24Distribution=0&CONTROLGROUPCONTACT%24ButtonSubmit=Ti%E1%BA%BFp+t%E1%BB%A5c", param.FirstName, param.LastName, param.Phone, param.Email); webClient = WebClientEx.CreateMekongAirWebClient("https://booking.airmekong.com.vn/Contact.aspx"); webClient.Headers["Cookie"] = "ASP.NET_SessionId=maebhn55333a1unuwov03z45; CONTROLGROUPCONTACT_ContactInputView_dsadsadsada=CONTROLGROUPCONTACT_ContactInputView_DropDownListTitle=MR&CONTROLGROUPCONTACT_ContactInputView_DropDownListSuffix=&CONTROLGROUPCONTACT_ContactInputView_DropDownListStateProvince=VN|BMV&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine1=dasdasd&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine2=&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine3=&CONTROLGROUPCONTACT_ContactInputView_TextBoxCity=&CONTROLGROUPCONTACT_ContactInputView_TextBoxPostalCode=&CONTROLGROUPCONTACT_ContactInputView_DropDownListCountry=VN&CONTROLGROUPCONTACT_ContactInputView_TextBoxHomePhone=dsada&CONTROLGROUPCONTACT_ContactInputView_TextBoxWorkPhone=&CONTROLGROUPCONTACT_ContactInputView_TextBoxOtherPhone=&CONTROLGROUPCONTACT_ContactInputView_TextBoxFax=7631296&CONTROLGROUPCONTACT_ContactInputView_TextBoxEmailAddress=abnc%40gmail.com; CONTROLGROUPCONTACT_ContactInputView_fdsfsdfdf=CONTROLGROUPCONTACT_ContactInputView_DropDownListTitle=MR&CONTROLGROUPCONTACT_ContactInputView_DropDownListSuffix=&CONTROLGROUPCONTACT_ContactInputView_DropDownListStateProvince=VN|DLI&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine1=fsfdsf&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine2=&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine3=&CONTROLGROUPCONTACT_ContactInputView_TextBoxCity=&CONTROLGROUPCONTACT_ContactInputView_TextBoxPostalCode=&CONTROLGROUPCONTACT_ContactInputView_DropDownListCountry=VN&CONTROLGROUPCONTACT_ContactInputView_TextBoxHomePhone=34242&CONTROLGROUPCONTACT_ContactInputView_TextBoxWorkPhone=&CONTROLGROUPCONTACT_ContactInputView_TextBoxOtherPhone=&CONTROLGROUPCONTACT_ContactInputView_TextBoxFax=1761619&CONTROLGROUPCONTACT_ContactInputView_TextBoxEmailAddress=thienan289%40gmail.com; __utma=187758136.1032547902.1356189845.1356195522.1356225069.3; __utmb=187758136.1.10.1356225069; __utmc=187758136; __utmz=187758136.1356225069.3.3.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided)"; webClient.DownloadFileEx(postData, fileName); postData = string.Format( "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwUBMGRk77h9CNekodLMZhdJu3riPx9ebN8%3D&pageToken=&AvailabilitySearchInputPassengerView%24RadioButtonMarketStructure=OneWay&originStation1=HAN&AvailabilitySearchInputPassengerView%24TextBoxMarketOrigin1=HAN&destinationStation1=SGN&AvailabilitySearchInputPassengerView%24TextBoxMarketDestination1=SGN&AvailabilitySearchInputPassengerView%24DropDownListMarketDay1=25&AvailabilitySearchInputPassengerView%24DropDownListMarketMonth1=2012-12&AvailabilitySearchInputPassengerView%24DropDownListMarketDateRange1=0%7C4&date_picker=2012-12-25&originStation2=&AvailabilitySearchInputPassengerView%24TextBoxMarketOrigin2=%C4%90i%E1%BB%83m+%C4%91i...&destinationStation2=&AvailabilitySearchInputPassengerView%24TextBoxMarketDestination2=%C4%90i%E1%BB%83m+%C4%91%E1%BA%BFn...&AvailabilitySearchInputPassengerView%24DropDownListMarketDay2=30&AvailabilitySearchInputPassengerView%24DropDownListMarketMonth2=2012-12&AvailabilitySearchInputPassengerView%24DropDownListMarketDateRange2=0%7C4&date_picker=2012-12-30&AvailabilitySearchInputPassengerView%24DropDownListPassengerType_ADT=1&AvailabilitySearchInputPassengerView%24DropDownListPassengerType_CHD=0&AvailabilitySearchInputPassengerView%24DropDownListPassengerType_INFANT=0&AvailabilitySearchInputPassengerView%24DropDownListSearchBy=columnView&CONTROLGROUPPASSENGER%24PassengerInputViewPassengerView%24DropDownListTitle_0=MR&CONTROLGROUPPASSENGER%24PassengerInputViewPassengerView%24TextBoxLastName_0=ngoc&CONTROLGROUPPASSENGER%24PassengerInputViewPassengerView%24TextBoxFirstName_0=nguyen&CONTROLGROUPPASSENGER%24PassengerInputViewPassengerView%24TextBoxProgramNumber_0=&CONTROLGROUPPASSENGER%24PassengerInputViewPassengerView%24DropDownListProgram_0=UAT&CONTROLGROUPPASSENGER%24ButtonSubmit=Ti%E1%BA%BFp+t%E1%BB%A5c"); webClient = WebClientEx.CreateMekongAirWebClient("https://booking.airmekong.com.vn/Passenger.aspx"); webClient.Headers["Cookie"] = "ASP.NET_SessionId=maebhn55333a1unuwov03z45; CONTROLGROUPCONTACT_ContactInputView_dsadsadsada=CONTROLGROUPCONTACT_ContactInputView_DropDownListTitle=MR&CONTROLGROUPCONTACT_ContactInputView_DropDownListSuffix=&CONTROLGROUPCONTACT_ContactInputView_DropDownListStateProvince=VN|BMV&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine1=dasdasd&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine2=&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine3=&CONTROLGROUPCONTACT_ContactInputView_TextBoxCity=&CONTROLGROUPCONTACT_ContactInputView_TextBoxPostalCode=&CONTROLGROUPCONTACT_ContactInputView_DropDownListCountry=VN&CONTROLGROUPCONTACT_ContactInputView_TextBoxHomePhone=dsada&CONTROLGROUPCONTACT_ContactInputView_TextBoxWorkPhone=&CONTROLGROUPCONTACT_ContactInputView_TextBoxOtherPhone=&CONTROLGROUPCONTACT_ContactInputView_TextBoxFax=7631296&CONTROLGROUPCONTACT_ContactInputView_TextBoxEmailAddress=abnc%40gmail.com; CONTROLGROUPCONTACT_ContactInputView_fdsfsdfdf=CONTROLGROUPCONTACT_ContactInputView_DropDownListTitle=MR&CONTROLGROUPCONTACT_ContactInputView_DropDownListSuffix=&CONTROLGROUPCONTACT_ContactInputView_DropDownListStateProvince=VN|DLI&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine1=fsfdsf&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine2=&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine3=&CONTROLGROUPCONTACT_ContactInputView_TextBoxCity=&CONTROLGROUPCONTACT_ContactInputView_TextBoxPostalCode=&CONTROLGROUPCONTACT_ContactInputView_DropDownListCountry=VN&CONTROLGROUPCONTACT_ContactInputView_TextBoxHomePhone=34242&CONTROLGROUPCONTACT_ContactInputView_TextBoxWorkPhone=&CONTROLGROUPCONTACT_ContactInputView_TextBoxOtherPhone=&CONTROLGROUPCONTACT_ContactInputView_TextBoxFax=1761619&CONTROLGROUPCONTACT_ContactInputView_TextBoxEmailAddress=thienan289%40gmail.com; __utma=187758136.1032547902.1356189845.1356195522.1356225069.3; __utmb=187758136.1.10.1356225069; __utmc=187758136; __utmz=187758136.1356225069.3.3.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided)"; webClient.DownloadFileEx(postData, fileName); postData = string.Format( "__EVENTTARGET=CONTROLGROUPPAYMENTBOTTOM%24PaymentInputViewPaymentView&__EVENTARGUMENT=HOLD&__VIEWSTATE=%2FwEPDwUBMGRk77h9CNekodLMZhdJu3riPx9ebN8%3D&pageToken=&AvailabilitySearchInputPaymentView%24RadioButtonMarketStructure=OneWay&originStation1=HAN&AvailabilitySearchInputPaymentView%24TextBoxMarketOrigin1=HAN&destinationStation1=SGN&AvailabilitySearchInputPaymentView%24TextBoxMarketDestination1=SGN&AvailabilitySearchInputPaymentView%24DropDownListMarketDay1=25&AvailabilitySearchInputPaymentView%24DropDownListMarketMonth1=2012-12&AvailabilitySearchInputPaymentView%24DropDownListMarketDateRange1=0%7C4&date_picker=2012-12-25&originStation2=&AvailabilitySearchInputPaymentView%24TextBoxMarketOrigin2=%C4%90i%E1%BB%83m+%C4%91i...&destinationStation2=&AvailabilitySearchInputPaymentView%24TextBoxMarketDestination2=%C4%90i%E1%BB%83m+%C4%91%E1%BA%BFn...&AvailabilitySearchInputPaymentView%24DropDownListMarketDay2=30&AvailabilitySearchInputPaymentView%24DropDownListMarketMonth2=2012-12&AvailabilitySearchInputPaymentView%24DropDownListMarketDateRange2=0%7C4&date_picker=2012-12-30&AvailabilitySearchInputPaymentView%24DropDownListPassengerType_ADT=1&AvailabilitySearchInputPaymentView%24DropDownListPassengerType_CHD=0&AvailabilitySearchInputPaymentView%24DropDownListPassengerType_INFANT=0&AvailabilitySearchInputPaymentView%24DropDownListSearchBy=columnView&CONTROLGROUPPAYMENTBOTTOM%24PaymentInputViewPaymentView%24DropDownListPaymentMethodCode=ExternalAccount%3AAX&CONTROLGROUPPAYMENTBOTTOM%24PaymentInputViewPaymentView%24TextBoxAMT=1.576.500&CONTROLGROUPPAYMENTBOTTOM%24PaymentInputViewPaymentView%24TextBoxACCTNO=&CONTROLGROUPPAYMENTBOTTOM%24PaymentInputViewPaymentView%24DropDownListEXPDAT_Month=12&CONTROLGROUPPAYMENTBOTTOM%24PaymentInputViewPaymentView%24DropDownListEXPDAT_Year=2012&CONTROLGROUPPAYMENTBOTTOM%24PaymentInputViewPaymentView%24TextBoxCC__AccountHolderName=&CONTROLGROUPPAYMENTBOTTOM%24PaymentInputViewPaymentView%24TextBoxCC__VerificationCode="); webClient = WebClientEx.CreateMekongAirWebClient("https://booking.airmekong.com.vn/Payment.aspx"); webClient.Headers["Cookie"] = "ASP.NET_SessionId=maebhn55333a1unuwov03z45; CONTROLGROUPCONTACT_ContactInputView_dsadsadsada=CONTROLGROUPCONTACT_ContactInputView_DropDownListTitle=MR&CONTROLGROUPCONTACT_ContactInputView_DropDownListSuffix=&CONTROLGROUPCONTACT_ContactInputView_DropDownListStateProvince=VN|BMV&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine1=dasdasd&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine2=&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine3=&CONTROLGROUPCONTACT_ContactInputView_TextBoxCity=&CONTROLGROUPCONTACT_ContactInputView_TextBoxPostalCode=&CONTROLGROUPCONTACT_ContactInputView_DropDownListCountry=VN&CONTROLGROUPCONTACT_ContactInputView_TextBoxHomePhone=dsada&CONTROLGROUPCONTACT_ContactInputView_TextBoxWorkPhone=&CONTROLGROUPCONTACT_ContactInputView_TextBoxOtherPhone=&CONTROLGROUPCONTACT_ContactInputView_TextBoxFax=7631296&CONTROLGROUPCONTACT_ContactInputView_TextBoxEmailAddress=abnc%40gmail.com; CONTROLGROUPCONTACT_ContactInputView_fdsfsdfdf=CONTROLGROUPCONTACT_ContactInputView_DropDownListTitle=MR&CONTROLGROUPCONTACT_ContactInputView_DropDownListSuffix=&CONTROLGROUPCONTACT_ContactInputView_DropDownListStateProvince=VN|DLI&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine1=fsfdsf&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine2=&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine3=&CONTROLGROUPCONTACT_ContactInputView_TextBoxCity=&CONTROLGROUPCONTACT_ContactInputView_TextBoxPostalCode=&CONTROLGROUPCONTACT_ContactInputView_DropDownListCountry=VN&CONTROLGROUPCONTACT_ContactInputView_TextBoxHomePhone=34242&CONTROLGROUPCONTACT_ContactInputView_TextBoxWorkPhone=&CONTROLGROUPCONTACT_ContactInputView_TextBoxOtherPhone=&CONTROLGROUPCONTACT_ContactInputView_TextBoxFax=1761619&CONTROLGROUPCONTACT_ContactInputView_TextBoxEmailAddress=thienan289%40gmail.com; __utma=187758136.1032547902.1356189845.1356195522.1356225069.3; __utmb=187758136.1.10.1356225069; __utmc=187758136; __utmz=187758136.1356225069.3.3.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided)"; webClient.DownloadFileEx(postData, fileName); postData = string.Format( "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwUBMGRk77h9CNekodLMZhdJu3riPx9ebN8%3D&pageToken=&AvailabilitySearchInputPaymentView%24RadioButtonMarketStructure=RoundTrip&originStation1=HAN&AvailabilitySearchInputPaymentView%24TextBoxMarketOrigin1=HAN&destinationStation1=SGN&AvailabilitySearchInputPaymentView%24TextBoxMarketDestination1=SGN&AvailabilitySearchInputPaymentView%24DropDownListMarketDay1=25&AvailabilitySearchInputPaymentView%24DropDownListMarketMonth1=2012-12&AvailabilitySearchInputPaymentView%24DropDownListMarketDateRange1=0%7C4&date_picker=2012-12-25&originStation2=SGN&AvailabilitySearchInputPaymentView%24TextBoxMarketOrigin2=SGN&destinationStation2=HAN&AvailabilitySearchInputPaymentView%24TextBoxMarketDestination2=HAN&AvailabilitySearchInputPaymentView%24DropDownListMarketDay2=30&AvailabilitySearchInputPaymentView%24DropDownListMarketMonth2=2012-12&AvailabilitySearchInputPaymentView%24DropDownListMarketDateRange2=0%7C4&date_picker=2012-12-30&AvailabilitySearchInputPaymentView%24DropDownListPassengerType_ADT=1&AvailabilitySearchInputPaymentView%24DropDownListPassengerType_CHD=0&AvailabilitySearchInputPaymentView%24DropDownListPassengerType_INFANT=0&AvailabilitySearchInputPaymentView%24DropDownListSearchBy=columnView&DropdowDS=ABO&CONTROLGROUPPAYMENTBOTTOM%24ButtonSubmit=Thanh+to%C3%A1n"); webClient = WebClientEx.CreateMekongAirWebClient("https://booking.airmekong.com.vn/Payment.aspx"); webClient.Headers["Cookie"] = "ASP.NET_SessionId=maebhn55333a1unuwov03z45; CONTROLGROUPCONTACT_ContactInputView_dsadsadsada=CONTROLGROUPCONTACT_ContactInputView_DropDownListTitle=MR&CONTROLGROUPCONTACT_ContactInputView_DropDownListSuffix=&CONTROLGROUPCONTACT_ContactInputView_DropDownListStateProvince=VN|BMV&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine1=dasdasd&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine2=&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine3=&CONTROLGROUPCONTACT_ContactInputView_TextBoxCity=&CONTROLGROUPCONTACT_ContactInputView_TextBoxPostalCode=&CONTROLGROUPCONTACT_ContactInputView_DropDownListCountry=VN&CONTROLGROUPCONTACT_ContactInputView_TextBoxHomePhone=dsada&CONTROLGROUPCONTACT_ContactInputView_TextBoxWorkPhone=&CONTROLGROUPCONTACT_ContactInputView_TextBoxOtherPhone=&CONTROLGROUPCONTACT_ContactInputView_TextBoxFax=7631296&CONTROLGROUPCONTACT_ContactInputView_TextBoxEmailAddress=abnc%40gmail.com; CONTROLGROUPCONTACT_ContactInputView_fdsfsdfdf=CONTROLGROUPCONTACT_ContactInputView_DropDownListTitle=MR&CONTROLGROUPCONTACT_ContactInputView_DropDownListSuffix=&CONTROLGROUPCONTACT_ContactInputView_DropDownListStateProvince=VN|DLI&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine1=fsfdsf&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine2=&CONTROLGROUPCONTACT_ContactInputView_TextBoxAddressLine3=&CONTROLGROUPCONTACT_ContactInputView_TextBoxCity=&CONTROLGROUPCONTACT_ContactInputView_TextBoxPostalCode=&CONTROLGROUPCONTACT_ContactInputView_DropDownListCountry=VN&CONTROLGROUPCONTACT_ContactInputView_TextBoxHomePhone=34242&CONTROLGROUPCONTACT_ContactInputView_TextBoxWorkPhone=&CONTROLGROUPCONTACT_ContactInputView_TextBoxOtherPhone=&CONTROLGROUPCONTACT_ContactInputView_TextBoxFax=1761619&CONTROLGROUPCONTACT_ContactInputView_TextBoxEmailAddress=thienan289%40gmail.com; __utma=187758136.1032547902.1356189845.1356195522.1356225069.3; __utmb=187758136.1.10.1356225069; __utmc=187758136; __utmz=187758136.1356225069.3.3.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided)"; webClient.DownloadFileEx(postData, fileName); ParseResult(fileName); File.Delete(fileName); }
public string GenerateJsonResult(FlightRegisterParameters parameters) { FlightRegister register = GetRegister(parameters); if (register != null) { register.Register(parameters); RegisterResult result = register.GetResult(); if (result != null) { string json = JsonConvert.SerializeObject(result, Formatting.None); return json; } } return ""; }
protected FlightRegister GetRegister(FlightRegisterParameters parameters) { string type = Regex.Match(parameters.DepartFlightNo, @"[A-Za-z]+").Value; if (type.Contains("VN") == true) { return new VNAirlineRegister(); } else if (type.Contains("BL") == true) { return new JestaRegister(); } else if (type.Contains("P") == true && Utilities.ExtractNumberAndCharacter(parameters.DepartFlightNo).Contains("P8") == true) { return new AirMekongRegister(); } return null; }
public string OneWayRegister(string from, string to, DateTime departDate, string departFlightNo, string firstName, string lastName, string tel, string email) { FlightRegisterParameters parameters = new FlightRegisterParameters(); parameters.BookingType = "oneway"; parameters.From = from; parameters.To = to; parameters.DepartDay = departDate.Day.ToString(); parameters.DepartMonth = departDate.Month.ToString(); parameters.DepartYear = departDate.Year.ToString(); parameters.DepartFlightNo = departFlightNo; parameters.FirstName = firstName; parameters.LastName = lastName; parameters.Phone = tel; parameters.Email = email; RegisterResultFactory registerResultFactory = new RegisterResultFactory(); string json = registerResultFactory.GenerateJsonResult(parameters); return json; }
protected void OneWayRegister(FlightRegisterParameters param) { _result = null; string fileName = Path.GetTempFileName(); WebScraping webScraping = new JestaWebScraping(); IWebScrapingDelegate webScrapingDelegate = webScraping.GetWebScrapingDelegate(param.BookingType); string cookie = "ASP.NET_SessionId=wnlg1y55kwwpga55bmw21gqt; multitabcounttimestamp=3; cae_browser=desktop; pageRefreshStatus=; sessionculture=vi-VN; multitabtimestamp=1356144700355.61; SiteCore_POS=Vietnam; Country_POS=vn-vi; txtOrigin#01=Tp.H%u1ED3%20Ch%ED%20Minh%20%28SGN%29; txtOriginCityCode#01=SGN; txtDestination#01=H%E0%20N%u1ED9i%20%28HAN%29; txtDestinationCityCode#01=HAN; txtDepart#01=30/12/2012; txtReturn#01=; ddlCurrency#01=VND; ddlAdults#01=1; ddlKids#01=0; rdoFlightTypeReturn#01=undefined; rdoFlightTypeOneWay#01=checked; rdoTravelPrefFixed#01=checked; rdoTravelPrefCheap#01=undefined; compactSearchSubmit#01=1356145146686; __utma=20450727.93390813.1356138950.1356138950.1356141839.2; __utmb=20450727.17.9.1356145146700; __utmc=20450727; __utmz=20450727.1356141839.2.2.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided)"; webScrapingDelegate.DownloadWebPage(param, fileName, cookie); GetPostData(fileName, param); string postData = string.Format("__EVENTTARGET=ControlGroupSelectView%24LinkButtonSubmit&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwUBMGQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgIFJ01lbWJlckxvZ2luU2VsZWN0VmlldyRtZW1iZXJfUmVtZW1iZXJtZQVEQ29udHJvbEdyb3VwU2VsZWN0VmlldyRBdmFpbGFiaWxpdHlJbnB1dFNlbGVjdFZpZXckUHJpY2VMb2NrQ2hlY2tib3jnzFtFjR2pAhdqCjacSoMMek2XLA%3D%3D&pageToken=&total_price{1}=&ControlGroupSelectView%24AvailabilityInputSelectView%24HiddenFieldTabIndex1=4&ControlGroupSelectView%24AvailabilityInputSelectView%24market1={0}&marketstructure=OneWay", _market1, _totalPrice); WebClientEx webClient = WebClientEx.CreateJetstarWebClient("http://booknow.jetstar.com/Select.aspx"); webClient.Headers["Cookie"] = "ASP.NET_SessionId=wnlg1y55kwwpga55bmw21gqt; multitabcounttimestamp=3; cae_browser=desktop; pageRefreshStatus=; SiteCore_POS=Vietnam; Country_POS=vn-vi; txtOrigin#01=Tp.H%u1ED3%20Ch%ED%20Minh%20%28SGN%29; txtOriginCityCode#01=SGN; txtDestination#01=H%E0%20N%u1ED9i%20%28HAN%29; txtDestinationCityCode#01=HAN; txtDepart#01=30/12/2012; txtReturn#01=; ddlCurrency#01=VND; ddlAdults#01=1; ddlKids#01=0; rdoFlightTypeReturn#01=undefined; rdoFlightTypeOneWay#01=checked; rdoTravelPrefFixed#01=checked; rdoTravelPrefCheap#01=undefined; compactSearchSubmit#01=1356145146686; sessionculture=vi-VN; multitabtimestamp=1356145139199.53; __utma=20450727.93390813.1356138950.1356138950.1356141839.2; __utmb=20450727.18.9.1356145146700; __utmc=20450727; __utmz=20450727.1356141839.2.2.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided)"; webClient.DownloadFileEx(postData, fileName); ParseResult(fileName); File.Delete(fileName); }
public abstract void Register(FlightRegisterParameters param);
void GetPostData(string fileName, FlightRegisterParameters param) { HtmlDocument document = new HtmlDocument(); ; document.Load(fileName); HtmlNode bookingTypeNode = document.DocumentNode.SelectSingleNode("//input[@id='marketstructure']"); if (null == bookingTypeNode) { return; } _bookingType = bookingTypeNode.GetAttributeValue("value", ""); HtmlNode totalPriceNode = document.DocumentNode.SelectSingleNode("//input[@id='total_price']"); if (null == totalPriceNode) { return; } string totalPrice = totalPriceNode.GetAttributeValue("value", ""); _totalPrice = totalPrice; _market1 = GetComboboxValue(document, param.DepartFlightNo, "1"); _market2 = GetComboboxValue(document, param.ReturnFlightNo, "2"); }
static void Main(string[] args) { //Parameters parameters = new Parameters(); //parameters.From = "SGN"; //parameters.To = "HAN"; //parameters.DepartDay = "20"; //parameters.DepartMonth = "12"; //parameters.DepartYear = "2012"; //parameters.ReturnDay = "30"; //parameters.ReturnMonth = "12"; //parameters.ReturnYear = "2012"; //parameters.BookingType = "roundtrip"; ////parameters.BookingType = "oneway"; //AirlineInfoFactory airlineInfoFactory = new AirlineInfoFactory(); //string json = airlineInfoFactory.GenerateJsonResult(parameters); //StreamWriter writer = new StreamWriter(new FileStream("d:\\result.txt", FileMode.Create)); //writer.Write(json); //writer.Close(); FlightRegisterParameters parameters = new FlightRegisterParameters(); parameters.From = "SGN"; parameters.To = "HAN"; parameters.DepartDay = "5"; parameters.DepartMonth = "1"; parameters.DepartYear = "2013"; //parameters.ReturnDay = "12"; //parameters.ReturnMonth = "1"; //parameters.ReturnYear = "2013"; parameters.DepartFlightNo = "P8-928"; //parameters.ReturnFlightNo = "P8-553 P8-565"; //parameters.BookingType = "roundtrip"; parameters.BookingType = "oneway"; //VN Airline ko cho nhap ten co dau parameters.FirstName = "Nguyen"; parameters.LastName = "Van Quy"; parameters.Phone = "0998 43353"; parameters.Email = "*****@*****.**"; RegisterResultFactory registerResultFactory = new RegisterResultFactory(); string json = registerResultFactory.GenerateJsonResult(parameters); StreamWriter writer = new StreamWriter(new FileStream("d:\\result.txt", FileMode.Create)); writer.Write(json); writer.Close(); Console.WriteLine("OK"); }