public async void Get_Customer_Mapping_Correct(Customer customer, NotificationConfiguration configuration)
        {
            string instanceName = Guid.NewGuid().ToString();

            using (var context = TestUtilities.GetDbContext(instanceName)) {
                customer.Subscriptions.Add(new NotificationSubscription()
                {
                    NotificationConfiguration = configuration,
                    IsDeleted = false
                });
                context.Customers.Add(customer);
                await context.SaveChangesAsync();
            }
            using (var context = TestUtilities.GetDbContext(instanceName)) {
                CustomerService service = new CustomerService(context, TestUtilities.GetMapper());

                CustomerItemModel item = await service.Get <CustomerItemModel>(customer.Id);

                Assert.Equal(customer.Contact.FirstName, item.Contact.FirstName);

                CustomerDetailModel model = await service.Get <CustomerDetailModel>(customer.Id);

                Assert.NotEmpty(model.SubscriptionConfiguration.Subscriptions);
            }
        }
Esempio n. 2
0
        public void Configuration(IAppBuilder app)
        {
            ConfigureAuth(app);

            var notificationConfig = new NotificationConfiguration(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString).RegisterNotifications(new Notification()
            {
                NotificationTriggered = (sender, model) =>
                {
                    new NotificationHandlerBuilder().NotificationTriggered(model);
                },
                NotifySpecificUsers = notification =>
                {
                    return(new NotificationHandlerBuilder().NotifySpecificUsers(notification));
                },
                AddAdditionalUserNotificationData = notification =>
                {
                    return(new NotificationHandlerBuilder().AddAdditionalUserNotificationData(notification));
                },
            });

            app.UseNotificationService(notificationConfig);


            //Azure Push
            var pushConfig = new PushNotifications.Configuration.PushNotificationServiceConfiguration()
                             .UseAzurePushNotifications(
                ConfigurationManager.ConnectionStrings["AzureHubConnection"].ConnectionString,
                ConfigurationManager.AppSettings["HubName"]);

            app.UsePushNotificationService(pushConfig);
        }
        public async Task <IActionResult> SaveNotificationConfiguration(UserSettingsViewModel viewModel)
        {
            if (!User.IsInRole(RoleNames.ROLE_ADMIN))
            {
                return(RedirectToAction(MethodNames.INDEX, viewModel));
            }

            var user = await _userManager.GetUserAsync(User);

            NotificationConfiguration config = _notificationConfigRepository.Find(c => c.AdminId == user.UserId).FirstOrDefault();

            if (config == null)
            {
                config         = new NotificationConfiguration();
                config.AdminId = user.UserId;
                _notificationConfigRepository.Add(config, false);
            }

            config.NewUserRegistered        = viewModel.NotificationConfiguration.NewUserRegistered;
            config.UserParticipationUpdated = viewModel.NotificationConfiguration.UserParticipationUpdated;

            _notificationConfigRepository.CommitChanges();

            return(RedirectToAction(MethodNames.INDEX, ControllerNames.HOME));
        }
 private static void WriteConfigurationCommon(XmlWriter xmlWriter, NotificationConfiguration notificationConfiguration)
 {
     if (notificationConfiguration.IsSetEvents())
     {
         foreach (EventType @event in notificationConfiguration.Events)
         {
             xmlWriter.WriteElementString("Event", "", S3Transforms.ToXmlStringValue(ConstantClass.op_Implicit(@event)));
         }
     }
     if (notificationConfiguration.IsSetFilter())
     {
         xmlWriter.WriteStartElement("Filter", "");
         Filter filter = notificationConfiguration.Filter;
         if (filter.IsSetS3KeyFilter())
         {
             xmlWriter.WriteStartElement("S3Key", "");
             S3KeyFilter s3KeyFilter = filter.S3KeyFilter;
             if (s3KeyFilter.IsSetFilterRules())
             {
                 foreach (FilterRule filterRule in s3KeyFilter.FilterRules)
                 {
                     if (filterRule != null)
                     {
                         xmlWriter.WriteStartElement("FilterRule", "");
                         xmlWriter.WriteElementString("Name", filterRule.Name);
                         xmlWriter.WriteElementString("Value", filterRule.Value);
                         xmlWriter.WriteEndElement();
                     }
                 }
             }
             xmlWriter.WriteEndElement();
         }
         xmlWriter.WriteEndElement();
     }
 }
