Beispiel #1
0
        public async Task UpdateBoxStatus(BoxStats boxstats)
        {
            var student = _studentRepository.GetStudentByRFID(boxstats.Rfid);
            var log     = new BoxLog
            {
                dateTime = DateTime.Now
            };
            var Box = _boxRepository.GetBox();

            Box.IsOpen        = boxstats.door;
            Box.StudentOppend = student;
            Box.StudentId     = student.Id;
            if (boxstats.door)
            {
                if (student != null)
                {
                    log.Message = "Box Door Opend By " + student.FullName;
                }
                else
                {
                    log.Message = "Warning! Box Door opend by unknown User";
                    //activate warning
                }
            }
            if (!boxstats.door)
            {
                log.Message = "Box Door Closed";
            }
            _boxRepository.AddLog(log);

            await _boxHub.Clients.All.SendAsync("doorStats", Box.StudentOppend.email, Box.IsOpen, DateTime.Now.ToString("HH:mm:ss"));

            await _notificationsRepository.AddNotificationAsync(log.Message);
        }
Beispiel #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,dateTime,Message")] BoxLog boxLog)
        {
            if (id != boxLog.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(boxLog);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BoxLogExists(boxLog.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(boxLog));
        }
Beispiel #3
0
        private async void LoopLog()
        {
            string[] logStringArr;

            while (true)
            {
                logStringArr = network.GetLogInfo();
                if ((threadLearning.IsCompleted == true) && (logStringArr.Length == 0))
                {
                    break;
                }

                if (logStringArr.Length != 0)
                {
                    for (int i = 0; i < logStringArr.Length; i++)
                    {
                        await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
                                                  () =>
                        {
                            BoxLog.Items.Add(logStringArr[i]);
                            if (ChBoxAutoScroll.IsChecked == true)
                            {
                                BoxLog.ScrollIntoView(BoxLog.Items.Last());
                            }
                        });
                    }
                }
                await Task.Delay(TimeSpan.FromSeconds(0.1));
            }
        }
Beispiel #4
0
        public async Task <IActionResult> Create([Bind("Id,dateTime,Message")] BoxLog boxLog)
        {
            if (ModelState.IsValid)
            {
                _context.Add(boxLog);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(boxLog));
        }