// ====================================================================
        // コンストラクター
        // ====================================================================

        // --------------------------------------------------------------------
        // メインコンストラクター
        // --------------------------------------------------------------------
        public EditMasterWindowViewModel(MusicInfoContextDefault musicInfoContext, DbSet <T> records)
        {
            Debug.Assert(musicInfoContext.ChangeTracker.QueryTrackingBehavior == QueryTrackingBehavior.TrackAll, "EditMasterWindowViewModel() bad QueryTrackingBehavior");
            _caption          = YlConstants.MUSIC_INFO_TABLE_NAME_LABELS[DbCommon.MusicInfoTableIndex <T>()];
            _musicInfoContext = musicInfoContext;
            _records          = records;
        }
        // ====================================================================
        // コンストラクター
        // ====================================================================

        // --------------------------------------------------------------------
        // メインコンストラクター
        // --------------------------------------------------------------------
        public ViewMastersWindowViewModel(MusicInfoContextDefault musicInfoContext, DbSet <T> records, ObservableCollection <DataGridColumn> columns)
        {
            _musicInfoContext = musicInfoContext;
            _records          = records;
            _caption          = YlConstants.MUSIC_INFO_TABLE_NAME_LABELS[DbCommon.MusicInfoTableIndex <T>()];
            Columns           = columns;

            UpdateAll(null);
        }
Exemple #3
0
        // ====================================================================
        // コンストラクター
        // ====================================================================

        // --------------------------------------------------------------------
        // メインコンストラクター
        // --------------------------------------------------------------------
        public TFoundSetter(ListContextInMemory listContextInMemory)
        {
            Debug.Assert(listContextInMemory.ChangeTracker.QueryTrackingBehavior == QueryTrackingBehavior.TrackAll, "TFoundSetter() bad QueryTrackingBehavior");
            _listContextInMemory = listContextInMemory;

            // MusicInfoContext は検索専用なので NoTracking にする
            _musicInfoContext = new MusicInfoContextDefault();
            _musicInfoContext.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;

            _categoryNames = DbCommon.SelectCategoryNames(_musicInfoContext.Categories);

            // スマートトラック判定用単語
            _offVocalWords  = YlConstants.SMART_TRACK_SEPARATOR + String.Join(YlConstants.SMART_TRACK_SEPARATOR, YlModel.Instance.EnvModel.YlSettings.OffVocalWords) + YlConstants.SMART_TRACK_SEPARATOR;
            _bothVocalWords = YlConstants.SMART_TRACK_SEPARATOR + String.Join(YlConstants.SMART_TRACK_SEPARATOR, YlModel.Instance.EnvModel.YlSettings.BothVocalWords) + YlConstants.SMART_TRACK_SEPARATOR;
        }
        // ====================================================================
        // コンストラクター
        // ====================================================================

        // --------------------------------------------------------------------
        // メインコンストラクター
        // --------------------------------------------------------------------
        public EditSequenceWindowViewModel(MusicInfoContextDefault musicInfoContext, DbSet <T> records, Boolean searchOnInitialize, String?captionDetail = null)
        {
            _musicInfoContext   = musicInfoContext;
            _records            = records;
            _searchOnInitialize = searchOnInitialize;
            _caption            = YlConstants.MUSIC_INFO_TABLE_NAME_LABELS[DbCommon.MusicInfoTableIndex <T>()];
            if (String.IsNullOrEmpty(captionDetail))
            {
                _captionDetail = _caption;
            }
            else
            {
                _captionDetail = captionDetail;
            }
        }
Exemple #5
0
        // ====================================================================
        // コンストラクター
        // ====================================================================

        // --------------------------------------------------------------------
        // プログラム中で使うべき引数付きコンストラクター
        // --------------------------------------------------------------------
        public EditSongWindowViewModel(MusicInfoContextDefault musicInfoContext, DbSet <TSong> records, String?newSongArtistNames = null)
            : base(musicInfoContext, records)
        {
            if (!String.IsNullOrEmpty(newSongArtistNames))
            {
                String[] newSongArtistNameArray = newSongArtistNames.Split(',');
                foreach (String artistName in newSongArtistNameArray)
                {
                    TPerson?person = DbCommon.SelectMasterByName(_musicInfoContext.People, artistName);
                    if (person == null)
                    {
                        continue;
                    }
                    _newSongArtists.Add(person);
                }
            }
        }
        // ====================================================================
        // コンストラクター
        // ====================================================================

        // --------------------------------------------------------------------
        // メインコンストラクター
        // --------------------------------------------------------------------
        public ViewTieUpGroupsWindowViewModel(MusicInfoContextDefault musicInfoContext, DbSet <TTieUpGroup> records, ObservableCollection <DataGridColumn> columns)
            : base(musicInfoContext, records, columns)
        {
        }
