/// <summary>
 /// Initialize comment controller
 /// </summary>
 /// <param name="classCalendarRepo">Class calendar repository</param>
 /// <param name="userprofileRepo">UserProfile repository</param>
 /// <param name="userActivityRepo">User activity repository</param>
 /// <param name="classRoomRepo">Class room repository</param>
 /// <param name="studentKeyRepo">Student key repository</param>
 /// <param name="lessonCatalogRepo">Lesson catalog repository</param>
 /// <param name="contractRepo">Contract repository</param>
 /// <param name="likeCommentRepo">Like comment repository</param>
 /// <param name="likeDiscussionRepo">Like discussion repository</param>
 /// <param name="likeLessonRepo">Like lesson repository</param>
 /// <param name="courseCatalogRepo">Course catalog repository</param>
 public MyCourseController(IClassCalendarRepository classCalendarRepo,
     IUserProfileRepository userprofileRepo,
     IUserActivityRepository userActivityRepo,
     IClassRoomRepository classRoomRepo,
     IStudentKeyRepository studentKeyRepo,
     ILessonCatalogRepository lessonCatalogRepo,
     ILikeLessonRepository likeLessonRepo,
     ILikeCommentRepository likeCommentRepo,
     ILikeDiscussionRepository likeDiscussionRepo,
     IContractRepository contractRepo,
     ICourseCatalogRepository courseCatalogRepo,
     ILoggerFactory loggerFactory,
     IDateTime dateTime)
 {
     _classCalendarRepo = classCalendarRepo;
     _userprofileRepo = userprofileRepo;
     _userActivityRepo = userActivityRepo;
     _classRoomRepo = classRoomRepo;
     _studentKeyRepo = studentKeyRepo;
     _lessonCatalogRepo = lessonCatalogRepo;
     _likeLessonRepo = likeLessonRepo;
     _likeCommentRepo = likeCommentRepo;
     _likeDiscussionRepo = likeDiscussionRepo;
     _contractRepo = contractRepo;
     _courseCatalogRepo = courseCatalogRepo;
     _logger = loggerFactory.CreateLogger<MyCourseController>();
     _dateTime = dateTime;
 }
 public QuestionVM(
     IDateTime dateTime, 
     IDictionaryEntryPicker dictionaryEntryPicker)
 {
     _dateTime = dateTime;
     _dictionaryEntryPicker = dictionaryEntryPicker;
 }
        public override IList<IPeriod> Evaluate(IDateTime referenceDate, DateTime periodStart, DateTime periodEnd, bool includeReferenceDateInResults)
        {
            Dictionary<IPeriod , bool> periodLookup = new Dictionary<IPeriod, bool>();

            List<IPeriod> periods = new List<IPeriod>();

            if (includeReferenceDateInResults)
            {
                IPeriod p = new Period(referenceDate);
                if (!periodLookup.ContainsKey(p))
                {
                    periodLookup.Add(p , true);
                    periods.Add(p);
                }
            }

            if (periodEnd < periodStart)
                return periods;

            foreach (IPeriod p in m_PeriodList)
            {
                if (!periodLookup.ContainsKey(p))
                {
                    periodLookup.Add(p, true);
                    periods.Add(p);
                }
            }

            return periods;
        }
Esempio n. 4
0
 public static IDateTime StartOfDay(IDateTime dt)
 {
     return dt.
         AddHours(-dt.Hour).
         AddMinutes(-dt.Minute).
         AddSeconds(-dt.Second);
 }
 /// <summary>
 /// Evaulates the RRule component, and adds each specified Period
 /// to the <see cref="Periods"/> collection.
 /// </summary>
 /// <param name="FromDate">The beginning date of the range to evaluate.</param>
 /// <param name="ToDate">The end date of the range to evaluate.</param>
 virtual protected void EvaluateRRule(IDateTime referenceDate, DateTime periodStart, DateTime periodEnd, bool includeReferenceDateInResults)
 {
     // Handle RRULEs
     if (Recurrable.RecurrenceRules != null &&
         Recurrable.RecurrenceRules.Count > 0)
     {
         foreach (IRecurrencePattern rrule in Recurrable.RecurrenceRules)
         {
             IEvaluator evaluator = rrule.GetService(typeof(IEvaluator)) as IEvaluator;
             if (evaluator != null)
             {
                 IList<IPeriod> periods = evaluator.Evaluate(referenceDate, periodStart, periodEnd, includeReferenceDateInResults);
                 foreach (IPeriod p in periods)
                 {
                     if (!Periods.Contains(p))
                         Periods.Add(p);
                 }
             }
         }
     }
     else if (includeReferenceDateInResults)
     {
         // If no RRULEs were found, then we still need to add
         // the initial reference date to the results.
         IPeriod p = new Period(referenceDate.Copy<IDateTime>());
         if (!Periods.Contains(p))
             Periods.Add(p);
     }
 }
 /// <summary>
 /// Initialize purchase controller
 /// </summary>
 /// <param name="courseCtrl">Course API</param>
 /// <param name="myCourseCtrl">MyCourse API</param>
 /// <param name="userProfileRepo">User profile repository</param>
 /// <param name="classRoomRepo">Class room repository</param>
 /// <param name="classCalendarRepo">Class calendar repository</param>
 /// <param name="lessonCatalogRepo">Lesson catalog repository</param>
 /// <param name="userActivityRepo">User activity repository</param>
 /// <param name="paymentRepo">Payment repository</param>
 public PurchaseController(CourseController courseCtrl,
     MyCourseController myCourseCtrl,
     IUserProfileRepository userProfileRepo,
     IClassRoomRepository classRoomRepo,
     IClassCalendarRepository classCalendarRepo,
     ILessonCatalogRepository lessonCatalogRepo,
     IUserActivityRepository userActivityRepo,
     IPaymentRepository paymentRepo,
     IOptions<AppConfigOptions> appConfig,
     IOptions<ErrorMessageOptions> errorMsgs,
     ILoggerFactory loggerFactory,
     IPayment payment,
     IDateTime dateTime)
 {
     _courseCtrl = courseCtrl;
     _myCourseCtrl = myCourseCtrl;
     _userprofileRepo = userProfileRepo;
     _classRoomRepo = classRoomRepo;
     _classCalendarRepo = classCalendarRepo;
     _lessonCatalogRepo = lessonCatalogRepo;
     _userActivityRepo = userActivityRepo;
     _paymentRepo = paymentRepo;
     _dateTime = dateTime;
     _appConfig = appConfig.Value;
     _errorMsgs = errorMsgs.Value;
     _logger = loggerFactory.CreateLogger<PurchaseController>();
     _payment = payment;
 }
 /// <summary>
 /// Initialize lesson controller
 /// </summary>
 /// <param name="classCalendarRepo">Class calendar repository</param>
 /// <param name="userprofileRepo">UserProfile repository</param>
 /// <param name="classRoomRepo">Class room repository</param>
 /// <param name="likeLessonRepo">Like lesson repository</param>
 /// <param name="lessonCatalogRepo">Lesson catalog repository</param>
 /// <param name="commentRepo">Comment repository</param>
 /// <param name="friendRequestRepo">Friend request repository</param>
 /// <param name="userActivityRepo">User activity repository</param>
 /// <param name="notificationCtrl">Notificaotion API</param>
 /// <param name="config">App configuration option</param>
 public LessonController(IClassCalendarRepository classCalendarRepo,
     IUserProfileRepository userprofileRepo,
     IClassRoomRepository classRoomRepo,
     ILikeLessonRepository likeLessonRepo,
     ILessonCatalogRepository lessonCatalogRepo,
     ICommentRepository commentRepo,
     IFriendRequestRepository friendRequestRepo,
     IUserActivityRepository userActivityRepo,
     NotificationController notificationCtrl,
     IOptions<AppConfigOptions> options,
     ILessonTestResultRepository lessonTestResultRepo,
     IDateTime dateTime)
 {
     _classCalendarRepo = classCalendarRepo;
     _userprofileRepo = userprofileRepo;
     _classRoomRepo = classRoomRepo;
     _likeLessonRepo = likeLessonRepo;
     _lessonCatalogRepo = lessonCatalogRepo;
     _commentRepo = commentRepo;
     _friendRequestRepo = friendRequestRepo;
     _userActivityRepo = userActivityRepo;
     _notificationCtrl = notificationCtrl;
     _appConfig = options.Value;
     _dateTime = dateTime;
     _lessonTestResultRepo = lessonTestResultRepo;
 }
