public async void Initialize()
        {
            ProcessKeeper keeper = new ProcessKeeper();
            await keeper.GetUsersOpenProcesses("IsActive=false and IsFrozen=false");

            if (keeper.Items.Any())
            {
                //there are planned processes assigned to the user
                Items       = new ObservableCollection <Process>(keeper.Items.OrderBy(i => i.PlannedStart));
                WelcomeText = $"Poniżej znajduje się lista planowanych konserwacji w bieżącym okresie, które zostały przypisane min. do Ciebie. Liczba pozycji: {Items.Count}";
                Display();
            }
        }
Beispiel #2
0
        public async Task SetUpFilter()
        {
            ProcessKeeper pk = new ProcessKeeper();
            await pk.Reload("IsCompleted = false and IsSuccessfull = false");

            foreach (Process p in pk.Items)
            {
                if (!Filter.ActionTypes.Any(i => i.ActionTypeId == p.ActionTypeId))
                {
                    Filter.ActionTypes.Add(new ActionType()
                    {
                        ActionTypeId = p.ActionTypeId, Name = p.ActionTypeName
                    });
                }
                if (!Filter.Places.Any(i => i.PlaceId == p.PlaceId))
                {
                    Filter.Places.Add(new Place()
                    {
                        PlaceId = p.PlaceId, Name = p.PlaceName
                    });
                }
                if (!Filter.Areas.Any(i => i.AreaId == p.AreaId))
                {
                    Filter.Areas.Add(new Area()
                    {
                        AreaId = p.AreaId ?? 0, Name = p.AreaName
                    });
                }
                if (!Filter.Sets.Any(i => i.SetId == p.SetId))
                {
                    Filter.Sets.Add(new Set()
                    {
                        SetId = p.SetId ?? 0, Name = p.SetName
                    });
                }
                if (!Filter.TimeVsPlanStatuses.Any(i => i == p.TimingVsPlan))
                {
                    Filter.TimeVsPlanStatuses.Add(p.TimingVsPlan);
                }
            }
            Filter.SetCaller(this);
            IsFilterSetUp = true;
        }
Beispiel #3
0
 public async Task LoadProcessResults()
 {
     ProcessStats = await ProcessKeeper.GetProcessStats(DateFrom, DateTo);
 }
