Exemplo n.º 1
0
 public static async Task RemoveCancelledLibraryItems(IDatabaseComponent database)
 {
     using (var transaction = database.BeginTransaction(database.PreferredIsolationLevel))
     {
         await database.ExecuteAsync(database.Queries.RemoveCancelledLibraryItems).ConfigureAwait(false);
     }
 }
Exemplo n.º 2
0
        public static async Task UpdatePlaylistItem(IDatabaseComponent database, int playlistItemId, Action <PlaylistItem> action)
        {
            using (var transaction = database.BeginTransaction(database.PreferredIsolationLevel))
            {
                await UpdatePlaylistItem(database, playlistItemId, action, transaction).ConfigureAwait(false);

                if (transaction.HasTransaction)
                {
                    transaction.Commit();
                }
            }
        }
Exemplo n.º 3
0
        public static async Task UpdateLibraryItem(IDatabaseComponent database, LibraryItem libraryItem)
        {
            using (var transaction = database.BeginTransaction(database.PreferredIsolationLevel))
            {
                await UpdateLibraryItem(database, libraryItem, transaction).ConfigureAwait(false);

                if (transaction.HasTransaction)
                {
                    transaction.Commit();
                }
            }
        }
Exemplo n.º 4
0
 public void InitializeDatabase(IDatabaseComponent database)
 {
     using (var transaction = database.BeginTransaction())
     {
         var set = database.Set <PlaylistColumn>(transaction);
         set.Add(new PlaylistColumn()
         {
             Name     = "Rating",
             Type     = PlaylistColumnType.Plugin,
             Sequence = 100,
             Plugin   = typeof(RatingBehaviour).AssemblyQualifiedName,
             Enabled  = false
         });
         transaction.Commit();
     }
 }
Exemplo n.º 5
0
 public void InitializeDatabase(IDatabaseComponent database, DatabaseInitializeType type)
 {
     //IMPORTANT: When editing this function remember to change the checksum.
     if (!type.HasFlag(DatabaseInitializeType.MetaData))
     {
         return;
     }
     using (var transaction = database.BeginTransaction(database.PreferredIsolationLevel))
     {
         var set = database.Set <MetaDataProvider>(transaction);
         set.Clear();
         //No default data, yet.
         if (transaction.HasTransaction)
         {
             transaction.Commit();
         }
     }
 }
Exemplo n.º 6
0
        public void InitializeDatabase(IDatabaseComponent database)
        {
            var scriptingRuntime = ComponentRegistry.Instance.GetComponent <IScriptingRuntime>();

            if (scriptingRuntime == null)
            {
                return;
            }
            using (var transaction = database.BeginTransaction())
            {
                var set = database.Set <PlaylistColumn>(transaction);
                set.Clear();
                set.Add(new PlaylistColumn()
                {
                    Name = "Playing", Type = PlaylistColumnType.Script, Sequence = 0, Script = scriptingRuntime.CoreScripts.Playing, IsDynamic = true, Enabled = true
                });
                set.Add(new PlaylistColumn()
                {
                    Name = "Artist / album", Type = PlaylistColumnType.Script, Sequence = 1, Script = scriptingRuntime.CoreScripts.Artist_Album, Enabled = true
                });
                set.Add(new PlaylistColumn()
                {
                    Name = "Track no", Type = PlaylistColumnType.Script, Sequence = 2, Script = scriptingRuntime.CoreScripts.Track, Enabled = true
                });
                set.Add(new PlaylistColumn()
                {
                    Name = "Title / track artist", Type = PlaylistColumnType.Script, Sequence = 3, Script = scriptingRuntime.CoreScripts.Title_Performer, Enabled = true
                });
                set.Add(new PlaylistColumn()
                {
                    Name = "Duration", Type = PlaylistColumnType.Script, Sequence = 4, Script = scriptingRuntime.CoreScripts.Duration, Enabled = true
                });
                set.Add(new PlaylistColumn()
                {
                    Name = "Codec", Type = PlaylistColumnType.Script, Sequence = 5, Script = scriptingRuntime.CoreScripts.Codec, Enabled = true
                });
                set.Add(new PlaylistColumn()
                {
                    Name = "BPM", Type = PlaylistColumnType.Script, Sequence = 6, Script = scriptingRuntime.CoreScripts.BPM, Enabled = false
                });
                transaction.Commit();
            }
        }