Esempio n. 8
0
        private void EventOccurrenceTest(
            IICalendar iCal,
            IDateTime fromDate,
            IDateTime toDate,
            IDateTime[] dateTimes,
            string[] timeZones,
            int eventIndex
        )
        {
            IEvent evt = iCal.Events[eventIndex];
            fromDate.AssociatedObject = iCal;
            toDate.AssociatedObject = iCal;

            IList<Occurrence> occurrences = evt.GetOccurrences(
                fromDate,
                toDate);

            Assert.AreEqual(
                dateTimes.Length,
                occurrences.Count,
                "There should be exactly " + dateTimes.Length + " occurrences; there were " + occurrences.Count);

            for (int i = 0; i < dateTimes.Length; i++)
            {
                // Associate each incoming date/time with the calendar.
                dateTimes[i].AssociatedObject = iCal;

                IDateTime dt = dateTimes[i];
                Assert.AreEqual(dt, occurrences[i].Period.StartTime, "Event should occur on " + dt);
                if (timeZones != null)
                    Assert.AreEqual(timeZones[i], dt.TimeZoneName, "Event " + dt + " should occur in the " + timeZones[i] + " timezone");
            }
        }
Esempio n. 9
0
        static public IList<Occurrence> GetOccurrences(IRecurrable recurrable, IDateTime periodStart, IDateTime periodEnd, bool includeReferenceDateInResults)
        {
            List<Occurrence> occurrences = new List<Occurrence>();

            IEvaluator evaluator = recurrable.GetService(typeof(IEvaluator)) as IEvaluator;
            if (evaluator != null)
            {
                // Change the time zone of periodStart/periodEnd as needed 
                // so they can be used during the evaluation process.
                periodStart = DateUtil.MatchTimeZone(recurrable.Start, periodStart);
                periodEnd = DateUtil.MatchTimeZone(recurrable.Start, periodEnd);

                IList<IPeriod> periods = evaluator.Evaluate(
                    recurrable.Start,
                    DateUtil.GetSimpleDateTimeData(periodStart),
                    DateUtil.GetSimpleDateTimeData(periodEnd),
                    includeReferenceDateInResults);

                foreach (IPeriod p in periods)
                {
                    // Filter the resulting periods to only contain those 
                    // that occur sometime between startTime and endTime.
                    // NOTE: fixes bug #3007244 - GetOccurences not returning long spanning all-day events 
                    IDateTime endTime = p.EndTime ?? p.StartTime;
                    if (endTime.GreaterThan(periodStart) && p.StartTime.LessThanOrEqual(periodEnd))
                        occurrences.Add(new Occurrence(recurrable, p));
                }

                occurrences.Sort();
            }
            return occurrences;
        }
Esempio n. 10
0
 public HomeController(
     IReviewRepository reviewRepository,
     IDateTime now)
 {
     _reviewRepository = reviewRepository;
     _now = now;
 }
Esempio n. 11
0
        void ProcessOccurrences(IDateTime referenceDate)
        {
            //// Sort the occurrences by start time
            //m_Occurrences.Sort(
            //    delegate(Occurrence o1, Occurrence o2)
            //    {
            //        if (o1.Period == null || o1.Period.StartTime == null)
            //            return -1;
            //        else if (o2.Period == null || o2.Period.StartTime == null)
            //            return 1;
            //        else return o1.Period.StartTime.CompareTo(o2.Period.StartTime);
            //    }
            //);

            for (int i = 0; i < m_Occurrences.Count; i++)
            {
                Occurrence curr = m_Occurrences.Values[i];
                Occurrence? next = i < m_Occurrences.Count - 1 ? (Occurrence?)m_Occurrences.Values[i + 1] : null;

                // Determine end times for our periods, overwriting previously calculated end times.
                // This is important because we don't want to overcalculate our time zone information,
                // but simply calculate enough to be accurate.  When date/time ranges that are out of
                // normal working bounds are encountered, then occurrences are processed again, and
                // new end times are determined.
                if (next != null && next.HasValue)
                {
                    curr.Period.EndTime = next.Value.Period.StartTime.AddTicks(-1);
                }
                else
                {
                    curr.Period.EndTime = ConvertToIDateTime(EvaluationEndBounds, referenceDate);
                }
            }
        }
