public StatisticsVisualViewModel(RoomStatisticsObj roomStats)
        {
            tepListConst     = new List <Tep_Sekvencia>();
            teplotaListConst = new List <Teplota_Sekvencia>();

            _roomStatistics = roomStats;
            _context        = new DatabaseContext();
            StartdateTime   = DateTime.Parse(_roomStatistics.StartTime);

            try {
                StopdateTime = DateTime.Parse(_roomStatistics.EndTime);
            }catch (Exception e)
            {
            }

            StartTime = _roomStatistics.StartTime;
            StopTime  = _roomStatistics.EndTime;

            ToBack = new Command(toBack);

            FillValues();
            CreateList();
            FindActivity();
        }
예제 #2
0
        private void FindRoomsStatisticsList()
        {
            RoomsDetection roomsDetection = new RoomsDetection();


            if (_context.MovementSekv.Any())
            {
                var movSekvList = _context.MovementSekv.ToList();
                int counter     = 0;
                foreach (var movSekv in movSekvList)
                {
                    // if (++counter > 20) break;
                    DateTime convertedDate = DateTime.Parse(movSekv.TimeStamp);

                    Izby   izba     = null;
                    String izbaName = "";
                    try
                    {
                        izba     = _context.Rooms.Where(t => t.IzbaID == movSekv.IzbyFK).First();
                        izbaName = izba.Nazov;
                    }
                    catch (Exception e)
                    {
                        izbaName = "Vonku";
                    }
                    List <Pohyb_Sekvencia> valueList = new List <Pohyb_Sekvencia>();

                    if (!RoomsList.Any())
                    {
                        valueList.Add(movSekv);
                        RoomStatisticsObj roomStatisticsObj = new RoomStatisticsObj
                        {
                            RoomName  = izbaName,
                            StartDate = convertedDate.ToShortDateString(),
                            StartTime = convertedDate.ToLongTimeString(),
                            Sekvencie = valueList
                        };
                        RoomsList.Add(roomStatisticsObj);
                        System.Diagnostics.Debug.WriteLine("ROOMS STATS FIRST " + movSekv.PohSekvId);
                    }
                    else
                    {
                        RoomStatisticsObj rObj = RoomsList.Last();

                        if (rObj.RoomName == izbaName)
                        {
                            valueList = rObj.Sekvencie;
                            valueList.Add(movSekv);
                            rObj.Sekvencie = valueList;
                            //System.Diagnostics.Debug.WriteLine("ROOMS STATS Adding " + movSekv.PohSekvId + " " + izbaName + " " + valueList.Count);
                        }
                        else
                        {
                            if (rObj.StartDate == convertedDate.ToShortDateString())
                            {
                                rObj.EndDate = "";
                            }
                            else
                            {
                                rObj.EndDate = convertedDate.ToShortDateString();
                            }

                            // rObj.EndDate = convertedDate.ToShortDateString();

                            //rObj.EndTime = convertedDate.ToLongTimeString();
                            try
                            {
                                rObj.EndTime = DateTime.Parse(movSekv.TimeStamp).ToLongTimeString();
                            }
                            catch (Exception e)
                            {
                                System.Diagnostics.Debug.WriteLine("Exception: " + nameof(StatisticsMainViewModel) + " " + e.ToString());
                                rObj.EndTime = convertedDate.ToLongTimeString();
                            }

                            valueList.Add(movSekv);
                            RoomStatisticsObj roomStatisticsObj = new RoomStatisticsObj
                            {
                                RoomName  = izbaName,
                                StartDate = convertedDate.ToShortDateString(),
                                StartTime = convertedDate.ToLongTimeString(),
                                Sekvencie = valueList
                            };
                            RoomsList.Add(roomStatisticsObj);

                            //System.Diagnostics.Debug.WriteLine("ROOMS STATS New " + movSekv.PohSekvId + " " + izbaName + " " + valueList.Count);
                        }
                    }
                }

                RoomsList = new ObservableCollection <RoomStatisticsObj>(RoomsList.Reverse());
            }
        }
 public StatisticVisualPage(RoomStatisticsObj roomStats)
 {
     InitializeComponent();
     BindingContext = new StatisticsVisualViewModel(roomStats);
 }