예제 #1
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();
 }
예제 #2
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);
                    var config = new MapperConfiguration(cfg =>
                    {
                        cfg.CreateMap <InspectionRepresentation, InspectionItemModel>();
                        cfg.CreateMap <EquipmentRepresentation, EquipmentModel>();
                        cfg.CreateMap <EquipmentLocationRepresentation, LocationModel>();
                        cfg.CreateMap <EquipmentTypeRepresentation, TypeModel>();
                        cfg.CreateMap <EquipmentIdentificationRepresentation, EquipmentIdentificationModel>();
                    });
                    mapper = config.CreateMapper();

                    var response = await Client.GetAsync <EquipmentRepresentation>(new Uri("fire-safety/equipment/barcode/" + scanReport.ScanDataLabel, UriKind.Relative), CancellationToken.None);

                    ScannedItem = new InspectionItemModel()
                    {
                        Equipment = mapper.Map <EquipmentModel>(response.EnsureContent <EquipmentRepresentation>())
                    };
                    await NavigateAsync();
                }
            }catch (Exception e)
            {
                sLogger.ScanningFailed(e);
            }
        }
예제 #3
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)
                {
                    var config = new MapperConfiguration(cfg =>
                    {
                        cfg.CreateMap <InspectionRepresentation, InspectionItemModel>();
                        cfg.CreateMap <EquipmentRepresentation, EquipmentModel>();
                        cfg.CreateMap <EquipmentLocationRepresentation, LocationModel>();
                        cfg.CreateMap <EquipmentTypeRepresentation, TypeModel>();
                        cfg.CreateMap <EquipmentIdentificationRepresentation, EquipmentIdentificationModel>();
                    });
                    mapper = config.CreateMapper();

                    var response = await Client.GetAsync <EquipmentRepresentation>(new Uri("fire-safety/equipment/barcode/" + code.Text.ToUpper(), UriKind.Relative), CancellationToken.None);

                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                    {
                        ScannedItem = new InspectionItemModel()
                        {
                            Equipment = mapper.Map <EquipmentModel>(response.EnsureContent <EquipmentRepresentation>())
                        };
                        await NavigateAsync();
                    }
                    else if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
                    {
                        UserDialogs.Instance.Alert("Het ingegeven toestel met code \n' " + code.Text.ToUpper() + "'\n is niet terug gevonden.", "Niet gevonden", "ok");
                    }
                    else
                    {
                        UserDialogs.Instance.Alert("Er is een probleem opgetreden tijdens het ophalen van de gegevens.", "error", "ok");
                    }
                }
            }
            catch (Exception e)
            {
                sLogger.FailedToFindEquipment(e);
            }
        }
예제 #4
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);
            }
        }