public async Task <string> GetGroupNameAsync([ActivityTrigger] GroupNameReaderRequest request)
        {
            await _loggingRepository.LogMessageAsync(new LogMessage { Message = $"{nameof(GroupNameReaderFunction)} function started", RunId = request.RunId });

            var groupName = await _graphUpdaterService.GetGroupNameAsync(request.GroupId);

            await _loggingRepository.LogMessageAsync(new LogMessage { Message = $"{nameof(GroupNameReaderFunction)} function completed", RunId = request.RunId });

            return(groupName);
        }
コード例 #2
0
        private async Task SendThresholdNotificationAsync(ThresholdResult threshold, SyncJob job, Guid runId)
        {
            var currentThresholdViolations = job.ThresholdViolations + 1;
            var followUpLimit              = _thresholdConfig.NumberOfThresholdViolationsToNotify + _thresholdConfig.NumberOfThresholdViolationsFollowUps;
            var sendNotification           = currentThresholdViolations >= _thresholdConfig.NumberOfThresholdViolationsToNotify && currentThresholdViolations <= followUpLimit;
            var sendDisableJobNotification = currentThresholdViolations == _thresholdConfig.NumberOfThresholdViolationsToDisableJob;

            if (!sendNotification && !sendDisableJobNotification)
            {
                return;
            }

            var groupName = await _graphUpdaterService.GetGroupNameAsync(job.TargetOfficeGroupId);

            var emailSubject = SyncThresholdEmailSubject;

            await _loggingRepository.LogMessageAsync(new LogMessage { Message = $"Threshold exceeded, no changes made to group {groupName} ({job.TargetOfficeGroupId}). ", RunId = runId });

            string contentTemplate;

            string[] additionalContent;
            string[] additionalSubjectContent = new[] { groupName };

            var thresholdEmail = GetThresholdEmail(groupName, threshold, job);

            contentTemplate   = thresholdEmail.ContentTemplate;
            additionalContent = thresholdEmail.AdditionalContent;

            var recipients = _emailSenderAndRecipients.SupportEmailAddresses ?? _emailSenderAndRecipients.SyncDisabledCCAddresses;

            if (!string.IsNullOrWhiteSpace(job.Requestor))
            {
                var recipientList = await GetThresholdRecipientsAsync(job.Requestor, job.TargetOfficeGroupId);

                if (recipientList.Count > 0)
                {
                    recipients = string.Join(",", recipientList);
                }
            }

            if (sendDisableJobNotification)
            {
                emailSubject      = SyncThresholdDisablingJobEmailSubject;
                contentTemplate   = SyncJobDisabledEmailBody;
                additionalContent = new[]
                {
                    groupName,
                    job.TargetOfficeGroupId.ToString(),
                    _gmmResources.LearnMoreAboutGMMUrl,
                    _emailSenderAndRecipients.SupportEmailAddresses
                };
            }

            await _graphUpdaterService.SendEmailAsync(
                recipients,
                contentTemplate,
                additionalContent,
                runId,
                ccEmail : _emailSenderAndRecipients.SupportEmailAddresses,
                emailSubject : emailSubject,
                additionalSubjectParams : additionalSubjectContent);
        }