/// <summary>
        /// Notify a new SOS location is comming
        /// </summary>
        public void NotifySOSLocationReceived(string uidSeekios
                                              , Tuple <int, int> batteryAndSignal
                                              , Tuple <double, double, double, double> location
                                              , DateTime dateCommunication)
        {
            // Get the concerned seekios
            var seekios = App.Locator.ListSeekios.LsSeekios.FirstOrDefault(el => el.UIdSeekios == uidSeekios);

            if (seekios == null)
            {
                return;
            }

            // Update seekios data
            double latitude  = location.Item1;
            double longitude = location.Item2;
            double altitude  = location.Item3;
            double accuracy  = location.Item4;

            seekios.BatteryLife   = batteryAndSignal.Item1;
            seekios.SignalQuality = batteryAndSignal.Item2;
            seekios.LastKnownLocation_accuracy             = accuracy;
            seekios.LastKnownLocation_altitude             = altitude;
            seekios.LastKnownLocation_latitude             = latitude;
            seekios.LastKnownLocation_longitude            = longitude;
            seekios.LastKnownLocation_dateLocationCreation = dateCommunication.ToLocalTime();

            // Add new location
            var locationToAdd = new LocationDTO
            {
                DateLocationCreation = seekios.LastKnownLocation_dateLocationCreation.Value,
                Latitude             = seekios.LastKnownLocation_latitude,
                Longitude            = seekios.LastKnownLocation_longitude,
                Altitude             = seekios.LastKnownLocation_altitude,
                Accuracy             = seekios.LastKnownLocation_accuracy,
                IdLocationDefinition = (int)LocationDefinition.SOS
            };

            App.CurrentUserEnvironment.LsLocations.Add(locationToAdd);

            // Update UI
            if (_dispatcherService == null)
            {
                return;
            }
            _dispatcherService.Invoke(() =>
            {
                App.RaiseSeekiosInformationChangedEverywhere(seekios.Idseekios);
                _localNotificationService.SendNotification(seekios
                                                           , Resources.NotificationSOSPositionTitle
                                                           , string.Format(Resources.NotificationSOSPositionContent
                                                                           , seekios.SeekiosName
                                                                           , dateCommunication.ToLocalTime().FormatDateTimeFromNow())
                                                           , true);
            });
        }
Ejemplo n.º 2
0
        public void OnSOSSentReceived(string uidSeekios
                                      , Tuple <int, int> batteryAndSignal
                                      , DateTime dateCommunication)
        {
            // Get the concerned seekios
            var seekios = App.Locator.ListSeekios.LsSeekios.FirstOrDefault(el => el.UIdSeekios == uidSeekios);

            if (seekios == null)
            {
                return;
            }

            // Update the seekios & mode
            seekios.IsRefreshingBattery   = false;
            seekios.BatteryLife           = batteryAndSignal.Item1;
            seekios.SignalQuality         = batteryAndSignal.Item2;
            seekios.DateLastCommunication = dateCommunication.ToLocalTime();
            seekios.DateLastSOSSent       = dateCommunication.ToLocalTime();
            seekios.IsLastSOSRead         = false;

            // Update UI
            if (_dispatcherService == null)
            {
                return;
            }
            _dispatcherService.Invoke(() =>
            {
                App.RaiseSeekiosInformationChangedEverywhere(seekios.Idseekios);
                _localNotificationService.SendNotification(seekios
                                                           , Resources.NotificationSOSAlertTitle
                                                           , string.Format(Resources.NotificationSOSAlertContent
                                                                           , seekios.SeekiosName
                                                                           , dateCommunication.ToLocalTime().FormatDateTimeFromNow())
                                                           , true);
            });
        }