예제 #1
0
        public async void LoadIndexesAsync(ISonicCache cache)
        {
            var x = new MusicFolders(cache);
            await LoadIndexesOperation.RunAsync(() => x.GetAsync(SourcePolicy.Cache), e => { });


            Indexes.StableMergeUpdate(x.Folders.First().Indexes);
        }
예제 #2
0
        /// <summary>Initializes a new instance of the <see cref="MusicDataBase"/> class.</summary>
        /// <param name="rootFolder">The root folder.</param>
        /// <exception cref="FileNotFoundException">WebFolder missing!</exception>
        /// <exception cref="Exception"></exception>
        public MusicDataBase(string rootFolder)
        {
            this.LogVerbose("Initializing MusicDataBase");

            RootFolder     = rootFolder;
            ConfigFileName = FileSystem.Combine(rootFolder, "JukeBob.ini");
            this.LogVerbose("Loading configuration {0}", ConfigFileName);
            Config = IniReader.FromFile(ConfigFileName);
            if (!Config.HasSection("MusicDataBase"))
            {
                throw new FileNotFoundException($"Missing configuration {ConfigFileName}!", ConfigFileName);
            }

            foreach (string folder in Config.ReadSection("MusicFolders", true))
            {
                string f = Path.GetFullPath(folder);
                this.LogVerbose("MusicFolder {0} => {1}", folder, f);
                if (!Directory.Exists(f))
                {
                    throw new DirectoryNotFoundException(string.Format("MusicFolder {0} not found!", folder));
                }

                MusicFolders.Include(f);
            }

            DataBasePath = GetFolderConfig("MusicDataBase", "DatabaseFolder", "database");
            this.LogVerbose("Using Database path {0}", DataBasePath);
            try
            {
                ArtistArtFolder = GetFolderConfig("MusicDataBase", "ArtFolder", "art");
                this.LogVerbose("ArtistArtFolder {0}", ArtistArtFolder);
                Directory.CreateDirectory(ArtistArtFolder);

                CacheFolder = GetFolderConfig("MusicDataBase", "CacheFolder", "cache");
                this.LogVerbose("CacheFolder {0}", CacheFolder);
                Directory.CreateDirectory(CacheFolder);

                WebFolder = GetFolderConfig("MusicDataBase", "WebFolder", "web");
                this.LogVerbose("WebFolder {0}", WebFolder);
                if (!File.Exists(FileSystem.Combine(WebFolder, "index.cwt")))
                {
                    throw new FileNotFoundException("WebFolder missing!");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Could not load configuration from {0}", ConfigFileName), ex);
            }
        }
예제 #3
0
        public IndexesViewModel(ISonicCache cache)
        {
            LoadIndexesOperation = new LongRunningOperation();

            LoadIndexesAsync(cache);

            RefreshCommand = new RelayCommand(async () =>
                {
                    ArbitraryContainer.Default.Resolve<INavigationService>().ClearPageCache();

                    var x = new MusicFolders(cache);
                    await x.GetAsync(SourcePolicy.Refresh);

                    Indexes.StableMergeUpdate(x.Folders.First().Indexes);
                });

            DirectoryClickedCommand = new RelayCommand<MusicDirectory>(
                x => ArbitraryContainer.Default.Resolve<INavigationService>().Navigate(typeof(MusicDirectoryView), x));
        }
예제 #4
0
 private void RemoveMusicFolder()
 {
     MusicFolders.Remove(MusicSearchPath);
     DataService.SetSavedSearchFolders(MusicFolders);
 }
예제 #5
0
 private void AddMusicFolder()
 {
     MusicSearchPath = DataService.OpenFolderBrowser();
     MusicFolders.Add(MusicSearchPath);
     DataService.SetSavedSearchFolders(MusicFolders);
 }