Exemple #1
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            //Xsignature = XSignature_Generate();
            HttpConnects h_Conn = new HttpConnects(ApiUrl_TB.Text + "/hotels", mainWindow.ApiKey_TB.Text, mainWindow.Security_TB.Text);

            var Json_RQ = Json_RQ4HotelList().ToString();

            RQ_Json_TB.Text = Json_RQ;



            change_button_status();

            RSResult rsResult = await h_Conn.searhAllRoomsInHotelS(Json_RQ);

            if (rsResult.rq_status == true)
            {
                RS_Json_TB.Text       = JValue.Parse(rsResult.result).ToString(Formatting.Indented);
                hotelRommsContionList = await Json_Paring(rsResult.result);

                hbHotelRoom_Grid.ItemsSource = hotelRommsContionList;
                statusBar.Content            = "Done: Checking Successfully";

                MessageBox.Show("Rate plan checking process has done !!");
            }
            else
            {
                MessageBoxResult result = MessageBox.Show(rsResult.result);
                statusBar.Content = "Error: " + rsResult.result;
            }

            change_button_status();
        }
        private async void Start_btn_Click(object sender, RoutedEventArgs e)
        {
            if (Booking_Ref.Text == "")
            {
                MessageBox.Show("Please Enter the HotelBeds Booking ID");
            }
            else
            {
                string       getApiUrl = ApiUrl_TB.Text + Booking_Ref.Text;
                HttpConnects h_Conn    = new HttpConnects(getApiUrl, mainWindow.ApiKey_TB.Text, mainWindow.Security_TB.Text);

                statusBar.Content = "Please wait for a Second.... Now We are Communicating with HB API ... -> Get Booking Info ";
                RSResult rsResult = await h_Conn.GetBookingDetail();

                if (rsResult.rq_status == true)
                {
                    RS_Json_TB.Text = JValue.Parse(rsResult.result).ToString(Formatting.Indented);

                    statusBar.Content = "Done: Checking Successfully";
                    MessageBox.Show("Booking Detail checking process has done !!");
                }
                else
                {
                    statusBar.Content = "Error: " + rsResult.result;
                    MessageBoxResult result = MessageBox.Show(rsResult.result);
                }
            }
        }
        private async void GetRoomDescrip_btn_Click(object sender, RoutedEventArgs e)
        {
            string status_barTxt = "";

            HBRoomDescList = new List <RoomDesc>();

            from         = 1;
            to           = 1000;
            total_number = 0;

            current_from = from;
            current_to   = to;

            string getApiUrl = ApiUrl_TB.Text + "types/rooms?fields=all&language=ENG&useSecondaryLanguage=false";

            //Console.WriteLine(getApiUrl);


            HttpConnects h_Conn = new HttpConnects(getApiUrl, mainWindow.ApiKey_TB.Text, mainWindow.Security_TB.Text);

            do
            {
                statusBar.Content = "Please wait for a Second.... Now We are Communicating with HB API ... -> Get Hotel from " + current_from + " to " + current_to;

                RSResult rsResult = await h_Conn.GetHotelContents(current_from, current_to);

                Console.WriteLine(rsResult.result);

                if (rsResult.rq_status == true)
                {
                    //RS_Json_TB.Text = rsResult.result;
                    await Json_Paring(rsResult.result);

                    status_barTxt = "Done: Successfully, Get Hotel from 1  to " + current_to;;
                    //popup_Txt = "Rate plan checking process has done !!"
                    //MessageBox.Show("Rate plan checking process has done !!");
                }
                else
                {
                    status_barTxt = "Error: " + rsResult.result;
                    //MessageBoxResult result = MessageBox.Show(rsResult.result);


                    break;
                }

                current_from = current_to + 1;
                current_to   = current_from + 999;

                //Console.WriteLine("ZZZZZZZ : " +total_number);
            } while (total_number > current_from);

            hbHotelRoom_Grid.ItemsSource = HBRoomDescList;

            await CreateCSVFromGenericList(HBRoomDescList, @"..\..\CSVfiles\RoomDesc.csv");

            statusBar.Content = status_barTxt;
            MessageBox.Show(status_barTxt);
        }
