private async Task <bool> HasNoUPRN() { try { bool flag = false; foreach (var prop in AppContext.AppContext.LstSriproperty) { if (prop.Status == SyncStatus.New && prop.RequestGroups[0].Records[0].Record.UPRN == null) { if (await SplitView.DisplayAlert("New Case Has Unvalidated Address", "The address for " + prop.Address.ShortAddress + " was not validated and so does not have a UPRN. Are you sure you want to sync?", "Yes", "No")) { flag = false; break; } else { flag = true; break; } } } return(flag); } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); return(false); } }
/// ------------------------------------------------------------------------------------------------ /// ------------------------------------------------------------------------------------------------ #region Private Functions #region Get Current Location public async Task <Plugin.Geolocator.Abstractions.Position> GetCurrentLocation() { try { var locator = CrossGeolocator.Current; //locator.AllowsBackgroundUpdates = true; //locator.DesiredAccuracy = 50; _posistion = await locator.GetPositionAsync(1000); } catch (Plugin.Geolocator.Abstractions.GeolocationException geoException) { AppContext.AppContext.CurrentLocation = null; if (geoException.Message.Contains("Unavailable")) { await SplitView.DisplayAlert(" GPS Disabled ", " Please enable the GPS to access your current location ", "OK", null); } if (geoException.Message.Contains("Unauthorized")) { await SplitView.DisplayAlert("Get Device Location", " Please grant permission for this application to access your current location ", "OK", null); } _posistion = null; } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); AppContext.AppContext.CurrentLocation = null; } return(_posistion); }
private async void OnCancelTapped() { try { if ( await SplitView.DisplayAlert("Cancel", "Are you sure you want to discard changes for this case", "Yes", "No")) { CloseView(); if (Device.OS == TargetPlatform.Android) { SplitView.MapView?.ClearPin(); var pagestack = SplitView._stackNavigationViews; if (pagestack.Count <= 1) { var formsMap = (AndroidMapView)SplitView.MapView; SplitView.Fullmapview.FindByName <Grid>("GlMapView").Children.Clear(); SplitView.Fullmapview.FindByName <Grid>("GlMapView").Children.Add(formsMap, 0, 0); SplitView.MapView?.LoadPins(AppContext.AppContext.LstGooglePin); } } } } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); } }
public async void GetPositionOnClick(double latitude, double longitude) { if (FullMapView.AddNewCasePointOnMapView != null && FullMapView.AddNewCasePointOnMapView.NewCaseAddView == null && AppData.PropertyModel.SelectedProperty == null) { if (!AppContext.AppContext.LocationSelected) { AppContext.AppContext.LocationSelected = true; if (await SplitView.DisplayAlert("Location Selected", "Do you want to create a new Service Record in this location?", "Yes", "No")) { FullMapView.AddNewCasePointOnMapView.PostionSelected(latitude, longitude); } else { AppContext.AppContext.LocationSelected = false; AppContext.AppContext.MapView?.ClearPin(); } } } else if (AddNewCaseView.EditLocInstance != null) { if (!AppContext.AppContext.LocationSelected) { AppContext.AppContext.LocationSelected = true; if (await SplitView.DisplayAlert("Location Selected", "Do you want to move the Service Record to this location?", "Yes", "No")) { AddNewCaseView.EditLocInstance.PostionSelected(latitude, longitude); } else { AppContext.AppContext.LocationSelected = false; AppContext.AppContext.MapView?.ClearPin(); } } } }
/// Name OnActionTapped /// /// <summary> /// Handles operation for tapping on Action. /// </summary> private async void OnActionTapped() { try { if (AppData.SyncInProgress) { await SplitView.DisplayAlert("Sync In Progress", "Please wait for the sync to finish before taking further actions.", "OK", null); } else if (AppContext.AppContext.NewRecordInProgress) { await SplitView.DisplayAlert("New Record creation is in progress", "Please save or cancel new sevice record to proceed", "OK", null); } else { if (Reachability.InternetConnectionStatus() != ReachabilityNetworkStatus.NotReachable) { SplitView.PopupContent.ShowPopupRelative(new ActionView(SplitView.PopupContent), Lbl_Action, 200, 100, true, ""); } else { await SplitView.DisplayAlert("Offline", "It is not possible to complete this action while in offline mode.\rConnect the device to a network and try again.", "OK", null); } } } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); } }
/// ------------------------------------------------------------------------------------------------ /// ------------------------------------------------------------------------------------------------ #region Public functions /// <summary> /// Check the Sync /// </summary> public async void SyncCheck() { try { if (await SplitView.DisplayAlert("Sync", "All changes saved on the device will be sent to the Uniform Cloud, any " + "Cases with no further inspections pending will be removed and any new for the officer " + "will be retreived.\r\nDo you wish to continue?", "Sync Now", "Cancel")) { if (AppContext.AppContext.LstSriproperty.Any(x => x.Status == SyncStatus.New)) { if (await HasNoLatLong() || await HasNoUPRN()) { return; } else { SyncBegin(); } } else { SyncBegin(); } } } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); } }
/// <summary> /// Raises the Case touch up inside event. /// </summary> /// <param name="cellIndex">Case index.</param> public async void OnCellTouchUpInside(int cellIndex) { try { if (AppData.SyncInProgress) { await SplitView.DisplayAlert("Sync In Progress", "Please wait for the sync to finish before taking further actions.", "OK", null); } else { if (AppContext.AppContext.NewRecordInProgress) { await SplitView.DisplayAlert("New Record creation is in progress", "Please save or cancel new sevice record to proceed", "OK", null); } else { var touchedEntry = MEntries[cellIndex]; bool isTouchingToClose = touchedEntry.IsOpen; var entriesToClose = MEntries.Where(e => e.IsOpen); foreach (var entry in entriesToClose) { InspectionCellView.CurrentUnifiedItem = null; InspectionCellView.DeSelectItem(); CloseCase(entry); // CloseAllEntries(); entry.IsOpen = false; Update(entry.Index, entry.IsOpen); } if (!isTouchingToClose) { await SplitView.Instace().Clear(); OpenCase(touchedEntry); touchedEntry.IsOpen = true; Update(touchedEntry.Index, touchedEntry.IsOpen); if (Device.OS == TargetPlatform.Android) { await SplitView.Instace() .PushRightContent(SplitView.PropertySummary = new PropertySummary()); } else { await SplitView.Instace().PushRightContent(new PropertySummary()); } } } } } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); } }
/// ------------------------------------------------------------------------------------------------ /// Name OnSaveClicked /// /// <summary> Save image and Dismisses the popup on clicking Save button. /// </summary> /// <param name="sender"> </param> /// <param name="e"> event arguments</param> /// ------------------------------------------------------------------------------------------------ private async void OnSaveClicked(object sender, EventArgs e) { try { if (_isExecute) { _isExecute = false; if (Txt_ImageDescription.Text != null && (Txt_ImageName.Text != null)) { Btn_Save.TextColor = Styles.MainAccent; Btn_Save.IsEnabled = true; IsSaveEnabled = true; } if (IsSaveEnabled) { OnSiteDocument doc; FileSystemArgs write; doc = new OnSiteDocument() { Description = Txt_ImageDescription.Text, Extension = ".png", Id = Guid.NewGuid().ToString(), MimeType = "application/png", Name = Txt_ImageName.Text, Status = SyncStatus.Changed, }; write = await FileSystem.WriteAsync(ImageBytes, doc.FileName); if (write.Error == null) { AppData.PropertyModel.AddDocument(doc); //saving doc to file for preserving it when loggedout PropertySummary.RefreshCount(); DocumentAdded?.Invoke(doc); AppContext.AppContext.InspectionCell.RefreshList(); } else { await SplitView.DisplayAlert("Saving Failed", write.Error.Message, "OK", null); } SplitView.CenterPopupContent?.DismisPopup(); } await Task.Run(() => { Task.Delay(2000).Wait(); _isExecute = true; }); } } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); } }
public override async void OnBackPressed() { if (await SplitView.DisplayAlert("Exit", "Do you want to exit Service Request?", "YES", "NO")) { AppData.MainModel.CurrentUser.LoginAction = LoginActions.Existing; var pid = global::Android.OS.Process.MyPid(); global::Android.OS.Process.KillProcess(pid); base.OnBackPressed(); } }
/// #endregion /// ------------------------------------------------------------------------------------------------ /// ------------------------------------------------------------------------------------------------ #region Constructor /// ------------------------------------------------------------------------------------------------ /// public AddVisitPopupView(PopupLayouts parentPopup, bool isFromMap = false) { try { InitializeComponent(); if (isFromMap) { NewSrUi(); } else { if (parentPopup == null) { return; } //Add new image var tapAddImage = new TapGestureRecognizer(); tapAddImage.Tapped += (sender, e) => { parentPopup.DismisPopup(); OnCameraCapture(); }; Gl_Add.GestureRecognizers.Add(tapAddImage); //Add audio var tapAddAudio = new TapGestureRecognizer(); tapAddAudio.Tapped += async(sender, e) => { parentPopup.DismisPopup(); var isMicrophoneAvailable = DependencyService.Get <IRecorder>().IsMicrophoneAvailable(); if (isMicrophoneAvailable) { //if (Device.OS.Equals(TargetPlatform.WinPhone) || Device.OS.Equals(TargetPlatform.Windows)) //{ // await Task.Delay(600); //} SplitView.CenterPopupContent.ShowPopupCenter(new AddNewAudioView(), 0.5); } else { await SplitView.DisplayAlert("No Microphone", "The Microphone is not available for this device. Please check in the device settings to see if the Microphone has been disabled.", "OK", null); } }; Gl_AddAudio.GestureRecognizers.Add(tapAddAudio); } } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); } }
private async void Nrequest(object sender, EventArgs e) { try { if (AppData.SyncInProgress) { await SplitView.DisplayAlert("Sync In Progress", "Please wait for the sync to finish before taking further actions.", "OK", null); } else if (!AppData.ConfigModel.IsNotEmpty) { await SplitView.DisplayAlert("No data", "Please download the data to proceed", "OK", null); } else { UserPosition = await SplitView.Fullmapview.GetCurrentLocation(); if (Reachability.InternetConnectionStatus() == ReachabilityNetworkStatus.NotReachable) { await SplitView.Instace().PushRightContent(NewCaseAddView = new AddNewCaseView()); } else { if (Device.OS == TargetPlatform.Android) { PointOnMapView = new AndroidMapView(); } else { PointOnMapView = new WindowsMapView(); } await SplitView.Instace().PushRightContent(AddNewCasePointOnMapView = new AddNewCasePointOnMapView(PointOnMapView, UserPosition)); } if (Device.OS != TargetPlatform.Android) { var t = Task.Run(async delegate { await Task.Delay(TimeSpan.FromSeconds(1)); AddNewCasePointOnMapView.MoveToPosition?.Invoke(); return(42); }); } } } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); } }
private async void SlowConnectionAlert() { try { var currentPage = SplitView.Instace().GetCurrentView(); if (currentPage.GetType() == typeof(AddNewCasePointOnMapView)) { await SplitView.DisplayAlert("Slow Connection", "If your map is taking a while to load it could be due to a slow internet connection. \nPlease click 'Skip' in the bottom right of the screen to set the location later or wait for the map to appear.", "Ok", null); } } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); } }
public async void PostionSelected(double selectedLatitude, double selectedLongitude) { try { if (AppData.MainModel.Environment == OnSiteEnvironments.Sales) { if (await SplitView.DisplayAlert("Demo Mode", "For security reasons in demo mode the address is not checked. When live you will be able to set to a validated addresses", "Ok", null)) { await CloseView(); AppContext.AppContext.SelectedNewLatitude = selectedLatitude; AppContext.AppContext.SelectedNewLongitude = selectedLongitude; await SplitView.Instace().PushRightContent(FullMapView.NewCaseAddView = new AddNewCaseView(selectedLatitude, selectedLatitude)); if (Device.OS == TargetPlatform.Android) { FullMapView.NewCaseAddView.UpdateLatLong(selectedLatitude, selectedLongitude); } } } else { //API Call await AppData.API.UtilityByCoordinates(selectedLatitude, selectedLongitude); if (AddNewCaseView.UtilityAddressesByCoord == null) { return; } //Close Map Page await CloseView(); AppContext.AppContext.SelectedNewLatitude = selectedLatitude; AppContext.AppContext.SelectedNewLongitude = selectedLongitude; //Open Add Case View await SplitView.Instace().PushRightContent(FullMapView.NewCaseAddView = new AddNewCaseView(selectedLatitude, selectedLongitude)); //if (Device.OS == TargetPlatform.Android) // AppContext.AppContext.LoadMapPin(selectedLatitude, selectedLongitude); } } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); } }
/// #endregion /// ------------------------------------------------------------------------------------------------ /// ------------------------------------------------------------------------------------------------ #region Private Functions, Properties and Methods /// ------------------------------------------------------------------------------------------------ /// /// ------------------------------------------------------------------------------------------------ /// Name FileSystemResponse /// /// <summary> Checks if there is an error in the response and displays an error message. /// </summary> /// <param name="response"> The file system response.</param> /// /// <remarks> /// </remarks> /// ------------------------------------------------------------------------------------------------ /// private bool FileSystemResponse(FileSystemArgs response) { try { if (response.Error != null) { SplitView.DisplayAlert("File Error", response.Error.Message, "OK", null); return(false); } return(true); } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); return(false); } }
/// ------------------------------------------------------------------------------------------------ /// Name ConflictHelp /// /// <summary> Opens an display alert about the Conflict Description. /// </summary> /// <param name="sender"> </param> /// <param name="e"> event arguments</param> /// <remarks> /// </remarks> /// ------------------------------------------------------------------------------------------------ /// private async void ConflictHelp(object sender, EventArgs e) { try { if (Device.OS == TargetPlatform.iOS) { DependencyService.Get <IDisplayAlertPopup>().ConflictHelp(); } else { await SplitView.DisplayAlert("Conflicts", "These items have conflicted with items in the cloud, you could be overwriting changes made by a Uniform user. \nSelect any items you wish to continue to upload and the cloud version will be overwritten. \n\nA record of any conflict will be available in the task log.", "Ok", null); } } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); } }
/// ------------------------------------------------------------------------------------------------ /// Name DeletionHelp /// /// <summary> Opens an display alert about the Deletion Description. /// </summary> /// <param name="sender"> </param> /// <param name="e"> event arguments</param> /// <remarks> /// </remarks> /// ------------------------------------------------------------------------------------------------ /// private async void DeletionHelp(object sender, EventArgs e) { try { if (Device.OS == TargetPlatform.iOS) { DependencyService.Get <IDisplayAlertPopup>().DeletionHelp(); } else { await SplitView.DisplayAlert("Deletion", "Not all items were recognised by the cloud, these items are either deleted from the cloud or referenced under a new ID. \n\nYou can either mark these items for deletion now, or make a note of the changes you have made and delete them at a later date. ", "Ok", null); } } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); } }
private async void GoogleMap_MapClicked(object sender, MapClickedEventArgs e) { try { var location = e.Point; if (FullMapView.AddNewCasePointOnMapView != null && FullMapView.AddNewCasePointOnMapView.NewCaseAddView == null && AppData.PropertyModel.SelectedProperty == null) { if (!AppContext.AppContext.LocationSelected) { AppContext.AppContext.LocationSelected = true; if (await SplitView.DisplayAlert("Location Selected", "Do you want to create a new Service Record in this location?", "Yes", "No")) { FullMapView.AddNewCasePointOnMapView.PostionSelected(location.Latitude, location.Longitude); } else { AppContext.AppContext.LocationSelected = false; AppContext.AppContext.MapView?.ClearPin(); } } } else if (AddNewCaseView.EditLocInstance != null) { if (!AppContext.AppContext.LocationSelected) { AppContext.AppContext.LocationSelected = true; if (await SplitView.DisplayAlert("Location Selected", "Do you want to move the Service Record to this location?", "Yes", "No")) { AddNewCaseView.EditLocInstance.PostionSelected(location.Latitude, location.Longitude); } else { AppContext.AppContext.LocationSelected = false; AppContext.AppContext.MapView?.ClearPin(); } } } } catch (Exception) { // ignored } }
private async Task <bool> Validation() { try { var result = false; if (!string.IsNullOrWhiteSpace(EdAddress.Text) && EdAddress.Text != "Please type address or use set by\nlocation to get a validated address" && EdPropertyDetails.Text != "Please fill the details" && !string.IsNullOrWhiteSpace(EdPropertyDetails.Text)) { result = true; } else { await SplitView.DisplayAlert("Warning", "Please ensure you have added an address and details prior to saving.", "Ok", null); } return(result); } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); return(false); } }
private async void OnDownload(object sender, EventArgs e) { try { if (Reachability.InternetConnectionStatus() != ReachabilityNetworkStatus.NotReachable) { var objSender = (Button)sender; DocumentViewModel documentListViewModel = (DocumentViewModel)objSender.BindingContext; if (documentListViewModel != null) { int selectedItemIndex = _lstDocuments.IndexOf(documentListViewModel); documentListViewModel.DownloadState = DocumentDownloadState.Inprogress; _lstDocuments[selectedItemIndex] = documentListViewModel; if (await AppData.PropertyModel.GetDocument(documentListViewModel.SriDocument)) { documentListViewModel.DownloadState = DocumentDownloadState.Completed; } else { documentListViewModel.DownloadState = DocumentDownloadState.Begin; } if (_lstDocuments.Count != 0) { _lstDocuments[selectedItemIndex] = documentListViewModel; } } } else { await SplitView.DisplayAlert("No network", " Check network before downloading document", "OK", null); } } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); } }
/// ------------------------------------------------------------------------------------------------ /// Name OnSaveClicked /// /// <summary> Save audio and Dismisses the popup on clicking Save button. /// </summary> /// <param name="sender"> </param> /// <param name="e"> event arguments</param> /// ------------------------------------------------------------------------------------------------ private async void OnSaveClicked(object sender, EventArgs e) { try { if (!_isRecording) { if (_isExecute) { _isExecute = false; if (Txt_AudioDescription.Text != null && (Txt_AudioName.Text != null)) { Btn_Save.TextColor = Styles.MainAccent; Btn_Save.IsEnabled = true; IsSaveEnabled = true; } if (IsSaveEnabled) { var audio = await DependencyService.Get <IRecorder>().AudioByte(); if (audio != null) { var doc = new OnSiteDocument() { Description = Txt_AudioDescription.Text, Extension = (Device.OS == TargetPlatform.iOS) ? ".wav" : ".mp3", Id = Guid.NewGuid().ToString(), MimeType = (Device.OS == TargetPlatform.iOS) ? "application/wav" : "application/mp3", Name = Txt_AudioName.Text, Status = SyncStatus.Changed, }; var write = await FileSystem.WriteAsync(audio, doc.FileName); if (write.Error == null) { AppData.PropertyModel.AddDocument(doc); //saving doc to file for preserving it when loggedout PropertySummary.RefreshCount(); AddNewImageView.DocumentAdded?.Invoke(doc); AppContext.AppContext.InspectionCell.RefreshList(); } else { await SplitView.DisplayAlert("Saving Failed", write.Error.Message, "OK", null); } DependencyService.Get <IRecorder>().ClearAudioFiles(); Cancel(); } else { if (Device.OS == TargetPlatform.iOS) { DependencyService.Get <IDisplayAlertPopup>().NoAudioAlert(); } else { await SplitView.DisplayAlert("No Audio Recorded", "Please give the audio input", "OK", null); } } } await Task.Run(() => { Task.Delay(2000).Wait(); _isExecute = true; }); } } else { if (Device.OS == TargetPlatform.iOS) { DependencyService.Get <IDisplayAlertPopup>().AudioIsRecording(); } else { await SplitView.DisplayAlert("Warning", "You can not save the Audio while recording", "OK", null); } } } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); // ignored } }
private async void ChooseAddressClicked(object sender, EventArgs e) { try { var s_Record = AppData.PropertyModel?.SelectedRecord?.Record?.Record; if (UtilityAddressesByCoord?.Addresses == null) { if (await SplitView.DisplayAlert("No Address Found", "Please use edit location try again or manually type an address.", "Ok", null)) { return; } } else { if (SelectedLatitude != 0 && SelectedLongitude != 0) { SplitView.PopupContent.ShowPopupRelative(new AddressesNearbyView(this, UtilityAddressesByCoord), new BoxView(), Width * 0.7, (GetHeight(UtilityAddressesByCoord.Addresses.Count, AddressesNearbyView.Groupedcount * AddressesNearbyView.CellHeight)), true, " "); } else if (UtilityAddressesByCoord != null && UtilityAddressesByCoord.Results > 0) { SplitView.PopupContent.ShowPopupRelative(new AddressesNearbyView(this, UtilityAddressesByCoord), new BoxView(), Width * 0.7, (GetHeight(UtilityAddressesByCoord.Addresses.Count, AddressesNearbyView.Groupedcount * AddressesNearbyView.CellHeight)), true, " "); } else { //API Call for preserved Lat & long if (s_Record != null) { if (s_Record.Latitude == 0 && s_Record.Longitude == 0) { await SplitView.DisplayAlert("Invalid Location", "Please use edit location try again or manually type an address.", "Ok", null); } else { await AppData.API.UtilityByCoordinates(s_Record.Latitude.Value, s_Record.Longitude.Value); } } else if (SelectedLatitude != 0 && SelectedLongitude != 0) { await AppData.API.UtilityByCoordinates(SelectedLatitude, SelectedLongitude); } else { SplitView.PopupContent.ShowPopupRelative(new AddressesNearbyView(this, UtilityAddressesByCoord), new BoxView(), Width * 0.7, (GetHeight(UtilityAddressesByCoord.Addresses.Count, AddressesNearbyView.Groupedcount * AddressesNearbyView.CellHeight)), true, " "); } // if (UtilityAddressesByCoord == null) { return; } if (UtilityAddressesByCoord.Results > 0) { SplitView.PopupContent.ShowPopupRelative(new AddressesNearbyView(this, UtilityAddressesByCoord), new BoxView(), Width * 0.7, (GetHeight(UtilityAddressesByCoord.Addresses.Count, AddressesNearbyView.Groupedcount * AddressesNearbyView.CellHeight)) + 40, true, " "); } } } //string[] button = { "Address", "Location", "Cancel" }; //string option = await SplitView.Instace().DisplayActionSheet("Choose Address By", null, null, button); //if (option == "Address") //{ // if (UtilityAddressesByAdd != null && UtilityAddressesByAdd.Results > 0) // { // SplitView.PopupContent.ShowPopupCenter(new AddressesNearbyView(this, UtilityAddressesByAdd), 0.5, ""); // } // else // { // if (!string.IsNullOrEmpty(EdAddress.Text)) // { // //API Call for preserved address // await AppData.API.UtilityByAddresses(EdAddress.Text); // // // if (UtilityAddressesByAdd == null) return; // if (UtilityAddressesByAdd.Results > 0) // { // SplitView.PopupContent.ShowPopupCenter(new AddressesNearbyView(this, UtilityAddressesByAdd), 0.5, ""); // } // } // else // await SplitView.DisplayAlert("Address not filled", " Please fill the address field to proceed ", "OK", null); // } //} //else if (option == "Location") //{ // if (SelectedLatitude != 0 && SelectedLongitude != 0) // { // SplitView.PopupContent.ShowPopupCenter(new AddressesNearbyView(this, UtilityAddressesByCoord), 0.5, ""); // } // else if (UtilityAddressesByCoord != null && UtilityAddressesByCoord.Results > 0) // { // SplitView.PopupContent.ShowPopupCenter(new AddressesNearbyView(this, UtilityAddressesByCoord), 0.5, ""); // } // else // { // //API Call for preserved Lat & long // if (s_Record != null) // await AppData.API.UtilityByCoordinates(s_Record.Latitude.Value, s_Record.Longitude.Value); // else if (SelectedLatitude != 0 && SelectedLongitude != 0) // await AppData.API.UtilityByCoordinates(SelectedLatitude, SelectedLongitude); // else // SplitView.PopupContent.ShowPopupCenter(new AddressesNearbyView(this, UtilityAddressesByCoord), 0.5, ""); // // // if (UtilityAddressesByCoord == null) return; // if (UtilityAddressesByCoord.Results > 0) // { // SplitView.PopupContent.ShowPopupCenter(new AddressesNearbyView(this, UtilityAddressesByCoord), 0.5, ""); // } // } //} //else // return; } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); } }
/// ------------------------------------------------------------------------------------------------ /// ------------------------------------------------------------------------------------------------ #region Private functions /// Name Inspection_Tapped /// /// <summary> /// Catches the item selected in the listview. /// </summary> /// /// <param name="sender"> The Inspection_RowSeleted instance.</param> /// <param name="e"> The event arguments of the row being selected.</param> /// /// <remarks> /// </remarks> /// ------------------------------------------------------------------------------------------------ /// private async void Inspection_Tapped(object sender, ItemTappedEventArgs e) { try { var item = e.Item as SRiRequestGroupModel; CurrentUnifiedItem = (SRiRequestGroupModel)e.Item; if (item != null) { var pMap = PropertyMappingFromIndex(item.ShortIndex); //get the property mapping from shortindex _refreshCellIndex = item.ShortIndex.Section; int index = 0; foreach (var indexMap in pMap.ActiveExpanded) { if (indexMap.Property == item.ShortIndex.PropertyIndex && indexMap.RequestGroup == item.ShortIndex.RequestGroupIndex && indexMap.Record == item.ShortIndex.RecordIndex) { var iMap = pMap.ActiveExpanded[index]; //check the indexmapping type if (iMap.Type == MappingType.Record) { var record = AppData.PropertyModel.EntityFromMapping(iMap) as SRiRecordMeta; if (record != null && (AppData.PropertyModel.SelectedRecord == null || !AppData.PropertyModel.SelectedRecord.Record.Record.KeyVal.Equals(record.Record?.KeyVal))) { if (AppData.PropertyModel.SelectedRecord != null && AppData.PropertyModel.SelectedRecord.Edited) { if (await SplitView.DisplayAlert("Unsaved changes", "Not all changes have been saved, what would like to do?", "Save", "Discard")) { Exception error; AppData.PropertyModel.SaveRecord(out error); if (error != null) { await SplitView.DisplayAlert("Save failed", error.Message, "OK", null); } AppData.PropertyModel.SelectedRecord = new SelectedRecord(record, iMap, false); await SplitView.Instace().PushRightContent(new RecordSummaryView()); } else { AppData.PropertyModel.SelectedRecord = new SelectedRecord(record, iMap, false); await SplitView.Instace().PushRightContent(new RecordSummaryView()); } } else { AppData.PropertyModel.SelectedRecord = new SelectedRecord(record, iMap, GetSyncStatus(record.Record.Status) == "new_upload.png" ? true : false); await SplitView.Instace().PushRightContent(new RecordSummaryView()); } } } break; } index++; } } if (Device.OS == TargetPlatform.Android) { SplitView.HubMaster.MakeDeleteVisible(CurrentUnifiedItem.UploadStatusImage == "new_upload.png"); } } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); } }
/// ------------------------------------------------------------------------------------------------ /// ------------------------------------------------------------------------------------------------ #region Private Functions /// ------------------------------------------------------------------------------------------------ /// private void TapGestures() { try { //Logout Tapped Tap_LogOut = new TapGestureRecognizer(); Boxvw_LogOut.GestureRecognizers.Add(Tap_LogOut); Lbl_LogOut.GestureRecognizers.Add(Tap_LogOut); Tap_LogOut.Tapped += async(s, args) => { if (AppData.Environment.ToString() != "Sales") { parentPopup.DismisPopup(); if (Reachability.InternetConnectionStatus() != ReachabilityNetworkStatus.NotReachable) { if (await SplitView.DisplayAlert("Log Out", "Do you want to Log Out ?", "YES", "NO")) { //On Logout or ReAuthentication when new request is in progress the new request operation must cancel AppContext.AppContext.NewRecordInProgress = false; LoginPage.LogOut(); Application.Current.MainPage = new LoginPage(); } } else { await SplitView.Instace() .DisplayAlert("No Network Connection", "Please ensure the device has a network connection before logging out entirely, re-authentication or authenticating a new user requires network access.", "OK"); } } else { parentPopup.DismisPopup(); if (await SplitView.DisplayAlert("Log Out", "Do you want to Log Out ?", "YES", "NO")) { //On Logout when new request is on progress the new request operation must cancel AppContext.AppContext.NewRecordInProgress = false; LoginPage.LogOut(); Application.Current.MainPage = new LoginPage(); } } //parentPopup.DismisPopup(); }; //Help Tapped Tap_Help = new TapGestureRecognizer(); Boxvw_Help.GestureRecognizers.Add(Tap_Help); Lbl_Help.GestureRecognizers.Add(Tap_Help); Tap_Help.Tapped += async(s, args) => { if (_isExecute) { _isExecute = false; parentPopup.DismisPopup(); if (!SplitView.Instace().Navigation.ModalStack.Contains(AppContext.AppContext.HelpPageInstance)) { await SplitView.Instace().Navigation.PushModalAsync(AppContext.AppContext.HelpPageInstance = new HelpPage(), true); } _isExecute = true; } }; //About Tapped Tap_About = new TapGestureRecognizer(); Boxvw_About.GestureRecognizers.Add(Tap_About); Lbl_About.GestureRecognizers.Add(Tap_About); Tap_About.Tapped += (s, args) => { parentPopup.DismisPopup(); SplitView.Instace().Navigation.PushModalAsync(new AboutPage(), true); }; Tap_ClrContent = new TapGestureRecognizer(); Boxvw_ClrContent.GestureRecognizers.Add(Tap_ClrContent); Lbl_ClrContent.GestureRecognizers.Add(Tap_ClrContent); Tap_ClrContent.Tapped += async(s, args) => { parentPopup.DismisPopup(); if (AppContext.AppContext.NewRecordInProgress) { SplitView.DisplayAlert("New Record creation is in progress", "Please save or cancel new sevice record to proceed", "OK", null); return; } else { if (await SplitView.DisplayAlert("Clear Content", "Are you sure you want to remove all content from the app?\r\nAll unsaved changes will be lost.", "Yes", "No")) { AppData.PropertyModel.Clear(); SplitView.Instace().FilterCheckAvailable(false); AppData.PropertyModel.Sort = SortMode.Date; AppData.PropertyModel.Filter = FilterMode.All; } } }; } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); } }
/// ------------------------------------------------------------------------------------------------ /// Name OnSave /// /// <summary> Saves the data and Dismisses the popup on clicking Save button. /// </summary> /// <param name="sender"> </param> /// /// <param name="e"> event arguments</param> /// <remarks> /// </remarks> /// ------------------------------------------------------------------------------------------------ /// private void OnSave(object sender, EventArgs e) { try { var pts = ParaViewModel; pts.SelectedParagraphs.RemoveAt(pts.SelectedParagraphs.Count - 1); // Check all paragraphs have a Type and paragraph set foreach (TypedParagraph pc in pts.SelectedParagraphs) { if (pc.Type == "Type" || pc.Paragraph.ParagraphText == "Paragraph") { if (Device.OS == TargetPlatform.iOS) { DependencyService.Get <IDisplayAlertPopup>().ShowAlertParagraph(); } else { SplitView.DisplayAlert("Error", "All items must have both Type and Paragraph set.", "OK", null); } AddNewCell(); return; } } // // Save paragraphs back to action foreach (TypedParagraph pc in pts.SelectedParagraphs) { var pi = new SRiActionParagraph { ParagraphType = pc.Type, Text = pc.Paragraph.ParagraphText }; // Don't add the made up code from "Insert Custom Text" option if (pc.Paragraph.Code != ParagraphViewModel.CustomCode) { pi.ParagraphCodeInserts = pc.Paragraph.Code; } pi.ActionKeyVal = AppData.PropertyModel.SelectedAction.Action.KeyVal; // Insert new paragraph at the end of this TypeCode group var paras = AppData.PropertyModel.SelectedAction.Action.Paragraphs; var i = paras.Count - 1; while ((i >= 0) && (string.CompareOrdinal(paras[i].ParagraphType, pi.ParagraphType) > 0)) { i--; } // Might as well set the sequance here. I'm also tempted to (re)set all sequence values it in VisitActionEditView.cmdSave_Click if ((i >= 0) && (paras[i].ParagraphType == pi.ParagraphType) && (paras[i].Sequence.HasValue)) { pi.Sequence = paras[i].Sequence.Value + 1; } else { pi.Sequence = 0; } paras.Insert(i + 1, pi); } VisitActionDetailsPage.CenterPopup.DismisPopup(); Refresh(); } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); } }