public static BeginTransaction ( ) : System.Data.SQLite.SQLiteTransaction | ||
return | System.Data.SQLite.SQLiteTransaction |
public static void deleteCreatureFromLog(Creature cr) { lock (hunts) { if (activeHunt.loot.killCount.ContainsKey(cr)) { activeHunt.loot.killCount.Remove(cr); } if (activeHunt.loot.creatureLoot.ContainsKey(cr)) { activeHunt.loot.creatureLoot.Remove(cr); } using (var transaction = LootDatabaseManager.BeginTransaction()) { foreach (KeyValuePair <string, List <string> > kvp in activeHunt.loot.logMessages) { foreach (string msg in kvp.Value) { if (Parser.ParseCreatureFromLootMessage(msg) == cr) { LootDatabaseManager.DeleteMessage(activeHunt, msg, transaction); } } } transaction.Commit(); } } LootDatabaseManager.UpdateLoot(); }
public static void ParseLootMessages(Hunt h, Dictionary <string, List <string> > newDrops, List <Tuple <Creature, List <Tuple <Item, int> >, string> > newItems, bool commit = true, bool switchHunt = false, bool addEverything = false) { SQLiteTransaction transaction = null; if (commit) { transaction = LootDatabaseManager.BeginTransaction(); } int stamp = TimestampManager.getDayStamp(); Dictionary <string, List <string> > itemDrops = addEverything ? new Dictionary <string, List <string> >() : globalMessages; // now the big one: parse the log messages and check the dropped items foreach (KeyValuePair <string, List <string> > kvp in newDrops) { string t = kvp.Key; List <string> itemList = kvp.Value; if (!itemDrops.ContainsKey(t)) { itemDrops.Add(t, new List <string>()); } if (itemList.Count > itemDrops[t].Count) { int hour = int.Parse(t.Substring(0, 2)); int minute = int.Parse(t.Substring(3, 2)); foreach (string message in itemList) { if (!itemDrops[t].Contains(message)) { // new log message, scan it for new items Tuple <Creature, List <Tuple <Item, int> > > resultList = ParseLootMessage(message); if (resultList == null) { continue; } Creature cr = resultList.Item1; if (switchHunt && commit) { h = HuntManager.CheckTrackedHunts(h, resultList, t, message, stamp, hour, minute, transaction); } HuntManager.AddKillToHunt(h, resultList, t, message, stamp, hour, minute, transaction); if (newItems != null && MainForm.fileWriter != null && SettingsManager.getSettingBool("AutomaticallyWriteLootToFile")) { MainForm.fileWriter.WriteLine(message); MainForm.fileWriter.Flush(); } if (newItems != null) { newItems.Add(new Tuple <Creature, List <Tuple <Item, int> >, string>(resultList.Item1, resultList.Item2, message)); } } else { itemDrops[t].Remove(message); } } itemDrops[t] = itemList; } } if (transaction != null) { transaction.Commit(); } }