예제 #1
0
        public List <ThresholdResult> ExecuteThresholds(List <VariableContainer> variableContainers, List <ThresholdEntity> thresholdEntities, Dictionary <string, OperationResult> operationResults)
        {
            List <ThresholdResult> resultList = new List <ThresholdResult>();

            foreach (VariableContainer container in variableContainers)
            {
                foreach (ThresholdEntity threshold in thresholdEntities)
                {
                    OperationResult operationResult = operationResults[string.Format("{0}{1}", threshold.OperationId, container.ID)];

                    string result           = string.Empty;
                    string comparisonDetail = string.Empty;
                    if (threshold.Operand.Equals("<"))
                    {
                        result           = operationResult.Result < threshold.ThresholdValue ? "true" : "false";
                        comparisonDetail = string.Format("{0} < {1:N2}", (operationResult.Result % 1 != 0 ? operationResult.Result.ToString("F2") : operationResult.Result.ToString()),
                                                         (threshold.ThresholdValue % 1 != 0 ? threshold.ThresholdValue.ToString("F2") : threshold.ThresholdValue.ToString()));
                    }
                    else if (threshold.Operand.Equals(">"))
                    {
                        result           = operationResult.Result > threshold.ThresholdValue ? "true" : "false";
                        comparisonDetail = string.Format("{0} > {1}", (operationResult.Result % 1 != 0 ? operationResult.Result.ToString("F2") : operationResult.Result.ToString()),
                                                         (threshold.ThresholdValue % 1 != 0 ? threshold.ThresholdValue.ToString("F2") : threshold.ThresholdValue.ToString()));
                    }

                    ThresholdResult thresholdResult = new ThresholdResult
                    {
                        ThresholdId      = threshold.ThresholdId,
                        EntityId         = container.ID,
                        OperationId      = threshold.OperationId,
                        ComparisonDetail = comparisonDetail,
                        Result           = result
                    };
                    resultList.Add(thresholdResult);
                }
            }
            return(resultList);
        }
예제 #2
0
        private (string ContentTemplate, string[] AdditionalContent) GetThresholdEmail(string groupName, ThresholdResult threshold, SyncJob job)
        {
            string increasedThresholdMessage = null;
            string decreasedThresholdMessage = null;
            string contentTemplate           = SyncThresholdBothEmailBody;

            string[] additionalContent;

            increasedThresholdMessage = _localizationRepository.TranslateSetting(
                IncreaseThresholdMessage,
                job.ThresholdPercentageForAdditions.ToString(),
                threshold.IncreaseThresholdPercentage.ToString("F2"));

            decreasedThresholdMessage = _localizationRepository.TranslateSetting(
                DecreaseThresholdMessage,
                job.ThresholdPercentageForRemovals.ToString(),
                threshold.DecreaseThresholdPercentage.ToString("F2"));

            if (threshold.IsAdditionsThresholdExceeded && threshold.IsRemovalsThresholdExceeded)
            {
                additionalContent = new[]
                {
                    groupName,
                    job.TargetOfficeGroupId.ToString(),
                    $"{increasedThresholdMessage}\n{decreasedThresholdMessage}",
                    _gmmResources.LearnMoreAboutGMMUrl,
                    _emailSenderAndRecipients.SupportEmailAddresses
                };
            }
            else if (threshold.IsAdditionsThresholdExceeded)
            {
                additionalContent = new[]
                {
                    groupName,
                    job.TargetOfficeGroupId.ToString(),
                    $"{increasedThresholdMessage}\n",
                    _gmmResources.LearnMoreAboutGMMUrl,
                    _emailSenderAndRecipients.SupportEmailAddresses
                };
            }
            else
            {
                additionalContent = new[]
                {
                    groupName,
                    job.TargetOfficeGroupId.ToString(),
                    $"{decreasedThresholdMessage}\n",
                    _gmmResources.LearnMoreAboutGMMUrl,
                    _emailSenderAndRecipients.SupportEmailAddresses
                };
            }

            return(contentTemplate, additionalContent);
        }
예제 #3
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);
        }
예제 #4
0
        public static void SetFusedScoreAutomaticClassificationThresholdTestRow(ExcelWorksheet ws, ThresholdResult result)
        {
            int signerIndex = Convert.ToInt32(result.Signer);
            int lineIndex   = signerIndex + 1;

            ws.Cells["A" + lineIndex].Value = signerIndex;
            ws.Cells["B" + lineIndex].Value = result.Far;
            ws.Cells["C" + lineIndex].Value = result.Frr;
            ws.Cells["D" + lineIndex].Value = result.Aer;

            ws.Cells["A" + lineIndex].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
        }