Exemple #7
0
        // ====================================================================
        // コンストラクター
        // ====================================================================

        // --------------------------------------------------------------------
        // メインコンストラクター
        // --------------------------------------------------------------------
        public EditMakerWindowViewModel(MusicInfoContextDefault musicInfoContext, DbSet <TMaker> records)
            : base(musicInfoContext, records)
        {
        }
        // ====================================================================
        // コンストラクター
        // ====================================================================

        // --------------------------------------------------------------------
        // メインコンストラクター
        // --------------------------------------------------------------------
        public EditTieUpGroupWindowViewModel(MusicInfoContextDefault musicInfoContext, DbSet <TTieUpGroup> records)
            : base(musicInfoContext, records)
        {
        }
        // ====================================================================
        // コンストラクター
        // ====================================================================

        // --------------------------------------------------------------------
        // メインコンストラクター
        // --------------------------------------------------------------------
        public EditCategorizableWindowViewModel(MusicInfoContextDefault musicInfoContext, DbSet <T> records)
            : base(musicInfoContext, records)
        {
        }
Exemple #10
0
        // --------------------------------------------------------------------
        // 紐付テーブルをインポート
        // --------------------------------------------------------------------
        private void ImportSequenceTable <T>(DbSet <T> recordsExport, DbSet <T> recordsDefault, MusicInfoContextDefault musicInfoContextDefault) where T : class, IRcSequence
        {
            _descriptionSetter(YlConstants.MUSIC_INFO_TABLE_NAME_LABELS[DbCommon.MusicInfoTableIndex <T>()] + "情報をインポート中...");

            List <T> resultsExport = recordsExport.Where(x => !x.Invalid).ToList();

            foreach (T resultExport in resultsExport)
            {
                // インポート後に Dirty になるようにフラグをセットしておく
                resultExport.Dirty = true;

                // 同じ Id かつ同じ連番があるか
                T?sameIdRecord = recordsDefault.FirstOrDefault(x => x.Id == resultExport.Id && x.Sequence == resultExport.Sequence);
                if (sameIdRecord != null)
                {
                    // 同じ Id かつ同じ連番がある場合は上書き
                    Common.ShallowCopyFields(resultExport, sameIdRecord);
                    continue;
                }

                // 新規挿入
                recordsDefault.Add(resultExport);
            }

            _cancellationToken.ThrowIfCancellationRequested();

            musicInfoContextDefault.SaveChanges();
        }
        // ====================================================================
        // コンストラクター
        // ====================================================================

        // --------------------------------------------------------------------
        // メインコンストラクター
        // --------------------------------------------------------------------
        public EditPeopleWindowViewModel(MusicInfoContextDefault musicInfoContext, DbSet <TPerson> records, Boolean searchOnInitialize, String captionDetail)
            : base(musicInfoContext, records, searchOnInitialize, captionDetail)
        {
        }
