protected override void OnStop()
        {
            base.OnStop();

            if (ServiceBus.UserService.CurrentUser != null &&
                !(ViewModel is LoginViewModel))
            {
                var settings = ServiceBus.SettingsService.GetSettings();
                if (settings != null && (settings.IsNewsNotificationEnabled ||
                                         settings.IsReviewerNotificationEnabled))
                {
                    NotificationReceiver.Run(this, settings);
                }
            }
        }
コード例 #2
0
        public NotificationReceiver Save([FromBody] NotificationReceiver model)
        {
            ModelState.Clear();
            TryValidateModel(model);
            ModelState.Validate();

            if (model.Id > 0)
            {
                _notificationReceiverRepository.Update(model);
            }
            else
            {
                _notificationReceiverRepository.Insert(model);
            }

            return(model);
        }
コード例 #3
0
        public Task <string> BuildBlogPostNotificationBodyAsync(NotificationReceiver notificationReceiver, BlogDTO blogDTO)
        {
            Preconditions.NotNull(notificationReceiver, nameof(notificationReceiver));
            Preconditions.NotNull(blogDTO, nameof(blogDTO));

            // TODO : use template.txt for body building
            #region Temporary Code

            var stringBuilder = new StringBuilder();

            stringBuilder.Append($"Hello {notificationReceiver.DisplayName} <br>");
            stringBuilder.Append($"{blogDTO.CreatedBy} just posted new article: <a href='https://localhost:44388/blog/view/{blogDTO.ID}/{blogDTO.Title}'>{blogDTO.Title}</a> <br>");
            stringBuilder.Append($"<a href='https://localhost:44388/notificationReceiver/delete/{notificationReceiver.ID}'> Remove notifications <a>");

            return(Task.FromResult(stringBuilder.ToString()));

            #endregion
        }
コード例 #4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);


            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            txtView = (TextView)FindViewById(Resource.Id.tbNotificationInfo);
            //txtView = (TextView)FindViewById(Resource.Id.textView1);
            nReceiver = new NotificationReceiver();
            IntentFilter filter = new IntentFilter();
            filter.AddAction("com.dpwebdev.handsetfree.NOTIFICATION_LISTENER_EXAMPLE");
            RegisterReceiver(nReceiver, filter);

            // Get our button from the layout resource,
            // and attach an event to it
            Button createButton = FindViewById<Button>(Resource.Id.MyButton);
            Button catchButton = FindViewById<Button>(Resource.Id.catchNotification);

            createButton.Click += delegate
            {
                NotificationManager nManager = (NotificationManager)GetSystemService(NotificationListenerService.NotificationService);
                Notification.Builder ncomp = new Notification.Builder(this);
                ncomp.SetContentTitle("My Notification");
                ncomp.SetContentText("Notification Listener Service Example");
                ncomp.SetTicker("Notification Listener Service Example");
                ncomp.SetSmallIcon(Resource.Drawable.Icon);
                ncomp.SetAutoCancel(true);
                nManager.Notify(DateTime.Now.Millisecond, ncomp.Build());

                

            };

            catchButton.Click += delegate
            {
                
                Intent i = new Intent("com.dpwebdev.handsetfree.NOTIFICATION_LISTENER_SERVICE_EXAMPLE");
                i.PutExtra("command", "list");
                SendBroadcast(i);
            };

        }
コード例 #5
0
            /// <summary>
            /// Logs messages using NotificationReceiver
            /// </summary>
            /// <param name="fileName"></param>
            public static void LoggerWithExtractorFactory(string fileName)
            {
                //ExStart:LoggerWithExtractorFactory
                //get file actual path
                String filePath           = Common.GetFilePath(fileName);
                var    receiverForFactory = new NotificationReceiver();
                var    factory            = new ExtractorFactory(null, null, null, receiverForFactory);

                var         receiver    = new NotificationReceiver();
                LoadOptions loadOptions = new LoadOptions();

                loadOptions.NotificationReceiver = receiver;

                using (var extractor = new CellsTextExtractor(filePath, loadOptions))
                {
                    Console.WriteLine(extractor.ExtractAll());
                }
                //ExEnd:LoggerWithExtractorFactory
            }
