/// ------------------------------------------------------------------------------------------------ /// Name DocSyncStatus /// /// <summary> Loads sync upload image /// </summary> /// <param> </param> /// <param name="document"></param> /// <remarks> /// </remarks> /// ------------------------------------------------------------------------------------------------ private static string DocSyncStatus(OnSiteDocument document) { try { string image; switch (document.Status) { case SyncStatus.Changed: image = PENDINGIMAGE; break; case SyncStatus.Saved: image = CLOUDIMAGE; break; default: image = string.Empty; break; } return(image); } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); return(null); } }
public static void AddDocument(this OnSiteDocumentMeta meta, OnSiteDocument doc) { bool docExists; // docExists = false; for (int d = 0; d < meta.Documents.Count; d++) { //if (doc.Id != null) //{ if (meta.Documents[d].Id.Equals(doc.Id)) { doc.Status = meta.Documents[d].Status; meta.Documents[d] = doc; docExists = true; break; } } // if (!docExists) { meta.Documents.Add(doc); } //} }
/// ------------------------------------------------------------------------------------------------ /// 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()); } }
private void OnDocumentAdded(OnSiteDocument document) { try { _lstDocuments.Add(new DocumentViewModel { DocumentName = document.FileName, SriDocument = document, DocumentSize = (document.Size.HasValue) ? document.Size.Value.ToByteSizeString() : "", ArrowImage = "chevron.png", BackgroundColor = Color.White, IsBtnVisible = false, IsDownloaded = true, PendingImage = DocumentViewModel.PENDINGIMAGE, //date = DateTime.Now }); } 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 } }