Esempio n. 5
0
        private void Window_Activated(object sender, EventArgs e)
        {
            WindowState = WindowState.Minimized;

            slider.Maximum   = sleepTime - 1;
            labelMax.Content = (sleepTime - 1).ToString();

            string notificationTimeString = ConfigurationManager.AppSettings.Get("NotificationTime");

            if (notificationTimeString == null)
            {
                notificationTime = 1;
                ConfigurationManager.AppSettings.Set("NotificationTime", notificationTime.ToString());
            }
            else
            {
                notificationTime = int.Parse(notificationTimeString);
            }
            slider.Value = notificationTime;

            dailogService        = new NotificationDialogService();
            notification         = new Notification();
            notification.ImgURL  = "pack://application:,,,/warning.png";
            notification.Title   = $"Компьютер скоро уйдёт в сон";
            notification.Message = "Пошевелите мышкой или нажмите кнопку";
            player = new System.Media.SoundPlayer(Properties.Resources.music);
            //player.FileName = "music.wav";
            //player = new System.Media.SoundPlayer("pack://application:,,,/music.wav");
            notificationConfiguration = new NotificationConfiguration(new TimeSpan(0, sleepTime - notificationTime, 0), 350, 150, "", null);

            notificationController = new NotificationController(notificationTime, sleepTime);
            notificationController.ShowNotification = ShowNotification;
            notificationController.HideNotification = HideNotification;
            notificationController.StartWorker();
        }
Esempio n. 6
0
        public async Task <bool> ProcessExternalMtaNotification(FormDetailModel form)
        {
            NotificationConfiguration notificationConfiguration = await _service.GetExternalMtaNotificationConfiguration();

            NotificationDto notificationDto = new NotificationDto(notificationConfiguration.Title);
            RecipientDto    recipientDto    = new RecipientDto()
            {
                EmailAddress = form.InitiationModel !.CustomerAdminSignature.Email,
                Name         = form.InitiationModel !.CustomerAdminSignature.PrintedName
            };

            notificationDto.AddRecipient(recipientDto);
            try {
                ExternalMtaNotification notificationModel = new ExternalMtaNotification(_settings.CurrentValue.BaseUrl, form);
                notificationDto.Body = _templateManager.GetContent(notificationConfiguration.Target, notificationConfiguration.TemplatePath, notificationModel).Result;
                int processedCount = await _service.CreateNotifications(notificationDto.ToNotifications());

                if (processedCount > 0)
                {
                    await _service.UpdateLastProcessedDate(notificationConfiguration.Id);

                    return(true);
                }
            }
            catch (Exception ex) {
                _logger.LogError(ex, "Failed to process notification configuration {notificationConfiguration}", notificationConfiguration);
            }
            return(false);
        }
        public async Task UpdateLastProcessedDate(int notificationConfigurationId)
        {
            NotificationConfiguration notificationConfiguration = await _context.NotificationConfigurations.FindAsync(notificationConfigurationId);

            notificationConfiguration.LastProcessed = DateTime.Now;
            await _context.SaveChangesAsync("SYSTEM");
        }
        /// <summary>
        /// Gets the enabled state check method call.
        /// </summary>
        /// <param name="stateToCheck">The state to check.</param>
        /// <param name="notificationConfiguration">The notification configuration.</param>
        /// <returns>The enabled state check method call.</returns>
        private Func <bool> GetEnabledStateCheck(ObservationState stateToCheck, NotificationConfiguration notificationConfiguration)
        {
            Func <bool> enabledCheck;

            switch (stateToCheck)
            {
            case ObservationState.Unknown:
                enabledCheck = () => notificationConfiguration.UnknownNotificationEnabled;
                break;

            case ObservationState.Unstable:
                enabledCheck = () => notificationConfiguration.UnstableNotificationEnabled;
                break;

            case ObservationState.Failure:
                enabledCheck = () => notificationConfiguration.FailureNotificationEnabled;
                break;

            case ObservationState.Success:
                enabledCheck = () => notificationConfiguration.SuccessNotificationEnabled;
                break;

            case ObservationState.Running:
                enabledCheck = () => notificationConfiguration.RunningNotificationEnabled;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(stateToCheck), stateToCheck, null);
            }

            return(enabledCheck);
        }
