Esempio n. 1
0
        protected override async void OnStart()
        {
            dataModel = new DataModel();
            await dataModel.InitAsync();

            // Replace the earlier empty MainPage with our real one now that the data model is set up.
            homePage = new HomePage();            
            MainPage = new NavigationPage(homePage);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            String message = "Database complete; press any key to exit.";

            // The database will be in the DBInitialize\bin\[Debug | Release] folder
            string path = "Altostratus.db3";            
            SQLiteAsyncConnection conn = new SQLiteAsyncConnection(path);

            Console.WriteLine("Database initializing.");

            // This timer creates progress dots in the console window to show progress.
            Timer ticker = new System.Timers.Timer(500);
            ticker.Elapsed += (object sender, ElapsedEventArgs e) =>
            {
                Console.Write('.');
            };

            ticker.AutoReset = true;
            ticker.Enabled = true;

            // Because this is a console utility, it doesn't have UI that needs to be responsive.
            // Therefore we can use .Wait() on async tasks instead of await. The timer above will
            // continue to tick and output dots.

            var dbInit = new DataAccessLayer(conn);
            dbInit.InitAsync().Wait();
                       
            DataModel model = new DataModel(dbInit);
            model.InitAsync().Wait();

            try
            {                               
                model.SyncCategories().Wait();
                model.SyncAuthProviders().Wait();
                model.SyncItems().Wait();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception during sync: " + ex.Message);                
                message = "So sorry, there was a problem: " + ex.Message + "/nPress any key to exit.";
            }

            ticker.Enabled = false;            
            Console.WriteLine();
            Console.WriteLine(message);

            //Wait until a key is pressed to exit.
            Console.ReadLine();                   
        }
Esempio n. 3
0
        public ItemViewModel(Item item)
        {
            dataModel = App.DataModel;            

            // If we failed to get the item, use a substitute. This could only happen if the user manages to 
            // invoke an item that's been removed from the database. This shouldn't happen because the ListView
            // source is always queried from the database before the cleanup process starts (see SyncItems in
            // in sync.cs), and because the only items that get removed are those that should already fall outside
            // the limit of the item query. Nevertheless, this check remains for robustness.
            if (item.Body == null)
            {
                item.Body = Resources.Item_RemovedMessage;
                Debug.WriteLine("Item page invoked for item that was removed from the database: " + item.Url);                
            }

            this.item = item;
        }