Exemplo n.º 1
0
        public static VisitInfo[] GetEvents
        (
            [NotNull] this VisitInfo[] events,
            DateTime day
        )
        {
            if (ReferenceEquals(events, null))
            {
                throw new ArgumentNullException("events");
            }

            string dayString = IrbisDate.ConvertDateToString(day);

            VisitInfo[] result = events
                                 .AsParallel()
                                 .Where(v => v.DateGivenString.SameString(dayString))
                                 .ToArray();
            return(result);
        }
Exemplo n.º 2
0
        public static VisitInfo[] GetEvents
        (
            [NotNull] this VisitInfo[] events,
            DateTime fromDay,
            DateTime toDay
        )
        {
            if (ReferenceEquals(events, null))
            {
                throw new ArgumentNullException("events");
            }

            string fromDayString = IrbisDate.ConvertDateToString(fromDay);
            string toDayString   = IrbisDate.ConvertDateToString(toDay);

            VisitInfo[] result = events
                                 .AsParallel()
                                 .Where(v => (v.DateGivenString.SafeCompare(fromDayString) >= 0) &&
                                        (v.DateGivenString.SafeCompare(toDayString) <= 0))
                                 .ToArray();
            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Подсчёт количества событий.
        /// </summary>
        public static int CountEvents
        (
            [NotNull] List <ReaderInfo> readers,
            DateTime fromDay,
            DateTime toDay,
            bool visit
        )
        {
            if (ReferenceEquals(readers, null))
            {
                throw new ArgumentNullException("readers");
            }

            string fromDayString = IrbisDate.ConvertDateToString(fromDay);
            string toDayString   = IrbisDate.ConvertDateToString(toDay);
            int    result        = readers
                                   .SelectMany(r => r.Visits)
                                   .Count(v => (v.DateGivenString.SafeCompare(fromDayString) >= 0) &&
                                          (v.DateGivenString.SafeCompare(toDayString) <= 0) &&
                                          (v.IsVisit == visit));

            return(result);
        }