Esempio n. 9
0
        public void Configuration(IAppBuilder app)
        {
            ConfigureAuth(app);

            var notificationConfig = new NotificationConfiguration(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString).RegisterNotifications(new Notification()
            {
                NotificationTriggered = (sender, model) =>
                {
                    new NotificationHandlerBuilder().NotificationTriggered(model);
                },
                NotifySpecificUsers = notification =>
                {
                    return(new NotificationHandlerBuilder().NotifySpecificUsers(notification));
                },
                AddAdditionalUserNotificationData = notification =>
                {
                    return(new NotificationHandlerBuilder().AddAdditionalUserNotificationData(notification));
                },
            });

            app.UseNotificationService(notificationConfig);

            //email service
            var config = new EmailService.Data.Configurations.EmailServiceConfiguration(
                ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString,
                ConfigurationManager.AppSettings["SendGridApiToken"],
                ConfigurationManager.AppSettings["FromEmail"], "https://fanword.blob.core.windows.net/appimages/emailHeader.png", "Fanword", "2815 Fletcher Avenue #38 Lincoln, NE 68504", "");

            app.UseEmailService(config);


            //Azure Push

            var pushConfig = new PushNotifications.Configuration.PushNotificationServiceConfiguration()
                             .UseAzurePushNotifications(
                ConfigurationManager.ConnectionStrings["AzureHubConnection"].ConnectionString,
                ConfigurationManager.AppSettings["HubName"]);

            app.UsePushNotificationService(pushConfig);

            var useServer = false;

            bool.TryParse(ConfigurationManager.AppSettings["UseHangfireServer"], out useServer);
            if (useServer)
            {
                GlobalConfiguration.Configuration.UseSqlServerStorage("DefaultConnection");

                app.UseHangfireServer(new BackgroundJobServerOptions()
                {
                    Queues = new string[] { "default", "rss_feed", "push_notifications" }
                });

                app.UseHangfireDashboard("/Hangfire", new DashboardOptions()
                {
                    Authorization        = Enumerable.Empty <IDashboardAuthorizationFilter>(),
                    AuthorizationFilters = Enumerable.Empty <IAuthorizationFilter>()
                });
                RecurringJob.AddOrUpdate("Rss Feed Sync", () => new RssFeedWorker().StartSyncAll(), Cron.MinuteInterval(5));
            }
        }
Esempio n. 10
0
        public static void parseConfiguration()
        {
            Console.WriteLine("Parsing XML");

            StringBuilder op = new StringBuilder();


            string readText = File.ReadAllText(path);
            // Create an XmlReader
            XmlDocument doc = new XmlDocument();

            doc.Load(path);

            XmlNode isEnabledNode    = doc.DocumentElement.SelectSingleNode("/notificationConfiguration/isEnabled");
            XmlNode smsEnabledNode   = doc.DocumentElement.SelectSingleNode("/notificationConfiguration/smsEnabled");
            XmlNode callEnabledNode  = doc.DocumentElement.SelectSingleNode("/notificationConfiguration/callEnabled");
            XmlNode otherEnabledNode = doc.DocumentElement.SelectSingleNode("/notificationConfiguration/otherEnabled");


            bool configIsEnabled    = bool.Parse(isEnabledNode.InnerText);
            bool configSmsEnabled   = bool.Parse(smsEnabledNode.InnerText);
            bool configCallEnabled  = bool.Parse(callEnabledNode.InnerText);
            bool configOtherEnabled = bool.Parse(otherEnabledNode.InnerText);

            NotificationConfiguration.getInstance().IsEnabled    = configIsEnabled;
            NotificationConfiguration.getInstance().SmsEnabled   = configSmsEnabled;
            NotificationConfiguration.getInstance().CallEnabled  = configCallEnabled;
            NotificationConfiguration.getInstance().OtherEnabled = configOtherEnabled;
        }
