Exemple #1
0
        // --------------------------------------------------------------------
        // 検出ファイルリストテーブルにファイル情報を追加
        // AddFileNames() で追加されない情報をすべて付与する
        // ファイルは再帰検索しない
        // --------------------------------------------------------------------
        private static void AddInfosCore(TargetFolderInfo targetFolderInfo)
        {
            // フォルダー設定を読み込む
            FolderSettingsInDisk   folderSettingsInDisk   = YlCommon.LoadFolderSettings(targetFolderInfo.TargetPath);
            FolderSettingsInMemory folderSettingsInMemory = YlCommon.CreateFolderSettingsInMemory(folderSettingsInDisk);

            using ListContextInMemory listContextInMemory = new();
            using TFoundSetter foundSetter = new(listContextInMemory);

            // 指定フォルダーの全レコード
            IQueryable <TFound> targetRecords = listContextInMemory.Founds.Where(x => x.Folder == targetFolderInfo.TargetPath);

            // 情報付与
            foreach (TFound record in targetRecords)
            {
                FileInfo fileInfo = new(record.Path);
                record.LastWriteTime = JulianDay.DateTimeToModifiedJulianDate(fileInfo.LastWriteTime);
                record.FileSize      = fileInfo.Length;
                foundSetter.SetTFoundValues(record, folderSettingsInMemory);

                YlModel.Instance.EnvModel.AppCancellationTokenSource.Token.ThrowIfCancellationRequested();
            }
            AddFolderTagsInfo(targetFolderInfo, targetRecords, listContextInMemory.Tags, listContextInMemory.TagSequences);

            // コミット
            listContextInMemory.SaveChanges();
        }
Exemple #2
0
        // --------------------------------------------------------------------
        // 過去の統計を更新
        // --------------------------------------------------------------------
        private void UpdatePast()
        {
            Debug.WriteLine("UpdatePast()");
            using YukariStatisticsContext yukariStatisticsContext = new();
            IQueryable <TYukariStatistics> targetYukariStatistics = yukariStatisticsContext.YukariStatistics.Where(x => (UpdatePastYukariStatisticsKind == UpdatePastYukariStatisticsKind.All || !x.AttributesDone) && !x.Invalid);

            foreach (TYukariStatistics oneStatistics in targetYukariStatistics)
            {
#if DEBUGz
                if (oneStatistics.RequestMoviePath == @"D:\TempD\TestNkl\TST9_楽曲情報編集\テストタイアップ1_テスト楽曲101_ファイル歌手1,初音ミク.mp4")
                {
                }
#endif
                if (!File.Exists(oneStatistics.RequestMoviePath))
                {
                    continue;
                }
                String requestMovieFolder = Path.GetDirectoryName(oneStatistics.RequestMoviePath) ?? String.Empty;
                if (YlCommon.FindSettingsFolder(requestMovieFolder) == null)
                {
                    continue;
                }
                Debug.WriteLine("UpdatePast() 設定:" + oneStatistics.RequestMoviePath);

                // TFound 下準備
                FileInfo fileInfo = new(oneStatistics.RequestMoviePath);
                TFound   found    = new()
                {
                    Path          = oneStatistics.RequestMoviePath,
                    Folder        = requestMovieFolder,
                    ParentFolder  = requestMovieFolder,
                    LastWriteTime = JulianDay.DateTimeToModifiedJulianDate(fileInfo.LastWriteTime),
                    FileSize      = fileInfo.Length,
                };

                // フォルダー設定を読み込む
                FolderSettingsInDisk   folderSettingsInDisk   = YlCommon.LoadFolderSettings(found.Folder);
                FolderSettingsInMemory folderSettingsInMemory = YlCommon.CreateFolderSettingsInMemory(folderSettingsInDisk);

                using ListContextInMemory listContextInMemory = new();
                using TFoundSetter foundSetter = new(listContextInMemory);

                // TFound 設定
                foundSetter.SetTFoundValues(found, folderSettingsInMemory);

                // 統計設定
                DbCommon.CopyFoundToYukariStatisticsIfAttributesPrepared(found, oneStatistics);
            }

            yukariStatisticsContext.SaveChanges();
            UpdatePastYukariStatisticsKind = UpdatePastYukariStatisticsKind.None;
        }