Esempio n. 12
0
        public void EvaluateToPreviousOccurrence(IDateTime completedDate, IDateTime currDt)
        {
            IDateTime beginningDate = completedDate.Copy<IDateTime>();

            if (Todo.RecurrenceRules != null)
            {
                foreach (IRecurrencePattern rrule in Todo.RecurrenceRules)
                    DetermineStartingRecurrence(rrule, ref beginningDate);
            }
            if (Todo.RecurrenceDates != null)
            {
                foreach (IPeriodList rdate in Todo.RecurrenceDates)
                    DetermineStartingRecurrence(rdate, ref beginningDate);
            }
            if (Todo.ExceptionRules != null)
            {
                foreach (IRecurrencePattern exrule in Todo.ExceptionRules)
                    DetermineStartingRecurrence(exrule, ref beginningDate);
            }
            if (Todo.ExceptionDates != null)
            {
                foreach (IPeriodList exdate in Todo.ExceptionDates)
                    DetermineStartingRecurrence(exdate, ref beginningDate);
            }

            Evaluate(Todo.Start, DateUtil.GetSimpleDateTimeData(beginningDate), DateUtil.GetSimpleDateTimeData(currDt).AddTicks(1), true);
        }
Esempio n. 13
0
        public static IDateTime MatchTimeZone(IDateTime dt1, IDateTime dt2)
        {
            Debug.Assert(dt1 != null && dt2 != null);

            // Associate the date/time with the first.
            IDateTime copy = dt2.Copy<IDateTime>();
            copy.AssociateWith(dt1);

            // If the dt1 time does not occur in the same time zone as the
            // dt2 time, then let's convert it so they can be used in the
            // same context (i.e. evaluation).
            if (dt1.TZID != null)
            {
                if (!string.Equals(dt1.TZID, copy.TZID))
                    return (dt1.TimeZoneObservance != null) ? copy.ToTimeZone(dt1.TimeZoneObservance.Value) : copy.ToTimeZone(dt1.TZID);
                else return copy;
            }
            else if (dt1.IsUniversalTime)
            {
                // The first date/time is in UTC time, convert!
                return new iCalDateTime(copy.UTC);
            }
            else
            {
                // The first date/time is in local time, convert!
                return new iCalDateTime(copy.Local);
            }
        }
Esempio n. 14
0
 static public IList<Occurrence> GetOccurrences(IRecurrable recurrable, IDateTime dt, bool includeReferenceDateInResults)
 {
     return GetOccurrences(
         recurrable, 
         new iCalDateTime(dt.Local.Date), 
         new iCalDateTime(dt.Local.Date.AddDays(1).AddSeconds(-1)),
         includeReferenceDateInResults);
 }
 public StartTaskWorkflowProcessor(ITaskByIdQueryProcessor taskByIdQueryProcessor,
 IUpdateTaskStatusQueryProcessor updateTaskStatusQueryProcessor, IAutoMapper autoMapper,IDateTime dateTime)
 {
     _taskByIdQueryProcessor = taskByIdQueryProcessor;
     _updateTaskStatusQueryProcessor = updateTaskStatusQueryProcessor;
     _autoMapper = autoMapper;
     _dateTime = dateTime;
 }
Esempio n. 16
0
 public Period(IDateTime start, IDateTime end) : this()
 {
     StartTime = start;
     if (end != null)
     {
         EndTime = end;
         Duration = end.Subtract(start);
     }
 }
Esempio n. 17
0
 public Period(IDateTime start, TimeSpan duration)
     : this()
 {
     StartTime = start;
     if (duration != default(TimeSpan))
     {
         Duration = duration;
         EndTime = start.Add(duration);
     }
 }
 public CompleteTaskWorkflowProcessor(ITaskByIdQueryProcessor taskByIdQueryProcessor,
     IUpdateTaskStatusQueryProcessor updateTaskStatusQueryProcessor, IAutoMapper autoMapper,
     ITaskLinkService taskLinkService, IDateTime dateTime)
 {
     _taskByIdQueryProcessor = taskByIdQueryProcessor;
     _updateTaskStatusQueryProcessor = updateTaskStatusQueryProcessor;
     _autoMapper = autoMapper;
     _taskLinkService = taskLinkService;
     _dateTime = dateTime;
 }
Esempio n. 19
0
 private void EventOccurrenceTest(
     IICalendar iCal,
     IDateTime fromDate,
     IDateTime toDate,
     IDateTime[] dateTimes,
     string[] timeZones
 )
 {
     EventOccurrenceTest(iCal, fromDate, toDate, dateTimes, timeZones, 0);
 }
Esempio n. 20
0
 /// <summary>
 /// Initialize Profile API
 /// </summary>
 /// <param name="userprofileRepo">User profile repository</param>
 /// <param name="classCalendarRepo">Class calendar repository</param>
 public ProfileController(IUserProfileRepository userprofileRepo, 
     IClassCalendarRepository classCalendarRepo,
     IDateTime dateTime,
     UserManager<ApplicationUser> userManager)
 {
     _userProfileRepo = userprofileRepo;
     _classCalendarRepo = classCalendarRepo;
     _dateTime = dateTime;
     _userManager = userManager;
 }
 /// <summary>
 /// Initialize purchase controller
 /// </summary>
 /// <param name="courseCtrl">Course API</param>
 /// <param name="myCourseCtrl">MyCourse API</param>
 /// <param name="userProfileRepo">User profile repository</param>
 public PurchaseController(CourseController courseCtrl, 
     MyCourseController myCourseCtrl,
     IUserProfileRepository userProfileRepo,
     IDateTime dateTime)
 {
     _courseCtrl = courseCtrl;
     _myCourseCtrl = myCourseCtrl;
     _userprofileRepo = userProfileRepo;
     _dateTime = dateTime;
 }
