コード例 #1
0
 /// <summary>
 /// Initialize controller with injectors.
 /// </summary>
 /// <param name="unitOfWork"></param>
 /// <param name="identityService"></param>
 /// <param name="systemTimeService"></param>
 public ApiBasicController(IUnitOfWork unitOfWork, IIdentityService identityService,
                           ISystemTimeService systemTimeService)
 {
     UnitOfWork        = unitOfWork;
     IdentityService   = identityService;
     SystemTimeService = systemTimeService;
 }
 public ShiftChangeHandler(TeamOrchestratorOptions teamOptions, IScheduleConnectorService scheduleConnectorService, IRequestCacheService requestCacheService, ISecretsService secretsService, IStringLocalizer <ChangeRequestTrigger> stringLocalizer, IScheduleCacheService scheduleCacheService, ISystemTimeService systemTimeService)
     : base(scheduleConnectorService, requestCacheService, secretsService, stringLocalizer)
 {
     _teamOptions          = teamOptions ?? throw new ArgumentNullException(nameof(teamOptions));
     _scheduleCacheService = scheduleCacheService ?? throw new ArgumentNullException(nameof(scheduleCacheService));
     _systemTimeService    = systemTimeService ?? throw new ArgumentNullException(nameof(systemTimeService));
 }
コード例 #3
0
 public OrchestratorTimerTrigger(TeamOrchestratorOptions teamOrchestratorOptions, FeatureOptions featureOptions, IScheduleConnectorService scheduleConnectorService, ISystemTimeService systemTimeService)
 {
     _options                  = teamOrchestratorOptions ?? throw new ArgumentNullException(nameof(teamOrchestratorOptions));
     _featureOptions           = featureOptions ?? throw new ArgumentNullException(nameof(featureOptions));
     _scheduleConnectorService = scheduleConnectorService ?? throw new ArgumentNullException(nameof(scheduleConnectorService));
     _systemTimeService        = systemTimeService ?? throw new ArgumentNullException(nameof(systemTimeService));
 }
コード例 #4
0
 /// <summary>
 /// Initiate controller with injectors.
 /// </summary>
 /// <param name="unitOfWork"></param>
 /// <param name="identityService"></param>
 /// <param name="systemTimeService"></param>
 /// <param name="specializedBusiness"></param>
 public SpecializedController(IUnitOfWork unitOfWork,
                              IIdentityService identityService,
                              ISystemTimeService systemTimeService,
                              ISpecializedBusiness specializedBusiness) : base(unitOfWork, identityService, systemTimeService)
 {
     _specializedBusiness = specializedBusiness;
 }
コード例 #5
0
ファイル: LoginViewModel.cs プロジェクト: danielwoodhead/app
 public LoginViewModel(
     IIdentityService identityService,
     ISettingsService settingsService,
     ISystemTimeService systemTimeService)
 {
     _identityService   = identityService;
     _settingsService   = settingsService;
     _systemTimeService = systemTimeService;
 }
コード例 #6
0
        public static string ConvertToLocalTime(string time, string localTimeZone, ISystemTimeService timeService)
        {
            var localDateTime = DateTime.ParseExact(time, "HH:mm:ss", CultureInfo.InvariantCulture);

            if (timeService.Today != DateTime.Today)
            {
                // in a testing scenario where we are working to a date other than today it is
                // necessary to reformulate the localDateTime to the date specified for the test,
                // otherwise it defaults to today
                localDateTime = timeService.Today.AddHours(localDateTime.Hour).AddMinutes(localDateTime.Minute).AddSeconds(localDateTime.Second);
            }

            var dateTime = localDateTime.ApplyTimeZoneOffset(localTimeZone);

            return(dateTime.AsTimeString());
        }
