示例#1
0
        /// <summary>
        /// Sends a notification to the user, this is usually for testing the settings.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="settings">The settings.</param>
        /// <returns></returns>
        public async Task Publish(NotificationOptions model, Settings.Settings.Models.Settings settings)
        {
            var notificationTasks = NotificationAgents.Select(notification => NotifyAsync(notification, model, settings));

            await Task.WhenAll(notificationTasks).ConfigureAwait(false);
        }
示例#2
0
        public async Task NotifyAsync(NotificationOptions model, Settings.Settings.Models.Settings settings)
        {
            Settings.ClearCache();
            if (settings == null)
            {
                await NotifyAsync(model);
            }

            var notificationSettings = (T)settings;

            if (!ValidateConfiguration(notificationSettings))
            {
                return;
            }

            // Is this a test?
            // The request id for tests is -1
            // Also issues are 0 since there might not be a request associated
            if (model.RequestId > 0)
            {
                await LoadRequest(model.RequestId, model.RequestType);
            }

            Customization = await CustomizationSettings.GetSettingsAsync();

            try
            {
                switch (model.NotificationType)
                {
                case NotificationType.NewRequest:
                    await NewRequest(model, notificationSettings);

                    break;

                case NotificationType.Issue:
                    await NewIssue(model, notificationSettings);

                    break;

                case NotificationType.RequestAvailable:
                    await AvailableRequest(model, notificationSettings);

                    break;

                case NotificationType.RequestApproved:
                    await RequestApproved(model, notificationSettings);

                    break;

                case NotificationType.Test:
                    await Test(model, notificationSettings);

                    break;

                case NotificationType.RequestDeclined:
                    await RequestDeclined(model, notificationSettings);

                    break;

                case NotificationType.ItemAddedToFaultQueue:
                    await AddedToRequestQueue(model, notificationSettings);

                    break;

                case NotificationType.IssueResolved:
                    await IssueResolved(model, notificationSettings);

                    break;

                case NotificationType.IssueComment:
                    await IssueComment(model, notificationSettings);

                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            catch (NotImplementedException)
            {
                // Do nothing, it's not implimented meaning it might not be ready or even used
            }
        }