예제 #1
0
        /// <summary>
        /// Triggers the load GPKG file asynchronous.
        /// </summary>
        /// <param name="deleteOld">
        /// if set to <c>true</c> [delete old].
        /// </param>
        /// <param name="gpkgFileName">
        /// Name of the GPKG file.
        /// </param>
        /// <returns>
        /// </returns>
        public async Task <bool> TriggerLoadGPKGFileAsync(bool deleteOld)
        {
            Analytics.TrackEvent("TriggerLoadGPKGFileAsync",
                                 new Dictionary <string, string> {
                { "FileName", DataStore.AD.CurrentInputFile.FilePath },
            });

            if (!DataStore.AD.CurrentInputFileValid)
            {
                return(false);
            }

            // HockeyClient.Current.TrackEvent("TriggerLoadGPKGFileAsync");
            await DataStore.CN.ChangeLoadingMessage("Loading GPKG data").ConfigureAwait(false);

            // await DataStore.CN.MajorStatusAdd("Loading GRAMPS XML data");
            {
                if (DataStore.AD.CurrentInputFileValid)
                {
                    // TODO create data folder await localStoreFile.SetDataFolderLocalStorage();

                    // Clear image cache
                    await ImageService.Instance.InvalidateCacheAsync(CacheType.All).ConfigureAwait(false);

                    // 1) Initialise local data copies (if any exist)
                    if (deleteOld)
                    {
                        await localStoreFile.DataStorageInitialiseAsync().ConfigureAwait(false);
                    }

                    // TODO work out how to delte excess files based on keepign the ones in the GPKG file
                    //// Delete directories of files. Assume files in root are ok
                    // IReadOnlyList<StorageFolder> t = await DataStore.AD.CurrentDataFolder.GetFoldersAsync();

                    // foreach (StorageFolder item in t) { await item.DeleteAsync(); }
                    await localStoreFile.DecompressTAR().ConfigureAwait(false);

                    // Save the current Index File modified date for later checking TODO How doe
                    // sthis work if only loading picked file?
                    // StoreFileNames.SaveFileModifiedSinceLastSave(CommonConstants.SettingsGPKGFileLastDateTimeModified, DataStore.AD.CurrentInputFile);
                }
            }

            await DataStore.CN.MajorStatusDelete().ConfigureAwait(false);

            await DataStore.CN.ChangeLoadingMessage(null).ConfigureAwait(false);

            return(false);
        }
예제 #2
0
        /// <summary>
        /// Triggers the load GPKG file asynchronous.
        /// </summary>
        /// <param name="deleteOld">
        /// if set to <c> true </c> [delete old].
        /// </param>
        /// <param name="gpkgFileName">
        /// Name of the GPKG file.
        /// </param>
        /// <returns>
        /// </returns>
        public async Task <FileInfoEx> TriggerLoadGPKGFileAsync()
        {
            Analytics.TrackEvent("TriggerLoadGPKGFileAsync",
                                 new Dictionary <string, string> {
                { "FileName", DataStore.Instance.AD.CurrentInputStreamPath },
            });

            if (!DataStore.Instance.AD.CurrentInputStreamValid)
            {
                return(new FileInfoEx());
            }

            _commonNotifications.DataLogEntryAdd("Later version of Gramps XML data plus Media compressed file found. Loading it into the program");

            // Only unZip gzip files

            _commonNotifications.DataLogEntryAdd("Loading GPKG data");

            if (DataStore.Instance.AD.CurrentInputStreamValid)
            {
                // TODO create data folder await localStoreFile.SetDataFolderLocalStorage();

                //await DataStore.Instance.FFIL.InvalidateCacheAsync(CacheType.All).ConfigureAwait(false);

                // TODO work out how to delete excess files based on keeping the ones in the GPKG file
                //// Delete directories of files. Assume files in root are ok
                // IReadOnlyList<StorageFolder> t = await DataStore.Instance.AD.CurrentDataFolder.GetFoldersAsync();

                // foreach (StorageFolder item in t) { await item.DeleteAsync(); }
                await _StoreFile.DecompressTAR().ConfigureAwait(false);

                // Save the current Index File modified date for later checking TODO How doe sthis
                // work if only loading picked file?
                // StoreFileNames.SaveFileModifiedSinceLastSave(Constants.SettingsGPKGFileLastDateTimeModified, DataStore.Instance.AD.CurrentInputFile);
            }

            return(new FileInfoEx(argFileName: Common.Constants.StorageGRAMPSFileName));
        }