コード例 #7
0
 public SubscribeTrigger(TeamOrchestratorOptions teamOrchestratorOptions, MicrosoftGraphOptions options,
                         FeatureOptions featureOptions, IScheduleConnectorService scheduleConnectorService, IWfmDataService wfmDataService,
                         ITeamsService teamsService, ISecretsService secretsService, IHttpClientFactory httpClientFactory,
                         ISystemTimeService systemTimeService, ITimeZoneService timeZoneService)
 {
     _teamOrchestratorOptions = teamOrchestratorOptions ?? throw new ArgumentNullException(nameof(teamOrchestratorOptions));
     _options                  = options ?? throw new ArgumentNullException(nameof(options));
     _featureOptions           = featureOptions ?? throw new ArgumentNullException(nameof(featureOptions));
     _scheduleConnectorService = scheduleConnectorService ?? throw new ArgumentNullException(nameof(scheduleConnectorService));
     _wfmDataService           = wfmDataService ?? throw new ArgumentNullException(nameof(wfmDataService));
     _teamsService             = teamsService ?? throw new ArgumentNullException(nameof(teamsService));
     _secretsService           = secretsService ?? throw new ArgumentNullException(nameof(secretsService));
     _httpClientFactory        = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory));
     _systemTimeService        = systemTimeService ?? throw new ArgumentNullException(nameof(systemTimeService));
     _timeZoneService          = timeZoneService ?? throw new ArgumentNullException(nameof(timeZoneService));
 }
 public ClearScheduleTrigger(TeamOrchestratorOptions options, ISystemTimeService timeService, IScheduleConnectorService scheduleConnectorService)
 {
     _options     = options ?? throw new System.ArgumentNullException(nameof(options));
     _timeService = timeService ?? throw new ArgumentNullException(nameof(timeService));
     _scheduleConnectorService = scheduleConnectorService ?? throw new ArgumentNullException(nameof(scheduleConnectorService));
 }
コード例 #9
0
 public MicrosoftGraphAvailabilityMap(ConnectorOptions options, ISystemTimeService timeService)
 {
     _options     = options ?? throw new ArgumentNullException(nameof(options));
     _timeService = timeService ?? throw new ArgumentNullException(nameof(timeService));
 }
コード例 #10
0
 /// <summary>
 /// Initiate controller with injectors.
 /// </summary>
 /// <param name="unitOfWork"></param>
 /// <param name="identityService"></param>
 /// <param name="systemTimeService"></param>
 public SpecializedController(IUnitOfWork unitOfWork, IIdentityService identityService, ISystemTimeService systemTimeService) : base(unitOfWork, identityService, systemTimeService)
 {
 }
        private static DaylightTime GetDaylightChanges(TimeZoneInfo timezoneInfo, int year, ISystemTimeService timeService)
        {
            var currentRules = timezoneInfo.GetAdjustmentRules().FirstOrDefault(rule => rule.DateStart <= timeService.Today && rule.DateEnd >= timeService.Today);

            if (currentRules != null)
            {
                var daylightStart = GetTransitionDate(currentRules.DaylightTransitionStart, year);

                var daylightEnd = GetTransitionDate(currentRules.DaylightTransitionEnd, year);

                return(new DaylightTime(daylightStart, daylightEnd, currentRules.DaylightDelta));
            }

            return(null);
        }
コード例 #12
0
 /// <summary>
 /// Initialize controller with injectors.
 /// </summary>
 /// <param name="unitOfWork"></param>
 /// <param name="identityService"></param>
 /// <param name="systemTimeService"></param>
 /// <param name="encryptionService"></param>
 /// <param name="emailService"></param>
 /// <param name="profileCacheService"></param>
 public AccountController(IUnitOfWork unitOfWork, IIdentityService identityService, ISystemTimeService systemTimeService, IEncryptionService encryptionService, IValueCacheService <int, ProfileViewModel> profileCacheService, IEmailService emailService) : base(unitOfWork, identityService, systemTimeService)
 {
     _encryptionService   = encryptionService;
     _emailService        = emailService;
     _profileCacheService = profileCacheService;
 }
コード例 #13
0
ファイル: JwtService.cs プロジェクト: VadimProkopchuk/VPX
 public JwtService(IOptions <AppSettings> options,
                   ISystemTimeService systemTimeService)
 {
     jwtSettings            = options.Value.Jwt;
     this.systemTimeService = systemTimeService;
 }