Esempio n. 22
0
 public void DetermineStartingRecurrence(IRecurrencePattern recur, ref IDateTime dt)
 {
     if (recur.Count != int.MinValue)
         dt = Todo.Start.Copy<IDateTime>();
     else
     {
         DateTime dtVal = dt.Value;
         IncrementDate(ref dtVal, recur, -recur.Interval);
         dt.Value = dtVal;
     }
 }
 /// <summary>
 ///     Initializes a new instance of the <see cref="HelloWorldDataService" /> class.
 /// </summary>
 /// <param name="appSettings">The injected application settings service</param>
 /// <param name="dateTimeWrapper">The injected DateTime wrapper</param>
 /// <param name="fileIOService">The injected File IO Service</param>
 /// <param name="helloWorldMapper">The injected Hello World Mapper</param>
 public HelloWorldDataService(
     IAppSettings appSettings,
     IDateTime dateTimeWrapper,
     IFileIOService fileIOService,
     IHelloWorldMapper helloWorldMapper)
 {
     this.appSettings = appSettings;
     this.dateTimeWrapper = dateTimeWrapper;
     this.fileIOService = fileIOService;
     this.helloWorldMapper = helloWorldMapper;
 }
Esempio n. 24
0
 public static DateTime SimpleDateTimeToMatch(IDateTime dt, IDateTime toMatch)
 {
     if (toMatch.IsUniversalTime && dt.IsUniversalTime)
         return dt.Value;
     else if (toMatch.IsUniversalTime)
         return dt.Value.ToUniversalTime();
     else if (dt.IsUniversalTime)
         return dt.Value.ToLocalTime();
     else
         return dt.Value;
 }
        private IRecurrencePattern ProcessRecurrencePattern(IDateTime referenceDate)
        {
            RecurrencePattern r = new RecurrencePattern();
            r.CopyFrom(Pattern);

            // Convert the UNTIL value to one that matches the same time information as the reference date
            if (r.Until != DateTime.MinValue)
                r.Until = DateUtil.MatchTimeZone(referenceDate, new iCalDateTime(r.Until)).Value;

            if (r.Frequency > FrequencyType.Secondly &&
                r.BySecond.Count == 0 &&
                referenceDate.HasTime /* NOTE: Fixes a bug where all-day events have BySecond/ByMinute/ByHour added incorrectly */)
                r.BySecond.Add(referenceDate.Second);
            if (r.Frequency > FrequencyType.Minutely &&
                r.ByMinute.Count == 0 &&
                referenceDate.HasTime /* NOTE: Fixes a bug where all-day events have BySecond/ByMinute/ByHour added incorrectly */)
                r.ByMinute.Add(referenceDate.Minute);
            if (r.Frequency > FrequencyType.Hourly &&
                r.ByHour.Count == 0 &&
                referenceDate.HasTime /* NOTE: Fixes a bug where all-day events have BySecond/ByMinute/ByHour added incorrectly */)
                r.ByHour.Add(referenceDate.Hour);

            // If BYDAY, BYYEARDAY, or BYWEEKNO is specified, then
            // we don't default BYDAY, BYMONTH or BYMONTHDAY
            if (r.ByDay.Count == 0 &&
                r.ByYearDay.Count == 0 &&
                r.ByWeekNo.Count == 0)
            {
                // If the frequency is weekly, and
                // no day of week is specified, use
                // the original date's day of week.
                // NOTE: fixes WeeklyCount1() and WeeklyUntil1() handling
                if (r.Frequency == FrequencyType.Weekly)
                    r.ByDay.Add(new WeekDay(referenceDate.DayOfWeek));

                // If BYMONTHDAY is not specified,
                // default to the current day of month
                // NOTE: fixes YearlyByMonth1() handling, added BYYEARDAY exclusion
                // to fix YearlyCountByYearDay1() handling
                if (r.Frequency > FrequencyType.Weekly &&
                    r.ByMonthDay.Count == 0)
                    r.ByMonthDay.Add(referenceDate.Day);

                // If BYMONTH is not specified, default to
                // the current month.
                // NOTE: fixes YearlyCountByYearDay1() handling
                if (r.Frequency > FrequencyType.Monthly &&
                    r.ByMonth.Count == 0)
                    r.ByMonth.Add(referenceDate.Month);
            }

            return r;
        }
Esempio n. 26
0
 /// <summary>
 /// Initialize Profile API
 /// </summary>
 /// <param name="userprofileRepo">User profile repository</param>
 /// <param name="classCalendarRepo">Class calendar repository</param>
 /// <param name="backgroundProcessQueue">Background process queue</param>
 public ProfileController(IUserProfileRepository userprofileRepo, 
     IClassCalendarRepository classCalendarRepo,
     IDateTime dateTime,
     Engines.IBackgroundProcessQueue backgroundProcessQueue,
     UserManager<ApplicationUser> userManager)
 {
     _userProfileRepo = userprofileRepo;
     _classCalendarRepo = classCalendarRepo;
     _dateTime = dateTime;
     _userManager = userManager;
     _backgroundProcessQueue = backgroundProcessQueue;
 }