Esempio n. 11
0
        public static void persistConfiguration()
        {
            Console.WriteLine("Persisting");

            StringBuilder op = new StringBuilder();


            string readText = File.ReadAllText(path);
            // Create an XmlReader
            XmlDocument doc = new XmlDocument();

            doc.Load(path);

            XmlNode isEnabledNode    = doc.DocumentElement.SelectSingleNode("/notificationConfiguration/isEnabled");
            XmlNode smsEnabledNode   = doc.DocumentElement.SelectSingleNode("/notificationConfiguration/smsEnabled");
            XmlNode callEnabledNode  = doc.DocumentElement.SelectSingleNode("/notificationConfiguration/callEnabled");
            XmlNode otherEnabledNode = doc.DocumentElement.SelectSingleNode("/notificationConfiguration/otherEnabled");

            isEnabledNode.InnerText    = NotificationConfiguration.getInstance().IsEnabled.ToString();
            smsEnabledNode.InnerText   = NotificationConfiguration.getInstance().SmsEnabled.ToString();
            callEnabledNode.InnerText  = NotificationConfiguration.getInstance().CallEnabled.ToString();
            otherEnabledNode.InnerText = NotificationConfiguration.getInstance().OtherEnabled.ToString();

            doc.Save(path);
        }
Esempio n. 12
0
 public EmailConfirmationContentProvider(IViewRenderService viewRenderService,
                                         NotificationConfiguration notificationConfiguration
                                         )
 {
     this.ViewRenderService = viewRenderService;
     this.Configuration     = notificationConfiguration;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="ClientRegistryNotificationService"/> class.
        /// </summary>
        public ClientRegistryNotificationService()
        {
            var configurationManager = ApplicationContext.Current.GetService <IConfigurationManager>();

            this.configuration = configurationManager.GetSection("openiz.messaging.hl7.notification.pixpdq") as NotificationConfiguration;

            this.threadPool = new WaitThreadPool(this.configuration.ConcurrencyLevel);
        }
Esempio n. 14
0
 public SMTPNotificationAgent(NotificationConfiguration config)
 {
     this.SMTPClient                       = new SmtpClient(config.Host, config.Port);
     this.SMTPClient.EnableSsl             = true;
     this.SMTPClient.UseDefaultCredentials = false;
     this.SMTPClient.Credentials           = new System.Net.NetworkCredential(config.UserName, config.Password);
     this.Config = config;
 }
Esempio n. 15
0
        public void Remove(NotificationConfiguration entity, bool commit = true)
        {
            _appDbContext.NotificationConfigurations.Remove(entity);

            if (commit)
            {
                _appDbContext.SaveChanges();
            }
        }
Esempio n. 16
0
 public ResendEmailConfirmationHandler(ApplicationUserManager userManager,
                                       NotificationConfiguration notificationConfiguration,
                                       IEmailSender emailSender,
                                       IEmailContentProvider <UserRegisteredNotification> emailContentProvider)
 {
     this.UserManager          = userManager;
     this.Configuration        = notificationConfiguration;
     this.EmailSender          = emailSender;
     this.EmailContentProvider = emailContentProvider;
 }
Esempio n. 17
0
        public override void Initialize()
        {
            base.Initialize();
            NotificationConfiguration configuration = new NotificationConfiguration();
            configuration.WindowsPhone.ChannelName = "My Channel";
            ANotificationServerConnector serverConnector = new MyServerConnector();

            NotificationManager.OnNotification += new NotificationManager.NotificationMessageHandle(NotificationManager_OnNotification);
            NotificationManager.Register(configuration, serverConnector);
        }
Esempio n. 18
0
        /// <summary>
        /// Sets the screen up (UI components, multimedia content, etc.)
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            NotificationConfiguration configuration = new NotificationConfiguration();
            configuration.WindowsPhone.ChannelName = "My Channel";
            configuration.Android.SenderEmail = "*****@*****.**";

            ANotificationServerConnector serverConnector = new UrbanArshipServerConnector("AppKey", "AppSecret", "Alias", new string[] { "tag01", "tag02" });

            NotificationManager.OnNotification += new NotificationManager.NotificationMessageHandle(NotificationManager_OnNotification);
            NotificationManager.Register(configuration, serverConnector);
        }
Esempio n. 19
0
        public static ContainerBuilder RegisterAppContext(this ContainerBuilder builder)
        {
            var notifyConfig = new NotificationConfiguration()
            {
                EnableParticipantNotifications = false,
                EnableMessageNotifications     = true,
                HideTimeout     = TimeSpan.FromSeconds(5),
                ShowingMaxCount = 3
            };

            builder.RegisterInstance <NotificationConfiguration>(notifyConfig);
            return(builder);
        }
