示例#1
0
        public static async void BarbecueFilter()
        {
            var repo    = new PhotoDbContext();
            var beaches = repo.Beaches.ToList();

            repo.Dispose();
            foreach (var beach in beaches)
            {
                using (var client = new HttpClient())
                {
                    var lat        = beach.Latitude;
                    var lng        = beach.Longitude;
                    var apiCallUrl =
                        $"http://www.meatinapark.com.au/multiplebbqfinder?long={lng}&lat={lat}&distance=2&userDetails=true&bbqCount=300";

                    client.BaseAddress = new Uri(apiCallUrl);
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    HttpResponseMessage response = await client.GetAsync("");

                    if (response.IsSuccessStatusCode)
                    {
                        var json = await response.Content.ReadAsStreamAsync();

                        using (var file = File.Create(OpenDataPath.BarbecueById(beach.BeachId)))
                        {
                            json.CopyTo(file);
                            file.Flush();
                        }
                    }
                }
            }
        }
示例#2
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         db.Dispose();
     }
     base.Dispose(disposing);
 }
示例#3
0
        public static void BikeShareFilter()
        {
            XmlSerializer serializer = new XmlSerializer(typeof(Response));
            Response      file;

            using (XmlReader reader = XmlReader.Create(OpenDataPath.BikeShare))
            {
                var repo    = new PhotoDbContext();
                var beaches = repo.Beaches.ToList();
                repo.Dispose();
                file          = (Response)serializer.Deserialize(reader);
                file.Rows.Row = file.Rows.Row.Where(r => BikeShareProceedRow(ref r, beaches)).ToList();
            }
            using (XmlWriter writer = XmlWriter.Create(OpenDataPath.BikeShareFiltered))
            {
                serializer.Serialize(writer, file);
                writer.Flush();
            }
        }
示例#4
0
        public static void ToiletFilter()
        {
            XmlSerializer   serializer = new XmlSerializer(typeof(ToiletMapExport));
            ToiletMapExport file;

            using (XmlReader reader = XmlReader.Create(OpenDataPath.Toilet))
            {
                var repo    = new PhotoDbContext();
                var beaches = repo.Beaches.ToList();
                repo.Dispose();
                file = (ToiletMapExport)serializer.Deserialize(reader);
                file.ToiletDetails = file.ToiletDetails.Where(t => ToiletProceedToiletDetail(ref t, beaches)).ToList();
            }
            using (XmlWriter writer = XmlWriter.Create(OpenDataPath.ToiletFiltered))
            {
                serializer.Serialize(writer, file);
                writer.Flush();
            }
        }