Esempio n. 1
0
        private async void HandleNewTag(object sender, NfcFormsTag e)
        {
            if (Navigation.NavigationStack.Count == 3)
            {
                try
                {
                    device.WriteTag(ndefMessage);
                    await DisplayAlert("Success", "NDEF write operation successful", "OK");

                    INavigation navigation  = Application.Current.MainPage.Navigation;
                    Page        currentPage = navigation.NavigationStack.ElementAt(navigation.NavigationStack.Count - 1);

                    while (navigation.NavigationStack.ElementAt(0) != currentPage)
                    {
                        navigation.RemovePage(navigation.NavigationStack.ElementAt(0));
                    }

                    Page scanPromptPage = new ScanPrompt();
                    navigation.InsertPageBefore(scanPromptPage, currentPage);
                    await Task.Delay(100);

                    await navigation.PopAsync();
                }

                catch
                {
                    await DisplayAlert("Error", "NDEF write operation unsuccessful", "OK");
                }
            }
        }
        async void ReadTag(object sender, NfcFormsTag e)
        {
            var encoding = Encoding.UTF8.GetString(e.NdefMessage.ToByteArray());
            var nfcText  = encoding.Substring(7, encoding.Length - 7);

            await LookUpPatient(nfcText);
        }
Esempio n. 3
0
 private void HandleNewTag(object sender, NfcFormsTag e)
 {
     if (Navigation.NavigationStack.Count == 1)
     {
         Navigation.PushAsync(new Pages.NDEFRead(Utilities.NDEFHandler.readNDEFPlainText(e.NdefMessage)));
     }
 }
        private ObservableCollection <string> readMifare(NfcFormsTag message)
        {
            ObservableCollection <string> collection = new ObservableCollection <string>();

            collection.Add("ID: " + ByteArrayToString(message.Id));
            return(collection);
        }
Esempio n. 5
0
        public NfcForms()
        {
            NfcManager NfcManager = (NfcManager)Android.App.Application.Context.GetSystemService(Context.NfcService);

            nfcDevice = NfcManager.DefaultAdapter;
            nfcTag    = new NfcFormsTag();
        }
        public async void ReadTag(object sender, NfcFormsTag e)
        {
            var encoding = Encoding.UTF8.GetString(e.NdefMessage.ToByteArray());
            var sn       = encoding.Substring(7, encoding.Length - 7);

            await LookUpSerialNumber(sn);
        }
Esempio n. 7
0
 private void RaiseNewTag(NfcFormsTag tag)
 {
     if (NewTag != null)
     {
         NewTag(this, tag);
     }
 }
Esempio n. 8
0
        private void HandleNewTag(object sender, NfcFormsTag e)
        {
            var message = e.NdefMessage;

            ExecuteCallBack(new NFCData {
                TagData = message.ToString()
            });
        }
Esempio n. 9
0
 private void RaiseTagDisconnected(NfcFormsTag tag)
 {
     nfcTag.IsConnected = false;
     if (TagDisconnected != null)
     {
         TagDisconnected(this, tag);
     }
 }
Esempio n. 10
0
 private void TagAuslesen(object sender, NfcFormsTag e)
 {
     if (e.IsNdefSupported)
     {
         var result = readNDEFMEssage(e.NdefMessage);
         DisplayAlert("Daten aus dem NFC-Tag", $"{string.Join(";",result)}", "Okay");
     }
 }
Esempio n. 11
0
        public void RaiseTagConnected(NfcFormsTag tag)
        {
            nfcTag.IsConnected = true;

            if (TagConnected != null)
            {
                TagConnected(this, tag);
            }
        }
        private async void LoginWidthCard(NfcFormsTag message)
        {
            String CardCert = ByteArrayToString(message.Id);

            if (!String.IsNullOrEmpty(CardCert))
            {
                if (CrossConnectivity.Current.IsConnected)
                {
                    try
                    {
                        lblCard.Text = "";
                        AddProgressBar();
                        APIServices.ApiServices apiServices = new APIServices.ApiServices();
                        LoginResult             result      = await apiServices.LoginCardAsync(CardCert);

                        if (result != null)
                        {
                            if (result.AuthStatus)
                            {
                                CrossSettings.Current.AddOrUpdateValue <bool>("IsLoggedIn", true);
                                CrossSettings.Current.AddOrUpdateValue <string>("Token", result.Token);

                                var navigation = new NavigationPage(new Dashboard());
                                navigation.BarBackgroundColor = Color.FromHex(App.Black);
                                navigation.BarTextColor       = Color.White;
                                App.Current.MainPage          = navigation;
                                lblCard.Text = "";
                            }
                            else
                            {
                                await DisplayAlert("Login Failed!", result.Message, "Ok");

                                lblCard.Text = CardCert;
                            }
                        }
                    }
                    catch (Exception pException)
                    {
                        await DisplayAlert("Login Failed!", pException.Message, "Ok");

                        System.Diagnostics.Debug.WriteLine("Exception : " + pException.Message);
                    }
                    finally
                    {
                        RemoveProgressBar();
                    }
                }
                else
                {
                    await DisplayAlert("Login", "Internet Connection Not Available.", "Ok");
                }
            }
            else
            {
                await DisplayAlert("Login Failed!", "Username and Password can not be empty", "Ok");
            }
        }
