Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
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();
        }