예제 #1
0
        public static async Task <bool> HasSmartStore(Account account)
        {
            IRandomAccessStreamWithContentType stream = null;
            bool fileExists = false;

            try
            {
                var path   = DBOpenHelper.GetOpenHelper(account).DatabaseFile;
                var folder = ApplicationData.Current.LocalFolder;
                var file   = await folder.GetFileAsync(path);

                stream = await file.OpenReadAsync();

                fileExists = true;
            }
            catch (UnauthorizedAccessException)
            {
                fileExists = true;
            }
            catch (Exception)
            {
                fileExists = false;
            }
            finally
            {
                if (stream != null)
                {
                    stream.Dispose();
                }
            }
            return(fileExists);
        }
        public static string GenerateDatabasePath(Account account)
        {
            DBOpenHelper open      = DBOpenHelper.GetOpenHelper(account);
            var          localPath = AppInfoService.GetApplicationLocalFolderPath();

            return(Path.Combine(localPath, open.DatabaseFile));
        }
        public static void DeleteAllDatabases(bool includeGlobal)
        {
            var accounts = AccountManager.GetAccounts();

            foreach (var accountKey in accounts.Keys)
            {
                var account = accounts[accountKey];
                var path    = DBOpenHelper.GetOpenHelper(account).DatabaseFile;
                var helper  = DBHelper.GetInstance(GenerateDatabasePath(account));
                DropAllSoups(path);
                SQLiteResult result = helper.Execute("DROP TABLE IF EXISTS " + SoupIndexMapTable);
                helper.Execute("DROP TABLE IF EXISTS " + SoupNamesTable);
                helper.Dispose();
            }
            if (includeGlobal)
            {
                var path   = DBOpenHelper.GetOpenHelper(null).DatabaseFile;
                var helper = DBHelper.GetInstance(GenerateDatabasePath(null));
                DropAllSoups(path);
                SQLiteResult result = helper.Execute("DROP TABLE IF EXISTS " + SoupIndexMapTable);
                helper.Execute("DROP TABLE IF EXISTS " + SoupNamesTable);
                helper.Dispose();
            }
        }
        public static async Task <bool> HasSmartStore(Account account)
        {
            var path = DBOpenHelper.GetOpenHelper(account).DatabaseFile;

            return(await AppInfoService.DoesFileExistAsync(path));
        }
예제 #5
0
        public static string GenerateDatabasePath(Account account)
        {
            DBOpenHelper open = DBOpenHelper.GetOpenHelper(AccountManager.GetAccount());

            return(Path.Combine(ApplicationData.Current.LocalFolder.Path, open.DatabaseFile));
        }