/// <summary> /// コンストラクタ /// 既存データの復元用 /// </summary> /// <param name="fileCode">FileCode</param> /// <param name="fileID">FileID</param> /// <param name="languageType">言語区分</param> /// <param name="createdAt">作成日</param> /// <param name="updatedAt">更新日</param> public MieFileEntry(long fileCode, string fileID, MieProduct.NLanguageType languageType, long updatedAt) { this.FileCode = fileCode; this.FileID = fileID; this.LanguageType = languageType; this.UpdateAt = new DateTime(updatedAt); }
/// <summary> /// コンストラクタ。 /// 新規作成用 /// </summary> /// <param name="fileID">FileID</param> /// <param name="fileCode">FileCode</param> /// <param name="languageType">LanguageType</param> public MieFileEntry(string fileID, long fileCode, MieProduct.NLanguageType languageType) { this.FileCode = fileCode; this.FileID = fileID; this.LanguageType = languageType; this.UpdateAt = DateTime.UtcNow; }
/// <summary> /// 指定した製品区分の言語エントリー数を返す。 /// </summary> /// <param name="nProductLine">製品区分</param> /// <param name="nLanguageType">言語区分</param> /// <returns>言語エントリー数</returns> public int GetEntryCount(MieProduct.NProductLine nProductLine, MieProduct.NLanguageType nLanguageType) { var count = this.Items .SelectMany((x) => x.Value.Items) .Count((x) => x.ProductLine.HasFlag(nProductLine)); return(count); }
public void LoadFromFolder( string folderPath, MieProduct.NProductLine productLine, MieProduct.NLanguageType languageType, MieFileList fileList) { this.languageInfo = MieStringTableDao.LoadFromFolder( folderPath, productLine, languageType, fileList); Console.WriteLine(this.languageInfo.FileCount); }
public int GetEntryCount(MieProduct.NProductLine productLine, MieProduct.NLanguageType languageType, bool ommitEmpty) { var total = 0; this.Items.Values .ToList() .ForEach(x => { total += x.GetEntryCount(productLine, languageType, ommitEmpty); }); return(total); }
public string GetSearchText(string text, MieProduct.NLanguageType languageType) { var key = this.GetDiscardedText(text); switch (languageType) { case MieProduct.NLanguageType.Chatter: throw new NotImplementedException(); case MieProduct.NLanguageType.Conversations: if (this.SearchConvItems.ContainsKey(key)) { return(this.SearchConvItems[key].DefaultTranslationText); } else if (this.SearchGameItems.ContainsKey(key)) { return(this.SearchGameItems[key].DefaultTranslationText); } else { return(null); } case MieProduct.NLanguageType.Game: if (this.SearchConvItems.ContainsKey(key)) { return(this.SearchGameItems[key].DefaultTranslationText); } else { return(null); } case MieProduct.NLanguageType.Quests: if (this.SearchQuestsItems.ContainsKey(key)) { return(this.SearchQuestsItems[key].DefaultTranslationText); } else if (this.SearchGameItems.ContainsKey(key)) { return(this.SearchGameItems[key].DefaultTranslationText); } else { return(null); } default: throw new Exception($"Unknown LanguageType({languageType})."); } }
/// <summary> /// FileIDとHashを登録する。 /// </summary> /// <param name="fileID">FileID</param> /// <param name="fileCode">FileCode</param> /// <param name="languageType">言語区分</param> public void AddEntryByFileIdAndFileCode(string fileID, long fileCode, MieProduct.NLanguageType languageType) { MieFileEntry mieFileEntry = new MieFileEntry(fileID, fileCode, languageType); if (this.Items.ContainsKey(mieFileEntry.FileCode)) { var msg = $"Duplicate fileID({fileCode}). Hash({mieFileEntry.FileCode})"; logger.Warn(msg); } else { this.Items.Add(mieFileEntry.FileCode, mieFileEntry); } }
/// <summary> /// 指定した製品区分のファイル数を返す。 /// </summary> /// <param name="nProductLine">製品区分</param> /// <param name="nLanguageType">言語区分</param> /// <returns>ファイル数</returns> public int GetFileCount(MieProduct.NProductLine nProductLine, MieProduct.NLanguageType nLanguageType) { int fileCount = 0; foreach (var file in this.Items.Values) { if (file.GetEntryCount(nProductLine, nLanguageType) > 0) { fileCount++; } } return(fileCount); }
/// <summary> /// 指定した製品区分の言語エントリー数を返す。 /// </summary> /// <param name="nProductLine">製品区分</param> /// <param name="nLanguageType">言語区分</param> /// <param name="ommitEmpty">空文をスキップする</param> /// <returns>言語エントリー数</returns> public int GetEntryCount(MieProduct.NProductLine nProductLine, MieProduct.NLanguageType nLanguageType, bool ommitEmpty = false) { var total = 0; if (ommitEmpty) { total = this.items.Values.Count( (x) => ( x.ProductLine.HasFlag(nProductLine) && !string.IsNullOrWhiteSpace(x.DefaultText))); } else { total = this.items.Values.Count( (x) => x.ProductLine.HasFlag(nProductLine)); } return(total); }
public static MieLanguageInfo LoadFromFolder( string folderPath, MieProduct.NProductLine productLine, MieProduct.NLanguageType languageType, MieFileList fileList) { var mieLanguageInfo = new MieLanguageInfo(); string[] files = Directory.GetFiles(folderPath, "*.stringtable", SearchOption.AllDirectories); files .Where(file => Path.GetExtension(file).ToLower() == ".stringtable") .ToList() .ForEach(x => { var fileID = string.Empty; var languageFile = LoadFromXml(x, productLine, out fileID); //// 言語情報の登録 mieLanguageInfo.AddFile(languageFile, false); //// FileListの作成 fileList.AddEntryByFileIdAndFileCode(fileID, languageFile.FileCode, languageType); }); return(mieLanguageInfo); }
public static MieFileList LoadFromSystemDB(MieSystemDB systemDB) { MieFileList fileList = new MieFileList(); SQLiteCommand command = systemDB.Connection.CreateCommand(); command.CommandText = @"SELECT * FROM FileList;"; using (SQLiteDataReader sdr = command.ExecuteReader()) { while (sdr.Read() == true) { var fileCode = (long)sdr["FileCode"]; var fileID = (string)sdr["FileID"]; var xLanguageType = (int)(long)sdr["LanguageType"]; var updatedAt = (long)sdr["UpdatedAt"]; MieProduct.NLanguageType languageType = (MieProduct.NLanguageType)Enum.ToObject(typeof(MieProduct.NLanguageType), xLanguageType); MieFileEntry fileEntry = new MieFileEntry(fileCode, fileID, languageType, updatedAt); fileList.AddEntry(fileEntry); } } return(fileList); }
public static void MargeFromFolder(MieLanguageInfo mieLanguageInfo, string folderPath, MieProduct.NProductLine productLine, MieProduct.NLanguageType languageType) { if (!Directory.Exists(folderPath)) { var msg = $"Warning: Folder not exists. Folder({folderPath})"; logger.Warn(msg); Console.WriteLine(msg); return; } string[] files = Directory.GetFiles(folderPath, "*.stringtable", SearchOption.AllDirectories); files .Where(file => Path.GetExtension(file).ToLower() == ".stringtable") .ToList() .ForEach(x => { var fileID = string.Empty; var languageFile = LoadFromXml(x, productLine, out fileID); mieLanguageInfo.AddFile(languageFile, true); }); }
/// <summary> /// 言語DBの初期化とDB化。 /// </summary> /// <param name="systemDb">データベース接続情報</param> /// <param name="langPath">言語情報フォルダーのパス</param> /// <param name="productLine">製品区分</param> /// <param name="languageType">言語区分</param> /// <param name="fileList">FileList</param> public void ConvertLanguage(MieSystemDB systemDb, string langPath, MieProduct.NProductLine productLine, MieProduct.NLanguageType languageType, MieFileList fileList) { if (!Directory.Exists(langPath)) { var msg = $"Directory not found({langPath})."; if (productLine == MieProduct.NProductLine.Vanilla) { logger.Error(msg); throw new DirectoryNotFoundException(msg); } else { logger.Warn(msg); Console.WriteLine(msg); return; } } //// 話者情報の読み込みとFileListの作成。 var langInfo = MieStringTableDao.LoadFromFolder(langPath, productLine, languageType, fileList); if (this.LanguageInfo == null) { this.LanguageInfo = langInfo; } else { foreach (var langFile in langInfo.Items.Values) { this.LanguageInfo.AddFile(langFile, true); } } }