本文整理汇总了C#中MediaPortal.TagReader.MusicTag类的典型用法代码示例。如果您正苦于以下问题:C# MusicTag类的具体用法?C# MusicTag怎么用?C# MusicTag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MusicTag类属于MediaPortal.TagReader命名空间,在下文中一共展示了MusicTag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MusicTag
/// <summary>
/// copy constructor
/// </summary>
/// <param name="tag"></param>
public MusicTag(MusicTag tag)
{
if (tag == null) return;
Artist = tag.Artist;
Album = tag.Album;
Genre = tag.Genre;
Title = tag.Title;
Comment = tag.Comment;
Year = tag.Year;
Duration = tag.Duration;
Track = tag.Track;
TimesPlayed = tag.m_TimesPlayed;
Rating = tag.Rating;
BitRate = tag.BitRate;
Composer = tag.Composer;
CoverArtImageBytes = tag.CoverArtImageBytes;
AlbumArtist = tag.AlbumArtist;
Lyrics = tag.Lyrics;
Comment = tag.Comment;
ReplayGainTrack = tag.ReplayGainTrack;
ReplayGainTrackPeak = tag.ReplayGainTrackPeak;
ReplayGainAlbum = tag.ReplayGainAlbum;
ReplayGainAlbumPeak = tag.ReplayGainAlbumPeak;
DateTimePlayed = tag.DateTimePlayed;
DateTimeModified = tag.DateTimeModified;
}
示例2: FolderThumbCreator
// Filename is a full path+file
public FolderThumbCreator(string Filename, MusicTag FileTag)
{
lock (_filename)
{
_filename = Filename;
_filetag = FileTag;
work = new Work(new DoWorkHandler(this.PerformRequest));
work.ThreadPriority = ThreadPriority.Lowest;
GlobalServiceProvider.Get<IThreadPool>().Add(work, QueuePriority.Low);
}
}
示例3: GetTrackTags
private void GetTrackTags()
{
if (CurrentTrackTag != null)
{
PreviousTrackTag = CurrentTrackTag;
}
bool isInternetStream = Util.Utils.IsAVStream(CurrentTrackFileName) && !Util.Utils.IsLastFMStream(CurrentTrackFileName);
if (isInternetStream && _usingBassEngine)
{
NextTrackTag = null;
return;
}
PlayListItem currentItem = PlaylistPlayer.GetCurrentItem();
PlayListItem nextItem = PlaylistPlayer.GetNextItem();
if (currentItem != null)
{
CurrentTrackTag = (MusicTag)currentItem.MusicTag;
}
else
{
CurrentTrackTag = null;
}
if (nextItem != null)
{
NextTrackTag = (MusicTag)nextItem.MusicTag;
}
else
{
NextTrackTag = null;
}
}
示例4: UpdateSimilarTrackWorker
private void UpdateSimilarTrackWorker(string filename, MusicTag tag)
{
if (tag == null) return;
lstSimilarTracks.Clear();
List<LastFMSimilarTrack> tracks;
try
{
Log.Debug("GUIMusicPlayingNow: Calling Last.FM to get similar Tracks");
tracks = LastFMLibrary.GetSimilarTracks(tag.Title, tag.Artist);
}
catch (Exception ex)
{
Log.Error("Error getting similar tracks in now playing");
Log.Error(ex);
return;
}
Log.Debug("GUIMusicPlayingNow: Number of similar tracks returned from Last.FM: {0}", tracks.Count);
var dbTracks = GetSimilarTracksInDatabase(tracks);
for (var i = 0; i < 3; i++)
{
if (dbTracks.Count > 0)
{
var trackNo = Randomizer.Next(0, dbTracks.Count);
var song = dbTracks[trackNo];
var t = song.ToMusicTag();
var item = new GUIListItem
{
AlbumInfoTag = song,
MusicTag = tag,
IsFolder = false,
Label = song.Title,
Path = song.FileName
};
item.AlbumInfoTag = song;
item.MusicTag = t;
GUIMusicBaseWindow.SetTrackLabels(ref item, MusicSort.SortMethod.Album);
dbTracks.RemoveAt(trackNo); // remove song after adding to playlist to prevent the same sone being added twice
if (g_Player.currentFileName != filename) return; // track has changed since request so ignore
lstSimilarTracks.Add(item);
}
}
Log.Debug("GUIMusicPlayingNow: Tracks returned after matching Last.FM results with database tracks: {0}", lstSimilarTracks.Count);
}
示例5: GetStreamTags
/// <summary>
/// Returns the Tags of an AV Stream
/// </summary>
/// <returns></returns>
public MusicTag GetStreamTags()
{
MusicTag tag = new MusicTag();
if (_tagInfo == null)
{
return tag;
}
// So let's filter it out ourself
string title = _tagInfo.title;
int streamUrlIndex = title.IndexOf("';StreamUrl=");
if (streamUrlIndex > -1)
{
title = _tagInfo.title.Substring(0, streamUrlIndex);
}
tag.Album = _tagInfo.album;
tag.Artist = _tagInfo.artist;
tag.Title = title;
tag.Genre = _tagInfo.genre;
try
{
tag.Year = Convert.ToInt32(_tagInfo.year);
}
catch (FormatException)
{
tag.Year = 0;
}
return tag;
}
示例6: GetMultipleValueFieldValue
/// <summary>
/// Returns the field value out of the MusicTag
/// </summary>
/// <param name="tag"></param>
/// <param name="field"></param>
/// <returns></returns>
private string GetMultipleValueFieldValue(MusicTag tag, string field)
{
if (field == "artist")
{
return tag.Artist;
}
else if (field == "albumartist")
{
return tag.AlbumArtist;
}
else if (field == "genre")
{
return tag.Genre;
}
else if (field == "composer")
{
return tag.Composer;
}
return "";
}
示例7: ExtractCoverArt
private void ExtractCoverArt(MusicTag tag)
{
string formattedAlbum = tag.Album.Trim(trimChars);
// Mantis 3078: Filename for Multiple Artists should not contain a semicolon, cause it wouldn't be found later on
int i = 0;
string formattedArtist = "";
string[] strArtistSplit = tag.Artist.Split(new char[] {';', '|'});
foreach (string strArtist in strArtistSplit)
{
string s = strArtist.Trim();
if (_stripArtistPrefixes)
{
Util.Utils.StripArtistNamePrefix(ref s, true);
}
// Concatenate multiple Artists with " _ "
// When we search for multiple artists Covers: "artist a | artist b", the string " | " gets replaced by " _ ",
// so we need to build the file accordingly
if (i > 0)
{
formattedArtist += " _ ";
}
formattedArtist += s.Trim();
i++;
}
string tagAlbumName = string.Format("{0}-{1}", formattedArtist, formattedAlbum);
string smallThumbPath = Util.Utils.GetCoverArtName(Thumbs.MusicAlbum, Util.Utils.MakeFileName(tagAlbumName));
string largeThumbPath = Util.Utils.GetLargeCoverArtName(Thumbs.MusicAlbum, Util.Utils.MakeFileName(tagAlbumName));
// Get the cover image directly out of the mp3 file's ID3 tag
if (_extractEmbededCoverArt)
{
try
{
if (tag.CoverArtImageBytes != null)
{
bool extractFile = false;
if (!Util.Utils.FileExistsInCache(smallThumbPath))
{
extractFile = true;
}
else
{
// Prevent creation of the thumbnail multiple times, when all songs of an album contain coverart <-- that's ugly (rtv)
try
{
DateTime fileDate = File.GetLastWriteTime(smallThumbPath);
TimeSpan span = _currentDate - fileDate;
if (span.Days > 0)
{
extractFile = true;
}
}
catch (Exception)
{
extractFile = true;
}
}
if (extractFile)
{
try
{
string mp3TagImage = tag.CoverArtFile;
if (!String.IsNullOrEmpty(mp3TagImage))
{
if (
!Util.Picture.CreateThumbnail(mp3TagImage, smallThumbPath, (int)Thumbs.ThumbResolution,
(int)Thumbs.ThumbResolution, 0, Thumbs.SpeedThumbsSmall))
{
Log.Info("MusicDatabase: Could not extract thumbnail from {0}", tag.FileName);
}
if (
!Util.Picture.CreateThumbnail(mp3TagImage, largeThumbPath, (int)Thumbs.ThumbLargeResolution,
(int)Thumbs.ThumbLargeResolution, 0, Thumbs.SpeedThumbsLarge))
{
Log.Info("MusicDatabase: Could not extract thumbnail from {0}", tag.FileName);
}
Util.Utils.FileDelete(mp3TagImage); // clean up the temp file directly
}
}
catch (Exception)
{
Log.Warn("MusicDatabase: Invalid cover art image found in {0}-{1}! {2}", tag.Artist, tag.Title,
tag.FileName);
}
}
}
}
catch (Exception) {}
}
// Scan folders only one time per song
if (string.IsNullOrEmpty(_previousNegHitDir) || (Path.GetDirectoryName(tag.FileName) != _previousNegHitDir))
{
string sharefolderThumb;
//.........这里部分代码省略.........
示例8: ShowSong
private void ShowSong(string filename)
{
GUIDialogNotify dlg = (GUIDialogNotify) GUIWindowManager.GetWindow((int) Window.WINDOW_DIALOG_NOTIFY);
if (dlg == null)
{
return;
}
//get albumart
string albumart = g_Player.CurrentFile;
int e = albumart.LastIndexOf(@"\") + 1;
albumart = albumart.Remove(e);
if (_slideList[_currentSlideIndex].Contains(albumart))
{
albumart = string.Empty;
}
else
{
albumart = Util.Utils.GetFolderThumbForDir(albumart);
if (!Util.Utils.FileExistsInCache(albumart))
{
albumart = string.Empty;
}
}
// get Song-info
// hwahrmann 2006-11-22 Using the Tagreader caused a COM exception in Win Media SDK, when reading WMA files
// Accessing the Music Database instead of using the Tagreader.
//MediaPortal.TagReader.MusicTag tag = MediaPortal.TagReader.TagReader.ReadTag(g_Player.CurrentFile);
Song song = new Song();
MusicTag currentSong = new MusicTag();
// If we don't have a tag in the db, we use the filename without the extension as song.title
if (!mDB.GetSongByFileName(g_Player.CurrentFile, ref song))
{
try
{
// try Tagreader method to parse information
var pl = PlayListPlayer.SingletonPlayer.GetPlaylist(PlayListPlayer.SingletonPlayer.CurrentPlaylistType);
var plI = pl.First(plItem => plItem.FileName == filename);
if (plI != null || plI.MusicTag != null)
{
currentSong = (MusicTag)plI.MusicTag;
}
}
catch (Exception)
{
// Catch the COM execption but continue code with Music Database instead.
}
}
// Show Dialog
dlg.Reset();
dlg.Dispose();
dlg.SetImage(albumart);
dlg.SetHeading(4540);
if (currentSong == null || string.IsNullOrEmpty(currentSong.Title) ||
(string.IsNullOrEmpty(currentSong.Artist) && string.IsNullOrEmpty(currentSong.AlbumArtist)))
{
song.Title = Path.GetFileNameWithoutExtension(g_Player.CurrentFile);
dlg.SetText(song.Title + "\n" + song.Artist + "\n" + song.Album);
}
else
{
dlg.SetText(currentSong.Title + "\n" + currentSong.Artist + "\n" + currentSong.Album);
}
dlg.TimeOut = 5;
dlg.DoModal(GUIWindowManager.ActiveWindow);
}
示例9: ToMusicTag
public MusicTag ToMusicTag()
{
MusicTag tmpTag = new MusicTag();
tmpTag.Title = this.Title;
tmpTag.Album = this.Album;
tmpTag.DiscID = this.DiscId;
tmpTag.DiscTotal = this.DiscTotal;
tmpTag.AlbumArtist = this.AlbumArtist;
tmpTag.Artist = this.Artist;
tmpTag.Duration = this.Duration;
tmpTag.Genre = this.Genre;
tmpTag.Composer = this.Composer;
tmpTag.Conductor = this.Conductor;
tmpTag.Track = this.Track;
tmpTag.TrackTotal = this.TrackTotal;
tmpTag.Year = this.Year;
tmpTag.Rating = this.Rating;
tmpTag.TimesPlayed = this.TimesPlayed;
tmpTag.Lyrics = this.Lyrics;
tmpTag.DateTimeModified = this.DateTimeModified;
tmpTag.DateTimePlayed = this.DateTimePlayed;
tmpTag.Comment = this.Comment;
tmpTag.FileType = this.FileType;
tmpTag.Codec = this.Codec;
tmpTag.BitRateMode = this.BitRateMode;
tmpTag.BPM = this.BPM;
tmpTag.BitRate = this.BitRate;
tmpTag.Channels = this.Channels;
tmpTag.SampleRate = this.SampleRate;
tmpTag.HasAlbumArtist = string.IsNullOrEmpty(this.AlbumArtist);
return tmpTag;
}
示例10: GetCoverArt
public static string GetCoverArt(bool isfolder, string filename, MusicTag tag)
{
string strAlbumName = string.Empty;
string strArtistName = string.Empty;
if (tag != null)
{
if (!string.IsNullOrEmpty(tag.Album))
{
strAlbumName = tag.Album;
}
if (!string.IsNullOrEmpty(tag.Artist))
{
strArtistName = tag.Artist;
}
}
// attempt to pick up album thumb if already scanned
string strThumb = Util.Utils.GetAlbumThumbName(strArtistName, strAlbumName);
if (Util.Utils.FileExistsInCache(strThumb))
{
if (_createMissingFolderThumbs && _createMissingFolderThumbCache)
{
string folderThumb = Util.Utils.GetFolderThumb(filename);
if (!Util.Utils.FileExistsInCache(folderThumb))
{
FolderThumbCreator thumbCreator = new FolderThumbCreator(filename, tag);
}
}
return strThumb;
}
// attempt to load folder.jpg
if (!Util.Utils.IsAVStream(filename))
{
string strFolderThumb = string.Empty;
if (isfolder)
{
strFolderThumb = Util.Utils.GetLocalFolderThumbForDir(filename);
}
else
{
strFolderThumb = Util.Utils.GetLocalFolderThumb(filename);
}
if (Util.Utils.FileExistsInCache(strFolderThumb))
{
return strFolderThumb;
}
else
{
if (_createMissingFolderThumbCache)
{
FolderThumbCacher thumbworker = new FolderThumbCacher(filename, false);
}
}
}
//TODO: consider lookup of embedded artwork
return string.Empty;
}
示例11: LoadPlayList
protected void LoadPlayList(string strPlayList, bool startPlayback, bool isAsynch, bool defaultLoad)
{
IPlayListIO loader = PlayListFactory.CreateIO(strPlayList);
if (loader == null)
{
return;
}
PlayList playlist = new PlayList();
if (!Util.Utils.FileExistsInCache(strPlayList))
{
Log.Info("Playlist: Skipping non-existing Playlist file: {0}", strPlayList);
return;
}
if (!loader.Load(playlist, strPlayList))
{
if (isAsynch && defaultLoad) // we might not be in GUI yet! we have asynch and default load because we might want to use asynch loading from gui button too, later!
throw new Exception(string.Format("Unable to load Playlist file: {0}", strPlayList)); // exception is handled in backgroundworker
else
TellUserSomethingWentWrong();
return;
}
if (_autoShuffleOnLoad)
{
playlist.Shuffle();
}
playlistPlayer.CurrentPlaylistName = Path.GetFileNameWithoutExtension(strPlayList);
if (playlist.Count == 1 && startPlayback)
{
Log.Info("GUIMusic:Play: play single playlist item - {0}", playlist[0].FileName);
// Default to type Music, when a playlist has been selected from My Music
g_Player.Play(playlist[0].FileName, g_Player.MediaType.Music);
return;
}
if (null != bw && isAsynch && bw.CancellationPending)
return;
// clear current playlist
//playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC).Clear();
Song song = new Song();
PlayList newPlaylist = new PlayList();
// add each item of the playlist to the playlistplayer
for (int i = 0; i < playlist.Count; ++i)
{
if (null != bw && isAsynch && bw.CancellationPending)
return;
PlayListItem playListItem = playlist[i];
m_database.GetSongByFileName(playListItem.FileName, ref song);
MusicTag tag = new MusicTag();
tag = song.ToMusicTag();
playListItem.MusicTag = tag;
if (Util.Utils.FileExistsInCache(playListItem.FileName) ||
playListItem.Type == PlayListItem.PlayListItemType.AudioStream)
{
newPlaylist.Add(playListItem);
}
else
{
Log.Info("Playlist: File {0} no longer exists. Skipping item.", playListItem.FileName);
}
}
if (null != bw && isAsynch && bw.CancellationPending)
return;
ReplacePlaylist(newPlaylist);
if (startPlayback)
StartPlayingPlaylist();
}
示例12: ShowAlbumInfo
public void ShowAlbumInfo(int parentWindowID, string artistName, string albumName, string strPath, MusicTag tag)
{
Log.Debug("Searching for album: {0} - {1}", albumName, artistName);
var dlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS);
var pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
var errorEncountered = true;
var album = new AlbumInfo();
var albumInfo = new MusicAlbumInfo();
if (m_database.GetAlbumInfo(albumName, artistName, ref album))
{
// we already have album info in database so just use that
albumInfo.Set(album);
errorEncountered = false;
}
else
{// lookup details. start with artist
if (null != pDlgOK && !Win32API.IsConnectedToInternet())
{
pDlgOK.SetHeading(703);
pDlgOK.SetLine(1, 703);
pDlgOK.SetLine(2, string.Empty);
pDlgOK.DoModal(GetID);
return;
}
// show dialog box indicating we're searching the album
if (dlgProgress != null)
{
dlgProgress.Reset();
dlgProgress.SetHeading(326);
dlgProgress.SetLine(1, albumName);
dlgProgress.SetLine(2, artistName);
dlgProgress.SetPercentage(0);
dlgProgress.StartModal(GetID);
dlgProgress.Progress();
dlgProgress.ShowProgressBar(true);
}
var scraper = new AllmusicSiteScraper();
List<AllMusicArtistMatch> artists;
var selectedMatch = new AllMusicArtistMatch();
if (scraper.GetArtists(artistName, out artists))
{
if (null != dlgProgress)
{
dlgProgress.SetPercentage(20);
dlgProgress.Progress();
}
if (artists.Count == 1)
{
// only have single match so no need to ask user
Log.Debug("Single Artist Match Found");
selectedMatch = artists[0];
}
else
{
// need to get user to choose which one to use
Log.Debug("Muliple Artist Match Found ({0}) prompting user", artists.Count);
var pDlg = (GUIDialogSelect2) GUIWindowManager.GetWindow((int) Window.WINDOW_DIALOG_SELECT2);
if (null != pDlg)
{
pDlg.Reset();
pDlg.SetHeading(GUILocalizeStrings.Get(1303));
foreach (var i in artists.Select(artistMatch => new GUIListItem
{
Label = artistMatch.Artist + " - " + artistMatch.Genre,
Label2 = artistMatch.YearsActive,
Path = artistMatch.ArtistUrl,
IconImage = artistMatch.ImageUrl
}))
{
pDlg.Add(i);
}
pDlg.DoModal(GetID);
// and wait till user selects one
var iSelectedMatch = pDlg.SelectedLabel;
if (iSelectedMatch < 0)
{
return;
}
selectedMatch = artists[iSelectedMatch];
}
if (null != dlgProgress)
{
dlgProgress.Reset();
dlgProgress.SetHeading(326);
dlgProgress.SetLine(1, albumName);
dlgProgress.SetLine(2, artistName);
dlgProgress.SetPercentage(40);
dlgProgress.StartModal(GetID);
dlgProgress.ShowProgressBar(true);
dlgProgress.Progress();
}
//.........这里部分代码省略.........
示例13: FindCoverArt
public void FindCoverArt(bool isFolder, string artistName, string albumName, string strPath, MusicTag tag,
int albumId)
{
GUIDialogOK pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
if (null != pDlgOK && !Win32API.IsConnectedToInternet())
{
pDlgOK.SetHeading(703);
pDlgOK.SetLine(1, 703);
pDlgOK.SetLine(2, string.Empty);
pDlgOK.DoModal(GetID);
//throw new Exception("no internet");
return;
}
else if (!Win32API.IsConnectedToInternet())
{
//throw new Exception("no internet");
return;
}
bool bDisplayErr = false;
GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
AlbumInfo albuminfo = new AlbumInfo();
MusicAlbumInfo album = new MusicAlbumInfo();
GUICoverArtGrabberResults guiCoverGrabberResults =
(GUICoverArtGrabberResults)GUIWindowManager.GetWindow((int)Window.WINDOW_MUSIC_COVERART_GRABBER_RESULTS);
if (null != guiCoverGrabberResults)
{
guiCoverGrabberResults.SearchMode = GUICoverArtGrabberResults.SearchDepthMode.Album;
GUIDialogProgress dlgProgress =
(GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS);
if (dlgProgress != null)
{
dlgProgress.Reset();
dlgProgress.SetHeading(185);
dlgProgress.SetLine(1, albumName);
dlgProgress.SetLine(2, artistName);
dlgProgress.SetLine(3, string.Empty);
dlgProgress.StartModal(GetID);
}
guiCoverGrabberResults.GetAlbumCovers(artistName, albumName, strPath, GetID, true);
guiCoverGrabberResults.DoModal(GetID);
albuminfo = guiCoverGrabberResults.SelectedAlbum;
if (GUICoverArtGrabberResults.CancelledByUser)
{
string line1Text = GUILocalizeStrings.Get(4507);
if (line1Text.Length == 0)
{
line1Text = "Cover art grabber aborted by user";
}
string caption = GUILocalizeStrings.Get(4511);
if (caption.Length == 0)
{
caption = "Cover Art Grabber Done";
}
if (null != dlgOk)
{
dlgOk.SetHeading(caption);
dlgOk.SetLine(1, line1Text);
dlgOk.SetLine(2, string.Empty);
dlgOk.DoModal(GetID);
}
}
else if (albuminfo != null)
{
// the GUICoverArtGrabberResults::SelectedAlbum AlbumInfo object contains
// the Artist and Album name returned by the Amazon Webservice which may not
// match our original artist and album. We want to use the original artist
// and album name...
albuminfo.Artist = artistName;
albuminfo.Album = albumName;
SaveCoverArtImage(albuminfo, strPath, true, true);
facadeLayout.RefreshCoverArt();
}
else
{
bDisplayErr = true;
}
}
if (bDisplayErr)
{
if (null != dlgOk)
{
dlgOk.SetHeading(187);
dlgOk.SetLine(1, 187);
//.........这里部分代码省略.........
示例14: BuildAutoDJFilter
private static string BuildAutoDJFilter(string filterMask, MusicTag tag)
{
var filter = filterMask;
try
{
if (!string.IsNullOrEmpty(tag.Genre))
{
filter = filter.Replace("{genre}", "'" + tag.Genre + "'");
}
if (!string.IsNullOrEmpty(tag.Album))
{
filter = filter.Replace("{album}", "'" + tag.Album + "'");
}
if (!string.IsNullOrEmpty(tag.AlbumArtist))
{
filter = filter.Replace("{albumartist}", "'" + tag.AlbumArtist + "'");
}
if (!string.IsNullOrEmpty(tag.Artist))
{
filter = filter.Replace("{albumartist}", "'" + tag.Artist + "'");
}
if (tag.Year > 0)
{
filter = filter.Replace("{year}", tag.Year.ToString(CultureInfo.InvariantCulture));
}
if (tag.Rating > 0)
{
filter = filter.Replace("{rating}", tag.Rating.ToString(CultureInfo.InvariantCulture));
}
if (tag.BPM > 0)
{
filter = filter.Replace("{BPM}", tag.BPM.ToString(CultureInfo.InvariantCulture));
}
}
catch (Exception ex)
{
Log.Debug("Applying filter failed: {0}, exception {1}", filter, ex);
}
return filter;
}
示例15: AddMultipleValueFields
private void AddMultipleValueFields(MusicTag tag)
{
try
{
string strSQL;
string strMultiValueFieldValue = "";
foreach (string field in _multipleValueFields)
{
// split up the multiple value field
strMultiValueFieldValue = GetMultipleValueFieldValue(tag, field).Trim(new char[] {'|', ' '});
string[] splittedFields = strMultiValueFieldValue.Split(new char[] {';', '|'});
foreach (string s in splittedFields)
{
// ATTENTION: We need to use the 'like' operator instead of '=' to have case insensitive searching
strSQL = String.Format("select {0} from {1} where {0} like '{2}'", GetMultipleValueField(field),
GetMultipleValueTable(field), s == "" ? " " : s.Trim());
if (DirectExecute(strSQL).Rows.Count < 1)
{
// Insert the Artist
strSQL = String.Format("insert into {1} ({0}) values ('{2}')", GetMultipleValueField(field),
GetMultipleValueTable(field), s == "" ? " " : s.Trim());
DirectExecute(strSQL);
}
}
}
}
catch (Exception ex)
{
Log.Error("Musicdatabase: Exception adding multiple field value: {0} stack: {1}", ex.Message, ex.StackTrace);
Open();
}
}