Esempio n. 20
0
        public Boolean isMessageDisplayAuthorised(Notification notification)
        {
            Boolean addMessage          = true;
            Boolean notificationHandled = false;

            if ((notification.Application.Equals("com.android.sms") || notification.Application.Equals("com.android.mms") || notification.Application.Equals("com.samsung.android.messaging")))
            {
                if (NotificationConfiguration.getInstance().SmsEnabled)
                {
                    Console.WriteLine("SMS reçu et traité");
                }
                else
                {
                    addMessage = false;
                    Console.WriteLine("Sms reçu et non traité");
                }
                notificationHandled = true;
            }
            if (notificationHandled == false)
            {
                if (notification.Application.Equals("com.android.server.telecom") || notification.Application.Equals("com.android.incallui"))
                {
                    if (NotificationConfiguration.getInstance().CallEnabled)
                    {
                        Console.WriteLine("Appel reçu et traité");
                    }
                    else
                    {
                        addMessage = false;
                        Console.WriteLine("Appel reçu et non traité");
                    }
                    notificationHandled = true;
                }
            }
            if (notificationHandled == false)
            {
                if (NotificationConfiguration.getInstance().OtherEnabled)
                {
                    Console.WriteLine("Autre reçu et traité");
                }
                else
                {
                    addMessage = false;
                    Console.WriteLine("Autre reçu et non traité");
                }
                notificationHandled = true;
            }
            return(addMessage);
        }
Esempio n. 21
0
 public async void SendGridTest()
 {
     var config = NotificationConfigBuilder.Build();
     var sgc    = new NotificationConfiguration {
         APIKey = config.APIKey
     };
     var sendgrid = new Email
     {
         Subject = "*****@*****.**",
         To      = new System.Collections.Generic.List <string> {
             "*****@*****.**"
         },
         Content = "Hello world"
     };
     var publisher = new NotificationPublisher <SendGridNotificationAgent <Notification.Concerns.Notification> >(sgc);
     var obj       = publisher.Publish(sendgrid);
 }
Esempio n. 22
0
        public bool CheckNotificationShowTest(bool onlyIfChanged, ObservationState currentState, ObservationState historyState1, ObservationState historyState2, ObservationState historyState3, ObservationState historyState4)
        {
            var observationScheduler = new ObservationScheduler();
            var configuration        = new ApplicationConfiguration();

            configuration.OpenMinimized = true;
            var trayHandler = new TrayHandler(observationScheduler, configuration);

            var connectorViewModel = new ConnectorViewModel();
            var statusViewModel    = new StatusViewModel(connectorViewModel);

            statusViewModel.State = currentState;
            var status1 = new BuildStatusViewModel(connectorViewModel)
            {
                State = currentState
            };
            var status2 = new BuildStatusViewModel(connectorViewModel)
            {
                State = historyState1
            };
            var status3 = new BuildStatusViewModel(connectorViewModel)
            {
                State = historyState2
            };
            var status4 = new BuildStatusViewModel(connectorViewModel)
            {
                State = historyState3
            };
            var status5 = new BuildStatusViewModel(connectorViewModel)
            {
                State = historyState4
            };

            connectorViewModel.ConnectorSnapshots.Add(status5);
            connectorViewModel.ConnectorSnapshots.Add(status4);
            connectorViewModel.ConnectorSnapshots.Add(status3);
            connectorViewModel.ConnectorSnapshots.Add(status2);
            connectorViewModel.ConnectorSnapshots.Add(status1);

            var notificationConfiguration = new NotificationConfiguration();

            notificationConfiguration.OnlyIfChanged = onlyIfChanged;
            notificationConfiguration.RunningNotificationEnabled = false;

            return(trayHandler.CheckNotificationShow(statusViewModel, currentState, notificationConfiguration));
        }
