Beispiel #1
0
        public async Task NewScanAndAddAsync(string path)
        {
            lock (ScanObject)
            {
                if (ViewModel.IsScanning)
                {
                    return;
                }
                ViewModel.IsScanning = true;
            }

            _scanCts = new CancellationTokenSource();
            await BeatmapDbOperator.RemoveLocalAllAsync();

            var dirInfo = new DirectoryInfo(path);

            foreach (var privateFolder in dirInfo.EnumerateDirectories(searchPattern: "*.*", searchOption: SearchOption.TopDirectoryOnly))
            {
                if (_scanCts.IsCancellationRequested)
                {
                    break;
                }
                await ScanPrivateFolderAsync(privateFolder);
            }

            lock (ScanObject)
            {
                ViewModel.IsScanning = false;
            }
        }
Beispiel #2
0
        public SearchPage()
        {
            _mainWindow = (MainWindow)Application.Current.MainWindow;
            _beatmapDbOperator = new BeatmapDbOperator();

            InitializeComponent();
        }
Beispiel #3
0
        private async Task AddFileAsync(BeatmapDbOperator dbOperator, OsuFile osuFile, FileInfo fileInfo)
        {
            var beatmap = Data.EF.Model.Beatmap.ParseFromOSharp(osuFile);

            beatmap.BeatmapFileName  = fileInfo.Name;
            beatmap.LastModifiedTime = fileInfo.LastWriteTime;
            beatmap.FolderName       = fileInfo.Directory.Name;
            beatmap.InOwnFolder      = true;
            await dbOperator.AddNewMapAsync(beatmap);
        }
Beispiel #4
0
        private async Task ScanPrivateFolderAsync(DirectoryInfo privateFolder)
        {
            using (var dbOperator = new BeatmapDbOperator())
            {
                foreach (var fileInfo in privateFolder.EnumerateFiles(searchPattern: "*.osu", searchOption: SearchOption.TopDirectoryOnly))
                {
                    if (_scanCts.IsCancellationRequested)
                    {
                        return;
                    }

                    var osuFile = await OsuFile.ReadFromFileAsync(fileInfo.FullName);
                    await AddFileAsync(dbOperator, osuFile, fileInfo);
                }
            }
        }
Beispiel #5
0
        private static void InitLocalDb()
        {
            FluentMapper.Initialize(config =>
            {
                config.AddMap(new BeatmapMap());
                config.AddMap(new MapInfoMap());
            });

            AppDbOperator.ValidateDb();
            BeatmapDbOperator.ValidateDb();

            var appDbOperator = new AppDbOperator();
            var defCol        = appDbOperator.GetCollections();
            var locked        = defCol.Where(k => k.LockedBool);

            if (!locked.Any())
            {
                appDbOperator.AddCollection("最喜爱的", true);
            }
        }