Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,CoordinateAsJson,FireSeverity,TimeStamp,DroneAssignmentId")] FireReport fireReport)
        {
            if (id != fireReport.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(fireReport);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FireReportExists(fireReport.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(fireReport));
        }
Exemplo n.º 2
0
        public async Task <bool> AlertForFire(double lat, double lng, EFireSeverity severity, string description)
        {
            try
            {
                var report = new FireReport()
                {
                    Description  = description,
                    FireSeverity = severity,
                    TimeStamp    = DateTime.Now,
                    Coordinates  = new Coordinate()
                    {
                        Latitude  = lat,
                        Longitude = lng
                    }
                };

                var result = await UncommonRequestHelper.ProcessPostRequestAsync <FireReport>("http://inferno-web.azurewebsites.net/api/firereport", report, new UncommonRequestOptions()
                {
                    Authorized = true,
                    Timeout    = 12000
                }).ConfigureAwait(false);

                if (result.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    return(true);
                }
                return(false);
            }
            catch (Exception e)
            {
            }
            return(false);
        }
Exemplo n.º 3
0
        public static void TweetRecieved(object sender, MatchedTweetReceivedEventArgs args)
        {
            if (args.Tweet == null)
            {
                return;
            }

            Console.WriteLine($"Tweet recieved {args.Tweet.FullText}");

            var report = new FireReport()
            {
                TimeStamp    = args.Tweet.CreatedAt,
                FireSeverity = EFireSeverity.Unkown,
                Description  = args.Tweet.FullText
            };

            if (report.Description != null && (report.Description.ToLower().Contains("severe") || report.Description.ToLower().Contains("urgent")))
            {
                report.FireSeverity = EFireSeverity.LargerThan100LessThan500Meters;
            }

            if (args.Tweet.Place?.BoundingBox?.Coordinates != null)
            {
                report.BoundingBox = args.Tweet.Place.BoundingBox.Coordinates.Select(x => x.ToGeoCoordinate()).ToList();
                report.Coordinates = new GeoCoordinate(args.Tweet.Place.BoundingBox.Coordinates.Average(x => x.Latitude), args.Tweet.Place.BoundingBox.Coordinates.Average(x => x.Longitude));
            }

            Console.WriteLine($"Trying to store tweet {JsonConvert.SerializeObject(report)}");

            _serviceProvider.GetService <IFireReport>()?.AddReport(report);
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("Id,CoordinateAsJson,FireSeverity,TimeStamp,DroneAssignmentId")] FireReport fireReport)
        {
            if (ModelState.IsValid)
            {
                _context.Add(fireReport);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(fireReport));
        }
Exemplo n.º 5
0
 public async Task <IActionResult> Fire([FromBody] FireReport report)
 {
     if (report != null && report.Coordinates != null)
     {
         report.BoundingBox = new List <GeoCoordinate>()
         {
             report.Coordinates,
             report.Coordinates,
             report.Coordinates,
             report.Coordinates
         };
         await _fireReport.AddReport(report);
     }
     return(Ok("Burn baby burn!"));
 }
Exemplo n.º 6
0
        public ComplaintByDesk(IPlace place)
        {
            var report = new FireReport(place);

            this.Complaint = report;
        }
Exemplo n.º 7
0
        public void SoundAlarm(IPlace place)
        {
            var report = new FireReport(place);

            ComplaintList.Add(report);
        }