Exemplo n.º 7
0
        public static async Task SetLibraryItemsStatus(IDatabaseComponent database, LibraryItemStatus status)
        {
            var query = database.QueryFactory.Build();

            query.Update.SetTable(database.Tables.LibraryItem);
            query.Update.AddColumn(database.Tables.LibraryItem.Column("Status"));
            using (var transaction = database.BeginTransaction(database.PreferredIsolationLevel))
            {
                await database.ExecuteAsync(query, (parameters, phase) =>
                {
                    switch (phase)
                    {
                    case DatabaseParameterPhase.Fetch:
                        parameters["status"] = status;
                        break;
                    }
                }, transaction).ConfigureAwait(false);

                transaction.Commit();
            }
        }
Exemplo n.º 8
0
 public void InitializeDatabase(IDatabaseComponent database, DatabaseInitializeType type)
 {
     //IMPORTANT: When editing this function remember to change the checksum.
     if (!type.HasFlag(DatabaseInitializeType.Playlist))
     {
         return;
     }
     using (var transaction = database.BeginTransaction(database.PreferredIsolationLevel))
     {
         var set = database.Set <PlaylistColumn>(transaction);
         set.Add(new PlaylistColumn()
         {
             Name     = "Playing",
             Type     = PlaylistColumnType.Plugin,
             Sequence = 0,
             Plugin   = this.Id,
             Enabled  = true
         });
         transaction.Commit();
     }
 }