Beispiel #4
0
        private async void btnScan_Clicked(object sender, EventArgs e)
        {
            btnScan.IsEnabled = false;
            PermissionStatus status = await CrossPermissions.Current.CheckPermissionStatusAsync <CameraPermission>();

            if (status != PermissionStatus.Granted)
            {
                status = await CrossPermissions.Current.RequestPermissionAsync <CameraPermission>();
            }
            if (status != PermissionStatus.Granted)
            {
                await DisplayAlert("Odmowa", "Skanowanie kodu QR wymaga uprawnień do użycia kamery. Użytkownik odmówił tego uprawnienia. Spróbuj jeszcze raz i przyznaj odpowiednie uprawnienie", "OK");
            }
            else
            {
                var options = new ZXing.Mobile.MobileBarcodeScanningOptions
                {
                    PossibleFormats = new List <ZXing.BarcodeFormat>
                    {
                        ZXing.BarcodeFormat.QR_CODE
                    },
                    TryHarder   = false,
                    AutoRotate  = false,
                    TryInverted = false,
                };
                scanPage = new ZXingScannerPage();
                scanPage.AutoFocus();
                scanPage.OnScanResult += (result) =>
                {
                    //DateTime _start = DateTime.Now;
                    scanPage.IsScanning = false;

                    Device.BeginInvokeOnMainThread(async() =>
                    {
                        Navigation.PopAsync();
                        PopupNavigation.Instance.PushAsync(new LoadingScreen(), true);
                        try
                        {
                            //check if this is MES process string
                            string[] mesStr = Regex.Split(result.Text, ";");
                            if (mesStr.Length == 7)
                            {
                                //there are 7 fields split by ; in the string, there's good chance it comes from MES
                                MesString ms = new MesString();
                                try
                                {
                                    ms.MesId          = mesStr[0];
                                    ms.MesDate        = DateTime.Parse(mesStr[1]);
                                    ms.SetName        = mesStr[2];
                                    ms.ActionTypeName = mesStr[3];
                                    ms.Reason         = mesStr[5];
                                }
                                catch (Exception ex)
                                {
                                    await DisplayAlert("Problem z kodem", string.Format("Coś poszło nie tak podczas deserializacji kodu {0}", result.Text) + ". Opis błędu: " + ex.Message, "OK");
                                }
                                try
                                {
                                    //check if such a mesId exists before creating new one
                                    ProcessKeeper pKeeper = new ProcessKeeper();
                                    Process nProcess      = await pKeeper.GetProcess(ms.MesId);

                                    //pass everything to ProcessPage.xaml
                                    if (nProcess == null)
                                    {
                                        await Application.Current.MainPage.Navigation.PushAsync(new ProcessPage(ms));
                                    }
                                    else
                                    {
                                        await Application.Current.MainPage.Navigation.PushAsync(new ProcessPage(ms, nProcess, true));
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Static.Functions.CreateError(ex, "No connection", nameof(scanPage.OnScanResult), this.GetType().Name);
                                }
                            }
                            else if (result.Text.Contains("<Part>"))
                            {
                                //it's a part
                                string res = result.Text.Replace("<Part>", "");

                                Part Part = await new PartKeeper().GetByToken(res);
                                if (Part != null)
                                {
                                    if (Part.IsArchived == true)
                                    {
                                        await Application.Current.MainPage.DisplayAlert("Część zarchiwizowana", "Ta część została zarchiwizowana! Być może ta część występuje teraz pod nowym numerem, w takim przypadku należy wydrukować i okleić ją nowym kodem", "OK");
                                    }
                                    else
                                    {
                                        await Application.Current.MainPage.Navigation.PushAsync(new PartPage(Part));
                                    }
                                }
                                else
                                {
                                    DependencyService.Get <IToaster>().ShortAlert($"Nie znaleziono części oznaczonej kodem {res}..");
                                }
                            }
                            else
                            {
                                //try to find place of such token
                                Place = await Keeper.GetPlace(result.Text);
                                if (Place == null)
                                {
                                    await DisplayAlert("Brak dopasowań", string.Format("Zeskanowany kod: {0} nie odpowiada żadnemu istniejącemu zasobowi. Spróbuj zeskanować kod jeszcze raz.", result.Text), "OK");
                                }
                                else
                                {
                                    try
                                    {
                                        if (Place.IsArchived == true)
                                        {
                                            await Application.Current.MainPage.DisplayAlert("Zasób zarchiwizowany", "Ten zasób został zarchiwizowany! Być może ten zasób występuje teraz pod nowym numerem, w takim przypadku należy wydrukować i okleić go nowym kodem", "OK");
                                        }
                                        else
                                        {
                                            await Navigation.PushAsync(new ScanningResults(Place, true));
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        if (PopupNavigation.Instance.PopupStack.Any())
                                        {
                                            await PopupNavigation.Instance.PopAllAsync(true);
                                        }                                                                                                 // Hide loading screen
                                        await DisplayAlert("Brak połączenia", "Nie można połączyć się z serwerem. Prawdopodobnie utraciłeś połączenie internetowe. Upewnij się, że masz połączenie z internetem i spróbuj jeszcze raz", "OK");
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            await DisplayAlert("Brak połączenia", "Nie można połączyć się z serwerem. Prawdopodobnie utraciłeś połączenie internetowe. Upewnij się, że masz połączenie z internetem i spróbuj jeszcze raz", "OK");
                        }
                        if (PopupNavigation.Instance.PopupStack.Any())
                        {
                            await PopupNavigation.Instance.PopAllAsync(true);
                        }                                                                                                     // Hide loading screen
                    });
                };

                await Navigation.PushAsync(scanPage);
            }

            btnScan.IsEnabled = true;
        }