void ExportCategory(EventType evt) { string headers; List <TimelineEvent> plays; output.Add("CATEGORY: " + evt.Name); plays = project.EventsByType(evt); /* Write Headers for this category */ headers = "Name;Time;Start;Stop;Team;Player"; if (evt is ScoreEventType) { headers += ";Score"; } if (evt is AnalysisEventType) { foreach (Tag tag in (evt as AnalysisEventType).Tags) { headers += String.Format(";{0}", tag.Value); } } output.Add(headers); foreach (LMTimelineEvent play in plays.OrderBy(p => p.Start)) { string line; line = String.Format("{0};{1};{2};{3};{4};{5}", play.Name, play.EventTime == null ? "" : play.EventTime.ToMSecondsString(), play.Start.ToMSecondsString(), play.Stop.ToMSecondsString(), TeamName(play.Teams.Cast <LMTeam> ().ToList()), String.Join(" | ", play.Players)); if (evt is ScoreEventType) { line += ";" + (evt as ScoreEventType).Score.Points; } /* Strings Tags */ if (evt is AnalysisEventType) { foreach (Tag tag in (evt as AnalysisEventType).Tags) { line += ";" + (play.Tags.Contains(tag) ? "1" : "0"); } } output.Add(line); } output.Add(""); }
public void Update_WithCommonTags() { LMProject project = Utils.CreateProject(); EventType evtType = project.EventTypes [0]; var evt = project.EventsByType(evtType) [0]; evt.Tags.Add(project.Dashboard.CommonTagsByGroup.Values.First() [0]); EventTypeStats stats = new EventTypeStats(project, new EventsFilter(project), evtType); stats.Update(); Assert.AreEqual(1, stats.TotalCount); Assert.AreEqual(2, stats.SubcategoriesStats.Count); Assert.AreEqual("", stats.SubcategoriesStats [1].Name); }
public void Update() { List <TimelineEvent> originalEventsByType = project.EventsByType(eventType); var eventsByType = new List <LMTimelineEvent> (); foreach (var eventType in originalEventsByType) { eventsByType.Add(eventType as LMTimelineEvent); } events = eventsByType.Where(filter.IsVisible).ToList(); homeEvents = events.Where(e => e.Teams.Contains(project.LocalTeamTemplate) || e.Players.Intersect(project.LocalTeamTemplate.List).Any()).ToList(); awayEvents = events.Where(e => e.Teams.Contains(project.VisitorTeamTemplate) || e.Players.Intersect(project.VisitorTeamTemplate.List).Any()).ToList(); TotalCount = events.Count; LocalTeamCount = homeEvents.Count; VisitorTeamCount = awayEvents.Count; SubcategoriesStats = new List <SubCategoryStat> (); if (eventType is AnalysisEventType) { var tagsByGroup = (eventType as AnalysisEventType).TagsByGroup; foreach (string grp in tagsByGroup.Keys) { SubCategoryStat substat = new SubCategoryStat(grp); foreach (Tag t in tagsByGroup[grp]) { int count, localTeamCount, visitorTeamCount; count = events.Count(e => e.Tags.Contains(t)); localTeamCount = homeEvents.Count(e => e.Tags.Contains(t)); visitorTeamCount = awayEvents.Count(e => e.Tags.Contains(t)); PercentualStat pStat = new PercentualStat(t.Value, count, localTeamCount, visitorTeamCount, TotalCount); substat.OptionStats.Add(pStat); } SubcategoriesStats.Add(substat); } } }
public void Update() { List <TimelineEvent> originalEventsByType = project.EventsByType(eventType); var eventsByType = new List <LMTimelineEvent> (); foreach (var eventType in originalEventsByType) { eventsByType.Add(eventType as LMTimelineEvent); } events = eventsByType.Where(filter.IsVisible).ToList(); homeEvents = events.Where(e => e.Teams.Contains(project.LocalTeamTemplate) || e.Players.Intersect(project.LocalTeamTemplate.List).Any()).ToList(); awayEvents = events.Where(e => e.Teams.Contains(project.VisitorTeamTemplate) || e.Players.Intersect(project.VisitorTeamTemplate.List).Any()).ToList(); TotalCount = events.Count; LocalTeamCount = homeEvents.Count; VisitorTeamCount = awayEvents.Count; SubcategoriesStats = new List <SubCategoryStat> (); if (eventType is AnalysisEventType) { CreateGroupStats((eventType as AnalysisEventType).TagsByGroup); CreateGroupStats(project.Dashboard.CommonTagsByGroup, false); } }
void UpdateTimePlayed() { LineupEvent lineup = project.Lineup; List <SubstitutionEvent> subs; Time start; List <TimeNode> timenodes, playingTimeNodes; TimeNode last; subs = project.EventsByType(project.SubstitutionsEventType). Where(s => !(s is LineupEvent) && ((s as SubstitutionEvent).In == Player || (s as SubstitutionEvent).Out == Player)) .OrderBy(e => e.EventTime).Select(e => e as SubstitutionEvent).ToList(); if (lineup.AwayStartingPlayers.Contains(Player) || lineup.HomeStartingPlayers.Contains(Player)) { start = lineup.EventTime; } else { SubstitutionEvent sub = subs.Where(s => s.In == Player).FirstOrDefault(); if (sub == null) { TimePlayed = new Time(0); return; } else { start = sub.EventTime; } } timenodes = new List <TimeNode> (); /* Find the sequences of playing time */ last = new TimeNode { Start = start }; timenodes.Add(last); if (subs.Count == 0) { last.Stop = project.Description.FileSet.Duration; } else { foreach (SubstitutionEvent sub in subs) { if (last.Stop == null) { if (sub.Out == Player) { last.Stop = sub.EventTime; } } else { if (sub.In == Player) { last = new TimeNode { Start = sub.EventTime }; timenodes.Add(last); } } } } /* If the last substitution was Player IN */ if (last.Stop == null) { last.Stop = project.Description.FileSet.Duration; } playingTimeNodes = new List <TimeNode> (); /* Get the real playing time intersecting with the periods */ foreach (TimeNode timenode in timenodes) { foreach (Period p in project.Periods) { if (p.PeriodNode.Intersect(timenode) != null) { foreach (TimeNode ptn in p.Nodes) { TimeNode res = ptn.Intersect(timenode); if (res != null) { playingTimeNodes.Add(res); } } } } } TimePlayed = new Time(playingTimeNodes.Sum(t => t.Duration.MSeconds)); }