private void OnNFCMessageReceived(ITagInfo tagInfo) { if (Device.RuntimePlatform == Device.Android) { App.HideLoading(); } try { var textId = tagInfo.SerialNumber; if (_oListSource.Any(o => string.Compare(o.Id, textId, StringComparison.OrdinalIgnoreCase) == 0)) { App.ShowToast(AppResources.nfc_exists); } else { AddNewRecord(textId); App.ShowToast(AppResources.nfc_tag_found); } } catch (Exception ex) { App.AddLog(ex.Message); } }
private static void MessageReceived(ITagInfo tagInfo) { string id = tagInfo.SerialNumber; //Messages reader string message = ""; if (!tagInfo.IsEmpty) { foreach (NFCNdefRecord record in tagInfo.Records) { message += record.Message != null?record.Message.ToString() : " "; } } var tag = new NFCTag() { TagId = id, MeetingCode = message }; foreach (var handler in OnMessageReceivedHandler) { handler(tag); } }
async void Current_OnMessageReceived(ITagInfo tagInfo) { try { if (tagInfo == null) { await DisplayAlert("Alert", "No tag found", "Ok"); return; } // Customized serial number var identifier = tagInfo.Identifier; var serialNumber = tagInfo.SerialNumber; if (serialNumber != "") { labelNFCCard.Text = serialNumber; } else { await DisplayAlert("Alert", "NFC Card serial number unable to found.", "Ok"); return; } } catch (Exception ex) { await DisplayAlert("Alert", "Unable to proceed,Please contact Admin" + ex.Message, "Ok"); } }
private void CurrentOnOnMessageReceived(ITagInfo tagInfo) { AppendText("MessageReceived"); AppendText($"SerialNumber = {tagInfo.SerialNumber}"); var id = NFCUtils.ByteArrayToHexString(tagInfo.Identifier); AppendText($"Identifier = {id}"); AppendText($"tagInfo.IsEmpty = {tagInfo.IsEmpty}"); AppendText($"tagInfo.IsWritable = {tagInfo.IsWritable}"); if (tagInfo.Records != null && tagInfo.Records.Any()) { AppendText($"tagInfo.Records.Length = {tagInfo.Records.Length}"); foreach (var record in tagInfo.Records) { if (record.Payload != null && record.Payload.Any()) { var payload = NFCUtils.ByteArrayToHexString(record.Payload); AppendText($"record.Payload = {payload}"); } if (record.Message != null) { AppendText($"record.Message = {record.Message}"); } } } Device.BeginInvokeOnMainThread(CrossNFC.Current.StartListening); Analytics.TrackEvent("NfcTag", new Dictionary <string, string> { { "Identifier", id } }); }
async void Current_OnMessageReceived(ITagInfo tagInfo) { if (tagInfo == null) { await ShowAlert("No tag found"); return; } // Customized serial number var identifier = tagInfo.Identifier; var serialNumber = NFCUtils.ByteArrayToHexString(identifier, ":"); var title = !string.IsNullOrWhiteSpace(serialNumber) ? $"Tag [{serialNumber}]" : "Tag Info"; if (!tagInfo.IsSupported) { await ShowAlert("Unsupported tag (app)", title); } else if (tagInfo.IsEmpty) { await ShowAlert("Empty tag", title); } else { var first = tagInfo.Records[0]; await ShowAlert(GetMessage(first), title); } }
/// <summary> /// Creates a new tag info with basic parameters. /// </summary> /// <param name="newTagName"></param> /// <param name="info"></param> public XmlTagInfo(string newTagName, ITagInfo info) { _tagName = newTagName; _inner = info.InnerWhiteSpaceType; _following = info.FollowingWhiteSpaceType; _flags = info.Flags; _type = info.Type; }
/// <summary> /// Creates a new tag info with basic parameters. /// </summary> /// <param name="newTagName"></param> /// <param name="info"></param> public AscxTagInfo(string newTagName, ITagInfo info) { SetTagName(newTagName); _inner = info.InnerWhiteSpaceType; _following = info.FollowingWhiteSpaceType; _flags = info.Flags; _type = info.Type; }
/// <summary> /// Publish or write a message on a tag /// </summary> /// <param name="tagInfo">see <see cref="ITagInfo"/></param> /// <param name="makeReadOnly">make tag read-only</param> public void PublishMessage(ITagInfo tagInfo, bool makeReadOnly = false) { if (!IsWritingTagSupported) { return; } throw new NotImplementedException(); }
/// <summary> /// Format tag /// </summary> /// <param name="tagInfo">see <see cref="ITagInfo"/></param> public void ClearMessage(ITagInfo tagInfo) { if (!IsWritingTagSupported) { return; } throw new NotImplementedException(); }
protected void Page_Load(object sender, EventArgs e) { tagId = Request.QueryString["id"]; if(!String.IsNullOrEmpty(tagId)) tag = PhotoLibrary.GetTag(tagId); photos = PhotoLibrary.GetPhotosByTag(tagId).ToList(); initContent(); initTitle(); }
/// <summary> /// Executes the command. /// </summary> /// <param name="tagInfo"> /// The tag information. /// </param> public void Execute(ITagInfo tagInfo) { if (tagInfo == null) throw new ArgumentNullException("tagInfo"); using (var tagger = new Tagger(tagInfo)) { tagger.CreateTag(); } }
public override bool CanContainTag(ITagInfo info) { if (info.Type == ElementType.Any | info.Type == ElementType.Inline | info.Type == ElementType.Block) //info.TagName.ToLower().Equals("table") | info.TagName.ToLower().Equals("hr"))) /* JOERG: != 0 */ { return(true); } else { return(false); } }
public void AddTag(string group, string tag, dpTypes type) { ITagInfo newTag = DatapoolSvr.CreateTagInfo(group, tag, type); if (!tags.ContainsValue(newTag)) { tags.Add(key, newTag); tags[key].UpdateValueEvent += NewTag_UpdateValueEvent; key++; } }
private async void Current_OnMessageReceived(ITagInfo tagInfo) { lbl.Text = tagInfo.SerialNumber + "\n"; foreach (var x in tagInfo.Records) { lbl.Text += x.ExternalType; lbl.Text += x.Message; } CrossNFC.Current.StopListening(); CrossNFC.Current.StartPublishing(); CrossNFC.Current.PublishMessage(tagInfo); }
/// <summary> /// Executes the command. /// </summary> /// <param name="tagInfo"> /// The tag information. /// </param> public void Execute(ITagInfo tagInfo) { if (tagInfo == null) { throw new ArgumentNullException("tagInfo"); } using (var tagger = new Tagger(tagInfo)) { tagger.CreateTag(); } }
public bool TryOpenTag(ITagInfo tag, int position) { if (this.Any(token => token.Tag == tag)) { return(false); } var newToken = tag.GetNewToken(position); newToken.SetParent(lastToken); lastToken = newToken; return(true); }
public override bool CanContainTag(ITagInfo info) { if (info.Type == ElementType.Any) { return(true); } if ((info.Type == ElementType.Inline | info.Type == ElementType.Block)) /* JOERG: != 0 */ { return(true); } else { return(false); } }
public override bool CanContainTag(ITagInfo info) { if (info.Type == ElementType.Any | info.Type == ElementType.Inline) { return(true); } if (info.TagName.ToLower().Equals("li")) { return(true); } else { return(false); } }
void CurrentHome_OnMessageReceived(ITagInfo tagInfo) { string checkInmsg = string.Empty; try { if (tagInfo == null) { DisplayAlert("Alert", "No tag found", "Ok"); return; } // Customized serial number var identifier = tagInfo.Identifier; var serialNumber = tagInfo.SerialNumber; if (serialNumber != "") { DALCheckIn dal_ChckeIn = new DALCheckIn(); if (App.Current.Properties.ContainsKey("LoginUser") && App.Current.Properties.ContainsKey("apitoken")) { VehicleCheckIn objNFCCardVehicle = new VehicleCheckIn(); User objloginuser = (User)App.Current.Properties["LoginUser"]; objNFCCardVehicle.UserID = objloginuser.UserID; objNFCCardVehicle.LocationID = objloginuser.LocationParkingLotID.LocationID.LocationID; objNFCCardVehicle.LocationParkingLotID = objloginuser.LocationParkingLotID.LocationParkingLotID; objNFCCardVehicle.NFCCardNumber = serialNumber; checkInmsg = dal_ChckeIn.SaveNFCCardVehicleCheckIn(Convert.ToString(App.Current.Properties["apitoken"]), objNFCCardVehicle); if (checkInmsg != "Success") { DisplayAlert("Alert", checkInmsg, "Ok"); } else { LoadParkedVehicle(null); } } else { DisplayAlert("Alert", "NFC Card serial number unable to found.", "Ok"); return; } } } catch (Exception ex) { DisplayAlert("Alert", "Unable to proceed,Please contact Admin" + ex.Message, "Ok"); dal_Exceptionlog.InsertException(Convert.ToString(App.Current.Properties["apitoken"]), "Operator App", ex.Message, "MasterDetailHomePage.xaml.cs", "", "CurrentHome_OnMessageReceived"); } }
public ITagInfo GetTitleInfo(string url, ITagInfo meta, out string title) { title = null; Url = url; Metadata = meta; Document = new HtmlDocument(); Document.Load(new MemoryStream(WebClient.DownloadData(GetUrl))); object result = Invoke(); var strResult = result as string; if (strResult != null) { title = strResult; var temp = TagsProvider.CreateEmpty(); temp.Title = title; return temp; } var strArrResult = result as string[]; if (strArrResult != null) { switch (strArrResult.Length) { case 0: return null; case 1: title = strArrResult[0]; var temp1 = TagsProvider.CreateEmpty(); temp1.Title = title; return temp1; default: title = strArrResult[1] + strArrResult[0]; var temp2 = TagsProvider.CreateEmpty(); temp2.Title = strArrResult[0]; temp2.Artist = strArrResult[1]; return temp2; } } var tag = result as ITagInfo; if (tag == null) return null; title = tag.Artist + tag.Title; return tag; }
public void ExecuteCorrectlyCreatesTag( CreateTagCommand sut, ITagInfo tagInfo) { tagInfo.Of( i => i.AccessToken == "*******" && i.Owner == "jwChung" && i.Repository == "CIBuild" && i.ReleaseNotes == "test" && i.AuthorName == "Jin-Wook Chung" && i.AuthorEmail == "*****@*****.**" && i.RefOrSha == "refs/heads/master" && i.TagName == Guid.NewGuid().ToString("N")); Assert.DoesNotThrow(() => sut.Execute(tagInfo)); }
private void Current_OnMessageReceived(ITagInfo tagInfo) { Vibrator vibrator = (Vibrator)this.GetSystemService(Context.VibratorService); vibrator.Vibrate(100); var memory = tagInfo.Records.AsMemory(); if (memory.Span.ToArray().Length > 0) { nfcText.Text = memory.Span.ToArray()[0].Message; } else { Toast.MakeText(this, GetString(Resource.String.errorReadNFC), ToastLength.Long).Show(); } }
public bool TryCloseTag(CollectionView <char> collectionView, out ITagInfo tag) { tag = null; foreach (var token in this) { if (!token.Tag.EndCondition(collectionView)) { continue; } lastToken.Abort(token); lastToken = token.Parent; tag = token.Tag; return(true); } return(false); }
private void initContent(string photoId) { if (!String.IsNullOrEmpty(tagId)) tag = PhotoLibrary.GetTag(tagId); CurrentPhoto = PhotoLibrary.GetPhoto(photoId); var nextPhoto = PhotoLibrary.GetNextPhoto(photoId, tagId); if (nextPhoto != null) { NextPhotoLink.PhotoId = nextPhoto.Id; NextPhotoLink.TagId = tagId; NextPhotoLink.HoverIconUrl = "/App_Themes/" + Theme + "/images/go-next.png"; NextPhoto = nextPhoto; FullSizePhoto.Loaded = String.Format(@"preload('{0}')",PhotoFile.GetUrlFor(nextPhoto.Id, PhotoFileSize.Normal)); } else NextPhotoLink.Visible = false; var previousPhoto = PhotoLibrary.GetPreviousPhoto(photoId, tagId); if (previousPhoto != null) { PreviousPhotoLink.TagId = tagId; PreviousPhotoLink.PhotoId = previousPhoto.Id; PreviousPhotoLink.HoverIconUrl = "/App_Themes/" + Theme + "/images/go-previous.png"; } else PreviousPhotoLink.Visible = false; FullSizePhoto.PhotoId = photoId; FullSizePhoto.Metadatas = CurrentPhoto.Metadatas; this.CalendarLink.NavigateUrl = MonthCalendar.GetUrlFor(CurrentPhoto.Date, tagId); tagList.Tags = PhotoLibrary.GetTagsByPhoto(CurrentPhoto.Id); if (CurrentPhoto.Latitude.HasValue && CurrentPhoto.Longitude.HasValue) { this.PhotoMap.Visible = true; this.PhotoMap.Latitude = CurrentPhoto.Latitude.Value; this.PhotoMap.Longitude = CurrentPhoto.Longitude.Value; this.PhotoMap.ThumbnailUrl = PhotoFile.GetUrlFor(photoId, PhotoFileSize.Thumbnail); } else { this.PhotoMap.Visible = false; } }
async void Current_OnMessagePublished(ITagInfo tagInfo) { try { CrossNFC.Current.StopPublishing(); if (tagInfo.IsEmpty) { await ShowAlert("Formatting tag successfully"); } else { await ShowAlert("Writing tag successfully"); } } catch (System.Exception ex) { await ShowAlert(ex.Message); } }
void Current_OnMessageReceived(ITagInfo tagInfo) { string checkInmsg = string.Empty; try { if (tagInfo == null) { return; } // Customized serial number var identifier = tagInfo.Identifier; var serialNumber = tagInfo.SerialNumber; if (serialNumber != "") { } } catch (Exception ex) { } }
async void Current_OnMessageReceived(ITagInfo tagInfo) { if (tagInfo == null) { await ShowAlert("No tag found"); return; } if (tagInfo.IsEmpty) { await ShowAlert("Empty tag"); } else { var first = tagInfo.Records[0]; var type = first.TypeFormat.ToString(); var raw = Encoding.UTF8.GetString(first.Payload); await ShowAlert($"{type} => {first.Message} [{raw}] ({first.MimeType})"); } }
private async void OnMessageReceived(ITagInfo tagInfo) { int tagID = BitConverter.ToInt32(tagInfo.Identifier, 0); //await DisplayAlert("NFC chip found!", tagID.ToString(), "OK"); ItemsViewModel itemsViewModel = new ItemsViewModel(); IDataStore <Account> dataStore = DependencyService.Get <IDataStore <Account> >(); IEnumerable <Account> items = await dataStore.GetItemsAsync(true); Account account = items.FirstOrDefault(o => o.TagID == tagID); if (account != null) // Found { await Navigation.PushModalAsync(new NavigationPage(new UpdateAccountBalancePage(new UpdateAccountBalanceViewModel(account)))); } else // Not found, open register window { await Navigation.PushModalAsync(new NavigationPage(new NewItemPage(tagID))); } }
private static void SendData(ITagInfo tagInfo, bool format) { try { ITagInfo info = tagInfo; List <NFCNdefRecord> records = new List <NFCNdefRecord>(); NFCNdefRecord record = new NFCNdefRecord() { MimeType = "", TypeFormat = NFCNdefTypeFormat.WellKnown, Payload = Encoding.ASCII.GetBytes(currentMessage) }; records.Add(record); info.Records = records.ToArray(); CrossNFC.Current.PublishMessage(info, makeReadOnly: false); } catch (Exception ex) { //Application.Current.MainPage.DisplayAlert("Error", ex.ToString(), "Ok"); } }
async void Current_OnTagDiscovered(ITagInfo tagInfo, bool format) { if (!CrossNFC.Current.IsWritingTagSupported) { await ShowAlert("Writing tag is not supported on this device"); return; } try { var record = new NFCNdefRecord { TypeFormat = NFCNdefTypeFormat.Mime, MimeType = MIME_TYPE, Payload = NFCUtils.EncodeToByteArray("Hi Buddy!") //TypeFormat = NFCNdefTypeFormat.Uri, //Payload = NFCUtils.EncodeToByteArray("http://google.fr") }; tagInfo.Records = new[] { record }; if (format) { CrossNFC.Current.ClearMessage(tagInfo); } else { CrossNFC.Current.PublishMessage(tagInfo); } } catch (System.Exception ex) { await ShowAlert(ex.Message); } }
async void Current_OnMessageReceived(ITagInfo tagInfo) { try { if (tagInfo == null) { await DisplayAlert("Alert", "No tag found", "Ok"); return; } // Customized serial number var identifier = tagInfo.Identifier; var serialNumber = tagInfo.SerialNumber; if (serialNumber != "") { if (objResultCustomerVehiclePass.PassPriceID.PassTypeID.PassTypeCode.ToUpper() == "WP") { slNFC.IsVisible = false; } else { labelNFCCard.Text = serialNumber; } } else { await DisplayAlert("Alert", "NFC Card serial number unable to found.", "Ok"); return; } } catch (Exception ex) { await DisplayAlert("Alert", "Unable to proceed,Please contact Admin" + ex.Message, "Ok"); } }
/// <summary> /// Write or Clear a NDEF message /// </summary> /// <param name="tagInfo"><see cref="ITagInfo"/></param> /// <param name="clearMessage">Clear Message</param> /// <param name="makeReadOnly">Make tag read-only</param> internal void WriteOrClearMessage(ITagInfo tagInfo, bool clearMessage = false, bool makeReadOnly = false) { try { if (_currentTag == null) { throw new Exception(Configuration.Messages.NFCErrorMissingTag); } if (tagInfo == null) { throw new Exception(Configuration.Messages.NFCErrorMissingTagInfo); } var ndef = Ndef.Get(_currentTag); if (ndef != null) { try { if (!ndef.IsWritable) { throw new Exception(Configuration.Messages.NFCErrorReadOnlyTag); } if (ndef.MaxSize < NFCUtils.GetSize(tagInfo.Records)) { throw new Exception(Configuration.Messages.NFCErrorCapacityTag); } ndef.Connect(); OnTagConnected?.Invoke(null, EventArgs.Empty); NdefMessage message = null; if (clearMessage) { message = GetEmptyNdefMessage(); } else { var records = new List <NdefRecord>(); for (var i = 0; i < tagInfo.Records.Length; i++) { var record = tagInfo.Records[i]; if (GetAndroidNdefRecord(record) is NdefRecord ndefRecord) { records.Add(ndefRecord); } } if (records.Any()) { message = new NdefMessage(records.ToArray()); } } if (message != null) { ndef.WriteNdefMessage(message); if (!clearMessage && makeReadOnly) { if (!MakeReadOnly(ndef)) { Console.WriteLine("Cannot lock tag"); } } var nTag = GetTagInfo(_currentTag, ndef.NdefMessage); OnMessagePublished?.Invoke(nTag); } else { throw new Exception(Configuration.Messages.NFCErrorWrite); } } catch (Android.Nfc.TagLostException tlex) { throw new Exception("Tag Lost Error: " + tlex.Message); } catch (Java.IO.IOException ioex) { throw new Exception("Tag IO Error: " + ioex.Message); } catch (Android.Nfc.FormatException fe) { throw new Exception("Tag Format Error: " + fe.Message); } catch (Exception ex) { throw new Exception("Tag Error:" + ex.Message); } finally { if (ndef.IsConnected) { ndef.Close(); } _currentTag = null; OnTagDisconnected?.Invoke(null, EventArgs.Empty); } } else { throw new Exception(Configuration.Messages.NFCErrorNotCompliantTag); } } catch (Exception ex) { StopPublishingAndThrowError(ex.Message); } }
/// <summary> /// Format tag /// </summary> /// <param name="tagInfo">see <see cref="ITagInfo"/></param> public void ClearMessage(ITagInfo tagInfo) => WriteOrClearMessage(tagInfo, true);
void ITag.Add(ITagInfo tagInfo) { _tagInfo.Enqueue(tagInfo); }
public Tagger(ITagInfo tagInformation) { this.tagInformation = tagInformation; }
public void BuildCompled() { _eventAggregator.GetEvent<RadioPlayerNewTagEvent, ITagInfo>().Subscribe(t => _currentTag = t); _eventAggregator = null; }
public bool FileHasTag(IFileInfo file, ITagInfo tag) { return(tag.ContainsFile(file.FullName)); }
internal static TAG_INFO GetInfo(ITagInfo intInfo) { var info = new TAG_INFO() { title = intInfo.Title, artist = intInfo.Artist, album = intInfo.Album, albumartist = intInfo.Albumartist, year = intInfo.Year, comment = intInfo.Comment, genre = intInfo.Genre, track = intInfo.Track, disc = intInfo.Disc, copyright = intInfo.Copyright, encodedby = intInfo.Encodedby, composer = intInfo.Composer, publisher = intInfo.Publisher, lyricist = intInfo.Lyricist, remixer = intInfo.Remixer, producer = intInfo.Producer, bpm = intInfo.Bpm, filename = intInfo.Filename, replaygain_track_gain = intInfo.ReplaygainTrackGain, replaygain_track_peak = intInfo.ReplaygainTrackPeak, conductor = intInfo.Conductor, grouping = intInfo.Grouping, mood = intInfo.Mood, rating = intInfo.Rating, isrc = intInfo.Isrc, duration = intInfo.Duration, bitrate = intInfo.Bitrate }; foreach (var picture in intInfo.Pictures) { info.AddPicture(BassPicture.GeTagPicture(picture)); } return info; }