Esempio n. 27
0
 /// <summary>
 /// Initialize friend controller
 /// </summary>
 /// <param name="classCalendarRepo">Class calendar repository</param>
 /// <param name="userprofileRepo">UserProfile repository</param>
 /// <param name="friendRequestRepo">Friend request repository</param>
 /// <param name="userActivityRepo">User activity repository</param>
 public FriendController(IClassCalendarRepository classCalendarRepo,
     IUserProfileRepository userprofileRepo,
     IFriendRequestRepository friendRequestRepo,
     IUserActivityRepository userActivityRepo,
     IDateTime dateTime)
 {
     _classCalendarRepo = classCalendarRepo;
     _userprofileRepo = userprofileRepo;
     _friendRequestRepo = friendRequestRepo;
     _userActivityRepo = userActivityRepo;
     _dateTime = dateTime;
 }
 /// <summary>
 /// constructor - ensure source statement is passed
 /// </summary>
 /// <param name="sourceStatementFile">source statement file name including path</param>
 /// <param name="parser">the particular tidy-tool</param>
 /// <param name="statementManagerDateTime">contains the server date to be used in the header</param>
 public SmileStatementManager(string sourceStatementFile, IHtmlParser parser, IDateTime statementManagerDateTime)
 {
     if (string.IsNullOrEmpty(sourceStatementFile)) {
         throw new ArgumentNullException("sourceStatementFile", @"No source statement file specified");
     }
     if (parser == null) {
         throw new ArgumentNullException("parser", @"parser is null");
     }
     _sourceStatementFilePath = sourceStatementFile;
     _smileParser = parser;
     _statementManagerDateTime = statementManagerDateTime;
 }
        public override HashSet<IPeriod> Evaluate(IDateTime referenceDate, DateTime periodStart, DateTime periodEnd, bool includeReferenceDateInResults)
        {
            // Time zones must include an effective start date/time
            // and must provide an evaluator.
            if (TimeZoneInfo != null)
            {
                // Always include the reference date in the results
                return base.Evaluate(referenceDate, periodStart, periodEnd, true);
            }

            return new HashSet<IPeriod>();            
        }
 public CompleteGameProcessor(
     IDateTime dateTime, 
     IAutoMapper autoMapper, 
     IGameLinkService gameLinkService,
     IGameByIdQueryProcessor gameByIdQueryProcessor, 
     IUpdateGameStatusQueryProcessor updateGameStatusQueryProcessor)
 {
     _dateTime = dateTime;
     _autoMapper = autoMapper;
     _gameLinkService = gameLinkService;
     _gameByIdQueryProcessor = gameByIdQueryProcessor;
     _updateGameStatusQueryProcessor = updateGameStatusQueryProcessor;
 }
Esempio n. 31
0
 public TenantDbContext(DbContextOptions options, IMediator mediator, IdentityUser user, IDateTime dateTime)
     : base(options, mediator, user, dateTime)
 {
 }
Esempio n. 32
0
 /// <summary>
 /// Returns a list of occurrences of each recurring component
 /// for the date provided (<paramref name="dt"/>).
 /// </summary>
 /// <param name="dt">The date for which to return occurrences. Time is ignored on this parameter.</param>
 /// <returns>A list of occurrences that occur on the given date (<paramref name="dt"/>).</returns>
 virtual public IList <Occurrence> GetOccurrences(IDateTime dt)
 {
     return(GetOccurrences <IRecurringComponent>(
                new iCalDateTime(dt.Local.Date),
                new iCalDateTime(dt.Local.Date.AddDays(1).AddSeconds(-1))));
 }
Esempio n. 33
0
 public void Evaluate <T>(IDateTime FromDate, IDateTime ToDate)
 {
     throw new NotSupportedException("Evaluate() is no longer supported as a public method.  Use GetOccurrences() instead.");
 }
Esempio n. 34
0
 public static IDateTime EndOfDay(IDateTime dt)
 {
     return(StartOfDay(dt).AddDays(1).AddTicks(-1));
 }
 public DeleteExpenseHandler(IExpenseService expenseService, ICurrentUserService currentUserService, IDateTime dateTime)
 {
     _expenseService     = expenseService ?? throw new ArgumentNullException(nameof(_expenseService));
     _currentUserService = currentUserService ?? throw new ArgumentNullException(nameof(_currentUserService));
     _dateTime           = dateTime ?? throw new ArgumentNullException(nameof(_dateTime));
 }
Esempio n. 36
0
 virtual public void Remove(IDateTime dt)
 {
     Periods.Remove(new Period(dt));
 }
Esempio n. 37
0
 virtual public void Add(IDateTime dt)
 {
     Periods.Add(new Period(dt));
 }
Esempio n. 38
0
        private RecurrencePattern ProcessRecurrencePattern(IDateTime referenceDate)
        {
            var r = new RecurrencePattern();

            r.CopyFrom(Pattern);

            // Convert the UNTIL value to one that matches the same time information as the reference date
            if (r.Until != DateTime.MinValue)
            {
                r.Until = DateUtil.MatchTimeZone(referenceDate, new CalDateTime(r.Until, referenceDate.TzId)).Value;
            }

            if (r.Frequency > FrequencyType.Secondly && r.BySecond.Count == 0 && referenceDate.HasTime
                /* NOTE: Fixes a bug where all-day events have BySecond/ByMinute/ByHour added incorrectly */)
            {
                r.BySecond.Add(referenceDate.Second);
            }
            if (r.Frequency > FrequencyType.Minutely && r.ByMinute.Count == 0 && referenceDate.HasTime
                /* NOTE: Fixes a bug where all-day events have BySecond/ByMinute/ByHour added incorrectly */)
            {
                r.ByMinute.Add(referenceDate.Minute);
            }
            if (r.Frequency > FrequencyType.Hourly && r.ByHour.Count == 0 && referenceDate.HasTime
                /* NOTE: Fixes a bug where all-day events have BySecond/ByMinute/ByHour added incorrectly */)
            {
                r.ByHour.Add(referenceDate.Hour);
            }

            // If BYDAY, BYYEARDAY, or BYWEEKNO is specified, then
            // we don't default BYDAY, BYMONTH or BYMONTHDAY
            if (r.ByDay.Count == 0)
            {
                // If the frequency is weekly, use the original date's day of week.
                // NOTE: fixes WeeklyCount1() and WeeklyUntil1() handling
                // If BYWEEKNO is specified and BYMONTHDAY/BYYEARDAY is not specified,
                // then let's add BYDAY to BYWEEKNO.
                // NOTE: fixes YearlyByWeekNoX() handling
                if (r.Frequency == FrequencyType.Weekly || (r.ByWeekNo.Count > 0 && r.ByMonthDay.Count == 0 && r.ByYearDay.Count == 0))
                {
                    r.ByDay.Add(new WeekDay(referenceDate.DayOfWeek));
                }

                // If BYMONTHDAY is not specified,
                // default to the current day of month.
                // NOTE: fixes YearlyByMonth1() handling, added BYYEARDAY exclusion
                // to fix YearlyCountByYearDay1() handling
                if (r.Frequency > FrequencyType.Weekly && r.ByWeekNo.Count == 0 && r.ByYearDay.Count == 0 && r.ByMonthDay.Count == 0)
                {
                    r.ByMonthDay.Add(referenceDate.Day);
                }

                // If BYMONTH is not specified, default to
                // the current month.
                // NOTE: fixes YearlyCountByYearDay1() handling
                if (r.Frequency > FrequencyType.Monthly && r.ByWeekNo.Count == 0 && r.ByYearDay.Count == 0 && r.ByMonth.Count == 0)
                {
                    r.ByMonth.Add(referenceDate.Month);
                }
            }

            return(r);
        }