Exemple #12
0
        // --------------------------------------------------------------------
        // 別名テーブルをインポート
        // --------------------------------------------------------------------
        private void ImportAliasTable <T>(DbSet <T> recordsExport, DbSet <T> recordsDefault, MusicInfoContextDefault musicInfoContextDefault) where T : class, IRcAlias
        {
            _descriptionSetter(YlConstants.MUSIC_INFO_TABLE_NAME_LABELS[DbCommon.MusicInfoTableIndex <T>()] + "情報をインポート中...");

            List <T> resultsExport = recordsExport.Where(x => !x.Invalid).ToList();

            foreach (T resultExport in resultsExport)
            {
                // インポート後に Dirty になるようにフラグをセットしておく
                resultExport.Dirty = true;

                // 同じ Id があるか
                T?sameIdRecord = DbCommon.SelectBaseById(recordsDefault, resultExport.Id, true);
                if (sameIdRecord != null)
                {
                    // 同じ Id がある場合、_importSameName なら上書き
                    if (_importSameName)
                    {
                        Common.ShallowCopyFields(resultExport, sameIdRecord);
                    }
                    continue;
                }

                // 同じ別名があるか
                T?sameAliasRecord = DbCommon.SelectAliasByAlias(recordsDefault, resultExport.Alias, true);
                if (sameAliasRecord != null)
                {
                    // 同じ別名がある場合、_importSameName なら上書き
                    if (_importSameName)
                    {
                        Common.ShallowCopyFields(resultExport, sameAliasRecord);
                    }
                    continue;
                }

                // 新規挿入
                recordsDefault.Add(resultExport);
            }

            _cancellationToken.ThrowIfCancellationRequested();

            musicInfoContextDefault.SaveChanges();
        }
        // ====================================================================
        // コンストラクター
        // ====================================================================

        // --------------------------------------------------------------------
        // メインコンストラクター
        // --------------------------------------------------------------------
        public EditTagWindowViewModel(MusicInfoContextDefault musicInfoContext, DbSet <TTag> records)
            : base(musicInfoContext, records)
        {
        }
        // ====================================================================
        // コンストラクター
        // ====================================================================

        // --------------------------------------------------------------------
        // メインコンストラクター
        // --------------------------------------------------------------------
        public EditTieUpGroupsWindowViewModel(MusicInfoContextDefault musicInfoContext, DbSet <TTieUpGroup> records, Boolean searchOnInitialize)
            : base(musicInfoContext, records, searchOnInitialize)
        {
        }
        // ====================================================================
        // コンストラクター
        // ====================================================================

        // --------------------------------------------------------------------
        // メインコンストラクター
        // --------------------------------------------------------------------
        public EditPersonWindowViewModel(MusicInfoContextDefault musicInfoContext, DbSet <TPerson> records)
            : base(musicInfoContext, records)
        {
        }
Exemple #16
0
        // --------------------------------------------------------------------
        // マスターテーブルをインポート
        // --------------------------------------------------------------------
        private void ImportMasterTable <T>(DbSet <T> recordsExport, DbSet <T> recordsDefault, MusicInfoContextDefault musicInfoContextDefault) where T : class, IRcMaster
        {
            _descriptionSetter(YlConstants.MUSIC_INFO_TABLE_NAME_LABELS[DbCommon.MusicInfoTableIndex <T>()] + "情報をインポート中...");

            List <T> resultsExport = recordsExport.Where(x => !x.Invalid).ToList();

            foreach (T resultExport in resultsExport)
            {
                // インポート後に Dirty になるようにフラグをセットしておく
                resultExport.Dirty = true;

                // 同じ Id があるか
                T?sameIdRecord = DbCommon.SelectBaseById(recordsDefault, resultExport.Id, true);
                if (sameIdRecord != null)
                {
                    // 同じ Id がある場合、_importSameName なら上書き
                    if (_importSameName)
                    {
                        Common.ShallowCopyFields(resultExport, sameIdRecord);
                    }
                    continue;
                }

                // 同じ名前があるか
                List <T> sameNameRecords = recordsDefault.Where(x => x.Name == resultExport.Name).ToList();
                if (sameNameRecords.Any())
                {
                    if (_importSameName)
                    {
                        T?sameKeywordRecord = sameNameRecords.FirstOrDefault(x => x.Keyword == null && resultExport.Keyword == null || x.Keyword != null && x.Keyword == resultExport.Keyword);
                        if (sameKeywordRecord != null)
                        {
                            // _importSameName かつ同じキーワードがある場合は上書き
                            Common.ShallowCopyFields(resultExport, sameKeywordRecord);
                            continue;
                        }
                        else
                        {
                            // _importSameName かつ同じキーワードがない場合は、ここでは何もせず新規挿入に進む
                        }
                    }
                    else
                    {
                        // _importSameName でない場合は何もしない
                        continue;
                    }
                }

                // 新規挿入
                recordsDefault.Add(resultExport);
            }

            _cancellationToken.ThrowIfCancellationRequested();

            musicInfoContextDefault.SaveChanges();
        }
        // ====================================================================
        // コンストラクター
        // ====================================================================

        // --------------------------------------------------------------------
        // メインコンストラクター
        // --------------------------------------------------------------------
        public ViewPeopleWindowViewModel(MusicInfoContextDefault musicInfoContext, DbSet <TPerson> records, ObservableCollection <DataGridColumn> columns)
            : base(musicInfoContext, records, columns)
        {
        }