Exemplo n.º 9
0
        public void InitializeDatabase(IDatabaseComponent database, DatabaseInitializeType type)
        {
            //IMPORTANT: When editing this function remember to change the checksum.
            if (!type.HasFlag(DatabaseInitializeType.Playlist))
            {
                return;
            }
            var scriptingRuntime = ComponentRegistry.Instance.GetComponent <IScriptingRuntime>();

            if (scriptingRuntime == null)
            {
                return;
            }
            using (var transaction = database.BeginTransaction(database.PreferredIsolationLevel))
            {
                {
                    var set = database.Set <Playlist>(transaction);
                    foreach (var playlist in set)
                    {
                        //TODO: Bad .Wait()
                        PlaylistTaskBase.RemovePlaylistItems(database, playlist.Id, PlaylistItemStatus.None, transaction).Wait();
                    }
                    set.Clear();
                    set.Add(new Playlist()
                    {
                        Name = "Default", Type = PlaylistType.None, Enabled = true
                    });
                }
                {
                    var set = database.Set <PlaylistColumn>(transaction);
                    set.Clear();
                    set.Add(new PlaylistColumn()
                    {
                        Name = "Artist / album", Type = PlaylistColumnType.Script, Sequence = 1, Script = scriptingRuntime.CoreScripts.Artist_Album, Width = PlaylistColumn.WIDTH_LARGE, Enabled = true
                    });
                    set.Add(new PlaylistColumn()
                    {
                        Name = "Track no", Type = PlaylistColumnType.Script, Sequence = 2, Script = scriptingRuntime.CoreScripts.Track, Enabled = true
                    });
                    set.Add(new PlaylistColumn()
                    {
                        Name = "Title / track artist", Type = PlaylistColumnType.Script, Sequence = 3, Script = scriptingRuntime.CoreScripts.Title_Performer, Width = PlaylistColumn.WIDTH_LARGE, Enabled = true
                    });
                    set.Add(new PlaylistColumn()
                    {
                        Name = "Duration", Type = PlaylistColumnType.Tag, Sequence = 4, Tag = CommonProperties.Duration, Format = CommonFormats.TimeSpan, Enabled = true
                    });
                    set.Add(new PlaylistColumn()
                    {
                        Name = "Codec", Type = PlaylistColumnType.Script, Sequence = 5, Script = scriptingRuntime.CoreScripts.Codec, Enabled = true
                    });
                    set.Add(new PlaylistColumn()
                    {
                        Name = "BPM", Type = PlaylistColumnType.Tag, Sequence = 6, Tag = CommonMetaData.BeatsPerMinute, Enabled = false
                    });
                    set.Add(new PlaylistColumn()
                    {
                        Name = "Album gain", Type = PlaylistColumnType.Script, Sequence = 7, Script = scriptingRuntime.CoreScripts.ReplayGainAlbumGain, Enabled = false
                    });
                    set.Add(new PlaylistColumn()
                    {
                        Name = "Album peak", Type = PlaylistColumnType.Script, Sequence = 8, Script = scriptingRuntime.CoreScripts.ReplayGainAlbumPeak, Enabled = false
                    });
                    set.Add(new PlaylistColumn()
                    {
                        Name = "Track gain", Type = PlaylistColumnType.Script, Sequence = 9, Script = scriptingRuntime.CoreScripts.ReplayGainTrackGain, Enabled = false
                    });
                    set.Add(new PlaylistColumn()
                    {
                        Name = "Track peak", Type = PlaylistColumnType.Script, Sequence = 10, Script = scriptingRuntime.CoreScripts.ReplayGainTrackPeak, Enabled = false
                    });
                    set.Add(new PlaylistColumn()
                    {
                        Name = "Play count", Type = PlaylistColumnType.Script, Sequence = 11, Script = scriptingRuntime.CoreScripts.PlayCount, Enabled = false
                    });
                    set.Add(new PlaylistColumn()
                    {
                        Name = "Last played", Type = PlaylistColumnType.Script, Sequence = 12, Script = scriptingRuntime.CoreScripts.LastPlayed, Enabled = false
                    });
                    set.Add(new PlaylistColumn()
                    {
                        Name = "Initial key", Type = PlaylistColumnType.Tag, Sequence = 13, Tag = CommonMetaData.InitialKey, Enabled = false
                    });
                }
                transaction.Commit();
            }
        }
