Exemple #1
0
        public async Task Initialize()
        {
            Notify("Getting data ready...");
            try
            {
                StaticData.MapVm.AllBus = await StorageHelper.Json2Object <ObservableCollection <BusTotal> >("data.dat");
            }
            catch
            {
                // ignored
            }
            if (StaticData.MapVm.AllBus == null)
            {
                Notify("Initializing for the first use...");
                //Copy data to local storage
                StorageFile file =
                    await StorageFile.GetFileFromApplicationUriAsync(new Uri(@"ms-appx:///Data/data.dat"));

                StorageFolder dataFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync("data");

                await file.CopyAsync(dataFolder);

                StaticData.MapVm.AllBus = await StorageHelper.Json2Object <ObservableCollection <BusTotal> >("data.dat");

                UpdateProgress(50);
            }

            try
            {
                StaticData.MapVm.AllStation =
                    await StorageHelper.Json2Object <ObservableCollection <StationTotal> >("allstation.dat");
            }
            catch
            {
                // ignored
            }
            if (StaticData.MapVm.AllStation == null)
            {
                Notify("Getting all bus station ready...");
                UpdateDatabaseViewModel vm = new UpdateDatabaseViewModel();
                await vm.CalculateStationTotal();
            }

            Notify("Completed");
        }
 public UpdateDatabasePage()
 {
     InitializeComponent();
     _vm = DataContext as UpdateDatabaseViewModel;
 }