예제 #1
0
        /// <summary>
        /// Change the alarm's BeginTime to now
        /// </summary>
        /// <param name="bs"></param>
        public void TriggerAlarm(BusStop bs)
        {
            if (bs == null)
            {
                return;
            }

            var alarm = ScheduledActionService.Find(bs.Id) as Alarm;

            if (alarm == null)
            {
                return;
            }

            alarm.BeginTime = DateTime.Now.AddSeconds(30);
            try
            {
                ScheduledActionService.Replace(alarm);
            }
            catch
            {
                ShellToast toast = new ShellToast()
                {
                    Content       = "Your stop is nearing",
                    NavigationUri = new Uri("/Pages/PanoPage.xaml", UriKind.Relative),
                    Title         = "Stop Alarm"
                };
                toast.Show();
            }

            this.Notif = null;
        }
예제 #2
0
 public void DeleteReminder()
 {
     if (Long.SelectedItems.Count == 1)
     {
         if (MessageBox.Show("Do you want to remove this reminder?", "Confirmation", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
         {
             ScheduledNotification remind = Notifications.First(r => r.Name == ((ScheduledNotification)(Long.SelectedItems[0])).Name);
             ScheduledActionService.Remove(remind.Name);
             MessageBox.Show("Reminder removed");
             NavigationService.GoBack();
         }
     }
     else
     {
         if (MessageBox.Show("Do you want to remove these reminders?", "Confirmation", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
         {
             foreach (ScheduledNotification item in Long.SelectedItems)
             {
                 ScheduledNotification remind = Notifications.First(r => r.Name == item.Name);
                 ScheduledActionService.Remove(remind.Name);
             }
             MessageBox.Show("Reminders removed");
             NavigationService.GoBack();
         }
     }
 }
예제 #3
0
        public void DeleteNotification(long noteId)
        {
            ScheduledNotification schedulednotification = databaseHelper.GetNotificationByNoteId(noteId);

            NotificationScheduler.DeleteScheduledNotification(schedulednotification.SchedulingId);
            databaseHelper.DeleteNotificationByNoteId(noteId);
        }
예제 #4
0
        private void LoadScheduledNotificationsWhenDisabled()
        {
            string fileName = GetSerializationFileName();

            if (File.Exists(fileName))
            {
                try
                {
                    FileStream file = File.OpenRead(fileName);
                    using (BinaryReader stream = new BinaryReader(file))
                    {
                        int count = stream.ReadInt32();
                        m_scheduledNotificationsWhenDisabled = new List <ScheduledNotification>(count);
                        for (int i = 0; i < count; ++i)
                        {
                            ScheduledNotification scheduledNotification = new ScheduledNotification();
                            scheduledNotification.Read(stream);
                            m_scheduledNotificationsWhenDisabled.Add(scheduledNotification);
                        }
                    }
                    file.Close();
                }
                catch (Exception e)
                {
                    UnityEngine.Debug.LogException(e);
                }
            }
            else
            {
                m_scheduledNotificationsWhenDisabled = null;
            }
        }
예제 #5
0
        /// <summary>
        /// Update the default Live Tile and by extension the lock screen with the count of notifications remaining
        /// in the day, and the title of the next notification.
        /// </summary>
        public static void UpdateDefaultTile()
        {
            // the sample code uses static to enable calls from MainPage.xaml.xs. The code in the book does not use static.
            DateTime now = DateTime.Now;
            //now = new DateTime(now.Year, now.Month, now.Day+2, 0, 0, 0);
            DateTime endOfDay      = new DateTime(now.Year, now.Month, now.Day, 23, 59, 59);
            var      notifications = ScheduledActionService.GetActions <ScheduledNotification>()
                                     .Where((item) => item.BeginTime > now && item.BeginTime < endOfDay)
                                     .OrderBy((item) => item.BeginTime);
            int count = notifications.Count();
            ScheduledNotification nextNotification = notifications.FirstOrDefault();

            string message = null;

            if (nextNotification != null)
            {
                message = string.Format("{0:t} {1}", nextNotification.BeginTime, nextNotification.Title);
            }

            ShellTile        defaultTile = ShellTile.ActiveTiles.First();
            StandardTileData tileData    = new StandardTileData
            {
                Count       = count,
                BackContent = message,
            };

            defaultTile.Update(tileData);
        }
예제 #6
0
        private void DeleteNotification(long noteID)
        {
            ScheduledNotification schedulednotification = simpleNoteHelper.GetNotificationByNoteId(noteID);

            NotificationScheduler.DeleteScheduledNotification(schedulednotification.SchedulingId);
            simpleNoteHelper.DeleteNotificationByNoteId(noteID);
        }
예제 #7
0
        private void AssertNotificationScheduledSuccessful(NotificationTest test, NotificationAccount <Guid> account, Notification expectedNotification, DateTimeOffset expectedDeliveryDateTime)
        {
            ScheduledNotification <Guid> scheduledNotification = test.GetScheduledNotification();

            scheduledNotification.AccountId.ShouldBeEquivalentTo(account.AccountId);
            scheduledNotification.DeliveryDateTime.ShouldBeEquivalentTo(expectedDeliveryDateTime);

            this.AssertNotificationScheduledEventRaised(test, account, expectedNotification, expectedDeliveryDateTime);
        }
예제 #8
0
            public void DeleteNotificationByNoteId(long noteId)
            {
                ScheduledNotification notification = GetNotificationByNoteId(noteId);

                if (notification != null)
                {
                    NotificationHelper.DeleteNotificationById(notification.DataBaseId);
                }
            }
예제 #9
0
        private void RemoveAlarm()
        {
            List <ScheduledNotification> notifications = ScheduledActionService.GetActions <ScheduledNotification>() as List <ScheduledNotification>;

            if (notifications.Count > 0)
            {
                ScheduledNotification al = notifications.First(r => r.Name == "Sunlight");
                ScheduledActionService.Remove(al.Name);
            }
        }
예제 #10
0
            public void DeleteNotificationByNoteId(long noteId)
            {
                ScheduledNotification notification = GetNotificationByNoteId(noteId);

                if (notification != null)
                {
                    Debug.WriteLine("Deleting notification from database");
                    NotificationHelper.DeleteNotificationById(notification.DataBaseId);
                }
            }
예제 #11
0
        private void NotificationList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("selection changed");
            ScheduledNotification notification =
                notificationList.SelectedItem as ScheduledNotification;

            if (notification != null)
            {
                NavigationService.Navigate(new Uri("/ReminderPage.xaml?name=" + notification.Name, UriKind.Relative));
            }
        }
 public static void ToScheduledNotification(this ScheduledNotificationDto notificationDto,
     ScheduledNotification notification)
 {
     notification.NotificationDate = notificationDto.NotificationDate;
     notification.NotificationType = (NotificationType)notificationDto.NotificationType;
     notification.Message = notificationDto.Message;
     notification.IsSent = notificationDto.IsSent;
     notification.IsShown = notificationDto.IsShown;
     notification.CandidateId = notificationDto.CandidateId;
     notification.UserProfileId = notificationDto.UserProfileId;
 }
예제 #13
0
            public ScheduledNotification GetNotificationByNoteId(long noteId)
            {
                ISQLiteStatement statement = dbConn.Prepare(SELECT_PHOTO_NOTE_NOTIFICATION_BY_NOTE_ID);

                statement.Bind(1, noteId);
                ScheduledNotification notification = null;

                while (statement.Step() == SQLiteResult.ROW)
                {
                    notification = new ScheduledNotification((long)statement[0], (string)statement[1], DateTimeOffset.Parse((string)statement[2]));
                }
                return(notification);
            }
 public static ScheduledNotification ToScheduledNotification(this ScheduledNotificationDto notificationDto)
 {
     var notification = new ScheduledNotification
     {
         NotificationDate = notificationDto.NotificationDate,
         NotificationType = (NotificationType)notificationDto.NotificationType,
         Message = notificationDto.Message,
         IsSent = notificationDto.IsSent,
         IsShown = notificationDto.IsShown,
         CandidateId = notificationDto.CandidateId,
         UserProfileId = notificationDto.UserProfileId
     };
     return notification;
 }
예제 #15
0
        public void UpdateNote(long id, string title, string photoPath, string content)
        {
            PhotoNote             photoNote    = databaseHelper.GetNoteById(id) as PhotoNote;
            ScheduledNotification notification = photoNote.ScheduledNotification;

            if (notification != null)
            {
                Debug.WriteLine("Deleting scheduled notification");
                NotificationScheduler.DeleteScheduledNotification(notification.SchedulingId);
            }
            if (photoNote.PhotoPath != photoPath)
            {
                DeleteImageFromLocalFolder(photoNote.PhotoPath);
            }
            databaseHelper.UpdateNoteAndDeleteNotification(id, title, content, photoPath);
        }
예제 #16
0
        /// <summary>
        /// Set an alarm/reminder for the given bus stop
        /// </summary>
        /// <param name="bs"></param>
        public void PrepareAlarm(BusStop bs)
        {
            this.ClearAlarms();

            if (bs == null) return;

            Alarm alarm = new Alarm(bs.Id)
            {
                BeginTime = DateTime.Now.AddHours(2),
                Content = "Your stop is nearing!",
                RecurrenceType = RecurrenceInterval.None,
                Sound = new Uri("/Sounds/clockring.mp3", UriKind.Relative)
            };

            ScheduledActionService.Add(alarm);
            this.Notif = alarm;
        }
예제 #17
0
        /// <summary>
        /// Set an alarm/reminder for the given bus stop
        /// </summary>
        /// <param name="bs"></param>
        public void PrepareAlarm(BusStop bs)
        {
            this.ClearAlarms();

            if (bs == null)
            {
                return;
            }

            Alarm alarm = new Alarm(bs.Id)
            {
                BeginTime      = DateTime.Now.AddHours(2),
                Content        = "Your stop is nearing!",
                RecurrenceType = RecurrenceInterval.None,
                Sound          = new Uri("/Sounds/clockring.mp3", UriKind.Relative)
            };

            ScheduledActionService.Add(alarm);
            this.Notif = alarm;
        }
예제 #18
0
            public static ScheduledNotification GetNotificationById(long notificationId)
            {
                ISQLiteStatement statement = dbConn.Prepare(SELECT_SIMPLE_NOTE_NOTIFICATION);

                statement.Bind(1, notificationId);
                ScheduledNotification notification = null;

                while (statement.Step() == SQLiteResult.ROW)
                {
                    string dateTime = (String)statement[2];
                    Debug.WriteLine("Getting notification from database..");
                    Debug.WriteLine("Data before parsing " + dateTime);
                    Debug.WriteLine("Data parsed " + DateTimeOffset.Parse(dateTime));
                    notification = new ScheduledNotification((long)statement[0], (String)statement[1], DateTimeOffset.Parse(dateTime));
                }
                if (notification == null)
                {
                    Debug.WriteLine("notificaiton not found");
                }
                return(notification);
            }
예제 #19
0
        private ScheduledNotification ToScheduledNotification(LocalNotification notification, DateTime now)
        {
            ScheduledNotification scheduledNotification = new ScheduledNotification();

            scheduledNotification.badgeNumber = notification.applicationIconBadgeNumber;
            scheduledNotification.alertAction = notification.alertAction;
            scheduledNotification.alertBody   = notification.alertBody;
            if (notification.fireDate > now)
            {
                scheduledNotification.fireDate = notification.fireDate;
            }
            else
            {
                scheduledNotification.fireDate = DateTime.MinValue;
            }
            scheduledNotification.repeatInterval = notification.repeatInterval;
            scheduledNotification.userData       = UserInfoToDictionaryOfStrings(notification.userInfo);
            scheduledNotification.soundName      = notification.soundName;

            return(scheduledNotification);
        }
        public static Permission IsPermitted(string node, WebRequest req)
        {
            if (req != null && _store != null)
            {
                if (_ntfPermError != null)
                {
                    _ntfPermError.Enabled = false;
                }

                var match   = _store.Where(x => x.Name == req.AuthenticatedAs).ToArray();
                var allowed = false;
                var found   = false;

                var nodesForUser = match
                                   .SelectMany(x => x.Nodes)
                                   .Where(x => x.Key == node)
                                   .ToArray();
                foreach (var nd in nodesForUser)
                {
                    if (!found)
                    {
                        found = true;
                    }
                    if (nd.Deny)
                    {
                        return(Permission.Denied);
                    }
                    if (nd.Deny == false)
                    {
                        allowed = true;
                    }
                }

                //Check for group permissions second
                nodesForUser = match.SelectMany(x => x.MatchedGroups)
                               .SelectMany(x => x.Nodes)
                               .Where(x => x.Key == node)
                               .ToArray();
                foreach (var nd in nodesForUser)
                {
                    if (!found)
                    {
                        found = true;
                    }
                    if (nd.Deny)
                    {
                        return(Permission.Denied);
                    }
                    if (nd.Deny == false)
                    {
                        allowed = true;
                    }
                }

                ////Check for DEFAULT group permissions second
                //if (!String.IsNullOrEmpty(req.AuthenticatedAs))
                //{
                //    nodesForUser = _store.Groups
                //            .Where(y => y.Attributes
                //                .Where(z => z.Key == "ApplyToGuests" && z.Value.ToLower() == "true")
                //                .Count() > 0)
                //            .SelectMany(y => y.Nodes)
                //            .Where(x => x.Key == node)
                //            .ToArray();
                //    foreach (var nd in nodesForUser)
                //    {
                //        if (!found) found = true;
                //        if (nd.Deny) return Permission.Denied;
                //        if (nd.Deny == false) allowed = true;
                //    }
                //}

                if (!found)
                {
                    return(Permission.NodeNonExistent);
                }

                return(allowed ? Permission.Permitted : Permission.Denied);
            }
            else
            {
                if (null == _store)
                {
                    if (_ntfPermError == null)
                    {
                        _ntfPermError = new ScheduledNotification("Web permissions are missing and is preventing logins", Microsoft.Xna.Framework.Color.Red, 10);
                        _ntfPermError.SetImmediate();
                    }

                    if (!_ntfPermError.Enabled)
                    {
                        _ntfPermError.Enabled = true;
                    }
                }
            }

            return(Permission.Denied);
        }
예제 #21
0
파일: SNM.cs 프로젝트: odbb/ggj16
	//----------------------------------------------------------------------------------
	// Notifications
	//----------------------------------------------------------------------------------

	public void ScheduleNotification( string gameName, string notifName, int afterSeconds )
	{
		AppBehaviour app = appManager.GetAppBehaviour( gameName );

		if( app == null )
		{
			Debug.LogError( "Add the app" );
			return;
		}

		ScheduledNotification n = new ScheduledNotification();
		n.name = notifName;
		n.secondsAt = UtcSeconds + afterSeconds;
		n.onApp = app;

		notifications.Add( n );
	}
예제 #22
0
        /// <summary>
        /// Change the alarm's BeginTime to now
        /// </summary>
        /// <param name="bs"></param>
        public void TriggerAlarm(BusStop bs)
        {
            if (bs == null) return;

            var alarm = ScheduledActionService.Find(bs.Id) as Alarm;
            if (alarm == null) return;

            alarm.BeginTime = DateTime.Now.AddSeconds(30);
            try
            {
                ScheduledActionService.Replace(alarm);
            }
            catch
            {
                ShellToast toast = new ShellToast()
                {
                    Content = "Your stop is nearing",
                    NavigationUri = new Uri("/Pages/PanoPage.xaml", UriKind.Relative),
                    Title = "Stop Alarm"
                };
                toast.Show();
            }

            this.Notif = null;
        }