public WeaponUserListModel(User user, WeaponGlobal weapon) { User = user ?? throw new ArgumentNullException(nameof(user)); Weapon = weapon ?? throw new ArgumentNullException(nameof(weapon)); foreach (var g in Weapon.Games) { DataProvider.CompleteGame(g); } UpdateDamageData(); }
public WeaponGlobalModel(WeaponGlobal obj) { Weapon = obj ?? throw new ArgumentNullException(nameof(obj)); DisplayName = DisplayStringFactory.AssetName(Weapon.Name); UpdateCollectionsSafe(); }
private void InternalCommit(IEnumerable <ILogEntry> delta) { if (delta == null) { return; } bool hasFinish = false; using (var en = delta.GetEnumerator()) { while (en.MoveNext()) { if (en.Current.TimeStamp > LogEntryTimeStampLowerLimit) { LogEntryTimeStampLowerLimit = en.Current.TimeStamp; } if (en.Current is LevelLoad ll) { if (yield) { if (!hasFinish) { gameLog.Add(DummyGameFinish(gameLog[gameLog.Count - 1].TimeStamp + 1)); } FinalizeGameLog(); } yield = !IgnoreLevel(ll); hasFinish = false; } if (yield) { gameLog.Add(en.Current); if (en.Current is GameFinish) { hasFinish = true; } } } } if (games.Count != 0) //games were finished in the added logs { var users = User.Parse(games); var weapons = WeaponGlobal.ParseWeapons(games); using (var statCon = new StatisticsConnection()) { using (var trans = statCon.BeginTransaction()) { statCon.Insert(games); trans.Commit(); } using (var trans = statCon.BeginTransaction()) { for (int i = 0; i < users.Count; i++) { statCon.UpdateUser(users[i]); } trans.Commit(); } using (var trans = statCon.BeginTransaction()) { for (int i = 0; i < weapons.Count; i++) { statCon.UpdateWeaponGlobal(weapons[i]); } trans.Commit(); } } if (OperatingMode == UploaderOperatingMode.Incremental) { var userIDs = users.Select(x => x.UserID); var weaponNames = weapons.Select(x => x.Name); var maps = games.Select(x => x.Map.Name).Distinct(); //send event invalidating changed data logger.Info("Invalidate existing data. {0} different maps played. {1} user changed. {2} weapons changed.", maps.Count(), userIDs.Count(), weapons.Count()); InvalidateCachedData?.Invoke(this, new InvalidateCachedDataEventArgs(userIDs, weaponNames, maps)); } games.Clear(); } }