Beispiel #1
0
        public async Task Scan()
        {
            try
            {
                QrHandler qr  = new QrHandler();
                string    res = await qr.Scan();

                res = res.Replace("<Part>", "");
                Part p = await PartKeeper.GetByToken(res);

                if (p == null)
                {
                    DependencyService.Get <IToaster>().ShortAlert($"Część o kodzie {res} nie została znaleziona!");
                }
                else
                {
                    PartUsage pu = new PartUsage
                    {
                        PartId       = p.PartId,
                        Name         = p.Name,
                        Symbol       = p.Symbol,
                        ProducerId   = p.ProducerId,
                        ProducerName = p.ProducerName,
                        Description  = p.Description,
                        Image        = p.Image,
                        Amount       = 1
                    };
                    Items.Add(pu);
                }
            }
            catch (Exception ex)
            {
                DependencyService.Get <IToaster>().ShortAlert($"Error: {ex.Message}");
            }
        }
        public async Task Scan()
        {
            try
            {
                QrHandler qr  = new QrHandler();
                string    res = await qr.Scan();

                res = res.Replace("<Part>", "");
                Part Part = await Keeper.GetByToken(res);

                if (Part != null)
                {
                    await Application.Current.MainPage.Navigation.PushAsync(new PartPage(Part));
                }
                else
                {
                    DependencyService.Get <IToaster>().ShortAlert($"Nie znaleziono części oznaczonej kodem {res}..");
                }
            }
            catch (Exception ex)
            {
                await App.Current.MainPage.DisplayAlert(RuntimeSettings.ConnectionErrorTitle, RuntimeSettings.ConnectionErrorText, "OK");
            }
        }
Beispiel #3
0
 public EquipmentQrController(QrHandler handler, StudioContext context)
 {
     _handler = handler;
     _context = context;
 }
        public async Task <string> ValidateQr(bool EndValidation = false)
        {
            bool   qrToStart  = false;
            bool   qrToFinish = false;
            string _Result    = "OK";

            try
            {
                if (ActionTypes.Where(a => a.ActionTypeId == _thisProcess.ActionTypeId).FirstOrDefault().RequireQrToStart != null)
                {
                    qrToStart = (bool)ActionTypes.Where(a => a.ActionTypeId == _thisProcess.ActionTypeId).FirstOrDefault().RequireQrToStart;
                }
                if (ActionTypes.Where(a => a.ActionTypeId == _thisProcess.ActionTypeId).FirstOrDefault().RequireQrToFinish != null)
                {
                    qrToFinish = (bool)ActionTypes.Where(a => a.ActionTypeId == _thisProcess.ActionTypeId).FirstOrDefault().RequireQrToFinish;
                }


                if ((qrToStart && !EndValidation) || (qrToFinish && EndValidation))
                {
                    //qr is required to start, but maybe we're already scanned
                    if (!IsQrConfirmed)
                    {
                        //no, we're not scanned yet
                        //Scan
                        //what QR text should it be?
                        //download asynchronously
                        DependencyService.Get <IToaster>().LongAlert($"Zmiana statusu wymaga zeskanowania kodu QR zasobu..");
                        QrHandler qrHandler = new QrHandler();
                        try
                        {
                            string qrToken = await qrHandler.Scan();

                            if (CurrentPlace == null)
                            {
                                DependencyService.Get <IToaster>().LongAlert($"Próbuje pobrać kod zasobu..");
                                await InitializeCurrentPlace();
                            }
                            if (CurrentPlace == null)
                            {
                                _Result = $"Nie znaleziono zasobu o ID {_thisProcess.PlaceId} dla którego jest to zgłoszenie..";
                            }
                            else
                            {
                                if (qrToken == CurrentPlace.PlaceToken)
                                {
                                    if (CurrentPlace.IsArchived == true)
                                    {
                                        _Result = "Zeskanowany kod odpowiada zarchwizowanemu zasobowi.. Należy okleić zasób nowym kodem..";
                                    }
                                    //scanned code matches
                                    IsQrConfirmed = true;
                                    _Result       = "OK";
                                }
                                else
                                {
                                    _Result = "Zeskanowany kod nie odpowiada kodowi zasobu.. Spróbuj jeszcze raz";
                                }
                            }
                        }catch (Exception ex)
                        {
                            _Result = ex.Message;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(_Result);
        }