private void TriggerUpdateOnTeamRunners(string className, string teamName, int leg) { TeamHolder team = m_cache[className][teamName]; ClassConfiguration classConfig = Configuration.GetClassConfiguration(className); foreach (var legItem in team.Legs.Where(x => x.Leg >= leg)) { var res = new Result { Class = className + "-" + legItem.Leg, ID = legItem.DbId, RunnerClub = teamName, RunnerName = legItem.RunnerName, SplitTimes = GetSplitTimes(team, legItem, classConfig), StartTime = legItem.StartTime, }; res.Status = m_cache[className][teamName].GetTeamTotalStatusAfterLeg(legItem.Leg); if (legItem.Status == 10) { res.Status = 10; } if (res.Status != 0) { res.Time = -1 * res.Status; } else { res.Time = team.GetTeamTotalTimeAfterLeg(legItem.Leg, classConfig); var legRunners = team.Legs.Where(x => x.Leg == legItem.Leg && x.Status == 0); if (legRunners.Count() > 1) { res.Time += (legItem.Time - legRunners.Min(x => x.Time)); } } OnResultChanged(res); } }
private List <ResultStruct> GetSplitTimes(TeamHolder team, TeamLegHolder legItem, ClassConfiguration classConfig) { if (legItem.Splits == null) { return(null); } List <ResultStruct> ret = new List <ResultStruct>(); for (int i = 0; i < legItem.Splits.Count(); i++) { ret.Add(new ResultStruct() { ControlCode = legItem.Splits[i].controlCode + 1000 * legItem.Splits[i].passingNumber, Time = legItem.Splits[i].time + team.GetTeamTotalTimeAfterLeg(legItem.Leg - 1, classConfig) }); } return(ret); }