示例#1
0
 private void UpdateCurrentResultList()
 {
     if (m_resultPosition == 1000)
     {
         m_currentResultList = m_emmaMysqlClient.GetRunnersInClass(m_className)
                               .Where(x => x.Status != 9 && x.Status != 10 && x.Time > 0).OrderBy(x => x.Status).ThenBy(x => x.Time).Select(
             x => new ResultListItem
         {
             Runner = x,
             Status = x.Status,
             Time   = x.Time
         }).ToArray();
     }
     else
     {
         m_currentResultList = m_emmaMysqlClient.GetRunnersInClass(m_className)
                               .Where(x => x.SplitTimes != null && x.SplitTimes.Any(y => y.Control == m_resultPosition))
                               .OrderBy(x => x.SplitTimes.First(y => y.Control == m_resultPosition).Time)
                               .Select(x => new ResultListItem
         {
             Runner = x,
             Status = 0,
             Time   = x.SplitTimes.First(y => y.Control == m_resultPosition).Time
         }).ToArray();
     }
 }
示例#2
0
        protected override void SetData(CasparCGDataCollection cgData)
        {
            m_nextForcedUpdate = DateTime.MaxValue;
            cgData.SetData("title", "Förvarnade");
            int follIdx = 0;

            //Finished within 10sek
            var  curRealTime = DateTime.Now.Hour * 360000 + DateTime.Now.Minute * 6000 + DateTime.Now.Second * 100;
            bool hadRunnerFinishedWithin10sek = false;

            foreach (var prewarned in m_emmaMysqlClient.GetAllRunners()
                     .Where(x => x.Time > 0 && (x.StartTime + x.Time) > curRealTime - 10 * 100 && x.Status == 0)
                     .OrderBy(x => x.StartTime + x.Time))
            {
                int startTime = prewarned.StartTime;
                if ((curRealTime - 10 * 100) > startTime + prewarned.Time)
                {
                    continue;
                }

                var betterResInclass = m_emmaMysqlClient.GetRunnersInClass(prewarned.Class)
                                       .Where(x => x.Time > 0 && x.Time < prewarned.Time && x.Status == 0).OrderBy(x => x.Time).ToArray();
                var leader = betterResInclass.Any() ? betterResInclass[0] : null;

                cgData.SetData("res_name_" + follIdx, prewarned.Name);
                cgData.SetData("res_club_" + follIdx, prewarned.Club);
                cgData.SetData("res_class_" + follIdx, prewarned.Class);
                var pTime = prewarned.Time;
                cgData.SetData("res_place_" + follIdx, betterResInclass.Count() + 1 + "");
                cgData.SetData("res_time_" + follIdx,
                               Helpers.FormatTime(prewarned.Time, prewarned.Status, false, true, true));
                cgData.SetData("res_timeplus_" + follIdx,
                               "+" + Helpers.FormatTime(prewarned.Time - (leader != null ? leader.Time : prewarned.Time), prewarned.Status, false, true,
                                                        true));
                follIdx++;
                hadRunnerFinishedWithin10sek = true;
                if (follIdx > 15)
                {
                    break;
                }
            }

            if (hadRunnerFinishedWithin10sek)
            {
                m_nextForcedUpdate = DateTime.Now.AddSeconds(11);
            }

            double minTimeUntilUpdatePlaceRequired = double.MaxValue;

            foreach (var prewarned in m_emmaMysqlClient.GetAllRunners()
                     .Where(x => x.Time <= 0 && (x.Status == 0 || x.Status == 9 || x.Status == 10) && x.SplitTimes != null &&
                            x.SplitTimes.Any(y => Array.IndexOf(m_prewarningControls, y.Control) >= 0))
                     .OrderBy(x => x.StartTime + x.SplitTimes.Max(m => m.Time)))
            {
                var classResults = m_emmaMysqlClient.GetRunnersInClass(prewarned.Class).Where(x => x.Time > 0 && x.Status == 0)
                                   .OrderBy(x => x.Time).ToArray();
                Runner leader = classResults.Any() ? classResults[0] : null;

                int startTime = prewarned.StartTime;

                var curTime = DateTime.Now.Hour * 360000 + DateTime.Now.Minute * 6000 + DateTime.Now.Second * 100 - startTime;
                cgData.SetData("res_name_" + follIdx, prewarned.Name);
                cgData.SetData("res_class_" + follIdx, prewarned.Class);
                cgData.SetData("res_club_" + follIdx, prewarned.Club);
                cgData.SetData("res_tref_" + follIdx, (curTime / 100).ToString());

                if (classResults.Any())
                {
                    var nextRunner = classResults.Where(x => x.Time > curTime).OrderBy(x => x.Time).FirstOrDefault();
                    if (nextRunner != null)
                    {
                        var timeUntilPlaceChanges = (nextRunner.Time - curTime) / 100;
                        if (timeUntilPlaceChanges < minTimeUntilUpdatePlaceRequired)
                        {
                            minTimeUntilUpdatePlaceRequired = timeUntilPlaceChanges;
                        }
                    }
                }

                if (leader != null)
                {
                    string place =
                        (prewarned.Status != 9 && prewarned.Status != 10 && prewarned.Status != 0 &&
                         Helpers.ContainsRunnerStatus(prewarned.Status))
                        ? Helpers.RunnerStatus(prewarned.Status)
                        : (classResults.Count(x => x.Time <= curTime) + 1).ToString();
                    cgData.SetData("res_tplusref_" + follIdx, ((curTime - leader.Time) / 100).ToString());
                    cgData.SetData("res_place_" + follIdx, "(" + place + ")");
                }
                else
                {
                    string place =
                        (prewarned.Status != 9 && prewarned.Status != 10 && prewarned.Status != 0 &&
                         Helpers.ContainsRunnerStatus(prewarned.Status))
                        ? Helpers.RunnerStatus(prewarned.Status)
                        : "1";
                    cgData.SetData("res_tplusref_" + follIdx, "-999999");
                    cgData.SetData("res_place_" + follIdx, "(" + place + ")");
                }
                follIdx++;
                if (follIdx > 16)
                {
                    break;
                }
            }

            if (minTimeUntilUpdatePlaceRequired < double.MaxValue)
            {
                if (DateTime.Now.AddSeconds(minTimeUntilUpdatePlaceRequired) < m_nextForcedUpdate)
                {
                    m_nextForcedUpdate = DateTime.Now.AddSeconds(minTimeUntilUpdatePlaceRequired);
                }
            }
        }