Esempio n. 39
0
        /**
         * Returns a list of start dates in the specified period represented by this recur. This method includes a base date
         * argument, which indicates the start of the fist occurrence of this recurrence. The base date is used to inject
         * default values to return a set of dates in the correct format. For example, if the search start date (start) is
         * Wed, Mar 23, 12:19PM, but the recurrence is Mon - Fri, 9:00AM - 5:00PM, the start dates returned should all be at
         * 9:00AM, and not 12:19PM.
         */

        private HashSet <DateTime> GetDates(IDateTime seed, DateTime periodStart, DateTime periodEnd, int maxCount, RecurrencePattern pattern,
                                            bool includeReferenceDateInResults)
        {
            var dates        = new HashSet <DateTime>();
            var originalDate = DateUtil.GetSimpleDateTimeData(seed);
            var seedCopy     = DateUtil.GetSimpleDateTimeData(seed);

            // optimize the start time for selecting candidates
            // (only applicable where a COUNT is not specified)
            if (pattern.Count == int.MinValue)
            {
                var incremented = seedCopy;
                while (incremented < periodStart)
                {
                    seedCopy = incremented;
                    IncrementDate(ref incremented, pattern, pattern.Interval);
                }
            }

            var expandBehavior = RecurrenceUtil.GetExpandBehaviorList(pattern);

            var noCandidateIncrementCount = 0;
            var candidate = DateTime.MinValue;

            while (maxCount < 0 || dates.Count < maxCount)
            {
                if (pattern.Until != DateTime.MinValue && candidate != DateTime.MinValue && candidate > pattern.Until)
                {
                    break;
                }

                if (candidate != DateTime.MinValue && candidate > periodEnd)
                {
                    break;
                }

                //No need to continue if the seed is after the periodEnd
                if (seedCopy > periodEnd)
                {
                    break;
                }

                var candidates = GetCandidates(seedCopy, pattern, expandBehavior);
                if (candidates.Count > 0)
                {
                    noCandidateIncrementCount = 0;

                    foreach (var t in candidates.OrderBy(c => c).Where(t => t >= originalDate))
                    {
                        candidate = t;

                        // candidates MAY occur before periodStart
                        // For example, FREQ=YEARLY;BYWEEKNO=1 could return dates
                        // from the previous year.
                        //
                        // exclude candidates that start at the same moment as periodEnd if the period is a range but keep them if targeting a specific moment
                        if (pattern.Count >= 1 && dates.Count >= pattern.Count)
                        {
                            break;
                        }

                        if ((candidate >= periodEnd && periodStart != periodEnd) || candidate > periodEnd && periodStart == periodEnd)
                        {
                            continue;
                        }

                        if (pattern.Until == DateTime.MinValue || candidate <= pattern.Until)
                        {
                            dates.Add(candidate);
                        }
                    }
                }
                else
                {
                    noCandidateIncrementCount++;
                    if (_maxIncrementCount > 0 && noCandidateIncrementCount > _maxIncrementCount)
                    {
                        break;
                    }
                }

                IncrementDate(ref seedCopy, pattern, pattern.Interval);
            }

            return(dates);
        }
Esempio n. 40
0
        public static HashSet <Occurrence> GetOccurrences(IRecurrable recurrable, IDateTime periodStart, IDateTime periodEnd, bool includeReferenceDateInResults)
        {
            var evaluator = recurrable.GetService(typeof(IEvaluator)) as IEvaluator;

            if (evaluator == null || recurrable.Start == null)
            {
                return(new HashSet <Occurrence>());
            }

            // Ensure the start time is associated with the object being queried
            var start = recurrable.Start;

            start.AssociatedObject = recurrable as ICalendarObject;

            // Change the time zone of periodStart/periodEnd as needed
            // so they can be used during the evaluation process.
            periodStart = DateUtil.MatchTimeZone(start, periodStart);
            periodEnd   = DateUtil.MatchTimeZone(start, periodEnd);

            var periods = evaluator.Evaluate(start, DateUtil.GetSimpleDateTimeData(periodStart), DateUtil.GetSimpleDateTimeData(periodEnd), includeReferenceDateInResults);

            var otherOccurrences =
                from p in periods
                let endTime = p.EndTime ?? p.StartTime
                              where endTime.GreaterThan(periodStart) && p.StartTime.LessThanOrEqual(periodEnd)
                              select new Occurrence(recurrable, p);

            var occurrences = new HashSet <Occurrence>(otherOccurrences);

            return(occurrences);
        }
Esempio n. 41
0
 public static HashSet <Occurrence> GetOccurrences(IRecurrable recurrable, IDateTime dt, bool includeReferenceDateInResults) => GetOccurrences(recurrable, new CalDateTime(dt.AsSystemLocal.Date), new CalDateTime(dt.AsSystemLocal.Date.AddDays(1).AddSeconds(-1)),
                                                                                                                                               includeReferenceDateInResults);
Esempio n. 42
0
 public iCalDateTime(IDateTime value)
 {
     Initialize(value.Value, value.TZID, null);
 }
Esempio n. 43
0
 public TimeSpan Subtract(IDateTime dt)
 {
     return(this - dt);
 }
