示例#1
0
        //Mouse'dan alınan noktaları Range Search algoritması için Query'e yollar.
        async Task postMouseClickLocation()
        {
            LocationClient newLocation = new LocationClient();

            for (int i = 0; i < latList.Count; i++)
            {
                newLocation.locationsX = latList[i].ToString();
                newLocation.locationsY = longList[i].ToString();

                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri("http://localhost:6354/");
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    HttpResponseMessage response = await client.PostAsJsonAsync("api/Query", newLocation);

                    if (response.IsSuccessStatusCode)
                    {
                        bool result = await response.Content.ReadAsAsync <bool>();

                        if (result)
                        {
                            label7.Text = "Tamamdır";
                        }

                        else
                        {
                            label7.Text = "Olmadı Kanki";
                        }
                    }
                }
            }
        }
示例#2
0
        //Txt'den alınan verileri servera gönderir.
        async Task postLocationData()
        {
            List <string>  locations   = new List <string>();
            List <string>  locationsX  = new List <string>();
            List <string>  locationsY  = new List <string>();
            LocationClient newLocation = new LocationClient();
            //Txt'yi oku ve satırları locations listesine ekle.
            StreamReader reader   = new StreamReader("dataset1.txt");
            string       contents = reader.ReadToEnd();
            var          lines    = contents.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string line in lines)
            {
                locations.Add(line);
            }
            reader.Close();

            //Virgüle kadar oku latitude listesine at virgülden sonrasını longitude listesine at.
            for (int i = 0; i < locations.Count; i++)
            {
                string[] point = locations[i].Split(',');

                locationsX.Add(point[0]);
                locationsY.Add(point[1]);

                Array.Clear(point, 0, point.Length);
            }

            for (int i = 0; i < locations.Count; i++)
            {
                newLocation.locationsX = locationsX[i];
                newLocation.locationsY = locationsY[i];

                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri("http://localhost:6354/");
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    HttpResponseMessage response = await client.PostAsJsonAsync("api/Location", newLocation);

                    if (response.IsSuccessStatusCode)
                    {
                        bool result = await response.Content.ReadAsAsync <bool>();

                        if (result)
                        {
                            label1.Text = "Servera veri eklendi.";
                        }

                        else
                        {
                            label1.Text = "Server'a veri eklenirken hata oluştu.";
                        }
                    }
                }
            }
            //Servera veri eklendikten sonra veri çekme işlemi başlasın.
            GetLocationData();
        }