private static void init() { if (mapDB2 == null) { var m_definitions = DBFilesClient.Load(Application.StartupPath + @"\Data\DBFilesClient\dblayout.xml"); var definitions = m_definitions.Tables.Where(t => t.Name == "Map"); if (!definitions.Any()) { definitions = m_definitions.Tables.Where(t => t.Name == Path.GetFileName("Map")); } if (definitions.Count() == 1) { var table = definitions.First(); mapDB2 = DBReaderFactory.GetReader(Application.StartupPath + @"\Data\DBFilesClient\Map.db2", table) as DB6Reader; if (_cachedMapRows == null || _cachedRecords == null) { if (mapDB2 != null) { _cachedMapRows = mapDB2.Rows.ToArray(); _cachedRecords = new MapDbcRecord[_cachedMapRows.Length]; for (int i = 0; i < _cachedMapRows.Length - 1; i++) { _cachedRecords[i] = DB6Reader.ByteToType <MapDbcRecord>(_cachedMapRows[i]); } } } Logging.Write(mapDB2.FileName + " loaded with " + mapDB2.RecordsCount + " entries."); } else { Logging.Write("DB2 Map not read-able."); } } }
public static DBFilesClient Load(string path) { XmlSerializer deser = new XmlSerializer(typeof(DBFilesClient)); using (var fs = new FileStream(path, FileMode.Open)) { DBFilesClient cat = (DBFilesClient)deser.Deserialize(fs); cat.File = path; return(cat); } }
public static void Save(DBFilesClient db) { string dir = Path.GetDirectoryName(db.File); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } XmlSerializer ser = new XmlSerializer(typeof(DBFilesClient)); XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces(); namespaces.Add(string.Empty, string.Empty); using (var fs = new FileStream(db.File, FileMode.Create)) ser.Serialize(fs, db, namespaces); }
private static void init() { if (_rSiteDB2 == null) { var mDefinitions = DBFilesClient.Load(Application.StartupPath + @"\Data\DBFilesClient\dblayout.xml"); var definitions = mDefinitions.Tables.Where(t => t.Name == "ResearchSite"); if (!definitions.Any()) { definitions = mDefinitions.Tables.Where(t => t.Name == Path.GetFileName("ResearchSite")); } if (definitions.Count() == 1) { var table = definitions.First(); if (Usefuls.GetClientLanguage().Length == 4) { _rSiteDB2 = DBReaderFactory.GetReader(Application.StartupPath + @"\Data\DBFilesClient\" + Usefuls.GetClientLanguage() + @"\ResearchSite.db2", table) as DB6Reader; } else { _rSiteDB2 = DBReaderFactory.GetReader(Application.StartupPath + @"\Data\DBFilesClient\AllWoW\ResearchSite.db2", table) as DB6Reader; } if (_cachedResearchSiteRows == null || _cachedRecords == null) { if (_rSiteDB2 != null) { _cachedResearchSiteRows = _rSiteDB2.Rows.ToArray(); _cachedRecords = new ResearchSiteDb2Record[_cachedResearchSiteRows.Length]; for (int i = 0; i < _cachedResearchSiteRows.Length - 1; i++) { _cachedRecords[i] = DB6Reader.ByteToType <ResearchSiteDb2Record>(_cachedResearchSiteRows[i]); } } } Logging.Write(_rSiteDB2.FileName + " loaded with " + _rSiteDB2.RecordsCount + " entries."); } else { Logging.Write("DB2 ResearchSite not read-able."); } } }
private static void Init() // todo make DBC loading shared accross all others reads with a better loading class. { if (_spellCategoriesDb2 == null) { var mDefinitions = DBFilesClient.Load(Application.StartupPath + @"\Data\DBFilesClient\dblayout.xml"); var definitions = mDefinitions.Tables.Where(t => t.Name == "SpellCategories"); if (!definitions.Any()) { definitions = mDefinitions.Tables.Where(t => t.Name == Path.GetFileName("SpellCategories")); } if (definitions.Count() == 1) { var table = definitions.First(); _spellCategoriesDb2 = DBReaderFactory.GetReader(Application.StartupPath + @"\Data\DBFilesClient\SpellCategories.db2", table) as DB6Reader; if (_cachedSpellCategoriesRows == null || _cachedRecords == null) { if (_spellCategoriesDb2 != null) { _cachedSpellCategoriesRows = _spellCategoriesDb2.Rows.ToArray(); _cachedRecords = new SpellCategoriesDbcRecord[_cachedSpellCategoriesRows.Length]; for (int i = 0; i < _cachedSpellCategoriesRows.Length - 1; i++) { _cachedRecords[i] = DB6Reader.ByteToType <SpellCategoriesDbcRecord>(_cachedSpellCategoriesRows[i]); } } } if (_spellCategoriesDb2 != null) { Logging.Write(_spellCategoriesDb2.FileName + " loaded with " + _spellCategoriesDb2.RecordsCount + " entries."); } } else { Logging.Write("DB2 SpellCategories not read-able."); } } }
private static void Init() { if (_lockDB2 == null) { var mDefinitions = DBFilesClient.Load(Application.StartupPath + @"\Data\DBFilesClient\dblayout.xml"); var definitions = mDefinitions.Tables.Where(t => t.Name == "Lock"); if (!definitions.Any()) { definitions = mDefinitions.Tables.Where(t => t.Name == Path.GetFileName("Lock")); } if (definitions.Count() == 1) { var table = definitions.First(); _lockDB2 = DBReaderFactory.GetReader(Application.StartupPath + @"\Data\DBFilesClient\Lock.db2", table) as DB6Reader; Logging.Write(_lockDB2.FileName + " loaded with " + _lockDB2.RecordsCount + " entries."); } else { Logging.Write("DB2 Lock not read-able."); } } }
private static void Init() // todo make DBC loading shared accross all others reads with a better loading class. { if (_itemClassDB2 == null) { var mDefinitions = DBFilesClient.Load(Application.StartupPath + @"\Data\DBFilesClient\dblayout.xml"); var definitions = mDefinitions.Tables.Where(t => t.Name == "ItemClass"); if (!definitions.Any()) { definitions = mDefinitions.Tables.Where(t => t.Name == Path.GetFileName("ItemClass")); } if (definitions.Count() == 1) { var table = definitions.First(); _itemClassDB2 = DBReaderFactory.GetReader(Application.StartupPath + @"\Data\DBFilesClient\ItemClass.db2", table) as DB6Reader; Logging.Write(_itemClassDB2.FileName + " loaded with " + _itemClassDB2.RecordsCount + " entries."); } else { Logging.Write("DB2 ItemClass not read-able."); } } }