private async Task Json_Paring(string json)
        {
            try
            {
                //total = 0;

                //Console.WriteLine(json);

                JObject obj = JObject.Parse(json);


                if (total_number == 0)
                {
                    //Console.WriteLine(obj["total"].ToString());
                    total_number = int.Parse(obj["total"].ToString());
                }

                JArray hotel_hotels = JArray.Parse(obj["rooms"].ToString());
                foreach (JObject itemObj in hotel_hotels)
                {
                    RoomDesc contents = new RoomDesc();

                    if (itemObj.ContainsKey("code") == true)
                    {
                        contents.room_code = itemObj["code"].ToString();
                    }

                    if (itemObj.ContainsKey("description") == true)
                    {
                        contents.room_description = itemObj["description"].ToString();
                    }

                    if (itemObj.ContainsKey("type") == true)
                    {
                        contents.room_type = itemObj["type"].ToString();
                    }

                    if (itemObj.ContainsKey("typeDescription") == true)
                    {
                        contents.room_typeDescription = itemObj["typeDescription"]["content"].ToString();
                    }

                    if (itemObj.ContainsKey("characteristic") == true)
                    {
                        contents.room_characteristic = itemObj["characteristic"].ToString();
                    }

                    if (itemObj.ContainsKey("characteristicDescription") == true)
                    {
                        contents.room_characteristicDescription = itemObj["characteristicDescription"]["content"].ToString();
                    }

                    HBRoomDescList.Add(contents);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 2
0
 public BaseRoom(RoomDesc roomDesc, string password)
 {
     RoomState           = new RoomState(roomDesc);
     RoomState.RoomOwner = 0;
     Users         = new UserToken[roomDesc.MaxPlayerNum];
     m_playersGuid = new Guid[roomDesc.MaxPlayerNum];
     this.Password = password;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 创建房间,交给服务器查询房间号是否重复
        /// </summary>
        /// <param name="room">房间号及其配置</param>
        /// <returns>在房间中的id,-1为不成功</returns>
        public int CreateRoom(RoomDesc room, string password)
        {
            CreateRoomC2S createRoom = new CreateRoomC2S(room, password);

            Send(createRoom);
            //waitTimer.Start();
            wait.WaitOne();
            return((int)transmit);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 6
0
 public CreateRoomC2S(RoomDesc room, string password)
 {
     this.RoomDesc = room;
     this.Password = password;
 }