public ProcessPage(MesString ms, Models.Process Process, bool IsQrConfirmed=false) { //From MES, existing InitializeComponent(); vm = new ProcessPageViewModel(ms, Process, IsQrConfirmed); BindingContext = vm; }
public ProcessPage(MesString ms) { //From MES, new one InitializeComponent(); vm = new ProcessPageViewModel(ms); BindingContext = vm; }
public ProcessPageViewModel(int PlaceId, Process Process, bool isQrConfirmed) { _thisProcess = Process; _thisProcess.PlaceId = PlaceId; IsQrConfirmed = isQrConfirmed; _this = new Handling(); _this.PlaceId = PlaceId; IsProcessOpen = true; if (!_thisProcess.IsActive && !_thisProcess.IsFrozen) { IsNew = true; } if (!string.IsNullOrEmpty(_thisProcess.MesId)) { IsMesRelated = true; MesString = new MesString { SetName = _thisProcess.SetName, ActionTypeName = _thisProcess.ActionTypeName, MesId = _thisProcess.MesId, MesDate = _thisProcess.MesDate, Reason = _thisProcess.Reason }; } if (_thisProcess.IsCompleted == true || _thisProcess.IsSuccessfull == true) { //process is closed and open from history IsProcessOpen = false; _this.Status = "Zakończony"; OnPropertyChanged(nameof(NextState)); OnPropertyChanged(nameof(NextStateColor)); OnPropertyChanged(nameof(IsOpen)); } SetUpMessagingCenter(); //Initialize(_this.ActionTypeId); }
public ProcessPageViewModel(MesString ms) { _thisProcess = new Process(); _thisProcess.Reason = ms.Reason; _thisProcess.MesDate = ms.MesDate; _thisProcess.MesId = ms.MesId; IsQrConfirmed = true; _this = new Handling(); IsNew = true; IsProcessOpen = false; IsMesRelated = true; MesString = ms; SetUpMessagingCenter(); }
public ProcessPageViewModel(MesString ms, Process process, bool isQrConfirmed) { _thisProcess = process; _thisProcess.Reason = ms.Reason; _thisProcess.MesDate = ms.MesDate; IsQrConfirmed = isQrConfirmed; _this = new Handling(); IsNew = false; IsProcessOpen = true; IsMesRelated = true; MesString = ms; if (_thisProcess.IsCompleted == true || _thisProcess.IsSuccessfull == true) { //process is closed and open from history _this.Status = "Zakończony"; OnPropertyChanged(nameof(NextState)); OnPropertyChanged(nameof(NextStateColor)); OnPropertyChanged(nameof(IsOpen)); } SetUpMessagingCenter(); }
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; }