private void ReadStatistics() { try { foreach (string str in from line in File.ReadLines(base.StatFile) where !string.IsNullOrEmpty(line) select line) { IStatsDataSource item = this.ParseLine(str.Trim()); item.RecordTime = DateTime.Now; item.GameFileID = this.m_gameFile.GameFileID.Value; if (!this.m_statistics.Contains(item)) { this.m_statistics.Add(item); if (this.NewStastics != null) { this.NewStastics(this, new NewStatisticsEventArgs(item)); } } } } catch (FileNotFoundException exception) { base.m_errors.Add($"The file {exception.FileName} was not found and could not be parsed."); } }
public void InsertStats(IStatsDataSource ds) { List <DbParameter> list; string[] exclude = new string[] { "StatID", "SaveFile" }; string sql = this.InsertStatement("Stats", ds, exclude, out list); this.DataAccess.ExecuteNonQuery(sql, list); }
public override bool Equals(object obj) { IStatsDataSource source = obj as IStatsDataSource; if (source == null) { return(false); } return(((((this.GameFileID == source.GameFileID) && (this.KillCount == source.KillCount)) && ((this.TotalKills == source.TotalKills) && (this.SecretCount == source.SecretCount))) && (((this.TotalSecrets == source.TotalSecrets) && (this.ItemCount == source.ItemCount)) && ((this.TotalItems == source.TotalItems) && (this.LevelTime == source.LevelTime)))) && (this.MapName.ToLower() == source.MapName.ToLower())); }
public bool Delete() { if ((this.dgvMain.SelectedRows.Count <= 0) || (MessageBox.Show(this, "Delete selected statistic(s)?", "Confirm", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) != DialogResult.OK)) { return(false); } foreach (DataGridViewRow row in this.dgvMain.SelectedRows) { IStatsDataSource statsFromGridRow = this.GetStatsFromGridRow(row); this.DataSourceAdapter.DeleteStats(statsFromGridRow.StatID); } return(true); }
public void SetStatistics(IEnumerable <IStatsDataSource> stats) { StatsDataSource source = new StatsDataSource(); foreach (IStatsDataSource source2 in stats) { source.KillCount += source2.KillCount; source.TotalKills += source2.TotalKills; source.SecretCount += source2.SecretCount; source.TotalSecrets += source2.TotalSecrets; source.ItemCount += source2.ItemCount; source.TotalItems += source2.TotalItems; source.LevelTime += source2.LevelTime; } this.m_stats = source; }
private void ReadStatistics() { try { string format = @"#+\w+#+Time:\d+:\d+.\d+Kills:\d+/\d+#+Items:\d+/\d+Secrets:\d+/\d+"; MatchCollection matchs = Regex.Matches(File.ReadAllText(base.StatFile).Replace(" ", string.Empty).Replace(Environment.NewLine, string.Empty), string.Format(format, new object[0]), RegexOptions.Singleline); foreach (Match match in matchs) { IStatsDataSource item = null; if (match.Success) { item = this.ParseLine(match.Value); } if (item != null) { item.RecordTime = DateTime.Now; item.GameFileID = this.m_gameFile.GameFileID.Value; if (!this.m_statistics.Contains(item)) { this.m_statistics.Add(item); if (this.NewStastics != null) { this.NewStastics(this, new NewStatisticsEventArgs(item)); } } } } if (matchs.Count == 0) { base.m_errors.Add($"The file {base.StatFile} did not contain any statistics information."); } } catch (FileNotFoundException exception) { base.m_errors.Add($"The file {exception.FileName} was not found and could not be parsed."); } catch (Exception exception2) { base.m_errors.Add($"Unexpected exception: {exception2.Message}{Environment.NewLine}{exception2.StackTrace}"); } }
public void InsertStats(IStatsDataSource ds) { throw new NotImplementedException(); }
public NewStatisticsEventArgs(IStatsDataSource stats) { this.Statistics = stats; this.Update = false; }
public NewStatisticsEventArgs(IStatsDataSource stats, bool update) { this.Statistics = stats; this.Update = update; }
public StatsBind(string map, string kills, string secrets, string items, TimeSpan time, DateTime recordtime, string sourceport, IStatsDataSource statsdatasource) { this.MapName = map; this.FormattedKills = kills; this.FormattedSecrets = secrets; this.FormattedItems = items; this.FormattedTime = time; this.RecordTime = recordtime; this.SourcePort = sourceport; this.StatsDataSource = statsdatasource; }