/** * The scanner read the QR-code and than searches the equipment. */ public async Task ScanItemAsync() { try { IBarcodeScannerReport scanReport; using (CancellationTokenSource cancellationSource = new CancellationTokenSource()) { using (var dialog = UserDialogs.Instance.Loading("Scanning", () => cancellationSource.Cancel())) { sLogger.Scanning(); var scanner = await GetService <IBarcodeScannerService>().GetDefaultAsync(); scanReport = await scanner.ScanAsync(cancellationSource.Token); dialog.Hide(); sLogger.ScanningCompleted(); } } if (scanReport != null) { UserDialogs.Instance.Toast(scanReport.ScanDataLabel); if (DevicesToInspect.Count != 0) { SelectedItem = DevicesToInspect.FirstOrDefault(x => x.Equipment.EquipmentIdentifications.Any(z => z.Value == scanReport.ScanDataLabel)); if (SelectedItem == null) { SelectedItem = DevicesInspected.FirstOrDefault(x => x.Equipment.EquipmentIdentifications.Any(z => z.Value == scanReport.ScanDataLabel)); if (SelectedItem != null) { var goDetail = await UserDialogs.Instance.ConfirmAsync("U hebt dit toestel al eens gecontroleerd wilt u de details bekijken?", "Detail toestel", "Ja", "Neen", null); if (goDetail) { await NavigateAsync(); } } else { UserDialogs.Instance.Alert("Dit toestel zit niet in deze controle ronde", "verkeerd toestel", "ok"); } } else { await NavigateAsync(); } } } } catch (Exception e) { UserDialogs.Instance.Alert("Het scannen is niet gelukt", "scanner error", "ok"); sLogger.ScanningFailed(e); } }
/** * In this method the user enter a code in and it searches the equipment */ private async Task TypeItemAsync() { try { sLogger.SearchingEquipmentStared(); var code = await UserDialogs.Instance.PromptAsync("", "", "zoeken", null, "Vul code in"); if (code.Ok) { if (DevicesToInspect.Count != 0) { SelectedItem = DevicesToInspect.FirstOrDefault(x => x.Equipment.EquipmentIdentifications.Any(z => z.Value == code.Text.ToUpper())); if (SelectedItem == null) { SelectedItem = DevicesInspected.FirstOrDefault(x => x.Equipment.EquipmentIdentifications.Any(z => z.Value == code.Text.ToUpper())); if (SelectedItem != null) { var goDetail = await UserDialogs.Instance.ConfirmAsync("U hebt dit toestel al eens gecontroleerd wilt u de details bekijken?", "Detail toestel", "Ja", "Neen", null); if (goDetail) { await NavigateAsync(); } } else { UserDialogs.Instance.Alert("Dit toestel zit niet in deze controle ronde", "verkeerd toestel", "ok"); } } else { await NavigateAsync(); } } } } catch (Exception e) { sLogger.FailedToFindEquipment(e); } }
/** * This method handle the message send from the ok page or not ok page */ public async Task HandleAsync(InspectionCompleteMessage message, CancellationToken cancellationToken) { sLogger.FeedbackMessageSended(); UserDialogs.Instance.ShowLoading("opslaan..."); var device = DevicesToInspect.FirstOrDefault(x => x.Equipment.EquipmentId == message.EquipmentId); if (device == null) { device = DevicesInspected.FirstOrDefault(x => x.Equipment.EquipmentId == message.EquipmentId); if (device == null) { await UserDialogs.Instance.AlertAsync("Dit toestel is niet gevonden", "save error", "ok"); return; } device.Equipment.DateVisualInspection = DateTime.Now; if (device.Status == StatusTypes.Ok) { DevicesOk.Remove(device); device.Color = Color.Red; device.Status = StatusTypes.Not_Ok; DevicesNotOk.Add(device); await UpdateToDatabase(device, message.Result, message.Vera, message.Photos, message.Weight, message.FeedbackType.FeedbackTypeId, message.Remarks); } else { DevicesNotOk.Remove(device); device.Status = StatusTypes.Ok; device.Color = Color.Green; DevicesOk.Add(device); await UpdateToDatabase(device, message.Result, message.Vera, message.Photos, message.Weight); } Filter(); } else { if (message.Result == InspectionResult.Ok) { device.Status = StatusTypes.Ok; device.Color = Color.Green; DevicesOk.Add(device); await RefreshOverviewAsync(device); await SaveToDatabase(device, message.Result, message.Vera, message.Photos, message.Weight); } if (message.Result == InspectionResult.NotOk) { device.Color = Color.Red; device.Status = StatusTypes.Not_Ok; DevicesNotOk.Add(device); var equipmentRaportItem = new EquipmentReportItemModel(); equipmentRaportItem.Equipment = device.Equipment.EquipmentLocation.Name; equipmentRaportItem.LocationDescription = device.Equipment.EquipmentLocation.Description; equipmentRaportItem.QRCode = device.Equipment.EquipmentIdentifications[0].Value; equipmentRaportItem.FeedBack = message.FeedbackType.Description; equipmentRaportItem.Remark = message.Remarks; equipmentRaportItem.Vera = message.Vera; ReportItems.Add(equipmentRaportItem); await RefreshOverviewAsync(device); await SaveToDatabase(device, message.Result, message.Vera, message.Photos, message.Weight, message.FeedbackType.FeedbackTypeId, message.Remarks); } } UserDialogs.Instance.HideLoading(); }