Exemple #1
0
        static async Task <FourMacIds> GetThreeMacIds(HttpClient client, string path)
        {
            FourMacIds          macIds   = null;
            HttpResponseMessage response = await client.GetAsync(path);

            if (response.IsSuccessStatusCode)
            {
                macIds = await response.Content.ReadAsAsync <FourMacIds>();
            }
            return(macIds);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Press enter to start.");
            Console.ReadLine();

            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("http://localhost:1471/localization/rooms/");
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(
                new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

            try
            {
                //adding new room
                FourMacIds determinantMacIds = new FourMacIds
                {
                    FirstMacId  = "first",
                    SecondMacId = "second",
                    ThirdMacId  = "third"
                };

                PutNewRoomInfo(client, "MCHTR", determinantMacIds).Wait();
                Console.WriteLine("Added new room to db.");

                //getting rooms list
                Console.WriteLine("Room list:");
                List <RoomInfo> possibleRooms = GetPossibleRoomsAsync(client, "").Result;
                foreach (var item in possibleRooms)
                {
                    Console.WriteLine(item.roomId);
                    Console.WriteLine(item.roomName);
                    Console.WriteLine("*");
                }

                //adding new measurment point
                addMeasurmentPoint(client, 1, 1, 10, 10, 10);
                addMeasurmentPoint(client, 2, 2, 30, 30, 30);
                addMeasurmentPoint(client, 3, 3, 40, 40, 40);
                addMeasurmentPoint(client, 4, 4, 60, 60, 60);

                //get nearest measurment point
                Point nearestPoint = GetNearestXYLocalizationPoint(client, "1/point?firstMacId=-99&secondMacId=-2&thirdMacId=-55").GetAwaiter().GetResult();
                Console.WriteLine("Nearest Point:\n" + nearestPoint.x + "\n" + nearestPoint.y);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Exemple #3
0
        static async Task PutNewRoomInfo(HttpClient client, string path, FourMacIds determinantMacIds)
        {
            HttpResponseMessage response = await client.PutAsJsonAsync(path, determinantMacIds);

            response.EnsureSuccessStatusCode();
        }