コード例 #1
0
        // GET: Teacher
        public ActionResult Index()
        {
            var enteredBadgeString = User.Identity.Name;
            var selectedTeacher    = _db.SchoolTeachersWithADLogins.FirstOrDefault(i => i.BADGE_NUM == enteredBadgeString);
            var badgeNumber        = int.Parse(enteredBadgeString); // convert string to int

            ViewBag.Name          = selectedTeacher.TeacherFirstName + " " + selectedTeacher.TeacherLastName;
            ViewBag.NeedsApproval = _db.SubMinutes.Count(i => i.BadgeNumber == badgeNumber && i.IsApproved == null);  // tells teacher how many entries need approval
            var now  = _db.EnteredPeMinutes.Select(x => x.InstructionTime).DistinctBy(x => x.Value.Date).OrderByDescending(x => x).FirstOrDefault().Value.Date;
            var end  = _db.EnteredPeMinutes.Where(x => x.InstructionTime <= now).Select(x => x.InstructionTime).DistinctBy(x => x.Value.Date).OrderByDescending(x => x).Take(10).LastOrDefault().Value.Date;
            var tivm = new TeacherIndexViewModel();
            var teachersPeMinutes = _db.EnteredPeMinutes.Where(i => i.BadgeNumber == badgeNumber && i.InstructionTime >= end.Date && i.InstructionTime < now.Date).OrderBy(x => x.InstructionTime).ToList(); // Finds all of the teachers minutes for the last 2 weeks

            foreach (var item in teachersPeMinutes)
            {
                MinuteCount mc = new MinuteCount();

                mc.Minutes  = item.Minutes;
                mc.Date     = item.InstructionTime.Value.ToShortDateString();
                mc.ID       = item.ID;
                mc.Activity = item.Activity;
                tivm.MinCount.Add(mc);
            }

            tivm.Percentage = (float)(teachersPeMinutes.Sum(x => x.Minutes) / 2);

            tivm.Minutes  = teachersPeMinutes.Sum(x => x.Minutes);
            tivm.MinCount = tivm.MinCount.ToList();
            return(View(tivm));
        }
コード例 #2
0
        private void RecordRun()
        {
            #region RunSpeed
            if (RunSpeed_RecentRuns.Count >= 100)
            {
                RunSpeed_RecentRuns.Dequeue();
            }
            RunSpeed_RecentRuns.Enqueue(Stopwatch.ElapsedMilliseconds);
            #endregion

            #region RunCount_Lifetime
            RunCount_Lifetime++;
            #endregion

            #region Yesterday and Today
            if (TimeStamp.Date < DateTime.Today)
            {
                RunCount_Yesterday = RunCount_Today;
                RunCount_Today     = 0;
                TimeStamp          = DateTime.Now;
            }
            RunCount_Today++;
            #endregion

            #region This Hour and Last Hour
            if (TimeStamp.Hour < DateTime.Now.Hour)
            {
                RunCount_LastHour = RunCount_ThisHour;
                RunCount_ThisHour = 0;
                TimeStamp         = DateTime.Now;
            }
            RunCount_ThisHour++;
            #endregion

            #region RunCount_RecentMinutes
            if (RunCount_RecentMinutes.Count >= 120)
            {
                RunCount_RecentMinutes.Dequeue();
            }
            MinuteCount objMinute = null;
            foreach (var point in RunCount_RecentMinutes)
            {
                if (point != null && point.TimeStamp.Date == DateTime.Today && point.TimeStamp.Hour == DateTime.Now.Hour && point.TimeStamp.Minute == DateTime.Now.Minute)
                {
                    point.DoCount();
                    objMinute = point;
                }
            }
            if (objMinute == null)
            {
                RunCount_RecentMinutes.Enqueue(new MinuteCount());
            }
            #endregion
        }