public async void CameraBtn_Tapped(object sender, EventArgs e) { try { using (var scope = new ActivityIndicatorScope(activityIndicator, activityIndicatorPanel, true)) { IPlatform platform = DependencyService.Get <IPlatform>(); string sourceImagePath = await platform.TakePhotoAsync(App.UIContext); if (sourceImagePath != null) { bool bCreateImage = this.fileName.Contains("{Correlation Id}"); this.fileName = this.fileName.Replace("{Correlation Id}", this.claimViewModel.Claim.Id); string copiedFilePath = await FileHelper.CopyFileAsync(this.claimViewModel.Claim.Id, fileName, sourceImagePath, MobileServiceHelper.msInstance.DataFilesPath); if (bCreateImage || claimViewModel.getKindImagesFileCount(type) == 0) { await claimViewModel.AddNewClaimFileAsync(fileName, copiedFilePath); } //replace only refresh claimViewModel.PropertyChangeImages(); } } } catch (Exception ex) { Utils.TraceException("Image upload failed. ", ex); await DisplayAlert("Image upload failed", "Image upload failed. Please try again later", "Ok"); } }
public async void CameraBtn_Tapped(object sender, EventArgs e) { try { using (var scope = new ActivityIndicatorScope(activityIndicator, activityIndicatorPanel, true)) { int selectIndex = claimViewModel.getIncidentSelectIconIndex(); IPlatform platform = DependencyService.Get <IPlatform>(); string sourceImagePath = await platform.TakePhotoAsync(App.UIContext); if (sourceImagePath != null) { string fileName = "claim-{Correlation Id}-0" + selectIndex.ToString(); fileName = fileName.Replace("{Correlation Id}", this.claimViewModel.Claim.Id); string copiedFilePath = await FileHelper.CopyFileAsync(this.claimViewModel.Claim.Id, fileName, sourceImagePath, MobileServiceHelper.msInstance.DataFilesPath); var fileModel = claimViewModel.getIncidentIconFile(selectIndex); if (fileModel == null) { await claimViewModel.AddNewClaimFileAsync(fileName, copiedFilePath); } //refresh claimViewModel.PropertyChangeImages();; } } } catch (Exception ex) { Utils.TraceException("Image upload failed. ", ex); await DisplayAlert("Image upload failed", "Image upload failed. Please try again later", "Ok"); } }