Beispiel #1
0
 public TeamOrchestrator(TeamOrchestratorOptions options, IScheduleConnectorService scheduleConnectorService, IScheduleSourceService scheduleSourceService, ITimeZoneService timeZoneService)
 {
     _options = options ?? throw new ArgumentNullException(nameof(options));
     _scheduleConnectorService = scheduleConnectorService ?? throw new ArgumentNullException(nameof(scheduleConnectorService));
     _scheduleSourceService    = scheduleSourceService ?? throw new ArgumentNullException(nameof(scheduleSourceService));
     _timeZoneService          = timeZoneService ?? throw new ArgumentNullException(nameof(timeZoneService));
 }
Beispiel #2
0
 public TeamHealthTrigger(ConnectorOptions options, ISecretsService secretsService, IScheduleSourceService scheduleSourceService, IScheduleConnectorService scheduleConnectorService, IScheduleDestinationService scheduleDestinationService, IScheduleCacheService scheduleCacheService)
 {
     _options                    = options ?? throw new ArgumentNullException(nameof(options));
     _secretsService             = secretsService ?? throw new ArgumentNullException(nameof(secretsService));
     _scheduleSourceService      = scheduleSourceService ?? throw new ArgumentNullException(nameof(scheduleSourceService));
     _scheduleConnectorService   = scheduleConnectorService ?? throw new ArgumentNullException(nameof(scheduleConnectorService));
     _scheduleDestinationService = scheduleDestinationService ?? throw new ArgumentNullException(nameof(scheduleDestinationService));
     _scheduleCacheService       = scheduleCacheService ?? throw new ArgumentNullException(nameof(scheduleCacheService));
 }
Beispiel #3
0
 public SubscribeTrigger(MicrosoftGraphOptions options, IScheduleConnectorService scheduleConnectorService, IScheduleSourceService scheduleSourceService, IScheduleDestinationService scheduleDestinationService, ISecretsService secretsService, IHttpClientFactory httpClientFactory)
 {
     _options = options ?? throw new ArgumentNullException(nameof(options));
     _scheduleConnectorService   = scheduleConnectorService ?? throw new ArgumentNullException(nameof(scheduleConnectorService));
     _scheduleSourceService      = scheduleSourceService ?? throw new ArgumentNullException(nameof(scheduleSourceService));
     _scheduleDestinationService = scheduleDestinationService ?? throw new ArgumentNullException(nameof(scheduleDestinationService));
     _secretsService             = secretsService ?? throw new ArgumentNullException(nameof(secretsService));
     _httpClientFactory          = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory));
 }
Beispiel #4
0
 public WeekActivity(WeekActivityOptions options, IScheduleSourceService scheduleSourceService, IScheduleCacheService scheduleCacheService,
                     IScheduleDestinationService scheduleDestinationService, IScheduleDeltaService scheduleDeltaService, ISecretsService secretsService)
 {
     _options = options ?? throw new ArgumentNullException(nameof(options));
     _scheduleSourceService      = scheduleSourceService ?? throw new ArgumentNullException(nameof(scheduleSourceService));
     _scheduleCacheService       = scheduleCacheService ?? throw new ArgumentNullException(nameof(scheduleCacheService));
     _scheduleDestinationService = scheduleDestinationService ?? throw new ArgumentNullException(nameof(scheduleDestinationService));
     _scheduleDeltaService       = scheduleDeltaService ?? throw new ArgumentNullException(nameof(scheduleDeltaService));
     _secretsService             = secretsService ?? throw new ArgumentNullException(nameof(secretsService));
 }
Beispiel #5
0
        public static async Task <string> GetTimeZoneAsync(string teamId, int?timeZoneId, ITimeZoneService timeZoneService, IScheduleSourceService scheduleSourceService, IScheduleConnectorService scheduleConnectorService, ILogger log)
        {
            if (timeZoneId.HasValue)
            {
                var jdaTimeZoneName = await scheduleSourceService.GetJdaTimeZoneNameAsync(teamId, timeZoneId.Value).ConfigureAwait(false);

                try
                {
                    return(await timeZoneService.GetTimeZoneInfoIdAsync(jdaTimeZoneName).ConfigureAwait(false));
                }
                catch (KeyNotFoundException ex)
                {
                    // the BY time zone name was not found in the map table so just return null
                    log.LogTimeZoneError(ex, teamId, timeZoneId.Value, jdaTimeZoneName);
                }
            }

            return(null);
        }
Beispiel #6
0
        public static async Task <string> GetAndUpdateTimeZoneAsync(string teamId, ITimeZoneService timeZoneService, IScheduleConnectorService scheduleConnectorService, IScheduleSourceService scheduleSourceService)
        {
            var connection = await scheduleConnectorService.GetConnectionAsync(teamId).ConfigureAwait(false);

            if (connection == null)
            {
                // the team must have been unsubscribed
                throw new ArgumentException("This team cannot be found in the teams table.", teamId);
            }

            if (!string.IsNullOrEmpty(connection.TimeZoneInfoId))
            {
                return(connection.TimeZoneInfoId);
            }
            else
            {
                // we don't have a timezone for this existing connection, so try to get one
                var store = await scheduleSourceService.GetStoreAsync(connection.TeamId, connection.StoreId).ConfigureAwait(false);

                if (store?.TimeZoneId != null)
                {
                    var jdaTimeZoneName = await scheduleSourceService.GetJdaTimeZoneNameAsync(teamId, store.TimeZoneId.Value).ConfigureAwait(false);

                    var timeZoneInfoId = await timeZoneService.GetTimeZoneInfoIdAsync(jdaTimeZoneName).ConfigureAwait(false);

                    if (timeZoneInfoId != null)
                    {
                        connection.TimeZoneInfoId = timeZoneInfoId;
                        await scheduleConnectorService.SaveConnectionAsync(connection).ConfigureAwait(false);

                        return(timeZoneInfoId);
                    }
                }
            }

            return(null);
        }