private void CrunchNumbers()
        {
            if (AllRecords.Count <= 0)
            {
                return;
            }

            CrunchedNumbers.Clear();
            StatsList.Clear();

            foreach (List <RecordLite> recordSet in AllRecords)
            {
                if (recordSet.Count <= 0)
                {
                    continue;
                }

                int           teamNum = recordSet.First().TeamID;
                TeamStatsLite stats   = TeamStatsLite.MakeStats(recordSet);
                StatsList.Add(stats);

                CrunchedNumbers.Add(teamNum, stats.GetMeanRatings());
            }

            InfoTeamsList.Items.Clear();
            foreach (TeamStatsLite stat in StatsList)
            {
                InfoTeamsList.Items.Add(stat);
            }

            if (InfoTeamsList.Items.Count > 0)
            {
                InfoTeamsList.SelectedIndex = 0;
            }

            hasCrunched = true;

            SortDataGrid.ItemsSource = DataGridSummaries;
        }
Пример #2
0
        private void CreateRowIfPossible(string name, string firstDescription, string secondDescription = null,
                                         string icon = null)
        {
            if (!string.IsNullOrEmpty(firstDescription))
            {
                if (icon == null)
                {
                    icon = name;
                }

                using (CargoContext cargoContext = new CargoContext())
                {
                    StatsList.Add(new EquipmentStats
                    {
                        Name = name,
                        Icon = cargoContext.Icons.Find(icon)?.FileName,
                        DescriptionFirstPart  = firstDescription,
                        DescriptionSecondPart = secondDescription
                    });
                }
            }
        }
        private void CreateList()
        {
            List <Tep_Sekvencia> tepList = null;

            try
            {
                tepList = _context.PulseSekv.ToList();
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Cant find list pulse for selected time" + e.ToString());
            }
            List <Teplota_Sekvencia> tempList = null;

            try
            {
                tempList = _context.TemperatureSekv.ToList();
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Cant find list temperature for selected time" + e.ToString());
            }

            /* try {
             * tepList = _context.PulseSekv.Where(p => DateTime.Parse(p.TimeStart) >= StartdateTime && DateTime.Parse(p.TimeStart) <= StopdateTime || DateTime.Parse(p.TimeStart) <= StartdateTime && DateTime.Parse(p.TimeClose) >= StartdateTime || DateTime.Parse(p.TimeStart) <= StopdateTime && DateTime.Parse(p.TimeClose) >= StopdateTime || DateTime.Parse(p.TimeStart) <= StartdateTime && DateTime.Parse(p.TimeClose) >= StopdateTime).ToList();
             * }
             * catch(Exception e)
             * {
             *   System.Diagnostics.Debug.WriteLine("Cant find list pulse for selected time" + e.ToString());
             *   try
             *   {
             *       tepList = _context.PulseSekv.Where(p => DateTime.Parse(p.TimeStart) <= StartdateTime).ToList();
             *   }
             *   catch (Exception ee)
             *   {
             *       System.Diagnostics.Debug.WriteLine("Cant find list pulse for selected time" + ee.ToString());
             *   }
             *
             *   System.Diagnostics.Debug.WriteLine("Cant find list pulse for selected time" + e.ToString());
             * }
             *
             *
             * foreach (var t in tepList) {
             *   System.Diagnostics.Debug.WriteLine("************ Pulse: " + t.TimeStart + " " + t.TimeClose + " " + t.Sekvencia);
             *
             * }
             * List<Teplota_Sekvencia> tempList = null;
             * try
             * {
             *   tempList = _context.TemperatureSekv.Where(p => DateTime.Parse(p.TimeStart) >= StartdateTime && DateTime.Parse(p.TimeStart) <= StopdateTime || DateTime.Parse(p.TimeStart) <= StartdateTime && DateTime.Parse(p.TimeClose) >= StartdateTime || DateTime.Parse(p.TimeStart) <= StopdateTime && DateTime.Parse(p.TimeClose) >= StopdateTime || DateTime.Parse(p.TimeStart) <= StartdateTime && DateTime.Parse(p.TimeClose) >= StopdateTime).ToList();
             * }
             * catch (Exception e)
             * {
             *   System.Diagnostics.Debug.WriteLine("Cant find list temperature for selected time" + e.ToString());
             *
             *   try
             *   {
             *       tempList = _context.TemperatureSekv.Where(p => DateTime.Parse(p.TimeStart) <= StartdateTime).ToList();
             *   }
             *   catch (Exception ee)
             *   {
             *       System.Diagnostics.Debug.WriteLine("Cant find list temperature for selected time" + ee.ToString());
             *
             *   }
             *
             * }*/


            foreach (var t in tempList)
            {
                System.Diagnostics.Debug.WriteLine("************ Temperature: " + t.TimeStart + " " + t.TimeClose + " " + t.Sekvencia);
            }

            DateTime myTime = StartdateTime;

            Helpers.SekvenceHelper.LimitCheck loader = new Helpers.SekvenceHelper.LimitCheck();

            while (myTime <= StopdateTime)
            {
                string tempVal   = "NA";
                string tempAlert = "";
                try
                {
                    foreach (var t in tempList)
                    {
                        if (DateTime.Parse(t.TimeStart).TimeOfDay <= myTime.TimeOfDay && DateTime.Parse(t.TimeStart).Date == DateTime.Parse(_roomStatistics.StartDate))
                        {
                            if (t.TimeClose.Equals(""))
                            {
                                tempVal   = t.Sekvencia.ToString("n2") + " °C";
                                tempAlert = loader.getStringValuePulseAndTempLimit(t.Upozornenie);
                                if (!teplotaListConst.Contains(t))
                                {
                                    teplotaListConst.Add(t);
                                }
                                break;
                            }
                            else if (TimeSpan.Compare(DateTime.Parse(t.TimeClose).TimeOfDay, myTime.TimeOfDay) >= 0)
                            {
                                tempVal   = t.Sekvencia.ToString("n2") + " °C";
                                tempAlert = loader.getStringValuePulseAndTempLimit(t.Upozornenie);
                                if (!teplotaListConst.Contains(t))
                                {
                                    teplotaListConst.Add(t);
                                }
                                break;
                            }
                            else
                            {
                                tempVal   = "NA";
                                tempAlert = "";
                            }
                        }
                    }

/*
 *                  var temp = tempList.Where(p => DateTime.Parse(p.TimeStart).TimeOfDay <= myTime.TimeOfDay && DateTime.Parse(p.TimeClose).TimeOfDay >= myTime.TimeOfDay).First();
 *
 *                  tempVal = temp.Sekvencia.ToString("n2") + " °C";
 *                  tempAlert = loader.getStringValuePulseAndTempLimit(temp.Upozornenie);*/
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine("Cant find value for selected time" + e.ToString());

                    /* try
                     * {
                     *   var temp = tempList.Where(p => DateTime.Parse(p.TimeStart) <= myTime && p.TimeClose == "").First();
                     *
                     *   tempVal = temp.Sekvencia.ToString("n2") + " °C";
                     *   tempAlert = loader.getStringValuePulseAndTempLimit(temp.Upozornenie);
                     * }
                     * catch (Exception ee)
                     * {
                     *   System.Diagnostics.Debug.WriteLine("Cant find value for selected time" + ee.ToString());
                     *
                     * }*/
                }

                string pulseVal   = "NA";
                string pulseAlert = "";

                try
                {
                    /* var pulse = tepList.Where(p => DateTime.Parse(p.TimeStart) <= myTime && DateTime.Parse(p.TimeClose) >= myTime).First();
                     * pulseVal = pulse.Sekvencia.ToString() + " BPM";
                     * pulseAlert = loader.getStringValuePulseAndTempLimit(pulse.Upozornenie);*/
                    foreach (var t in tepList)
                    {
                        if (DateTime.Parse(t.TimeStart).TimeOfDay <= myTime.TimeOfDay && DateTime.Parse(t.TimeStart).Date == DateTime.Parse(_roomStatistics.StartDate))
                        {
                            if (t.TimeClose.Equals(""))
                            {
                                pulseVal   = t.Sekvencia.ToString() + " BPM";
                                pulseAlert = loader.getStringValuePulseAndTempLimit(t.Upozornenie);
                                if (!tepListConst.Contains(t))
                                {
                                    tepListConst.Add(t);
                                }
                                break;
                            }
                            else if (TimeSpan.Compare(DateTime.Parse(t.TimeClose).TimeOfDay, myTime.TimeOfDay) >= 0)
                            {
                                pulseVal   = t.Sekvencia.ToString() + " BPM";
                                pulseAlert = loader.getStringValuePulseAndTempLimit(t.Upozornenie);
                                if (!tepListConst.Contains(t))
                                {
                                    tepListConst.Add(t);
                                }
                                break;
                            }
                            else
                            {
                                pulseVal   = "NA";
                                pulseAlert = "";
                            }
                        }
                    }
                } catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine("Cant find value for selected time" + e.ToString());

                    /* try
                     * {
                     *   var pulse = tepList.Where(p => DateTime.Parse(p.TimeStart) <= myTime).First();
                     *   pulseVal = pulse.Sekvencia.ToString() + " BPM";
                     *   pulseAlert = loader.getStringValuePulseAndTempLimit(pulse.Upozornenie);
                     *
                     * }
                     * catch (Exception ee)
                     * {
                     *   System.Diagnostics.Debug.WriteLine("Cant find value for selected time" + ee.ToString());
                     *
                     * }*/
                }

                string fallValue = "";
                try
                {
                    var fall = fallList.Where(p => DateTime.Parse(p.TimeStamp) >= myTime && DateTime.Parse(p.TimeStamp) <= myTime.AddMinutes(1)).First();
                    if (fall != null)
                    {
                        fallValue = "Áno";
                    }
                    //System.Diagnostics.Debug.WriteLine("find value for selected time fall " + fall.TimeStamp);
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine("Cant find value for selected time fall " + e.ToString());
                }

                StatisticsObj statisticsObj = new StatisticsObj
                {
                    Time             = myTime.ToShortTimeString(),
                    PulseValue       = pulseVal,
                    PulseAlert       = pulseAlert,
                    TemperatureValue = tempVal,
                    TemperatureAlert = tempAlert,
                    isFall           = fallValue
                };

                StatsList.Add(statisticsObj);

                //  System.Diagnostics.Debug.WriteLine("--- LIST ---" + myTime + " " + pulseVal + " " + pulseAlert + " " + tempVal + " " + tempAlert + " " + fallValue);

                myTime = myTime.AddMinutes(1);
            }
            //StatsList = new ObservableCollection<StatisticsObj>(StatsList.Reverse());
        }