public override async void OnLoadResource(WebView view, string url) { // If the URL is not our own custom scheme, just let the webView load the URL as usual var scheme = "hybrid:"; //if (!url.StartsWith(scheme)) // return false; if (url.EndsWith("Scanner")) { var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(view.Context, new ZXing.Mobile.MobileBarcodeScanningOptions { PossibleFormats = new List <ZXing.BarcodeFormat> { ZXing.BarcodeFormat.QR_CODE } }); if (result != null) { Console.WriteLine("Scanned Barcode: " + result.Text); scanner.Cancel(); // TODO System.Net.WebClient client = new System.Net.WebClient(); var response = client.UploadString("https://idcoin.howell.no/Bank/Authenticated", result.Text); // - POST request to /Bank/AuthenticateOrWhatever with the keywords in the QR // - Navigate to /Authenticator/Success view.LoadUrl("https://idcoin.howell.no/Authenticator/Success"); } } }
protected async void SetUpScanner(Label labelToSet, ZXing.BarcodeFormat expectedFormat, string topText) { var scanner = new ZXing.Mobile.MobileBarcodeScanner { TopText = topText,//"Scan Asset Id Code", CancelButtonText = "Exit" }; var opts = new ZXing.Mobile.MobileBarcodeScanningOptions { PossibleFormats = new List <ZXing.BarcodeFormat> { expectedFormat } }; try { scanner.AutoFocus(); var result = await scanner.Scan(opts); scanner.CameraUnsupportedMessage = "camera Unsupported"; if (result != null) { labelToSet.Text = result.ToString(); labelToSet.TextColor = Color.Gray; scanner.Cancel(); } else { scanner.Cancel(); } }catch (Exception e) { await DisplayAlert(Constants.ERROR_TITLE, e.Message, Constants.BUTTON_POS); scanner.Cancel(); }finally { scanner.Cancel(); } }
public async Task <string> ScanAsync() { var scanner = new ZXing.Mobile.MobileBarcodeScanner() { UseCustomOverlay = true }; var options = new ZXing.Mobile.MobileBarcodeScanningOptions() { TryHarder = true, AutoRotate = false, UseFrontCameraIfAvailable = false, PossibleFormats = new List <ZXing.BarcodeFormat>() { ZXing.BarcodeFormat.QR_CODE } }; ScannerOverlayView customOverlay = new ScannerOverlayView(); customOverlay.OnCancel += () => { scanner?.Cancel(); }; customOverlay.OnResume += () => { scanner?.ResumeAnalysis(); }; customOverlay.OnPause += () => { scanner?.PauseAnalysis(); }; scanner.CustomOverlay = customOverlay; ZXing.Result scanResults = null; scanResults = await scanner.Scan(options); //customOverlay.Dispose(); if (scanResults != null) { return(scanResults.Text); } return(string.Empty); }
// This allows you to do QR scanning of office locations. Simply embed the name of the office into a QR code and scan it. private async void Scan_Tapped(object sender, TappedRoutedEventArgs e) { var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var overlay = new QRScanOverlay(); overlay.OnCancel += (a, b) => { scanner.Cancel(); }; scanner.CustomOverlay = overlay; scanner.UseCustomOverlay = true; var result = await scanner.Scan(new ZXing.Mobile.MobileBarcodeScanningOptions() { PossibleFormats = new List <ZXing.BarcodeFormat>(new ZXing.BarcodeFormat[] { ZXing.BarcodeFormat.QR_CODE }) }); if (result != null) { System.Diagnostics.Debug.WriteLine($"Scanned {result.Text}"); await Task.Delay(500); if (sender == ScanA) { searchFrom.Text = result.Text ?? ""; } else { searchTo.Text = result.Text ?? ""; } if (!string.IsNullOrWhiteSpace(result.Text)) { if (sender == ScanA) { VM.GeocodeFromLocation(result.Text); } else { VM.GeocodeToLocation(result.Text); } } } }
protected async void openBarCodeScaner(int successType) { var expectedFormat = ZXing.BarcodeFormat.CODE_93; //LOOKING FOR THESE TYPES OF BARCODES (CODE128 == IEMI) var opts = new ZXing.Mobile.MobileBarcodeScanningOptions { PossibleFormats = new List <ZXing.BarcodeFormat> { expectedFormat } }; var scanner = new ZXing.Mobile.MobileBarcodeScanner { TopText = "Scan Asset Id Code", CancelButtonText = "Exit" }; scanner.UseCustomOverlay = false; try { var result = await scanner.Scan(opts); if (result != null) { var username = usernameKey ?? string.Empty; var password = passKey ?? string.Empty; var deviceAddress = uniqueDeviceAddress ?? string.Empty; var toUsername = usernameKey ?? string.Empty; var assetId = result.Text ?? string.Empty; WebServiceResponse response = null; switch (successType) { case 0: //collect and assign EUS device from response response = await ServiceClient.Instance.TransferDeviceToEUS(username, password, assetId); if (response.ResponseCode != 200) { showResponseErrorAlert(response.ResponseString); return; } await DisplayAlert(Constants.TRANSFER_TITLE, Constants.TRANSFER_CONTENT, Constants.BUTTON_POS); break; case 1: //activateDevice must accept before transfering / disposing //For PM and EUS response = await ServiceClient.Instance.ActivateDevice(assetId, /*deviceAddress,*/ username, password, isDisposalAccept); if (response.ResponseCode != 200) { await DisplayAlert(string.Empty, response.ResponseString, Constants.BUTTON_POS); loadingOverlayHome.IsVisible = false; return; } await DisplayAlert(Constants.TRANSFER_TITLE, Constants.TRANSFER_CONTENT, Constants.BUTTON_POS); break; case 2: //Deactivate device //Only for EUS //Completes the disposal transfer to PM response = await ServiceClient.Instance.DeactivateDevice(/*deviceAddress*/ assetId, username, password); if (response.ResponseCode != 200) { showResponseErrorAlert(response.ResponseString); return; } await DisplayAlert(Constants.DISPOSAL_TITLE, Constants.DISPOSAL_SUBMIT_CONTENT, Constants.BUTTON_POS); break; case 3: //Dispose Device for PM only response = await ServiceClient.Instance.DisposeDevice(/*deviceAddress*/ assetId, username, password); if (response.ResponseCode != 200) { showResponseErrorAlert(response.ResponseString); return; } await DisplayAlert(Constants.DISPOSAL_TITLE, Constants.DISPOSAL_CONTENT, Constants.BUTTON_POS); break; default: await DisplayAlert("Tapped", "Error in code" + " row was selected", Constants.BUTTON_POS); break; } loadingOverlayHome.IsVisible = false; scanner.Cancel(); } else { await Navigation.PopAsync(); } } finally { scanner.Cancel(); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Start); lista = LDbConnection.GetActualUserExpo(); var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetDisplayShowTitleEnabled(false); SupportActionBar.SetHomeButtonEnabled(true); SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu); drawerLayout = FindViewById <Android.Support.V4.Widget.DrawerLayout>(Resource.Id.drawer_layout); navigationView = FindViewById <Android.Support.Design.Widget.NavigationView>(Resource.Id.nav_view); navigationView.NavigationItemSelected += HomeNavigationView_NavigationItemSelected; var qrcode = FindViewById <Android.Widget.ImageView>(Resource.Id.Start_qrcode); var writer = new ZXing.QrCode.QRCodeWriter(); String s = ""; if (LDbConnection.getUserType() == "Uczestnik") { s = "Uczestnik:" + LDbConnection.GetUser().Email; } else if (LDbConnection.getUserType() == "Wystawca") { s = "Wystawca:" + LDbConnection.GetCompany().Email; } ZXing.Common.BitMatrix bm = writer.encode(s, ZXing.BarcodeFormat.QR_CODE, 500, 500); Android.Graphics.Bitmap ImageBitmap = Android.Graphics.Bitmap.CreateBitmap(500, 500, Config.Argb8888); for (int i = 0; i < 500; i++) { //width for (int j = 0; j < 500; j++) { //height ImageBitmap.SetPixel(i, j, bm[i, j] ? Color.Black : Color.White); } } if (ImageBitmap != null) { qrcode.SetImageBitmap(ImageBitmap); } var expo_list = FindViewById <Android.Widget.Spinner>(Resource.Id.Start_targi); expo_list.ItemSelected += new System.EventHandler <Android.Widget.AdapterView.ItemSelectedEventArgs>(spinner_ItemSelected); var adapter = new MyExpoSingleListViewAdapter(lista, this); expo_list.Adapter = adapter; var btn1 = (Button)FindViewById(Resource.Id.Start_join); btn1.Visibility = Android.Views.ViewStates.Invisible; btn1.Click += delegate { var NxtAct = new Android.Content.Intent(this, typeof(UserActivity)); StartActivity(NxtAct); }; var button = FindViewById <Android.Widget.Button>(Resource.Id.Start_scan); button.Click += async delegate { ZXing.Mobile.MobileBarcodeScanner scanner; ZXing.Mobile.MobileBarcodeScanner.Initialize(Application); scanner = new ZXing.Mobile.MobileBarcodeScanner(); scanner.UseCustomOverlay = false; //We can customize the top and bottom text of the default overlay scanner.BottomText = "Poczekaj, aż kod kreskowy będzie automatycznie zeskanowany!"; //Start scanning var result = await scanner.Scan(); scanner.Cancel(); if (result == null) { scanner.Cancel(); } else { scanner.Cancel(); string[] scan = result.Text.Split(':'); if (scan[0] == "Wystawca") { var NxtAct = new Android.Content.Intent(this, typeof(CompanyActivity)); NxtAct.PutExtra("Email", scan[1]); NxtAct.PutExtra("expo_id", lista[select].Id); NxtAct.PutExtra("Search", result.Text); NxtAct.PutExtra("Show", true); StartActivity(NxtAct); } else if (scan[0].Contains("Uczestnik")) { System.Console.WriteLine("Uczestnik"); var NxtAct = new Android.Content.Intent(this, typeof(UserActivity)); NxtAct.PutExtra("Email", scan[1]); NxtAct.PutExtra("expo_id", lista[select].Id); NxtAct.PutExtra("Search", result.Text); NxtAct.PutExtra("Show", true); StartActivity(NxtAct); } } }; if (lista == null) { button.Visibility = Android.Views.ViewStates.Invisible; btn1.Visibility = Android.Views.ViewStates.Visible; } }
private async Task ExecuteLeitorQRCommand() { var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(); scanner.Cancel(); if (result != null) { IsBusy = true; string[] resultadoQR = result.Text.Split('|'); if (resultadoQR.Count() < 10) { await dialogService.AlertAsync("Etiqueta QR", "Etiqueta incompatível! Gere uma nova etiqueta QR!", "Ok"); IsBusy = false; return; } /* * A sequencia do QR novo é a seguinte: * lote_codigo|muda_id|qtde|data_estaq|band_dens|ponto_controle_id|estagio_id|colab_id|livre|tipo_etiqueta| * * A sequencia do QR em produção: * lote_codigo|muda_id|qtde|data_estaq|band_dens|ponto_controle_id|estagio_id|colab_id| */ var dadosQR = new { qrLoteCod = resultadoQR[0], qrMudaId = resultadoQR[1], qrQtd = resultadoQR[2], qrDataEstaq = resultadoQR[3], qrDensidade = resultadoQR[4], qrPontoControleId = resultadoQR[5], qrEstagioId = resultadoQR[6], qrColaboradorId = resultadoQR[7], qrLivre = resultadoQR[8], qrTipoEtiqueta = resultadoQR[9] }; if (dadosQR.qrTipoEtiqueta == null || dadosQR.qrTipoEtiqueta != "1") { await dialogService.AlertAsync("Etiqueta QR", "Etiqueta incompatível! Gere uma nova etiqueta QR!", "Ok"); return; } #region Lote var temp = loteRepositorio.ObterInformacoesParaIdentificacao(dadosQR.qrLoteCod); var infoLote = temp.Split('|'); if (infoLote[0] == "0") { await dialogService.AlertAsync("Etiqueta QR", "Lote indicado no QR inexistente! Sincronize o dispositivo.", "Ok"); } var informacoesLote = new { stat = infoLote[0], msg = infoLote[1], infoLoteId = Convert.ToInt32(infoLote[2]), infoLoteCodigo = infoLote[3], infoLoteObjetivo = infoLote[4], infoLoteCliente = infoLote[5], infoLoteProduto = infoLote[6], }; #endregion #region Muda var temp2 = mudaRepository.ObterInformacoesParaIdentificacao(Convert.ToInt32(dadosQR.qrMudaId)); var infoMuda = temp2.Split('|'); List <string> listaMuda = new List <string>(); listaMuda = infoMuda.ToList <string>(); if (infoMuda[0] == "0") { await dialogService.AlertAsync("Etiqueta QR", "Muda indicada no QR inexistente! Sincronize o dispositivo.", "Ok"); } var info_muda_id = infoMuda[2]; var info_muda_nome_interno = infoMuda[3]; var info_muda_nome = infoMuda[4]; var info_muda_especie = infoMuda[5]; var info_muda_origem = infoMuda[8]; var info_muda_viveiro = infoMuda[9]; var info_muda_canaletao = infoMuda[10]; var info_muda_linha = infoMuda[11]; var info_muda_coluna = infoMuda[12]; var info_muda_qtde = infoMuda[13]; #endregion #region Obtem Lista de Datas de Estaqueamento com colaborador e qualidade string lote = string.Empty; string muda = string.Empty; string dataEstqueamento = string.Empty; string quantidade = string.Empty; string qualidade = string.Empty; string colaboradorEstaqueamento = string.Empty; string estaqueamentos = string.Empty; double contadorQuantidade; contadorQuantidade = 0; // Lista Colaboradores Responsaveis Por Estaqueamento de Lote/Muda/Estaq var listaEstaqueamento = await estaqRepository.ListaDadosEstaqueamento(informacoesLote.infoLoteId, Convert.ToInt32(dadosQR.qrMudaId), Convert.ToDateTime(dadosQR.qrDataEstaq)); foreach (var item in listaEstaqueamento) { if (item.qtde != null) { contadorQuantidade = contadorQuantidade + Convert.ToDouble(item.qtde); estaqueamentos += $"<li>{item.colab_estaq} - <b style='color:#ff7b00;'>{item.qtde}</b></li>"; } } #endregion #region Lista Colaboradores Responsaveis Por Estaqueamento de Lote/Muda/Estaq string locais = string.Empty; string listaPontoControle = string.Empty; string listaPontoControleEstaqueamento = string.Empty; string quantidadePontoControleEstaqueamento = string.Empty; List <Ponto_Controle> listaLocalPontoControle = await pontoControleRepository.ListaDadosPontoControle(informacoesLote.infoLoteId, Convert.ToInt32(dadosQR.qrMudaId), Convert.ToDateTime(dadosQR.qrDataEstaq)); foreach (var pontoControle in listaLocalPontoControle) { locais += $"{pontoControle.titulo}"; // Lista Estagios do Ponto de Controle onde existe Lote/Muda/Estaq List <Estagio> listaLocalEstagio = await estagioRepository.ListaLocalEstagio(pontoControle.ponto_controle_id, informacoesLote.infoLoteId, Convert.ToInt32(dadosQR.qrMudaId), Convert.ToDateTime(dadosQR.qrDataEstaq)); foreach (var pontoControleEstaqueamento in listaLocalEstagio) { quantidadePontoControleEstaqueamento = await estagioRepository.LocalQuantidadeMudasNoEstagio(pontoControle.ponto_controle_id, informacoesLote.infoLoteId, Convert.ToInt32(dadosQR.qrMudaId), Convert.ToDateTime(dadosQR.qrDataEstaq)); listaPontoControleEstaqueamento += $"<li>{pontoControleEstaqueamento.titulo}: <b style='color:#ff7b00;'>{quantidadePontoControleEstaqueamento}</b></li>"; } if (!string.IsNullOrEmpty(listaPontoControleEstaqueamento)) { locais += $"<ul style='list-style-image: url((BASE64_IMG_SRC_LISTDOT_ESTAGIO));'>{listaPontoControleEstaqueamento}</ul>"; } locais += "</li>"; } #endregion #region Pagina HTML string codigoHtml = string.Empty; if (informacoesLote.stat == "1") { #region Planta string plantaHtml = $"<b>{info_muda_nome_interno}"; if (!string.IsNullOrEmpty(info_muda_especie)) { plantaHtml += $" - <small><i>{info_muda_especie}</i></small>"; } else if (!string.IsNullOrEmpty(info_muda_especie)) { plantaHtml += $" - <small><i>{info_muda_nome}</i></small>"; } plantaHtml += "</b><br/>"; string origem = $"{infoMuda[8]}"; string viveiro = $"{infoMuda[9]}"; string canaletao = $"{infoMuda[10]}"; string linha = $"{infoMuda[11]}"; string coluna = $"{infoMuda[12]}"; string qtde = $"{infoMuda[13]}"; string local = $"Linha: {linha}, Coluna: {coluna}, Qtde: {qtde}"; if (!string.IsNullOrEmpty(plantaHtml)) { //Origem plantaHtml += "<br/><b>Origem:</b> "; if (!string.IsNullOrEmpty(info_muda_origem)) { plantaHtml += $"<small>{info_muda_origem}</small>"; } else { plantaHtml += $"<small><i style='color:#ff0000;'>Indefinido!</i></small>"; } //Viveiro plantaHtml += "<br/><b>Viveiro:</b> "; if (!string.IsNullOrEmpty(info_muda_viveiro)) { plantaHtml += $"<small>{info_muda_viveiro}</small>"; } else { plantaHtml += "<small><i style='color:#ff0000;'>Indefinido!</i></small>"; } //Caneletao plantaHtml += "<br/><b>Caneletão:</b> "; if (!string.IsNullOrEmpty(info_muda_canaletao)) { plantaHtml += $"<small>{info_muda_canaletao}</small>"; } else { plantaHtml += "<small><i style='color:#ff0000;'>Indefinido!</i></small>"; } //Local plantaHtml += "<br/><b>Local:</b> <small>"; plantaHtml += "Linha: "; if (!string.IsNullOrEmpty(info_muda_coluna)) { plantaHtml += $"<small>{info_muda_coluna}</small>"; } else { plantaHtml += "<small><i style='color:#ff0000;'>Indefinido!</i></small>"; } plantaHtml += ", Coluna: "; if (!string.IsNullOrEmpty(info_muda_coluna)) { plantaHtml += $"<small>{info_muda_coluna}</small>"; } else { plantaHtml += "<small><i style='color:#ff0000;'>Indefinido!</i></small>"; } plantaHtml += ", Qtde: "; if (!string.IsNullOrEmpty(info_muda_qtde)) { plantaHtml += $"{info_muda_qtde}"; } else { plantaHtml += "<small><i style='color:#ff0000;'>Indefinido!</i></small>"; } plantaHtml += "</small>"; } #endregion #region Lote string loteHtml = informacoesLote.infoLoteCodigo; if (!string.IsNullOrEmpty(informacoesLote.infoLoteProduto)) { loteHtml += $" (<small>{informacoesLote.infoLoteProduto}</small>)"; } #endregion #region Quantida de Estaqueamento string quantidadeEstaquamento = Convert.ToString(contadorQuantidade); string estaqs = string.Empty; if (!string.IsNullOrEmpty(estaqueamentos)) { estaqs = $"<div class='font-size-70'><ul style='list-style-image: url((BASE64_IMG_SRC_LISTDOT2));';>{estaqueamentos}</ul></div>"; } #endregion codigoHtml = "<html><head><title>Prodfy APP</title></head>"; codigoHtml += "<style type='text/css'>"; codigoHtml += "body { background-color: transparent; font-family: Helvetica; font-size: 18px; margin:10px 0; padding:0; text-align:center; margin-left: 15px; margin-right: 15px; margin-top: 15px; }"; codigoHtml += ".info-table { width: 100%; } .info-table th { width: 60px; font-size: 18px; text-align: left; vertical-align: top; padding: 10px; color:black; white-space: nowrap; } .info-table td { width: 400px; font-size: 18px; text-align: left; vertical-align: top; padding: 10px; color:#0000ff; }"; codigoHtml += ".font-size-70 { font-size: 70%; }"; codigoHtml += "</style><body><center>"; codigoHtml += "<table class='info-table'>"; codigoHtml += $"<tr><th><b>Planta:</b></th></tr><tr><td><small>{plantaHtml}</small></td></tr>"; codigoHtml += $"<tr><th><br/><b>Lote:</b></th></tr><tr><td>{loteHtml}</td></tr>"; codigoHtml += $"<tr><th><br/><b>Objetivo:</b></th></tr><tr><td><small>{informacoesLote.infoLoteObjetivo}</small></td></tr>"; codigoHtml += $"<tr><th><br/><b>Cliente:</b></th></tr><tr><td><small>{informacoesLote.infoLoteCliente}</small></td></tr>"; codigoHtml += $"<tr><th><br/><b>Estaqueamento:</b></th></tr><tr><td>{Convert.ToDateTime(dadosQR.qrDataEstaq).ToShortDateString()} - <b style='color:#ff7b00;'>{quantidadeEstaquamento}</b> ({CalculaIdade.CalcularPorDataIniciaDataFinal(Convert.ToDateTime(dadosQR.qrDataEstaq), DateTime.Now)} Dias)</td></tr>"; codigoHtml += $"<tr><th><br/><b>Colaboradores:</b></th></tr><tr><td>{estaqs}</td></tr>"; codigoHtml += "</style><body><center>"; #region Localização string localHtml = string.Empty; if (!string.IsNullOrEmpty(locais)) { localHtml += locais; } #endregion string cap = string.Empty; if (string.IsNullOrEmpty(estaqs)) { cap = "<br/>"; } codigoHtml += $"<tr><th>{cap}<b>Localização:</b></th></tr><tr><td>{localHtml}</td></tr>"; codigoHtml += "</table><br/><br/></center></body></html>"; } else { codigoHtml = "<html>" + "<head>" + $"<title>Prodfy APP</title>" + "</head>" + "<style type='text/css'>" + "body " + "{ background-color: transparent;" + "font-family: Helvetica;" + "font-size: 60px;" + "margin:10px 0;" + " padding:0;" + "text-align:center;" + "}" + ".info-table { width: 100%; }" + ".info-table th { width: 60px;" + "font-size: 60px;" + "text-align: right;" + "vertical-align: top;" + "padding: 10px;" + "color:black;" + "white-space: nowrap;" + "}" + ".info-table td { width: 400px;" + "font-size: 60px;" + "text-align: left;" + "vertical-align: top;" + "padding: 10px;" + "color:#0000ff;" + "}" + ".colab_list { font-size: 70%; }" + "</style>" + "<body>" + $"<center><h3 style='color: red;'>{informacoesLote.msg}</h3></center>" + "</body>" + "</html>"; } #endregion IsBusy = false; await navigationService.PushAsync(new PaginaHtmlIdentificacaoView(codigoHtml)); } }
private async Task ExecuteLeitorQRCommand() { var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(); scanner.Cancel(); if (result != null) { IsBusy = true; string loteId = string.Empty; string loteCodigo = string.Empty; string loteProdutoId = string.Empty; string mudaId = string.Empty; string mudaNomeComum = string.Empty; string quantidade = string.Empty; string pontoControleId = string.Empty; string pontoControleCodigo = string.Empty; string pontoControleTitulo = string.Empty; string estagioId = string.Empty; string estagioCodigo = string.Empty; string estagioTitulo = string.Empty; string[] resultadoQR = result.Text.Split('|'); if (resultadoQR.Count() < 8) { await dialogService.AlertAsync("Etiqueta QR", "Etiqueta incompatível! Gere uma nova etiqueta QR!", "Ok"); IsBusy = false; } var dadosQR = new { qrLoteCod = resultadoQR[0], qrMudaId = resultadoQR[1], qrQtd = resultadoQR[2], qrDataEstaq = resultadoQR[3], qrDensidade = resultadoQR[4], qrPontoControleId = resultadoQR[5], qrEstagioId = resultadoQR[6], qrColaboradorId = resultadoQR[7], qrLivre = resultadoQR[8], qrTipoEtiqueta = resultadoQR[9] }; #region Lote if (dadosQR.qrLoteCod != null) { loteCodigo = dadosQR.qrLoteCod; //Lote ID string loteInfo = loteRepositorio.ObterLotePorId(dadosQR.qrLoteCod); var tmpLoteInfo = loteInfo.Split('|'); if (tmpLoteInfo[0] == "0") { await dialogService.AlertAsync("Etiqueta QR", "Lote indicado no QR inexistente! Sincronize o dispositivo.", "Ok"); } loteId = tmpLoteInfo[2]; //Lote Produto ID string loteProdutoInfo = loteRepositorio.ObterLoteProdutoPorId(dadosQR.qrLoteCod); var tmpLoteprodutoInfo = loteProdutoInfo.Split('|'); if (tmpLoteprodutoInfo[0] == "0") { await dialogService.AlertAsync("Etiqueta QR", "Produto associado ao Lote indicado no QR inexistente! Sincronize o dispositivo.", "Ok"); } loteProdutoId = tmpLoteInfo[2]; } #endregion #region Muda if (dadosQR.qrMudaId != null) { mudaId = dadosQR.qrMudaId; //Muda Nome Comum string mudaIndo = mudaRepositorio.ObterInformacoesParaIdentificacao(int.Parse(dadosQR.qrMudaId)); var tmpMudainfo = mudaIndo.Split('|'); if (tmpMudainfo[0] == "0") { await dialogService.AlertAsync("Etiqueta QR", "Muda indicada no QR inexistente! Sincronize o dispositivo.", "Ok"); } mudaNomeComum = tmpMudainfo[3]; } #endregion #region Quantidade if (dadosQR.qrQtd != null) { quantidade = dadosQR.qrQtd; } #endregion #region Ponto Controle if (resultadoQR.Count() >= 8) { if (dadosQR.qrPontoControleId == null) { pontoControleId = string.Empty; pontoControleCodigo = string.Empty; pontoControleTitulo = string.Empty; } else { pontoControleId = dadosQR.qrPontoControleId; //Ponto Controle Info string pontoControleInfo = pontoControleRepositorio.ObterInformacoesParaIdentificacao(int.Parse(dadosQR.qrPontoControleId)); var tmpPontoControleInfo = pontoControleInfo.Split('|'); if (tmpPontoControleInfo[0] == "0") { pontoControleId = string.Empty; pontoControleCodigo = string.Empty; pontoControleTitulo = string.Empty; await dialogService.AlertAsync("Etiqueta QR", "Ponto de Controle indicado não localizado!", "Ok"); } else { pontoControleCodigo = tmpPontoControleInfo[4]; pontoControleTitulo = tmpPontoControleInfo[5]; } } } #endregion #region Estagio if (!string.IsNullOrEmpty(pontoControleCodigo)) { if (dadosQR.qrEstagioId == null) { estagioId = string.Empty; estagioCodigo = string.Empty; estagioTitulo = string.Empty; } else { estagioId = dadosQR.qrEstagioId; //Estagio Info string estagioInfo = estagioRepositorio.ObterInformacoesParaIdentificacao(int.Parse(dadosQR.qrPontoControleId), int.Parse(dadosQR.qrEstagioId)); var tmpestagioInfo = estagioInfo.Split('|'); if (tmpestagioInfo[0] == "0") { estagioId = string.Empty; estagioCodigo = string.Empty; estagioTitulo = string.Empty; await dialogService.AlertAsync("Etiqueta QR", "Estágio indicado não localizado!", "Ok"); } else { estagioCodigo = tmpestagioInfo[5]; estagioTitulo = tmpestagioInfo[6]; } } } #endregion if (!string.IsNullOrEmpty(loteId) && !string.IsNullOrEmpty(loteCodigo) && !string.IsNullOrEmpty(loteProdutoId) && !string.IsNullOrEmpty(mudaId) && !string.IsNullOrEmpty(mudaNomeComum) && !string.IsNullOrEmpty(quantidade)) { var carregarCadastroPerdasQr = new CarregarDadosPerdaQr { OloteId = loteId, OloteCodigo = loteCodigo, OloteProdutoId = loteProdutoId, OmudaId = mudaId, OmudaNomeComum = mudaNomeComum, Oquantidade = quantidade, OpontoControleId = pontoControleId, OestagioId = estagioId }; await navigationService.PushAsync(new CadastroPerdasQrView(carregarCadastroPerdasQr)); } else { await dialogService.AlertAsync("Etiqueta QR", "Etiqueta incompatível! Gere uma nova etiqueta QR!", "Ok"); } if (dadosQR.qrTipoEtiqueta == null || dadosQR.qrTipoEtiqueta != "1") { await dialogService.AlertAsync("ERRO", "Erro ao carregar dados", "Ok"); } } }