Esempio n. 23
0
        public EmailNotificationService(IOptions <SmtpConfiguration> smtpConfiguration,
                                        ISmtpClient smtpClient,
                                        IEmailBuilder emailBuilder,
                                        IOptions <NotificationConfiguration> notificationConfiguration,
                                        ILogger <EmailNotificationService> logger)
        {
            Guard.Against.Null(smtpConfiguration, nameof(smtpConfiguration));
            Guard.Against.Null(smtpClient, nameof(smtpClient));
            Guard.Against.Null(emailBuilder, nameof(emailBuilder));
            Guard.Against.Null(notificationConfiguration, nameof(notificationConfiguration));
            Guard.Against.Null(logger, nameof(logger));

            _smtpConfiguration         = smtpConfiguration.Value;
            _smtpClient                = smtpClient;
            _emailBuilder              = emailBuilder;
            _notificationConfiguration = notificationConfiguration.Value;
            _logger = logger;
        }
Esempio n. 24
0
 private bool TryGetNotificationDto(NotificationConfiguration notificationConfiguration, EntityEvent entityEvent, out NotificationDto notificationDto)
 {
     notificationDto = new NotificationDto(notificationConfiguration.Subscriptions, notificationConfiguration.Title);
     try {
         List <RecipientDto> recipients = GetRecipients(notificationConfiguration.Target, entityEvent).Result;
         if (!recipients.Any())
         {
             return(false);
         }
         notificationDto.AddRecipients(recipients);
         notificationDto.Body = _templateManager.GetContent(notificationConfiguration.Target, notificationConfiguration.TemplatePath, entityEvent).Result;
         return(true);
     }
     catch (Exception ex) {
         _logger.LogError(ex, "Failed to process notification configuration {notificationConfiguration}", notificationConfiguration);
     }
     return(false);
 }
Esempio n. 25
0
        public async Task <int> ProcessNotificationConfiguration(NotificationConfiguration notificationConfiguration)
        {
            int processedNotificationsCount = 0;
            List <EntityEvent> events       = await _eventService.GetEvents(notificationConfiguration.EventTrigger, notificationConfiguration.LastProcessed);

            foreach (EntityEvent entityEvent in events)
            {
                if (TryGetNotificationDto(notificationConfiguration, entityEvent, out NotificationDto notificationDto))
                {
                    processedNotificationsCount += await _service.CreateNotifications(notificationDto.ToNotifications());
                }
            }
            if (processedNotificationsCount > 0)
            {
                await _service.UpdateLastProcessedDate(notificationConfiguration.Id);
            }
            return(processedNotificationsCount);
        }
Esempio n. 26
0
        private RavenConfiguration(string resourceName, ResourceType resourceType, string customConfigPath = null)
        {
            _logger = LoggingSource.Instance.GetLogger <RavenConfiguration>(resourceName);

            ResourceName      = resourceName;
            ResourceType      = resourceType;
            _customConfigPath = customConfigPath;
            PathSettingBase <string> .ValidatePath(_customConfigPath);

            _configBuilder = new ConfigurationBuilder();
            AddEnvironmentVariables();
            AddJsonConfigurationVariables(customConfigPath);

            Settings = _configBuilder.Build();

            Core = new CoreConfiguration();

            Http             = new HttpConfiguration();
            Replication      = new ReplicationConfiguration();
            Cluster          = new ClusterConfiguration();
            Etl              = new EtlConfiguration();
            Storage          = new StorageConfiguration();
            Security         = new SecurityConfiguration();
            Backup           = new BackupConfiguration();
            PerformanceHints = new PerformanceHintsConfiguration();
            Indexing         = new IndexingConfiguration(this);
            Monitoring       = new MonitoringConfiguration();
            Queries          = new QueryConfiguration();
            Patching         = new PatchingConfiguration();
            Logs             = new LogsConfiguration();
            Server           = new ServerConfiguration();
            Embedded         = new EmbeddedConfiguration();
            Databases        = new DatabaseConfiguration(Storage.ForceUsing32BitsPager);
            Memory           = new MemoryConfiguration();
            Studio           = new StudioConfiguration();
            Licensing        = new LicenseConfiguration();
            Tombstones       = new TombstoneConfiguration();
            Subscriptions    = new SubscriptionConfiguration();
            TransactionMergerConfiguration = new TransactionMergerConfiguration(Storage.ForceUsing32BitsPager);
            Notifications = new NotificationConfiguration();
            Updates       = new UpdatesConfiguration();
            Migration     = new MigrationConfiguration();
        }
