public List <string> GetNotificationProviderClassNames(NotificationProviderType type,
                                                               UserConnection userConnection)
        {
            var result = new List <string>();

            if (userConnection.GetIsFeatureEnabled("NotificationV2") && type != NotificationProviderType.Visa)
            {
                return(result);
            }
            var providersSelect = new Select(userConnection)
                                  .Column("NotificationProvider", "ClassName")
                                  .From("NotificationProvider")
                                  .Where("Type").IsEqual(Column.Parameter((int)type)) as Select;

            using (var dbExecutor = userConnection.EnsureDBConnection()) {
                using (var dataReader = providersSelect.ExecuteReader(dbExecutor)) {
                    int columnIndex = dataReader.GetOrdinal("ClassName");
                    while (dataReader.Read())
                    {
                        result.Add(dataReader.GetString(columnIndex));
                    }
                }
            }
            return(result);
        }
        private string GetPopupConfig(Guid sysAdminUnitId, NotificationProviderType type, DateTime date)
        {
            var           methodName    = "GetPopupConfig";
            var           result        = string.Empty;
            List <object> methodResults = GetResult(sysAdminUnitId, type, date, methodName).ToList();

            return(string.Join(", ", methodResults.FindAll(a => !string.IsNullOrWhiteSpace((string)a))));
        }
        private List <string> GetNotificationProviderClassNames(NotificationProviderType type)
        {
            bool isFeatureEnabled = _userConnection.GetIsFeatureEnabled("NotificationsOnOneClassJob");

            if (isFeatureEnabled)
            {
                return(GetNotImplementedProviders(_userConnection, type).ToList());
            }
            return(_notificationUtilities.GetNotificationProviderClassNames(type, _userConnection));
        }
        private IEnumerable <string> GetNotImplementedProviders(UserConnection userConnection,
                                                                NotificationProviderType type)
        {
            var store  = new NotificationStore();
            var helper = new ImplementedNotificationProviderHelper(userConnection, store);
            IDictionary <string, NotificationProviderType> providers = helper.GetNotImplementedProviders();

            return(providers
                   .Where(provider => provider.Value.Equals(type))
                   .Select(provider => provider.Key));
        }
        private int GetCount(Guid sysAdminUnitId, NotificationProviderType type, DateTime date)
        {
            var           methodName    = "GetCount";
            int           result        = 0;
            List <object> methodResults = GetResult(sysAdminUnitId, type, date, methodName).ToList();

            foreach (object item in methodResults)
            {
                result += (int)item;
            }
            return(result);
        }
