Exemplo n.º 1
0
 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.");
     }
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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()));
        }
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 5
0
        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;
        }
Exemplo n.º 6
0
 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}");
     }
 }
Exemplo n.º 7
0
 public void InsertStats(IStatsDataSource ds)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 8
0
 public NewStatisticsEventArgs(IStatsDataSource stats)
 {
     this.Statistics = stats;
     this.Update     = false;
 }
Exemplo n.º 9
0
 public NewStatisticsEventArgs(IStatsDataSource stats, bool update)
 {
     this.Statistics = stats;
     this.Update     = update;
 }
Exemplo n.º 10
0
 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;
 }