private static string GenerateInitialAlbumKey(string albumTitle, string albumArtists) { if (string.IsNullOrWhiteSpace(albumTitle)) { return(string.Empty); } if (!string.IsNullOrWhiteSpace(albumArtists)) { return(string.Join(string.Empty, FormatUtils.DelimitValue(albumTitle), albumArtists.ToLower())); } return(FormatUtils.DelimitValue(albumTitle)); }
public string GetWhereClausePart(Rule rule) { string whereSubClause = string.Empty; // Artist if (rule.Field.Equals("artist", StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals("is")) { whereSubClause = $"Artists LIKE '%{FormatUtils.DelimitValue(rule.Value)}%'"; } else if (rule.Operator.Equals("contains")) { whereSubClause = $"Artists LIKE '%{rule.Value}%'"; } } // AlbumArtist if (rule.Field.Equals("albumartist", StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals("is")) { whereSubClause = $"AlbumArtists LIKE '%{FormatUtils.DelimitValue(rule.Value)}%'"; } else if (rule.Operator.Equals("contains")) { whereSubClause = $"AlbumArtists LIKE '%{rule.Value}%'"; } } // Genre if (rule.Field.Equals("genre", StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals("is")) { whereSubClause = $"Genres LIKE '%{FormatUtils.DelimitValue(rule.Value)}%'"; } else if (rule.Operator.Equals("contains")) { whereSubClause = $"Genres LIKE '%{rule.Value}%'"; } } // Title if (rule.Field.Equals("title", StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals("is")) { whereSubClause = $"TrackTitle = '{rule.Value}'"; } else if (rule.Operator.Equals("contains")) { whereSubClause = $"TrackTitle LIKE '%{rule.Value}%'"; } } // Title if (rule.Field.Equals("albumtitle", StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals("is")) { whereSubClause = $"AlbumTitle = '{rule.Value}'"; } else if (rule.Operator.Equals("contains")) { whereSubClause = $"AlbumTitle LIKE '%{rule.Value}%'"; } } // BitRate if (rule.Field.Equals("bitrate", StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals("is")) { whereSubClause = $"BitRate = {rule.Value}"; } else if (rule.Operator.Equals("greaterthan")) { whereSubClause = $"BitRate > {rule.Value}"; } else if (rule.Operator.Equals("lessthan")) { whereSubClause = $"BitRate < {rule.Value}"; } } // TrackNumber if (rule.Field.Equals("tracknumber", StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals("is")) { whereSubClause = $"TrackNumber = {rule.Value}"; } else if (rule.Operator.Equals("greaterthan")) { whereSubClause = $"TrackNumber > {rule.Value}"; } else if (rule.Operator.Equals("lessthan")) { whereSubClause = $"TrackNumber < {rule.Value}"; } } // TrackCount if (rule.Field.Equals("trackcount", StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals("is")) { whereSubClause = $"TrackCount = {rule.Value}"; } else if (rule.Operator.Equals("greaterthan")) { whereSubClause = $"TrackCount > {rule.Value}"; } else if (rule.Operator.Equals("lessthan")) { whereSubClause = $"TrackCount < {rule.Value}"; } } // DiscNumber if (rule.Field.Equals("discnumber", StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals("is")) { whereSubClause = $"DiscNumber = {rule.Value}"; } else if (rule.Operator.Equals("greaterthan")) { whereSubClause = $"DiscNumber > {rule.Value}"; } else if (rule.Operator.Equals("lessthan")) { whereSubClause = $"DiscNumber < {rule.Value}"; } } // DiscCount if (rule.Field.Equals("disccount", StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals("is")) { whereSubClause = $"DiscCount = {rule.Value}"; } else if (rule.Operator.Equals("greaterthan")) { whereSubClause = $"DiscCount > {rule.Value}"; } else if (rule.Operator.Equals("lessthan")) { whereSubClause = $"DiscCount < {rule.Value}"; } } // Year if (rule.Field.Equals("year", StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals("is")) { whereSubClause = $"Year = {rule.Value}"; } else if (rule.Operator.Equals("greaterthan")) { whereSubClause = $"Year > {rule.Value}"; } else if (rule.Operator.Equals("lessthan")) { whereSubClause = $"Year < {rule.Value}"; } } // Rating if (rule.Field.Equals("rating", StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals("is")) { whereSubClause = $"Rating = {rule.Value}"; } else if (rule.Operator.Equals("greaterthan")) { whereSubClause = $"Rating > {rule.Value}"; } else if (rule.Operator.Equals("lessthan")) { whereSubClause = $"Rating < {rule.Value}"; } } // Love if (rule.Field.Equals("love", StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals("is")) { whereSubClause = $"Love = {rule.Value}"; } else if (rule.Operator.Equals("greaterthan")) { whereSubClause = $"Love > {rule.Value}"; } else if (rule.Operator.Equals("lessthan")) { whereSubClause = $"Love < {rule.Value}"; } } // PlayCount if (rule.Field.Equals("playcount", StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals("is")) { whereSubClause = $"PlayCount = {rule.Value}"; } else if (rule.Operator.Equals("greaterthan")) { whereSubClause = $"PlayCount > {rule.Value}"; } else if (rule.Operator.Equals("lessthan")) { whereSubClause = $"PlayCount < {rule.Value}"; } } // SkipCount if (rule.Field.Equals("skipcount", StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals("is")) { whereSubClause = $"SkipCount = {rule.Value}"; } else if (rule.Operator.Equals("greaterthan")) { whereSubClause = $"SkipCount > {rule.Value}"; } else if (rule.Operator.Equals("lessthan")) { whereSubClause = $"SkipCount < {rule.Value}"; } } return(whereSubClause); }
private string GetWhereClausePart(SmartPlaylistRule rule) { string whereSubClause = string.Empty; // Artist if (rule.Field.Equals(SmartPlaylistDecoder.FieldArtist, StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIs)) { whereSubClause = $"Artists LIKE '%{FormatUtils.DelimitValue(rule.Value)}%'"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIsNot)) { whereSubClause = $"Artists NOT LIKE '%{FormatUtils.DelimitValue(rule.Value)}%'"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorContains)) { whereSubClause = $"Artists LIKE '%{rule.Value}%'"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorDoesNotContain)) { whereSubClause = $"Artists NOT LIKE '%{rule.Value}%'"; } } // AlbumArtist if (rule.Field.Equals(SmartPlaylistDecoder.FieldAlbumArtist, StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIs)) { whereSubClause = $"AlbumArtists LIKE '%{FormatUtils.DelimitValue(rule.Value)}%'"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIsNot)) { whereSubClause = $"AlbumArtists NOT LIKE '%{FormatUtils.DelimitValue(rule.Value)}%'"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorContains)) { whereSubClause = $"AlbumArtists LIKE '%{rule.Value}%'"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorDoesNotContain)) { whereSubClause = $"AlbumArtists NOT LIKE '%{rule.Value}%'"; } } // Genre if (rule.Field.Equals(SmartPlaylistDecoder.FieldGenre, StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIs)) { whereSubClause = $"Genres LIKE '%{FormatUtils.DelimitValue(rule.Value)}%'"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIsNot)) { whereSubClause = $"Genres NOT LIKE '%{FormatUtils.DelimitValue(rule.Value)}%'"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorContains)) { whereSubClause = $"Genres LIKE '%{rule.Value}%'"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorDoesNotContain)) { whereSubClause = $"Genres NOT LIKE '%{rule.Value}%'"; } } // Title if (rule.Field.Equals(SmartPlaylistDecoder.FieldTitle, StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIs)) { whereSubClause = $"TrackTitle = '{rule.Value}'"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIsNot)) { whereSubClause = $"TrackTitle <> '{rule.Value}'"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorContains)) { whereSubClause = $"TrackTitle LIKE '%{rule.Value}%'"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorDoesNotContain)) { whereSubClause = $"TrackTitle NOT LIKE '%{rule.Value}%'"; } } // AlbumTitle if (rule.Field.Equals(SmartPlaylistDecoder.FieldAlbumTitle, StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIs)) { whereSubClause = $"AlbumTitle = '{rule.Value}'"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIsNot)) { whereSubClause = $"AlbumTitle <> '{rule.Value}'"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorContains)) { whereSubClause = $"AlbumTitle LIKE '%{rule.Value}%'"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorDoesNotContain)) { whereSubClause = $"AlbumTitle NOT LIKE '%{rule.Value}%'"; } } // BitRate if (rule.Field.Equals(SmartPlaylistDecoder.FieldBitrate, StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIs)) { whereSubClause = $"BitRate = {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIsNot)) { whereSubClause = $"BitRate <> {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorGreaterThan)) { whereSubClause = $"BitRate > {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorLessThan)) { whereSubClause = $"BitRate < {rule.Value}"; } } // TrackNumber if (rule.Field.Equals(SmartPlaylistDecoder.FieldTrackNumber, StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIs)) { whereSubClause = $"TrackNumber = {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIsNot)) { whereSubClause = $"TrackNumber <> {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorGreaterThan)) { whereSubClause = $"TrackNumber > {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorLessThan)) { whereSubClause = $"TrackNumber < {rule.Value}"; } } // TrackCount if (rule.Field.Equals(SmartPlaylistDecoder.FieldTrackCount, StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIs)) { whereSubClause = $"TrackCount = {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIsNot)) { whereSubClause = $"TrackCount <> {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorGreaterThan)) { whereSubClause = $"TrackCount > {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorLessThan)) { whereSubClause = $"TrackCount < {rule.Value}"; } } // DiscNumber if (rule.Field.Equals(SmartPlaylistDecoder.FieldDiscNumber, StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIs)) { whereSubClause = $"DiscNumber = {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIsNot)) { whereSubClause = $"DiscNumber <> {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorGreaterThan)) { whereSubClause = $"DiscNumber > {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorLessThan)) { whereSubClause = $"DiscNumber < {rule.Value}"; } } // DiscCount if (rule.Field.Equals(SmartPlaylistDecoder.FieldDiscCount, StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIs)) { whereSubClause = $"DiscCount = {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIsNot)) { whereSubClause = $"DiscCount <> {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorGreaterThan)) { whereSubClause = $"DiscCount > {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorLessThan)) { whereSubClause = $"DiscCount < {rule.Value}"; } } // Year if (rule.Field.Equals(SmartPlaylistDecoder.FieldYear, StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIs)) { whereSubClause = $"Year = {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIsNot)) { whereSubClause = $"Year <> {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorGreaterThan)) { whereSubClause = $"Year > {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorLessThan)) { whereSubClause = $"Year < {rule.Value}"; } } // Rating if (rule.Field.Equals(SmartPlaylistDecoder.FieldRating, StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIs)) { whereSubClause = $"Rating = {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIsNot)) { whereSubClause = $"Rating <> {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorGreaterThan)) { whereSubClause = $"Rating > {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorLessThan)) { whereSubClause = $"Rating < {rule.Value}"; } } // Love if (rule.Field.Equals(SmartPlaylistDecoder.FieldLove, StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIs)) { whereSubClause = $"Love = {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIsNot)) { whereSubClause = $"Love <> {rule.Value}"; } } // PlayCount if (rule.Field.Equals(SmartPlaylistDecoder.FieldPlayCount, StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIs)) { whereSubClause = $"PlayCount = {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIsNot)) { whereSubClause = $"PlayCount <> {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorGreaterThan)) { whereSubClause = $"PlayCount > {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorLessThan)) { whereSubClause = $"PlayCount < {rule.Value}"; } } // SkipCount if (rule.Field.Equals(SmartPlaylistDecoder.FieldSkipCount, StringComparison.InvariantCultureIgnoreCase)) { if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIs)) { whereSubClause = $"SkipCount = {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorIsNot)) { whereSubClause = $"SkipCount <> {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorGreaterThan)) { whereSubClause = $"SkipCount > {rule.Value}"; } else if (rule.Operator.Equals(SmartPlaylistDecoder.OperatorLessThan)) { whereSubClause = $"SkipCount < {rule.Value}"; } } return(whereSubClause); }