Пример #1
0
        /**
         *  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);
            }
        }
Пример #2
0
 /**
  * This method refresh the display list afther an equipment is checked.
  */
 private async Task RefreshOverviewAsync(InspectionItemModel device)
 {
     sLogger.RefreshingOverview();
     device.Equipment.DateVisualInspection = DateTime.Now;
     DevicesInspected.Add(device);
     DevicesToInspect.Remove(device);
     ControleProgress = Math.Round((double)(DevicesInspected.Count) / (double)(DevicesInspected.Count + DevicesToInspect.Count), 4);
     DisplayedDevices = new ObservableCollection <InspectionItemModel>(DevicesToInspect);
     TotalString      = DisplayedDevices.Count + "/" + (DevicesInspected.Count + DevicesToInspect.Count);
     await CheckEndControlAsync();
 }
Пример #3
0
        /**
         * In this method the equipment feedback is saved to the database.
         */
        private async Task SaveToDatabase(InspectionItemModel device, InspectionResult result, bool vera, ObservableCollection <MediaFile> photos, double?weight, int?FeedbackTypeId = null, string remarks = null)
        {
            try
            {
                sLogger.SavedFeedbackToDatabaseStarted();
                var equipmentFeedback = new InspectionEquipmentFeedbackRepresentationForCreation();
                equipmentFeedback.EquipmentId                  = SelectedItem.Equipment.EquipmentId;
                equipmentFeedback.Weight                       = weight;
                equipmentFeedback.Status                       = result.ToString();
                equipmentFeedback.FeedbackTypeId               = FeedbackTypeId;
                equipmentFeedback.Remark                       = remarks;
                equipmentFeedback.TimeCompleted                = DateTime.Now;
                equipmentFeedback.OperatorId                   = UserService.Operator.UserId;
                equipmentFeedback.EquipmentLocationName        = SelectedItem.Equipment.EquipmentLocation.Name;
                equipmentFeedback.EquipmentLocationDescription = SelectedItem.Equipment.EquipmentLocation.Description;
                equipmentFeedback.Vera = vera;
                var response = await Client.PostEnsureAsync("fire-safety/inspectionequipmentfeedback", equipmentFeedback);

                var href = response.Links.GetLink(WebApi.InspectionEquipmentFeedbacks.HypermediaLinks.Attachment);
                DevicesInspected.Where(x => x.Equipment.EquipmentId == device.Equipment.EquipmentId).SingleOrDefault().Equipment.LastFeedbackID = Int32.Parse(href.Href.Split('/')[4]);;
                sLogger.SavedFeedbackToDatabaseCompleted();
                if (photos != null)
                {
                    sLogger.SaveFeedbackPhotosToDatabaseStarted();
                    var config = new MapperConfiguration(cfg => { cfg.CreateMap <IFileInfo, InspectionEquipmentFeedbackAttachmentRepresentationForCreation>().ForMember(dest => dest.DateCreated, opt => opt.MapFrom(src => src.CreationTime)).ForMember(dest => dest.FileName, opt => opt.MapFrom(src => src.Name)).ForMember(dest => dest.Size, opt => opt.MapFrom(src => src.Length)); });
                    mapper = config.CreateMapper();
                    foreach (MediaFile photo in photos)
                    {
                        IFileInfo metaData           = GetService <IFileSystemService>().GetFileInfo(photo.Path);
                        var       attachment         = mapper.Map <InspectionEquipmentFeedbackAttachmentRepresentationForCreation>(metaData);
                        byte[]    bytes              = File.ReadAllBytes(photo.Path);
                        var       ms                 = photo.GetStream();
                        var       attachmentresponse = await Client.PostMultipartAsync(href.AsUri(), attachment, ms, CancellationToken.None);
                    }
                    sLogger.SaveFeedbackPhotosToDatabaseCompleted();
                }
            }
            catch (Exception e)
            {
                UserDialogs.Instance.Alert("Er is een probleem opgelopen tijdens het opslaan", "Save Error", "ok");
                sLogger.SavedFeedbackToDatabaseFailed(e);
            }
        }
Пример #4
0
        /**
         * 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);
            }
        }
Пример #5
0
        /**
         * If the user press the stop icon this method is called to safe a summery to the database
         */
        public async Task InspectionStopedAsync()
        {
            try
            {
                Stop = DateTime.Now;
                var TotalInspected   = DevicesInspected.Count();
                var TotalApproved    = DevicesOk.Count();
                var TotalDisApproved = DevicesNotOk.Count();
                var remark           = await UserDialogs.Instance.PromptAsync("", "", "stoppen", null, "reden van afsluiten");

                sLogger.ControlRoundHasStopped(remark.Text);
                if (remark.Ok)
                {
                    var inspectionSummary = new InspectionSummaryRepresentationForCreation();
                    inspectionSummary.OperatorId         = UserService.Operator.UserId;
                    inspectionSummary.BackupOperatorId   = UserService.BackupOperator?.UserId;
                    inspectionSummary.OrganisationUnitId = OrganisationUnitId;
                    inspectionSummary.LocationId         = LocationId;
                    inspectionSummary.DateStarted        = Start;
                    inspectionSummary.DateFinished       = Stop;
                    inspectionSummary.Completed          = false;
                    inspectionSummary.TotalToInspect     = DevicesInspected.Count + DevicesToInspect.Count;
                    inspectionSummary.TotalInspected     = DevicesInspected.Count;
                    inspectionSummary.TotalApproved      = DevicesOk.Count;
                    inspectionSummary.TotalDisApproved   = DevicesNotOk.Count;
                    inspectionSummary.Remarks            = remark.Text;
                    var config = new MapperConfiguration(cfg => { cfg.CreateMap <EquipmentReportItemModel, EquipmentReportItemRepresentation>(); });
                    mapper = config.CreateMapper();
                    inspectionSummary.ReportItems = mapper.Map <List <EquipmentReportItemRepresentation> >(ReportItems);
                    inspectionSummary.PLG_Mail    = UserService.Operator.PLG_Mail;
                    var response = await Client.PostEnsureAsync("fire-safety/inspectionsummary", inspectionSummary);

                    DependencyService.Get <IApplicationService>().CloseApplication();
                }
            }catch (Exception e)
            {
                sLogger.SendStopSummeryFailed(e);
            }
        }
Пример #6
0
        /**
         * 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();
        }