Ejemplo n.º 1
0
 public void OnNavigationBackRequested(object sender, BackRequestedEventArgs e)
 {
     CenterOnStartLocation();
     ClearNavigation();
     ClearPolygon();
     IncidentDatailsHandler?.Invoke(this, new IncidentSelectedEventArgs(-1, false));
     SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
     SystemNavigationManager.GetForCurrentView().BackRequested -= OnNavigationBackRequested;
 }
Ejemplo n.º 2
0
        private async void UpdateNavigationPosition()
        {
            if (_currentRoute != null && !_routeInAction)
            {
                _routeInAction = true;
                _userIcon.IncidentResponsePath = _currentRoute.Route.Path.Positions;
                var toastPositionIndex = _userIcon.IncidentResponsePath.Count / 2;

                bool complete;
                do
                {
                    complete = FollowCustomRoute(_userIcon);
                    if (toastPositionIndex == _userIcon.RouteIndex && _userIcon.RouteStepIndex == 0 && _currentIncident != null)
                    {
                        ToastHelper.PopIncidentUpdatedToast(_currentIncident.Id);
                        if (_currentIncident.UpdateDescription.IsNotNullOrWhiteSpace())
                        {
                            _currentIncident.Description = _currentIncident.UpdateDescription;
                        }
                    }

                    // stop user just before incident
                    var pathIndex = Math.Max(_userIcon.IncidentResponsePath.Count - 3, 0);
                    if (_userIcon.RouteIndex >= pathIndex)
                    {
                        complete = true;
                    }
                    await Task.Delay(Configuration.UpdateInterval);
                }while ((_currentRoute != null) && !complete);

                if (complete)
                {
                    _routeInAction = false;
                    _userIcon.UpdateStatus(ResponseStatus.Busy);
                    // navigate to the attend view
                    if (_currentIncident != null)
                    {
                        _currentIncident.ReadyToIdentify = true;
                        _mapControl.Center    = _currentIncident.GeoLocation;
                        _mapControl.ZoomLevel = Configuration.IncidentZoomLevel;
                        await AddTickets();
                        await ShowPolygonSearch();

                        IncidentDatailsHandler?.Invoke(this, new IncidentSelectedEventArgs(_currentIncident.Id, true, false));
                        SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
                        SystemNavigationManager.GetForCurrentView().BackRequested += OnNavigationBackRequested;

                        // adding request for additional responder
                        if (_currentIncident.IsHighPriority && _currentIncident.Responders.All(x => x.DepartmentType != DepartmentType.Ambulance))
                        {
                            var invoke = CreateResponderForPriorityIncidentHandler?.Invoke(this, new IncidentEventArgs(_currentIncident));
                            if (invoke != null)
                            {
                                var responseRequestModel = await invoke;
                                AddElements(responseRequestModel.ResponseUnit, responseRequestModel.ResponseUnit.Responder.GeoLocation, ResponderModel.AnchorPoint);
                                _currentIncident.Responders.Add(responseRequestModel);
                            }
                        }
                    }
                    ClearNavigation();
                    await UpdateSelectedItem(null);
                }
            }
        }