Ejemplo n.º 1
0
        public void GetAudioFile(WebData webData, long audioFileID)
        {
            webData.Result.AddMessage(webData.Method, "Retrieved AudioFile information.");
            var webAudioFile = RPCAudioFile.Load(mdb, audioFileID);
            var audioFile    = mdb.AudioFiles.TryGetStruct(audioFileID);
            var file         = mdb.Files.TryGetStruct(audioFile.FileID);

            webData.Result.AddStruct(webAudioFile);
            webData.Result.AddStruct(audioFile);
            webData.Result.AddStruct(file);
        }
Ejemplo n.º 2
0
        public void GetFilesWithErrorsList(WebData webData, int page = 0)
        {
            var  search   = Search.FieldNotEquals(nameof(MDBAudioFile.MetaErrors), MDBMetaErrors.None);
            long rowCount = mdb.AudioFiles.Count(search);
            var  ids      = mdb.AudioFiles.FindRows(search, ResultOption.Limit(RowsPerPage) + ResultOption.Offset(page * RowsPerPage));
            var  files    = ids.Select(i => RPCAudioFile.Load(mdb, i));

            webData.Result.AddMessage(webData.Method, "Retrieved AudioFiles with MetaErrors.");
            AddPagination(webData, page, rowCount);
            webData.Result.AddStructs(files);
        }
Ejemplo n.º 3
0
        public void SearchAudioFiles(WebData webData, int page = 0, long artistID   = 0, long albumID    = 0, long categoryID  = 0, long genreID    = 0, long tagID    = 0,
                                     string filter             = null, string title = null, string album = null, string artist = null, string genre = null, string tag = null)
        {
            if (title == null)
            {
                title = filter;
            }

            Search search = Search.None;

            if (artistID > 0)
            {
                if (artist != null)
                {
                    throw new WebServerException(WebError.InvalidParameters, 0, "Cannot use artist search and artistID at the same time!");
                }
                search &=
                    Search.FieldEquals(nameof(MDBAudioFile.AlbumArtistID), artistID) |
                    Search.FieldEquals(nameof(MDBAudioFile.SongArtistID), artistID);
            }
            else if (artist != null)
            {
                var ids = mdb.Artists.FindRows(Search.FieldLike(nameof(MDBArtist.Name), artist));
                search &=
                    Search.FieldIn(nameof(MDBAudioFile.AlbumArtistID), ids) |
                    Search.FieldIn(nameof(MDBAudioFile.SongArtistID), ids);
            }

            if (albumID > 0)
            {
                search &= Search.FieldEquals(nameof(MDBAudioFile.AlbumID), albumID);
                if (album != null)
                {
                    throw new WebServerException(WebError.InvalidParameters, 0, "Cannot use album search and albumID at the same time!");
                }
            }
            else if (album != null)
            {
                var ids = mdb.Albums.FindRows(Search.FieldLike(nameof(MDBArtist.Name), album));
                search &= Search.FieldIn(nameof(MDBAudioFile.AlbumID), ids);
            }

            if (categoryID > 0)
            {
                search &= GetCategorySearch(categoryID);
            }
            if (genreID > 0)
            {
                search &= Search.FieldEquals(nameof(MDBAudioFile.GenreID), genreID);
            }
            if (tagID > 0)
            {
                search &= Search.FieldEquals(nameof(MDBAudioFile.TagID), tagID);
            }
            if (genre != null)
            {
                search &= Search.FieldLike(nameof(MDBAudioFile.Genres), MDBSearch.Text("%" + genre + "%"));
            }
            if (tag != null)
            {
                search &= Search.FieldLike(nameof(MDBAudioFile.Tags), MDBSearch.Text("%" + tag + "%"));
            }
            if (title != null)
            {
                search &= Search.FieldLike(nameof(MDBAudioFile.Title), MDBSearch.Text("%" + title + "%"));
            }

            {
                long rowCount = mdb.AudioFiles.Count(search);
                var  ids      = mdb.AudioFiles.FindRows(search, ResultOption.Limit(RowsPerPage) + ResultOption.Offset(page * RowsPerPage) + ResultOption.SortAscending(nameof(MDBAudioFile.Title)));
                webData.Result.AddMessage(webData.Method, "Found {0} matching AudioFiles.", rowCount);
                AddPagination(webData, page, rowCount);
                var files = ids.Select(i => RPCAudioFile.Load(mdb, i));
                webData.Result.AddStructs(files);
            }
        }