Example #1
0
        // ====================================================================
        // private 関数
        // ====================================================================

        // --------------------------------------------------------------------
        // カテゴリーテーブルのレコードを作成
        // --------------------------------------------------------------------
        private static TCategory CreateCategoryRecord(Int32 idNumber, String name, String?ruby = null)
        {
            String?normalizedName = YlCommon.NormalizeDbString(name);

            (String? normalizedRubyForMusicInfo, _, _) = YlCommon.NormalizeDbRubyForMusicInfo(ruby);
            if (String.IsNullOrEmpty(normalizedRubyForMusicInfo))
            {
                normalizedRubyForMusicInfo = normalizedName;
            }
            (String? normalizedRubyForSearch, _, _) = YlCommon.NormalizeDbRubyForSearch(normalizedRubyForMusicInfo);

            return(new TCategory()
            {
                // IRcBase
                Id = YlConstants.MUSIC_INFO_SYSTEM_ID_PREFIX + YlConstants.MUSIC_INFO_ID_SECOND_PREFIXES[(Int32)MusicInfoTables.TCategory] + idNumber.ToString("D3"),
                Import = false,
                Invalid = false,
                UpdateTime = YlConstants.INVALID_MJD,
                Dirty = true,

                // IRcMaster
                Name = normalizedName,
                Ruby = normalizedRubyForMusicInfo,
                RubyForSearch = normalizedRubyForSearch,
                Keyword = null,
                KeywordRubyForSearch = null,
            });
        }
        // ====================================================================
        // protected 関数
        // ====================================================================

        // --------------------------------------------------------------------
        // 入力値を確認する
        // <例外> Exception, OperationCanceledException
        // --------------------------------------------------------------------
        protected override void CheckProperties()
        {
            // タイアップグループの場合、名前の重複は無条件で NG のため、基底より先にチェック
            String?normalizedName = YlCommon.NormalizeDbString(Name);

            if (!String.IsNullOrEmpty(normalizedName))
            {
                (_, Int32 numDups) = GetSameNameRecordsCaseInsensitive(normalizedName);
                if (numDups > 0)
                {
                    throw new Exception(_caption + "「" + normalizedName + "」は既に登録されています。\n同じ名前の" + _caption + "は登録できません。");
                }
            }

            // 基底
            base.CheckProperties();
        }