Esempio n. 1
0
        //Database Reset
        public static async Task DatabaseReset()
        {
            try
            {
                await EventProgressDisableUI("Resetting the database.", true);

                Debug.WriteLine("Resetting the database.");

                //Delete all files from local storage
                foreach (IStorageItem LocalFile in await ApplicationData.Current.LocalFolder.GetItemsAsync())
                {
                    try { await LocalFile.DeleteAsync(StorageDeleteOption.PermanentDelete); } catch { }
                }

                //Reset the online status
                OnlineUpdateFeeds   = true;
                OnlineUpdateNews    = true;
                OnlineUpdateStarred = true;
                ApiMessageError     = String.Empty;

                //Reset the last update setting
                AppVariables.ApplicationSettings["LastItemsUpdate"] = "Never";

                Debug.WriteLine("Resetted the database.");
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Failed resetting the database: " + ex.Message);
            }
        }
Esempio n. 2
0
        //Reset TimeMe status and All Files
        async void btn_ResetTimeMeStatus_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Nullable <bool> MessageDialogResult = null;
                MessageDialog   MessageDialog       = new MessageDialog("Do you really want to reset the TimeMe status and remove all files which will reset TimeMe to it's defaults? This is only recommended when TimeMe has stopped updating the live tile.\n\nAfter the application has been reset to it's defaults TimeMe will be closed and will need to be run again manually before live tile updates start to work.", "TimeMe");
                MessageDialog.Commands.Add(new UICommand("Yes", new UICommandInvokedHandler((cmd) => MessageDialogResult = true)));
                MessageDialog.Commands.Add(new UICommand("No", new UICommandInvokedHandler((cmd) => MessageDialogResult  = false)));
                await MessageDialog.ShowAsync();

                if (MessageDialogResult == true)
                {
                    grid_Main.Opacity          = 0.60;
                    grid_Main.IsHitTestVisible = false;
                    txt_StatusBar.Text         = "Resetting TimeMe, please wait...";
                    sp_StatusBar.Visibility    = Visibility.Visible;

                    //Stop all background tasks
                    foreach (KeyValuePair <Guid, IBackgroundTaskRegistration> BackgroundTask in BackgroundTaskRegistration.AllTasks)
                    {
                        BackgroundTask.Value.Unregister(true);
                    }

                    //Reset application settings
                    foreach (KeyValuePair <string, object> AppSetting in ApplicationData.Current.LocalSettings.Values)
                    {
                        ApplicationData.Current.LocalSettings.Values.Remove(AppSetting.Key);
                    }

                    //Delete all files from local storage
                    foreach (IStorageItem LocalFile in await ApplicationData.Current.LocalFolder.GetItemsAsync())
                    {
                        try { await LocalFile.DeleteAsync(StorageDeleteOption.PermanentDelete); } catch { }
                    }

                    //Unpin all the live tiles
                    foreach (SecondaryTile SecondaryTile in await SecondaryTile.FindAllAsync())
                    {
                        await SecondaryTile.RequestDeleteForSelectionAsync(GetElementRect((FrameworkElement)sender), Placement.Below);
                    }

                    //Clear all notification messages
                    ToastNotificationManager.History.Clear();

                    Application.Current.Exit();
                }
            }
            catch { Application.Current.Exit(); }
        }
Esempio n. 3
0
        //Clear Database Thread
        async Task ClearDatabase()
        {
            await ProgressDisableUI("Clearing stored items...");

            try
            {
                //Reset the online status
                OnlineUpdateFeeds   = true;
                OnlineUpdateNews    = true;
                OnlineUpdateStarred = true;
                ApiMessageError     = String.Empty;

                //Reset the last update setting
                AppVariables.ApplicationSettings["LastItemsUpdate"] = "Never";

                await ClearObservableCollection(List_Feeds);
                await ClearObservableCollection(List_FeedSelect);
                await ClearObservableCollection(List_NewsItems);
                await ClearObservableCollection(List_SearchItems);
                await ClearObservableCollection(List_StarredItems);

                //Wait for busy database
                await ApiUpdate.WaitForBusyDatabase();

                await SQLConnection.DeleteAllAsync <TableFeeds>();

                await SQLConnection.DropTableAsync <TableFeeds>();

                await SQLConnection.CreateTableAsync <TableFeeds>();

                await SQLConnection.DeleteAllAsync <TableOffline>();

                await SQLConnection.DropTableAsync <TableOffline>();

                await SQLConnection.CreateTableAsync <TableOffline>();

                await SQLConnection.DeleteAllAsync <TableItems>();

                await SQLConnection.DropTableAsync <TableItems>();

                await SQLConnection.CreateTableAsync <TableItems>();

                await SQLConnection.DeleteAllAsync <TableSearchHistory>();

                await SQLConnection.DropTableAsync <TableSearchHistory>();

                await SQLConnection.CreateTableAsync <TableSearchHistory>();

                //Delete all feed icons from local storage
                foreach (IStorageItem LocalFile in await ApplicationData.Current.LocalFolder.GetItemsAsync())
                {
                    try
                    {
                        if (LocalFile.Name.EndsWith(".png"))
                        {
                            await LocalFile.DeleteAsync(StorageDeleteOption.PermanentDelete);
                        }
                    }
                    catch { }
                }

                //Load and set database size
                await UpdateSizeInformation();
            }
            catch { }
            await ProgressEnableUI();
        }