Esempio n. 13
0
        public static async void readTag(object sender, NfcFormsTag e)
        {
            //IsWriteable.IsToggled = e.IsWriteable; error object reference instance
            // IsNDEFSupported.IsToggled = e.IsNdefSupported;

            if (e.IsNdefSupported)
            {
                ndefMessageCollection = readNDEFMEssage(e.NdefMessage);
            }
            test = ndefMessageCollection.ToString();
        }
Esempio n. 14
0
        //nfc found
        private void HandleNewTag(object sender, NfcFormsTag e)
        {
            var record = e.NdefMessage[0];

            // Go through each record, get payload
            var output   = System.Text.Encoding.ASCII.GetString(record.Payload);
            var cardname = output.Substring(3);

            Console.WriteLine("Name: " + cardname);
            UpdateCardImage(cardname);
        }
Esempio n. 15
0
        void device_TagConnected(object sender, NfcFormsTag e)
        {
#if SILVERLIGHT
            System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                IsConnected.IsToggled = true;
            });
#else
            IsConnected.IsToggled = true;
#endif
        }
Esempio n. 16
0
 public NfcForms()
 {
     nfcTag = new NfcFormsTag();
     if (ProximityDevice.GetDefault() != null)
     {
         nfcDevice = ProximityDevice.GetDefault();
         nfcDevice.SubscribeForMessage("NDEF", MessageReceivedHandler);
         nfcTag.IsWriteable        = false;
         nfcTag.MaxSize            = 0;
         nfcDevice.DeviceArrived  += nfcDevice_DeviceArrived;
         nfcDevice.DeviceDeparted += nfcDevice_DeviceDeparted;
     }
 }
Esempio n. 17
0
        void HandleNewTag(object sender, NfcFormsTag e)
        {
#if SILVERLIGHT
            System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                welcomePanel.IsVisible = false;

                IsWriteable.IsToggled     = e.IsWriteable;
                IsNDEFSupported.IsToggled = e.IsNdefSupported;

                if (TechList != null)
                {
                    TechList.ItemsSource = e.TechList;
                }

                if (e.IsNdefSupported)
                {
                    NDEFMessage.ItemsSource = readNDEFMEssage(e.NdefMessage);
                }
            });
#else
            welcomePanel.IsVisible = false;

            IsWriteable.IsToggled     = e.IsWriteable;
            IsNDEFSupported.IsToggled = e.IsNdefSupported;

            if (TechList != null)
            {
                TechList.ItemsSource = e.TechList;
            }

            if (e.IsNdefSupported)
            {
                NDEFMessage.ItemsSource = readNDEFMEssage(e.NdefMessage);
            }
            else
            {
                NDEFMessage.ItemsSource = readMifare(e);
            }
#endif
        }
        //Fire-a event HandleNewTag koji sprema u dvije liste tehnologiju mobitela koji podržavaju NFC i za čitanje poruke sa koda
        private async void HandleNewTag(object sender, NfcFormsTag e)
        {
            if (e.IsNdefSupported)
            {
                readNDEFMEssage(e.NdefMessage);
            }

            StanjePublikacije novoStanjePublikacije = new StanjePublikacije()
            {
                datum            = DateTime.Now,
                datum_do         = DateTime.Now.AddDays(30),
                nazivPublikacije = publikacijeD.naziv,
                nazivStatusa     = "Posudeno",
                kopijaId         = convertedMessage,
                clanoviId        = Clanovi.id,
                vrsta_statusaId  = 2
            };

            HttpClient client  = new HttpClient();
            var        Json    = JsonConvert.SerializeObject(novoStanjePublikacije);
            var        content = new StringContent(Json, Encoding.UTF8, "application/json");
            var        request = await client.PutAsync(WebServisInfo.PutanjaWebServisa + "GumbRezerviraj", content);

            var response = await request.Content.ReadAsStringAsync();

            var publikacije = JsonConvert.DeserializeObject <List <Classes.Publikacije> >(response);

            listaSvihPublikacija         = publikacije;
            ListaPublikacije.ItemsSource = listaSvihPublikacija;

            PosaljiObavijestPosudeno(publikacijeD.Kopija);

            MessagingCenter.Send <App>((App)Application.Current, "RezervacijaPublikacije");

            await PopupNavigation.Instance.PopAsync();
        }
 void device_TagConnected(object sender, NfcFormsTag e)
 {
     Debug.WriteLine(e.Id);
 }
 void HandleNewTag(object sender, NfcFormsTag e)
 {
     LoginWidthCard(e);
 }
 async void CheckBalance(object sender, NfcFormsTag e)
 {
     await Navigation.PushAsync(new CheckBalancePage());
 }
Esempio n. 22
0
        void ReadTag(object sender, NfcFormsTag e)
        {
            var encoding = Encoding.UTF8.GetString(e.NdefMessage.ToByteArray());

            NFCText = encoding.Substring(7, encoding.Length - 7);
        }
Esempio n. 23
0
 private void HandleNewTag(object sender, NfcFormsTag e)
 {
     var message = e.NdefMessage;
 }