Exemplo n.º 1
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected async override void OnInvoke(ScheduledTask task)
        {
            try
            {
                Config.Initialize();
                var services = new WPSilverlightCoreServices();
                var tb       = new TransitBase.TransitBaseComponent(
                    root: services.FileSystem.GetAppStorageRoot(),
                    directionsService: null,
                    preLoad: false,
                    bigTableLimit: Config.Current.BigTableLimit,
                    checkSameRoutes: Config.Current.CheckSameRoutes,
                    latitudeDegreeDistance: Config.Current.LatitudeDegreeDistance,
                    longitudeDegreeDistance: Config.Current.LongitudeDegreeDistance
                    );
                var ub     = new UserBase.UserBaseLinqToSQLComponent("Data Source=isostore:ddb.sdf", Config.Current.UBVersion, forbidMigration: true);
                var common = new CommonComponent(services, tb, ub);

                foreach (var tile in ShellTile.ActiveTiles)
                {
                    if (tile.NavigationUri.OriginalString.StartsWith("/MainPage.xaml?tile="))
                    {
                        if (tile.NavigationUri.OriginalString.StartsWith("/MainPage.xaml?tile=stoproute"))
                        {
                            updateTileUnknown(tile);
                        }
                        else
                        {
                            Deployment.Current.Dispatcher.BeginInvoke(() =>
                            {
                                Tiles.UpdateTile(tile);
                                //bool ret = Tiles.UpdateTile(tile);
                                //if (ret == false)
                                //    updateTileUnknown(tile);
                                tb.Flush();
                            });
                        }
                    }
                }
                if (NetworkInterface.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 && NetworkInterface.GetIsNetworkAvailable() && !AppFields.UpdateAvailable)
                {
                    var checkResult = await UpdateMonitor.CheckUpdate();

                    if (checkResult == UpdateMonitor.Result.Found)
                    {
                        ShellToast toast = new ShellToast();
                        toast.Title   = "Update";
                        toast.Content = "A database update is required.";
                        toast.Show();
                    }
                }
            }
            catch (Exception) { }


            NotifyComplete();
        }
Exemplo n.º 2
0
 // Code to execute when the application is launching (eg, from Start)
 // This code will not execute when the application is reactivated
 private void Application_Launching(object sender, LaunchingEventArgs e)
 {
     Common = new CommonComponent(new WPSilverlightServices(), new ComponentFactory());
     Common.ComposedComponentChanged += (s, component) =>
     {
         if (component is TransitBase.TransitBaseComponent)
         {
             performEngineLoaded();
         }
     };
     if (Common.TB.DatabaseExists)
     {
         performEngineLoaded();
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            Common = new CommonComponent(new WindowsUniversalServices(), new ComponentFactory());
            Common.ComposedComponentChanged += performApplicationComponentChanged;
            if (Common.TB.DatabaseExists)
            {
                performApplicationComponentChanged(this, Common.TB);
            }
            this.UnhandledException += App_UnhandledException;
#if WINDOWS_PHONE_APP
            if (e.TileId != null && e.TileId != "App")
            {
                SourceTileId = int.Parse(e.TileId);
                MainPage.NavigateToTile(SourceTileId.Value);
            }
#endif

#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                // TODO: change this value to a cache size that is appropriate for your application
                rootFrame.CacheSize = 10;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
#if WINDOWS_PHONE_APP
                // Removes the turnstile navigation for startup.
                if (rootFrame.ContentTransitions != null)
                {
                    this.transitions = new TransitionCollection();
                    foreach (var c in rootFrame.ContentTransitions)
                    {
                        this.transitions.Add(c);
                    }
                }

                rootFrame.ContentTransitions = null;
                rootFrame.Navigated         += this.RootFrame_FirstNavigated;
#endif

                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (!rootFrame.Navigate(typeof(MainPage), e.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }

            // Ensure the current window is active
            Window.Current.Activate();
        }