Esempio n. 27
0
 static void DeleteBucketNotification()
 {
     try
     {
         NotificationConfiguration    notificationConfig = new NotificationConfiguration();
         SetBucketNotificationRequest request            = new SetBucketNotificationRequest
         {
             BucketName    = bucketName,
             Configuration = notificationConfig
         };
         SetBucketNotificationResponse response = client.SetBucketNotification(request);
         Console.WriteLine("Delete bucket notification  response: {0}", response.StatusCode);
     }
     catch (ObsException ex)
     {
         Console.WriteLine("Exception errorcode: {0}, when delete bucket notification.", ex.ErrorCode);
         Console.WriteLine("Exception errormessage: {0}", ex.ErrorMessage);
     }
 }
Esempio n. 28
0
        static void SetBucketNotification()
        {
            try
            {
                FilterRule filterRule1 = new FilterRule();
                filterRule1.Name  = FilterNameEnum.Prefix;
                filterRule1.Value = "smn";
                TopicConfiguration topicConfiguration1 = new TopicConfiguration();
                topicConfiguration1.Id    = "Id001";
                topicConfiguration1.Topic = "urn:smn:globrg:35667523534:topic1";
                topicConfiguration1.Events.Add(EventTypeEnum.ObjectCreatedAll);
                topicConfiguration1.FilterRules = new List <FilterRule>();
                topicConfiguration1.FilterRules.Add(filterRule1);

                FilterRule filterRule2 = new FilterRule();
                filterRule2.Name  = FilterNameEnum.Suffix;
                filterRule2.Value = ".jpg";
                TopicConfiguration topicConfiguration2 = new TopicConfiguration();
                topicConfiguration2.Id    = "Id002";
                topicConfiguration2.Topic = "urn:smn:globrg:35667523535:topic2";
                topicConfiguration2.Events.Add(EventTypeEnum.ObjectRemovedAll);
                topicConfiguration2.FilterRules = new List <FilterRule>();
                topicConfiguration2.FilterRules.Add(filterRule2);

                NotificationConfiguration notificationConfiguration = new NotificationConfiguration();
                notificationConfiguration.TopicConfigurations = new List <TopicConfiguration>();
                notificationConfiguration.TopicConfigurations.Add(topicConfiguration1);
                notificationConfiguration.TopicConfigurations.Add(topicConfiguration2);

                SetBucketNotificationRequest request = new SetBucketNotificationRequest
                {
                    BucketName    = bucketName,
                    Configuration = notificationConfiguration,
                };
                SetBucketNotificationResponse response = client.SetBucketNotification(request);
                Console.WriteLine("Set bucket notification response: {0}", response.StatusCode);
            }
            catch (ObsException ex)
            {
                Console.WriteLine("Exception errorcode: {0}, when set bucket notification.", ex.ErrorCode);
                Console.WriteLine("Exception errormessage: {0}", ex.ErrorMessage);
            }
        }
Esempio n. 29
0
        /// <summary>
        /// Shows the specified notification.
        /// </summary>
        /// <param name="content">The notification content.</param>
        /// <param name="configuration">The notification configuration object.</param>
        public static void Show(object content, NotificationConfiguration configuration)
        {
            DataTemplate notificationTemplate = (DataTemplate)Application.Current.Resources[configuration.TemplateName];
            Window       window = new Window()
            {
                Title              = "",
                Width              = configuration.Width.Value,
                Height             = configuration.Height.Value,
                Content            = content,
                ShowActivated      = false,
                AllowsTransparency = true,
                WindowStyle        = WindowStyle.None,
                ShowInTaskbar      = false,
                Topmost            = true,
                Background         = Brushes.Transparent,
                UseLayoutRounding  = true,
                ContentTemplate    = notificationTemplate
            };

            Show(window, configuration.DisplayDuration, configuration.NotificationFlowDirection);
        }
