Exemplo n.º 1
0
        public async Task<JArray> FetchInterruptions(string postCodeFilePath)
        {

            var postCodeData = File.ReadAllText(postCodeFilePath);
            var locations = (JArray)JsonConvert.DeserializeObject(postCodeData);
            JArray interruptionList = new JArray();

            foreach (var instance in locations)
            {
                var location = (JObject)instance;
                var postCode = location.GetValue("PostCode").ToString();
                var scraper = new WpPiScraper(postCode);

                var interruptionsInfoForPostCode = await scraper.GetInteruptionData();

                if (interruptionsInfoForPostCode.Any())
                {
                    var interruptionInfo = interruptionsInfoForPostCode.ToList();
                    foreach (var interruption in interruptionInfo)
                    {
                        var asJson = JsonConvert.SerializeObject(interruption);
                        interruptionList.Add(JObject.Parse(asJson));
                    }
                   
                }
            }

            return interruptionList;
        }
Exemplo n.º 2
0
        public async Task<IEnumerable<InterruptionInfo>> GetInterruptionFromWp(string location)
        {

            var scraper = new WpPiScraper(location);

            try
            {
                var interruptionsInfoFromWp = await scraper.GetInteruptionData().ConfigureAwait(false);
                if (interruptionsInfoFromWp.Any())
                {
                    return interruptionsInfoFromWp.ToList();
                }
                return new List<InterruptionInfo>();
            }
            catch (Exception)
            {
                throw;
            }

        }
Exemplo n.º 3
0
        public async Task<IEnumerable<InterruptionInfo>> FetchInterruptions(List<string> locations)
        {
            var interruptionList = new List<InterruptionInfo>();

            foreach (var location in locations)
            {
                var scraper = new WpPiScraper(location);

                var interruptionsInfoForlocation = await scraper.GetInteruptionData().ConfigureAwait(false);

                if (interruptionsInfoForlocation.Any())
                {
                    var interruptionInfo = interruptionsInfoForlocation.ToList();
                    foreach (var interruption in interruptionInfo)
                    {
                        interruptionList.Add(interruption);
                    }
                }
            }

            return interruptionList;
        }