コード例 #6
0
        /// <summary>
        /// Registriert einen Client für den Empfang von Benachrichtigungen bei einem bestimmten Ereignis.
        /// </summary>
        /// <param name="eventName">Ereignisname</param>
        /// <param name="handler">Delegat auf Client-Ereignisprozedur</param>
        public Guid SubscribeEvent(string eventName, EventHandler <NotificationEventArgs> handler)
        {
            // Empfangsvorrichtung für Benachrichtigung erzeugen
            NotificationReceiver receiver = new NotificationReceiver(eventName, handler);

            // Für Benachrichtigung beim entfernten Komponentenhost registrieren
            RemoteComponentFactory.Subscribe(eventName, receiver.FireNotifyEvent);

            // Registrerungsschlüssel erzeugen
            Guid subscriptionID = Guid.NewGuid();

            lock (_subscriptionsLockObject)
            {
                // Empfangsvorrichtung in Wörterbuch speichern
                _subscriptions.Add(subscriptionID, receiver);
            }
            // Registrerungsschlüssel zurückgeben
            return(subscriptionID);
        }
コード例 #7
0
        /// <summary>
        /// Hebt eine Registrierung für den Empfang von Benachrichtigungen eines bestimmten Ereignisses auf.
        /// </summary>
        /// <param name="subscriptionID">Registrerungsschlüssel</param>
        public void UnsubscribeEvent(Guid subscriptionID)
        {
            lock (_subscriptionsLockObject)
            {
                // Wenn die angegebene Registrerungsschlüssel bekannt ist ...
                if (_subscriptions.ContainsKey(subscriptionID))
                {
                    // Empfangsvorrichtung abrufen
                    NotificationReceiver receiver = _subscriptions[subscriptionID];

                    // Für Benachrichtigung beim entfernten Komponentenhost registrieren
                    RemoteComponentFactory.Unsubscribe(receiver.EventName, receiver.FireNotifyEvent);

                    // Empfängervorrichtung aus Wörterbuch löschen
                    _subscriptions.Remove(subscriptionID);

                    // Empfängervorrichtung entsorgen
                    receiver.Dispose();
                }
            }
        }
コード例 #8
0
        public IntentManager(
            IToastOptions options,
            IAndroidNotificationManager androidNotificationManager,
            ISystemEventSource systemEventSource,
            IServiceProvider?serviceProvider)
        {
            this.mutex = new object();
            this.tasksByNotificationId = new Dictionary <ToastId, TaskCompletionSource <NotificationResult> >();
            this.options = options ?? throw new ArgumentNullException(nameof(options));
            this.androidNotificationManager = androidNotificationManager;
            this.systemEventSource          = systemEventSource;
            this.logger       = serviceProvider?.GetService <ILogger <IntentManager> >();
            this.intentFilter = new IntentFilter();
            this.receiver     = new NotificationReceiver(this);

            intentFilter.AddAction(IntentConstants.KTapped);
            intentFilter.AddAction(IntentConstants.KDismissed);
            intentFilter.AddAction(IntentConstants.KScheduled);

            Application.Context.RegisterReceiver(receiver, intentFilter);
        }
コード例 #9
0
            /// <summary>
            /// Logs messages using NotificationReceiver
            /// </summary>
            /// <param name="fileName"></param>
            public static void LoggerWithManualExceptionHandling(string fileName)
            {
                //ExStart:LoggerWithManualExceptionHandling
                //get file actual path
                String      filePath    = Common.GetFilePath(fileName);
                var         receiver    = new NotificationReceiver();
                LoadOptions loadOptions = new LoadOptions();

                loadOptions.NotificationReceiver = receiver;

                try
                {
                    using (var extractor = new CellsTextExtractor(filePath, loadOptions))
                    {
                        Console.WriteLine(extractor.ExtractAll());
                    }
                }
                catch (Exception ex)
                {
                    receiver.ProcessMessage(NotificationMessage.CreateErrorMessage(ex.Message, ex));
                }
                //ExEnd:LoggerWithManualExceptionHandling
            }
 protected override void OnStart()
 {
     base.OnStart();
     NotificationReceiver.Stop();
 }
コード例 #11
0
ファイル: Chatter.xaml.cs プロジェクト: Sufflavus/Waffle
 private void Subscribe()
 {
     NotificationReceiver.RegisterReceiver(_userId);
     NotificationReceiver.SubscribeForReceivingMessage(OnMessageReceive);
     NotificationReceiver.SubscribeForReceivingUserState(OnUserStateChanged);
 }
コード例 #12
0
 public UserStorageServiceSlave(IUserRepository userRepository)
     : base(userRepository)
 {
     Receiver           = new NotificationReceiver();
     Receiver.Received += NotificationReceived;
 }
コード例 #13
0
 /// <summary>
 /// Triggers before initialization
 /// </summary>
 void Awake()
 {
     // static instance of this class
     instance = this;
 }