コード例 #1
0
        public void Cleanup()
        {
            using (var rockContext = new RockContext())
            {
                var acService         = new AttendanceCodeService(rockContext);
                var attendanceService = new AttendanceService(rockContext);

                DateTime today       = RockDateTime.Today;
                DateTime tomorrow    = today.AddDays(1);
                var      todaysCodes = acService.Queryable()
                                       .Where(c => c.IssueDateTime >= today && c.IssueDateTime < tomorrow)
                                       .ToList();
                if (todaysCodes.Any())
                {
                    var ids = todaysCodes.Select(c => c.Id).ToList();

                    // get the corresponding attendance records and delete them first.
                    var todayTestAttendance = attendanceService.Queryable().Where(a => ids.Contains(a.AttendanceCodeId.Value));
                    if (todayTestAttendance.Any())
                    {
                        attendanceService.DeleteRange(todayTestAttendance);
                    }
                    acService.DeleteRange(todaysCodes);
                    rockContext.SaveChanges();
                }
            }
            AttendanceCodeService.FlushTodaysCodes();
        }
コード例 #2
0
        /// <summary>
        /// Deletes the test data added to the database for each tests.
        /// </summary>
        private void Cleanup()
        {
            using (var rockContext = new RockContext())
            {
                var service = new AttendanceCodeService(rockContext);

                DateTime today       = RockDateTime.Today;
                DateTime tomorrow    = today.AddDays(1);
                var      todaysCodes = service.Queryable()
                                       .Where(c => c.IssueDateTime >= today && c.IssueDateTime < tomorrow)
                                       .ToList();
                if (todaysCodes.Any())
                {
                    service.DeleteRange(todaysCodes);
                    rockContext.SaveChanges();
                }
            }
            AttendanceCodeService.FlushTodaysCodes();
        }
コード例 #3
0
        public void GenerateLotsOfCodes()
        {
            int  interations         = 6000;
            int  alphaNumbericDigits = 0;
            int  alphaDigits         = 0;
            int  numericDigits       = 4;
            bool isRandom            = false;

            var stopWatch = new System.Diagnostics.Stopwatch();

            stopWatch.Start();

            for (int i = 0; i < interations; i++)
            {
                AttendanceCodeService.GetNew(alphaNumbericDigits, alphaDigits, numericDigits, isRandom);
            }

            stopWatch.Stop();
            System.Diagnostics.Trace.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(Console.Out));
            System.Diagnostics.Trace.WriteLine($"New GetNew Method AlphaNumericDigits: {alphaNumbericDigits}, AlphaDigits: {alphaDigits}, NumericDigits: {numericDigits}, IsRandom: {isRandom}, Number of Codes Generated: {interations}. Total Time: {stopWatch.ElapsedMilliseconds} ms.");
            ClearAttendanceService();
            AttendanceCodeService.FlushTodaysCodes();
        }