Exemplo n.º 10
0
        public void InitializeDatabase(IDatabaseComponent database, DatabaseInitializeType type)
        {
            //IMPORTANT: When editing this function remember to change the checksum.
            if (!type.HasFlag(DatabaseInitializeType.Library))
            {
                return;
            }
            var scriptingRuntime = ComponentRegistry.Instance.GetComponent <IScriptingRuntime>();

            if (scriptingRuntime == null)
            {
                return;
            }
            using (var transaction = database.BeginTransaction(database.PreferredIsolationLevel))
            {
                var set = database.Set <LibraryHierarchy>(transaction);
                foreach (var libraryHierarchy in set)
                {
                    //TODO: Bad .Wait()
                    LibraryTaskBase.RemoveHierarchies(database, libraryHierarchy, null, transaction).Wait();
                }
                set.Clear();
                set.Add(new LibraryHierarchy()
                {
                    Name     = "Artist/Album/Title",
                    Type     = LibraryHierarchyType.Script,
                    Sequence = 0,
                    Enabled  = true,
                    Levels   = new ObservableCollection <LibraryHierarchyLevel>()
                    {
                        new LibraryHierarchyLevel()
                        {
                            Sequence = 0, Script = scriptingRuntime.CoreScripts.Artist
                        },
                        new LibraryHierarchyLevel()
                        {
                            Sequence = 1, Script = scriptingRuntime.CoreScripts.Year_Album
                        },
                        new LibraryHierarchyLevel()
                        {
                            Sequence = 2, Script = scriptingRuntime.CoreScripts.Disk_Track_Title
                        }
                    }
                });
                set.Add(new LibraryHierarchy()
                {
                    Name     = "Genre/Album/Title",
                    Type     = LibraryHierarchyType.Script,
                    Sequence = 1,
                    Enabled  = false,
                    Levels   = new ObservableCollection <LibraryHierarchyLevel>()
                    {
                        new LibraryHierarchyLevel()
                        {
                            Sequence = 0, Script = scriptingRuntime.CoreScripts.Genre
                        },
                        new LibraryHierarchyLevel()
                        {
                            Sequence = 1, Script = scriptingRuntime.CoreScripts.Year_Album
                        },
                        new LibraryHierarchyLevel()
                        {
                            Sequence = 2, Script = scriptingRuntime.CoreScripts.Disk_Track_Title
                        }
                    }
                });
                set.Add(new LibraryHierarchy()
                {
                    Name     = "Genre/Rating/Artist - Title [BPM]",
                    Type     = LibraryHierarchyType.Script,
                    Sequence = 2,
                    Enabled  = false,
                    Levels   = new ObservableCollection <LibraryHierarchyLevel>()
                    {
                        new LibraryHierarchyLevel()
                        {
                            Sequence = 0, Script = scriptingRuntime.CoreScripts.Genre
                        },
                        new LibraryHierarchyLevel()
                        {
                            Sequence = 1, Script = scriptingRuntime.CoreScripts.Rating
                        },
                        new LibraryHierarchyLevel()
                        {
                            Sequence = 2, Script = scriptingRuntime.CoreScripts.Artist_Title_BPM
                        }
                    }
                });
                set.Add(new LibraryHierarchy()
                {
                    Name     = "Folder Structure",
                    Type     = LibraryHierarchyType.FileSystem,
                    Sequence = 3,
                    Enabled  = false
                });
                transaction.Commit();
            }
        }
Exemplo n.º 11
0
        public void InitializeDatabase(IDatabaseComponent database)
        {
            var scriptingRuntime = ComponentRegistry.Instance.GetComponent <IScriptingRuntime>();

            if (scriptingRuntime == null)
            {
                return;
            }
            using (var transaction = database.BeginTransaction())
            {
                var set = database.Set <LibraryHierarchy>(transaction);
                set.Clear();
                set.Add(new LibraryHierarchy()
                {
                    Name     = "Artist/Album/Title",
                    Type     = LibraryHierarchyType.Script,
                    Sequence = 0,
                    Enabled  = true,
                    Levels   = new ObservableCollection <LibraryHierarchyLevel>()
                    {
                        new LibraryHierarchyLevel()
                        {
                            Sequence = 0, Script = scriptingRuntime.CoreScripts.Artist
                        },
                        new LibraryHierarchyLevel()
                        {
                            Sequence = 1, Script = scriptingRuntime.CoreScripts.Year_Album
                        },
                        new LibraryHierarchyLevel()
                        {
                            Sequence = 2, Script = scriptingRuntime.CoreScripts.Disk_Track_Title
                        }
                    }
                });
                set.Add(new LibraryHierarchy()
                {
                    Name     = "Genre/Album/Title",
                    Type     = LibraryHierarchyType.Script,
                    Sequence = 1,
                    Enabled  = false,
                    Levels   = new ObservableCollection <LibraryHierarchyLevel>()
                    {
                        new LibraryHierarchyLevel()
                        {
                            Sequence = 0, Script = scriptingRuntime.CoreScripts.Genre
                        },
                        new LibraryHierarchyLevel()
                        {
                            Sequence = 1, Script = scriptingRuntime.CoreScripts.Year_Album
                        },
                        new LibraryHierarchyLevel()
                        {
                            Sequence = 2, Script = scriptingRuntime.CoreScripts.Disk_Track_Title
                        }
                    }
                });
                set.Add(new LibraryHierarchy()
                {
                    Name     = "Folder Structure",
                    Type     = LibraryHierarchyType.FileSystem,
                    Sequence = 2,
                    Enabled  = false
                });
                transaction.Commit();
            }
        }