Пример #6
0
        /// <inheritdoc/>
        public INotificationProvider GetNotificationProvider(NotificationProviderType type)
        {
            switch (type)
            {
            case NotificationProviderType.Graph:
                return((INotificationProvider)this.serviceProvider.GetService(typeof(MSGraphNotificationProvider)));

            case NotificationProviderType.DirectSend:
                return((INotificationProvider)this.serviceProvider.GetService(typeof(DirectSendNotificationProvider)));

            default:
                return(null);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="NotificationProviderSettings" /> class.
 /// </summary>
 /// <param name="Provider">Provider (required).</param>
 /// <param name="Settings">Settings (required).</param>
 public NotificationProviderSettings(NotificationProviderType Provider = default(NotificationProviderType), NotificationSettings Settings = default(NotificationSettings))
 {
     // to ensure "Provider" is required (not null)
     if (Provider == null)
     {
         throw new InvalidDataException("Provider is a required property for NotificationProviderSettings and cannot be null");
     }
     else
     {
         this.Provider = Provider;
     }
     // to ensure "Settings" is required (not null)
     if (Settings == null)
     {
         throw new InvalidDataException("Settings is a required property for NotificationProviderSettings and cannot be null");
     }
     else
     {
         this.Settings = Settings;
     }
 }
        private IEnumerable <object> GetResult(Guid sysAdminUnitId, NotificationProviderType type, DateTime date, string methodName)
        {
            var result     = new List <object>();
            var parameters = new Dictionary <string, object> {
                {
                    "sysAdminUnitId", sysAdminUnitId
                }, {
                    "dueDate", date
                }, {
                    "userConnection", _userConnection
                }
            };
            List <string> classNames = GetNotificationProviderClassNames(type);

            object[] objectParams = { parameters };
            foreach (string className in classNames)
            {
                object methodResult = _notificationUtilities
                                      .GetMethodResult(className, methodName, objectParams);
                result.Add(methodResult);
            }
            return(result);
        }
 public string GetMessage(int id, NotificationProviderType notificationProviderType)
 {
     throw new NotImplementedException();
 }
Пример #10
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to add services to the container.
        /// </summary>
        /// <param name="services">An instance of <see cref="IServiceCollection"/>.</param>
        public void ConfigureServices(IServiceCollection services)
        {
            this.ConfigureServicesCommon(services);

            _ = services.AddMvc();
            _ = services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "NotificationService", Version = "v1"
                });
            });

            ITelemetryInitializer[] itm = new ITelemetryInitializer[1];
            var envInitializer          = new EnvironmentInitializer
            {
                Service         = this.Configuration[AIConstants.ServiceConfigName],
                ServiceLine     = this.Configuration[AIConstants.ServiceLineConfigName],
                ServiceOffering = this.Configuration[AIConstants.ServiceOfferingConfigName],
                ComponentId     = this.Configuration[AIConstants.ComponentIdConfigName],
                ComponentName   = this.Configuration[AIConstants.ComponentNameConfigName],
                EnvironmentName = this.Configuration[AIConstants.EnvironmentName],
                IctoId          = "IctoId",
            };

            itm[0] = envInitializer;

            NotificationProviders.Common.Logger.LoggingConfiguration loggingConfiguration = new NotificationProviders.Common.Logger.LoggingConfiguration
            {
                IsTraceEnabled  = true,
                TraceLevel      = (SeverityLevel)Enum.Parse(typeof(SeverityLevel), this.Configuration[ConfigConstants.AITraceLelelConfigKey]),
                EnvironmentName = this.Configuration[AIConstants.EnvironmentName],
            };

            var tconfig = TelemetryConfiguration.CreateDefault();

            tconfig.InstrumentationKey = this.Configuration[ConfigConstants.AIInsrumentationConfigKey];

            DependencyTrackingTelemetryModule depModule = new DependencyTrackingTelemetryModule();

            depModule.Initialize(tconfig);

            RequestTrackingTelemetryModule requestTrackingTelemetryModule = new RequestTrackingTelemetryModule();

            requestTrackingTelemetryModule.Initialize(tconfig);

            _ = services.AddSingleton <NotificationProviders.Common.Logger.ILogger>(_ => new NotificationProviders.Common.Logger.AILogger(loggingConfiguration, tconfig, itm));

            _ = services.AddScoped <IEmailManager, EmailManager>(s =>
                                                                 new EmailManager(
                                                                     this.Configuration,
                                                                     s.GetService <IRepositoryFactory>(),
                                                                     s.GetService <ILogger>(),
                                                                     s.GetService <IMailTemplateManager>(),
                                                                     s.GetService <ITemplateMerge>()))
                .AddScoped <IEmailServiceManager, EmailServiceManager>(s =>
                                                                       new EmailServiceManager(this.Configuration, s.GetService <IRepositoryFactory>(), s.GetService <ICloudStorageClient>(), s.GetService <ILogger>(),
                                                                                               s.GetService <INotificationProviderFactory>(), s.GetService <IEmailManager>()))
                .AddScoped <ITemplateMerge, TemplateMerge>()
                .AddSingleton <IEmailAccountManager, EmailAccountManager>()
                .AddScoped <INotificationProviderFactory, NotificationProviderFactory>();

            NotificationProviderType providerType = (NotificationProviderType)Enum.Parse(typeof(NotificationProviderType), this.Configuration[ConfigConstants.NotificationProviderType]);

            if (NotificationProviderType.DirectSend == providerType)
            {
                this.ConfigureDirectSendServices(services);
            }
            else if (NotificationProviderType.SMTP == providerType)
            {
                this.ConfigureSMTPServices(services);
            }
            else
            {
                this.ConfigureGraphServices(services);
            }
        }