/// <summary> /// Sets the "last database update" timestamp to 0 to force an update /// Queues a database update, followed by an item stat update. /// </summary> public void ForceDatabaseUpdate(string location, bool isVanilla) { // Override timestamp to force an update _databaseSettingDao.UpdateDatabaseTimestamp(0); var paths = GrimDawnDetector.GetGrimLocations(); if (!string.IsNullOrEmpty(location) && Directory.Exists(location) && _arzParser.NeedUpdate(location)) { ParsingDatabaseScreen parser = new ParsingDatabaseScreen( _databaseSettingDao, _arzParser, location, Properties.Settings.Default.LocalizationFile, false, !isVanilla); parser.ShowDialog(); //databaseSettingDao.UpdateCurrentDatabase(location); UpdateListview(paths); } else { Logger.Warn("Could not find the Grim Dawn install location"); } // Update item stats as well UpdatingPlayerItemsScreen x = new UpdatingPlayerItemsScreen(_playerItemDao); x.ShowDialog(); if (_itemViewUpdateTrigger != null) { _itemViewUpdateTrigger(); } }
public void UpdateDatabaseTimestamp(long ts) { ThreadExecuter.Execute( () => repo.UpdateDatabaseTimestamp(ts) ); }
/// <summary> /// Parses the data from Grim Dawn (arz and arc files) /// If the supplied location is a mod, supply whetever its an addative or a replacement for the original database. /// Eg, should it clear the existing database upon insert, or add/replace? /// The prior is faster, but will not work for mods with a partial database. /// </summary> /// <param name="grimdawnLocation"></param> /// <param name="localizationFile"></param> /// <param name="expansionOnlyMod">Whetever this mod only expands upon EXISTING content</param> public void LoadArzDb(string grimdawnLocation, string localizationFile, bool expansionOnlyMod) { try { // Init & abort if not needed Logger.InfoFormat("Parse Arz/Arc, Location: \"{0}\", Additive: {1}, ClearFix: {2}", grimdawnLocation, expansionOnlyMod, !expansionOnlyMod); string databaseFile = FindArzFile(grimdawnLocation); //string expansionDatabaseFile = FindArzFile(Path.Combine(grimdawnLocation, "gdx1")); string arcTagfile = FindArcFile(grimdawnLocation, "text_en.arc"); var arcItemsFile = FindArcFile(grimdawnLocation, "items.arc"); if (string.IsNullOrEmpty(arcTagfile) || string.IsNullOrEmpty(arcItemsFile) || string.IsNullOrEmpty(databaseFile)) { Logger.FatalFormat( "Unable to parse the Grim Dawn database, could not find the relevant files at {0}", grimdawnLocation); return; } //long lastExpansionModified = string.IsNullOrEmpty(expansionDatabaseFile) ? 0 : File.GetLastWriteTime(expansionDatabaseFile).Ticks; long lastModified = File.GetLastWriteTime(databaseFile).Ticks; Logger.Info("Updating..."); var mappedTags = LoadTags(arcTagfile, localizationFile, expansionOnlyMod); // Process the items loaded var skipLots = true; List <IItem> _items = Parser.Arz.ArzParser.LoadItemRecords(databaseFile, skipLots); // TODO int x = 9; { List <DatabaseItem> items = new List <DatabaseItem>(); foreach (IItem item in _items) { items.Add(new DatabaseItem { Record = item.Record, Stats = item.Stats.Select(map).ToList() }); } // Map the name using the name _tags MapItemNames(items, mappedTags); RenamePetStats(items); // Add skill accumulation _skills.AddRange(items.Where(m => m.Record.Contains("/skills/"))); var specialStats = CreateSpecialRecords(items, mappedTags); Logger.Info($"Mapped {specialStats.Count()} special stats"); Logger.Info("Storing items to database.."); // Store to DB (cache) if (expansionOnlyMod) { _databaseItemDao.SaveOrUpdate(items); } else { // Deletes all existing data and saves new _databaseItemDao.Save(items); Logger.InfoFormat("Stored {0} items and {1} stats to internal db.", items.Count, -1); } _databaseItemStatDao.Save(specialStats); Logger.Debug("Special stats saved to DB"); // Obs: Do this after storing items as the item IDs changes var skillParser = new ComplexItemParser(_items, mappedTags); skillParser.Generate(); _itemSkillDao.Save(skillParser.Skills, expansionOnlyMod); _itemSkillDao.Save(skillParser.SkillItemMapping, expansionOnlyMod); _databaseSettingDao.UpdateDatabaseTimestamp(lastModified); LoadIcons(arcItemsFile); _itemSkillDao.EnsureCorrectSkillRecords(); } } catch (AggregateException ex) { Logger.Warn("System.AggregateException waiting for tasks, throwing first exception."); foreach (var inner in ex.InnerExceptions) { Logger.Warn(inner.Message); Logger.Warn(inner.StackTrace); //ExceptionReporter.ReportException(inner, "[AggregateException]", true); if (inner.InnerException != null) { Logger.Warn(inner.InnerException.Message); Logger.Warn(inner.InnerException.StackTrace); } } ex.Handle(x => { throw x; }); } }