Exemple #4
0
        private async Task <bool> hotelCheckRates(string rateKey)
        {
            bool check_rst = false;

            try
            {
                HttpConnects h_Conn = new HttpConnects(ApiUrl_TB.Text + "/checkrates", mainWindow.ApiKey_TB.Text, mainWindow.Security_TB.Text);

                string rq_json = Json_RQ4RateCheck(rateKey).ToString();
                Console.WriteLine(rq_json);

                Console.WriteLine(testi);
                var result = await h_Conn.searhAllRoomsInHotelS(rq_json);


                if (result.rq_status == false || result.result == null || result.result == "")
                {
                    check_rst = false;
                    Console.WriteLine("error check --> " + result);
                }
                else
                {
                    //check_rst = true;
                    Console.WriteLine("ok check --> " + result);
                    JObject obj = JObject.Parse(result.result);
                    if (obj.ContainsKey("hotel") == true)
                    {
                        Console.WriteLine(obj.ContainsKey("hotel"));

                        JArray rooms_Jarr = JArray.Parse(obj["hotel"]["rooms"].ToString());

                        foreach (JObject itemObj in rooms_Jarr)
                        {
                            JArray hotel_rates_Jarr = JArray.Parse(itemObj["rates"].ToString());

                            foreach (JObject itemObj1 in hotel_rates_Jarr)
                            {
                                if (itemObj1["rateType"].ToString().Equals("BOOKABLE") == true)
                                {
                                    check_rst = true;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                check_rst = false;
            }

            return(check_rst);
        }
        private async void GetHotel_btn_Click(object sender, RoutedEventArgs e)
        {
            DestinationDescMomoryDB = File.ReadAllLines(@"..\..\CSVfiles\DestinationDesc.csv")
                                      .Skip(1)
                                      .Select(v => DestinationDesc.FromCsv(v))
                                      .ToList();

            RoomDescMomoryDB = File.ReadAllLines(@"..\..\CSVfiles\RoomDesc.csv")
                               .Skip(1)
                               .Select(v => RoomDesc.FromCsv(v))
                               .ToList();

            change_button_status();

            string status_barTxt = "";

            hotelContentsList = new List <HotelInformation>();
            HBRoomImageList   = new List <RoomImage>();
            HBWildCardsList   = new List <HotelWildCards>();
            HBHTRoomTypeList  = new List <HotelRoomTypeInfo>();

            from         = 1;
            to           = 1000;
            total_number = 0;

            current_from = from;
            current_to   = to;


            string getApiUrl = ApiUrl_TB.Text + setField4HotelContents(GL_target_Data);

            //Console.WriteLine(getApiUrl);


            HttpConnects h_Conn = new HttpConnects(getApiUrl, mainWindow.ApiKey_TB.Text, mainWindow.Security_TB.Text);

            do
            {
                statusBar.Content = "Please wait for a Second.... Now We are Communicating with HB API ... -> Get Hotel from " + current_from + " to " + current_to;

                RSResult rsResult = await h_Conn.GetHotelContents(current_from, current_to);

                //Console.WriteLine(rsResult.result);

                if (rsResult.rq_status == true)
                {
                    await Json_Paring(GL_target_Data, rsResult.result);

                    Console.WriteLine(GL_target_Data + "  -- " + rsResult.result);
                    status_barTxt = "Done: Successfully, Get Hotel from 1  to " + current_to;;
                }
                else
                {
                    status_barTxt = "Error: " + rsResult.result;
                    MessageBoxResult result = MessageBox.Show(rsResult.result);

                    break;
                }

                current_from = current_to + 1;
                current_to   = current_from + 999;
            } while (total_number > current_from);


            switch (GL_target_Data)
            {
            case "HT":
                //** THIS "hotelContentsList" Cooming from Json_Paring() function as a Global parameter
                hbHotelRoom_Grid.ItemsSource = hotelContentsList;
                break;

            case "IMG":
                //** THIS "hotelContentsList" Cooming from Json_Paring() function as a Global parameter
                HBRoomImageList = (from x in HBRoomImageList
                                   orderby x.hotel_code, x.imageOrder ascending
                                   select x).ToList();
                hbHotelRoom_Grid.ItemsSource = HBRoomImageList;
                break;

            case "WILD":
                hbHotelRoom_Grid.ItemsSource = HBWildCardsList;
                break;

            case "HTROOM":
                hbHotelRoom_Grid.ItemsSource = HBHTRoomTypeList;
                break;

            default:
                hbHotelRoom_Grid.ItemsSource = hotelContentsList;
                break;
            }


            statusBar.Content = status_barTxt;
            MessageBox.Show(status_barTxt);

            change_button_status();
        }
        private async void GetImage_btn_Click(object sender, RoutedEventArgs e)
        {
            string status_barTxt = "";

            //여기 부서 개발 시작 2018.06.27
            RoomDescMomoryDB = File.ReadAllLines(@"..\..\CSVfiles\RoomDesc.csv")
                               .Skip(1)
                               .Select(v => RoomDesc.FromCsv(v))
                               .ToList();
            //여기 부서 개발 시작


            HBRoomImageList = new List <RoomImage>();


            from         = 1;
            to           = 1000;
            total_number = 0;

            current_from = from;
            current_to   = to;

            string getApiUrl = ApiUrl_TB.Text + "hotels?fields=name%2CcountryCode%2CdestinationCode%2Cimages&language=ENG&useSecondaryLanguage=false";

            //Console.WriteLine(getApiUrl);


            HttpConnects h_Conn = new HttpConnects(getApiUrl, mainWindow.ApiKey_TB.Text, mainWindow.Security_TB.Text);

            do
            {
                statusBar.Content = "Please wait for a Second.... Now We are Communicating with HB API ... -> Get Hotel from " + current_from + " to " + current_to;

                RSResult rsResult = await h_Conn.GetHotelContents(current_from, current_to);

                Console.WriteLine(rsResult.result);

                if (rsResult.rq_status == true)
                {
                    //RS_Json_TB.Text = rsResult.result;
                    await Json_Paring_Img(rsResult.result);

                    status_barTxt = "Done: Successfully, Get Hotel from 1  to " + current_to;;
                    //popup_Txt = "Rate plan checking process has done !!"
                    //MessageBox.Show("Rate plan checking process has done !!");
                }
                else
                {
                    status_barTxt = "Error: " + rsResult.result;
                    //MessageBoxResult result = MessageBox.Show(rsResult.result);


                    break;
                }

                current_from = current_to + 1;
                current_to   = current_from + 999;

                //Console.WriteLine("ZZZZZZZ : " +total_number);
            } while (total_number > current_from);

            var HBRoomImageList_Oderby = (from x in HBRoomImageList
                                          orderby x.hotel_code, x.imageOrder ascending
                                          select x).ToList();

            hbHotelRoom_Grid.ItemsSource = HBRoomImageList_Oderby;

            await CreateCSVFromGenericList(HBRoomImageList_Oderby, @"..\..\CSVfiles\HBRoomImages.csv");

            statusBar.Content = status_barTxt;
            MessageBox.Show(status_barTxt);
        }