コード例 #14
0
 /// <summary>
 /// Initialize controller with injectors.
 /// </summary>
 /// <param name="unitOfWork"></param>
 /// <param name="identityService"></param>
 /// <param name="systemTimeService"></param>
 /// <param name="encryptionService"></param>
 public AccountController(IUnitOfWork unitOfWork, IIdentityService identityService, ISystemTimeService systemTimeService, IEncryptionService encryptionService) : base(unitOfWork, identityService, systemTimeService)
 {
     _encryptionService = encryptionService;
 }
        public static DateTime ConvertFromLocalTime(this DateTime dt, string timeZone, ISystemTimeService timeService)
        {
            var timezoneInfo = TZConvert.GetTimeZoneInfo(timeZone);

            dt = AdjustForDaylightSaving(dt, timezoneInfo, timeService);
            var localDateTime = DateTime.SpecifyKind(dt, DateTimeKind.Unspecified);

            return(TimeZoneInfo.ConvertTimeToUtc(localDateTime, timezoneInfo));
        }
        /// <summary>
        /// Finds the shift with the specified teams shift ID by searching all the cached shifts in
        /// the specified range of weeks.
        /// </summary>
        /// <param name="shiftId">The teams ID of the shift to search for.</param>
        /// <param name="teamId">The ID of the team containing the shift.</param>
        /// <param name="pastWeeks">The number of past weeks to search.</param>
        /// <param name="futureWeeks">The number of future weeks to search.</param>
        /// <param name="startDayOfWeek">The start day of the week for the team.</param>
        /// <param name="scheduleCacheService">The schedule cache service to use to load the schedules.</param>
        /// <param name="timeService">The time service to use to get the current times.</param>
        /// <returns></returns>
        internal static async Task <ShiftModel> FindShiftByTeamsShiftIdAsync(string shiftId, string teamId, int pastWeeks, int futureWeeks, DayOfWeek startDayOfWeek, IScheduleCacheService scheduleCacheService, ISystemTimeService timeService)
        {
            var cacheModels = await LoadSchedulesAsync(teamId, pastWeeks, futureWeeks, startDayOfWeek, scheduleCacheService, timeService).ConfigureAwait(false);

            return(FindShiftByTeamsShiftId(cacheModels, shiftId));
        }
コード例 #17
0
 public NavigationService(ISettingsService settingsService, ISystemTimeService systemTimeService)
 {
     _settingsService   = settingsService;
     _systemTimeService = systemTimeService;
 }
        /// <summary>
        /// Loads and returns all the cached schedules for the team between and including the past
        /// and future weeks.
        /// </summary>
        /// <param name="teamId">The ID of the team to return the cached schedules for.</param>
        /// <param name="pastWeeks">The number of past weeks to return.</param>
        /// <param name="futureWeeks">The number of future weeks to return.</param>
        /// <param name="startDayOfWeek">The start day of the week for the team.</param>
        /// <param name="scheduleCacheService">The schedule cache service to use to load the schedules.</param>
        /// <param name="timeService">The time service to use to get the current times.</param>
        /// <returns>The array of cached schedules.</returns>
        internal static async Task <CacheModel <ShiftModel>[]> LoadSchedulesAsync(string teamId, int pastWeeks, int futureWeeks, DayOfWeek startDayOfWeek, IScheduleCacheService scheduleCacheService, ISystemTimeService timeService)
        {
            var loadScheduleTasks = timeService.UtcNow
                                    .Range(pastWeeks, futureWeeks, startDayOfWeek)
                                    .Select(w => scheduleCacheService.LoadScheduleAsync(teamId, w));

            return(await Task.WhenAll(loadScheduleTasks).ConfigureAwait(false));
        }
コード例 #19
0
 /// <summary>
 /// Initiate controller with injectors.
 /// </summary>
 /// <param name="unitOfWork"></param>
 /// <param name="identityService"></param>
 /// <param name="systemTimeService"></param>
 public ClassController(IUnitOfWork unitOfWork, IIdentityService identityService, ISystemTimeService systemTimeService) : base(unitOfWork, identityService, systemTimeService)
 {
 }
        private static DateTime AdjustForDaylightSaving(DateTime dt, TimeZoneInfo timezoneInfo, ISystemTimeService timeService)
        {
            var key = $"{timezoneInfo.Id}_{dt.Year}";

            if (!_daylightTimes.ContainsKey(key))
            {
                _daylightTimes[key] = GetDaylightChanges(timezoneInfo, dt.Year, timeService);
            }

            var daylightTime = _daylightTimes[key];

            if (daylightTime != null && dt >= daylightTime.Start && dt < daylightTime.Start.Add(daylightTime.Delta))
            {
                // the datetime falls within the delta of time that will be skipped over when the
                // transition to daylight savings time occurs e.g. in the UK this is in period
                // 01:00:00 to 01:59:59, so shift the time forward by the delta e.g. in the UK a
                // time of 01:25 say will be shifted to 02:25
                return(dt.Add(daylightTime.Delta));
            }

            return(dt);
        }