Esempio n. 30
0
        /// <summary>
        /// Load configuration, populate the UI, etc
        /// </summary>
        /// <param name="configurationDom"></param>
        /// <returns></returns>
        public bool IsConfigured(System.Xml.XmlDocument configurationDom)
        {
            // This is a complex configuration so here we go.
            XmlElement configSectionNode = configurationDom.SelectSingleNode("//*[local-name() = 'configSections']/*[local-name() = 'section'][@name = 'marc.hi.ehrs.cr.notification.pixpdq']") as XmlElement,
                       configRoot        = configurationDom.SelectSingleNode("//*[local-name() = 'marc.hi.ehrs.cr.notification.pixpdq']") as XmlElement,
                       wcfRoot           = configurationDom.SelectSingleNode("//*[local-name() = 'system.serviceModel']") as XmlElement;

            // Load the current config if applicable
            if (configRoot != null)
            {
                this.m_configuration = new ConfigurationSectionHandler().Create(null, null, configRoot) as NotificationConfiguration;
            }
            else
            {
                this.m_configuration = new NotificationConfiguration(Environment.ProcessorCount);
            }

            bool isConfigured = configSectionNode != null && configRoot != null &&
                                wcfRoot != null && this.m_configuration != null && this.m_configuration.Targets.Count > 0;

            if (!this.m_needSync)
            {
                return(isConfigured);
            }
            this.EnableConfiguration = isConfigured;
            this.m_needSync          = false;

            if (configRoot == null) // makes the following logic clearer
            {
                configRoot = configurationDom.CreateElement("marc.hi.ehrs.cr.notification.pixpdq");
            }
            this.m_panel.OidRegistrar = OidRegistrarConfigurationPanel.LoadOidRegistrar(configurationDom);

            this.m_panel.SetTargets(this.m_configuration.Targets, wcfRoot);


            // Loop through the configuration templates
            return(isConfigured);
        }
Esempio n. 31
0
        private void MyToastTask()
        {
            var newNotification = new MailNotification()
            {
                Title   = "Vacation Request",
                Sender  = "Mohamed Magdy",
                Content = "I would like to request for vacation from 20 / 12 / 2015 to 30 / 12 / 2015............."
            };

            var configuration = new NotificationConfiguration(new TimeSpan(0, 0, 5), null,
                                                              null, "MailNotificationTemplate", NotificationFlowDirection.RightBottom);

            for (; ;)
            {
                App.Current?.Dispatcher?.Invoke(() =>
                {
                    _dailogService.ShowNotificationWindow(newNotification, configuration);
                });

                Thread.Sleep(4 * 1000);
            }
        }
Esempio n. 32
0
        private static void WriteConfigurationCommon(XmlWriter xmlWriter, NotificationConfiguration notificationConfiguration)
        {
            if (notificationConfiguration.IsSetEvents())
            {
                foreach (var evnt in notificationConfiguration.Events)
                {
                    xmlWriter.WriteElementString("Event", "", S3Transforms.ToXmlStringValue(evnt));
                }
            }

            if (notificationConfiguration.IsSetFilter())
            {
                xmlWriter.WriteStartElement("Filter", "");
                var filter = notificationConfiguration.Filter;
                if (filter.IsSetS3KeyFilter())
                {
                    xmlWriter.WriteStartElement("S3Key", "");
                    var s3key = filter.S3KeyFilter;
                    if (s3key.IsSetFilterRules())
                    {
                        var filterRules = s3key.FilterRules;
                        foreach (var filterRule in filterRules)
                        {
                            if (filterRule != null)
                            {
                                xmlWriter.WriteStartElement("FilterRule", "");
                                xmlWriter.WriteElementString("Name", filterRule.Name);
                                xmlWriter.WriteElementString("Value", filterRule.Value);
                                xmlWriter.WriteEndElement();
                            }
                        }
                    }
                    xmlWriter.WriteEndElement();
                }
                xmlWriter.WriteEndElement();
            }
        }
        public NotificationConfiguration PostNotification(Dictionary<string, object> data)
        {
            var notificationAction = GetNotificationInstance(data);

            var not = new NotificationConfiguration()
            {
                ConfigurationXml = notificationAction.Serialize(),
                NotificationType = notificationAction.GetType().FullName,
                ImapMailBoxConfigurationId =
                            int.Parse(data.First(x => x.Key.Equals("MailBoxId")).Value.ToString()),
            };

            //add a new record
            using (var ctx = new MailModelContainer())
            {
                ctx.NotificationConfigurations.Add(not);
                ctx.SaveChanges();
                var config = ctx.ImapMailBoxConfigurations.FirstOrDefault(x => x.Id == not.ImapMailBoxConfigurationId);
                Task.Factory.StartNew(() => InboxWatcher.ConfigureMailBox(config));
            }

            return not;
        }