Esempio n. 44
0
 public bool GreaterThanOrEqual(IDateTime dt)
 {
     return(this >= dt);
 }
 public DeleteVehicleLocationHandler(IVehicleLocationService vehicleLocationService, ICurrentUserService currentUserService, IDateTime dateTime)
 {
     _vehicleLocationService = vehicleLocationService ?? throw new ArgumentNullException(nameof(_vehicleLocationService));
 }
Esempio n. 46
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AdminController"/> class.
 /// </summary>
 /// <param name="httpConfigClient">
 /// The HttpClient implementation to use for interfacing with the Habitat Server.
 /// It's assumed that this implementation has been set up with the correct URL and security settings.
 /// </param>
 /// <param name="dateProvider">Provides timestamps in a loosely-coupled manner</param>
 public AdminController(HttpClient httpConfigClient, IDateTime dateProvider)
 {
     _httpConfigClient = httpConfigClient;
     _dateProvider     = dateProvider;
 }
 public GetNetWorthQueryHandler(NetWorthContext context, IMapper mapper, IDateTime dateTime)
 {
     _context  = context;
     _mapper   = mapper;
     _dateTime = dateTime;
 }
Esempio n. 48
0
 public IFreeBusy GetFreeBusy(IDateTime fromInclusive, IDateTime toExclusive)
 {
     return(this.Aggregate <ICalendar, IFreeBusy>(null, (current, iCal) => CombineFreeBusy(current, iCal.GetFreeBusy(fromInclusive, toExclusive))));
 }
Esempio n. 49
0
 public bool LessThanOrEqual(IDateTime dt)
 {
     return(this <= dt);
 }
        /// <summary>
        ///     Gets the dates.
        /// </summary>
        /// <param name="seed">The seed.</param>
        /// <param name="periodStart">The period start.</param>
        /// <param name="periodEnd">The period end.</param>
        /// <param name="maxCount">The max count.</param>
        /// <param name="pattern">The pattern.</param>
        /// <param name="includeReferenceDateInResults">
        ///     if set to <c>true</c> [include reference date in results].
        /// </param>
        /// <returns></returns>
        private IEnumerable <DateTime> GetDates(IDateTime seed, DateTime periodStart, DateTime periodEnd, int maxCount, IRecurrencePattern pattern, bool includeReferenceDateInResults)
        {
            var      dates        = new List <DateTime>( );
            DateTime originalDate = DateUtil.GetSimpleDateTimeData(seed);
            DateTime seedCopy     = DateUtil.GetSimpleDateTimeData(seed);

            if (includeReferenceDateInResults)
            {
                dates.Add(seedCopy);
            }

            // If the interval is set to zero, or our count prevents us
            // from getting additional items, then return with the reference
            // date only.
            if (pattern.Interval == 0 ||
                (pattern.Count != int.MinValue && pattern.Count <= dates.Count))
            {
                return(dates);
            }

            // optimize the start time for selecting candidates
            // (only applicable where a COUNT is not specified)
            if (pattern.Count == int.MinValue)
            {
                DateTime incremented = seedCopy;
                // FIXME: we can more aggressively increment here when
                // the difference between dates is greater.
                IncrementDate(ref incremented, pattern, pattern.Interval);
                while (incremented < periodStart)
                {
                    seedCopy = incremented;
                    IncrementDate(ref incremented, pattern, pattern.Interval);
                }
            }

            bool?[] expandBehavior = RecurrenceUtil.GetExpandBehaviorList(pattern);

            int      invalidCandidateCount     = 0;
            int      noCandidateIncrementCount = 0;
            DateTime candidate = DateTime.MinValue;

            while ((maxCount < 0) || (dates.Count < maxCount))
            {
                if (pattern.Until != DateTime.MinValue && candidate != DateTime.MinValue && candidate > pattern.Until)
                {
                    break;
                }

                if (candidate != DateTime.MinValue && candidate > periodEnd)
                {
                    break;
                }

                if (pattern.Count >= 1 && (dates.Count + invalidCandidateCount) >= pattern.Count)
                {
                    break;
                }

                List <DateTime> candidates = GetCandidates(seedCopy, pattern, expandBehavior);
                if (candidates.Count > 0)
                {
                    noCandidateIncrementCount = 0;

                    // sort candidates for identifying when UNTIL date is exceeded..
                    candidates.Sort( );

                    foreach (DateTime t in candidates)
                    {
                        candidate = t;

                        // don't count candidates that occur before the original date..
                        if (candidate >= originalDate)
                        {
                            // candidates MAY occur before periodStart
                            // For example, FREQ=YEARLY;BYWEEKNO=1 could return dates
                            // from the previous year.
                            //
                            // candidates exclusive of periodEnd..
                            if (candidate >= periodEnd)
                            {
                                invalidCandidateCount++;
                            }
                            else if (pattern.Count >= 1 && (dates.Count + invalidCandidateCount) >= pattern.Count)
                            {
                                break;
                            }
                            else if (pattern.Until == DateTime.MinValue || candidate <= pattern.Until)
                            {
                                if (!dates.Contains(candidate))
                                {
                                    dates.Add(candidate);
                                }
                            }
                        }
                    }
                }
                else
                {
                    noCandidateIncrementCount++;
                    if ((noCandidateIncrementCount > MaxIncrementCount))
                    {
                        break;
                    }
                }

                IncrementDate(ref seedCopy, pattern, pattern.Interval);
            }

            // sort final list..
            dates.Sort( );
            return(dates);
        }
Esempio n. 51
0
 public static DateTime GetSimpleDateTimeData(IDateTime dt)
 {
     return(DateTime.SpecifyKind(dt.Value, dt.IsUniversalTime ? DateTimeKind.Utc : DateTimeKind.Local));
 }
Esempio n. 52
0
 public bool GreaterThan(IDateTime dt)
 {
     return(this > dt);
 }
Esempio n. 53
0
 public static IDateTime StartOfDay(IDateTime dt)
 {
     return(dt.AddHours(-dt.Hour).AddMinutes(-dt.Minute).AddSeconds(-dt.Second));
 }
