예제 #1
0
        /// <summary>
        /// Invoked when application execution is being suspended.  Application state is saved
        /// without knowing whether the application will be terminated or resumed with the contents
        /// of memory still intact.
        /// </summary>
        /// <param name="sender">The source of the suspend request.</param>
        /// <param name="e">Details about the suspend request.</param>
        private async void OnSuspending(object sender, SuspendingEventArgs e)
        {
            var deferral = e.SuspendingOperation.GetDeferral();

            // TODO: Save application state and stop any background activity
            await SuspensionManager.SaveAsync();

            // save app's data
            AppDataManager.SaveTickets(MainPage.tickets);
            AppDataManager.SaveRequests(MainPage.requests);

            deferral.Complete();
        }
        private static void checkTickets()
        {
            IEnumerable <Ticket> tickets = AppDataManager.RetrieveTickets();

            foreach (Ticket tic in tickets)
            {
                if (tic.notifyBeforeDeparture && (tic.departure.GetDateTime() - DateTimeOffset.Now).Hours < 5)
                {
                    tic.notifyBeforeDeparture = false;
                    Notification.SendToast(
                        "У вас потяг " + tic.departure.date.ToString("d"),
                        tic.from + " - " + tic.to + " о " + tic.departure.time,
                        DateTimeOffset.Now.AddSeconds(15),
                        "UZTracer.TicketPage?info&" + JsonConvert.SerializeObject(tic));
                }
            }
            AppDataManager.SaveTickets(tickets);
        }
예제 #3
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // TODO: Prepare page for display here.

            // TODO: If your application contains multiple pages, ensure that you are
            // handling the hardware Back button by registering for the
            // Windows.Phone.UI.Input.HardwareButtons.BackPressed event.
            // If you are using the NavigationHelper provided by some templates,
            // this event is handled for you.
            navigationHelper.OnNavigatedTo(e);

            ticketsList.DataContext = null;
            ticketsList.DataContext = tickets;
            AppDataManager.SaveTickets(tickets);

            requestsList.DataContext = null;
            requestsList.DataContext = requests;
            AppDataManager.SaveRequests(requests);

            Notification.ClearBadge();
        }