Esempio n. 54
0
 public CreateExpenseHandler(IExpenseService expenseService, ICurrentUserService currentUserService, IDateTime dateTime, IMapper mapper)
 {
     _expenseService     = expenseService ?? throw new ArgumentNullException(nameof(_expenseService));
     _currentUserService = currentUserService ?? throw new ArgumentNullException(nameof(_currentUserService));
     _dateTime           = dateTime ?? throw new ArgumentNullException(nameof(_dateTime));
     _mapper             = mapper ?? throw new ArgumentNullException(nameof(mapper));
 }
Esempio n. 55
0
 public IFreeBusy GetFreeBusy(IOrganizer organizer, IAttendee[] contacts, IDateTime fromInclusive, IDateTime toExclusive)
 {
     return(this.Aggregate <ICalendar, IFreeBusy>(null, (current, iCal) => CombineFreeBusy(current, iCal.GetFreeBusy(organizer, contacts, fromInclusive, toExclusive))));
 }
Esempio n. 56
0
 /// <summary>
 /// Returns all occurrences of components of type T that start on the date provided.
 /// All components starting between 12:00:00AM and 11:59:59 PM will be
 /// returned.
 /// <note>
 /// This will first Evaluate() the date range required in order to
 /// determine the occurrences for the date provided, and then return
 /// the occurrences.
 /// </note>
 /// </summary>
 /// <param name="dt">The date for which to return occurrences.</param>
 /// <returns>A list of Periods representing the occurrences of this object.</returns>
 virtual public IList <Occurrence> GetOccurrences <T>(IDateTime dt) where T : IRecurringComponent
 {
     return(GetOccurrences <T>(
                new iCalDateTime(dt.Local.Date),
                new iCalDateTime(dt.Local.Date.AddDays(1).AddTicks(-1))));
 }
        /// <summary>
        ///     Processes the recurrence pattern.
        /// </summary>
        /// <param name="referenceDate">The reference date.</param>
        /// <returns></returns>
        private IRecurrencePattern ProcessRecurrencePattern(IDateTime referenceDate)
        {
            var r = new RecurrencePattern( );

            r.CopyFrom(Pattern);

            // Convert the UNTIL value to a local date/time based on the time zone information that
            // is in the reference date
            if (r.Until != DateTime.MinValue)
            {
                // Build an iCalDateTime with the correct time zone & calendar
                var until = new iCalDateTime(r.Until, referenceDate.TzId)
                {
                    AssociatedObject = referenceDate.AssociatedObject
                };

                // Convert back to local time so time zone comparisons match
                r.Until = until.Local;
            }

            if (r.Frequency > FrequencyType.Secondly &&
                r.BySecond.Count == 0 &&
                referenceDate.HasTime /* NOTE: Fixes a bug where all-day events have BySecond/ByMinute/ByHour added incorrectly */)
            {
                r.BySecond.Add(referenceDate.Second);
            }
            if (r.Frequency > FrequencyType.Minutely &&
                r.ByMinute.Count == 0 &&
                referenceDate.HasTime /* NOTE: Fixes a bug where all-day events have BySecond/ByMinute/ByHour added incorrectly */)
            {
                r.ByMinute.Add(referenceDate.Minute);
            }
            if (r.Frequency > FrequencyType.Hourly &&
                r.ByHour.Count == 0 &&
                referenceDate.HasTime /* NOTE: Fixes a bug where all-day events have BySecond/ByMinute/ByHour added incorrectly */)
            {
                r.ByHour.Add(referenceDate.Hour);
            }

            // If BYDAY, BYYEARDAY, or BYWEEKNO is specified, then
            // we don't default BYDAY, BYMONTH or BYMONTHDAY
            if (r.ByDay.Count == 0)
            {
                // If the frequency is weekly, use the original date's day of week.
                // NOTE: fixes WeeklyCount1() and WeeklyUntil1() handling
                // If BYWEEKNO is specified and BYMONTHDAY/BYYEARDAY is not specified,
                // then let's add BYDAY to BYWEEKNO.
                // NOTE: fixes YearlyByWeekNoX() handling
                if (r.Frequency == FrequencyType.Weekly ||
                    (
                        r.ByWeekNo.Count > 0 &&
                        r.ByMonthDay.Count == 0 &&
                        r.ByYearDay.Count == 0
                    ))
                {
                    r.ByDay.Add(new WeekDay(referenceDate.DayOfWeek));
                }

                // If BYMONTHDAY is not specified,
                // default to the current day of month.
                // NOTE: fixes YearlyByMonth1() handling, added BYYEARDAY exclusion
                // to fix YearlyCountByYearDay1() handling
                if (r.Frequency > FrequencyType.Weekly &&
                    r.ByWeekNo.Count == 0 &&
                    r.ByYearDay.Count == 0 &&
                    r.ByMonthDay.Count == 0)
                {
                    r.ByMonthDay.Add(referenceDate.Day);
                }

                // If BYMONTH is not specified, default to
                // the current month.
                // NOTE: fixes YearlyCountByYearDay1() handling
                if (r.Frequency > FrequencyType.Monthly &&
                    r.ByWeekNo.Count == 0 &&
                    r.ByYearDay.Count == 0 &&
                    r.ByMonth.Count == 0)
                {
                    r.ByMonth.Add(referenceDate.Month);
                }
            }

            return(r);
        }
Esempio n. 58
0
 /// <summary>
 /// Returns a list of occurrences of each recurring component
 /// that occur between <paramref name="FromDate"/> and <paramref name="ToDate"/>.
 /// </summary>
 /// <param name="FromDate">The beginning date/time of the range.</param>
 /// <param name="ToDate">The end date/time of the range.</param>
 /// <returns>A list of occurrences that fall between the dates provided.</returns>
 virtual public IList <Occurrence> GetOccurrences(IDateTime startTime, IDateTime endTime)
 {
     return(GetOccurrences <IRecurringComponent>(startTime, endTime));
 }
 public CacheDependencyDateTime(IDateTime dateTimeProvider, DateTime expires)
 {
     _dateTimeProvider = dateTimeProvider;
     this.Expires      = expires;
 }
Esempio n. 60
0
 public bool LessThan(IDateTime dt)
 {
     return(this < dt);
 }