示例#1
0
        /// <summary>
        /// Loads the data asynchronous.
        /// </summary>
        /// <returns>
        /// Task indicating if the data is loaded successfully.
        /// </returns>
        public async Task <bool> TriggerLoadSerialDataAsync()
        {
            try
            {
                _CL.LogRoutineEntry("TriggerLoadSerialDataAsync");

                // await DataStore.CN.ChangeLoadingMessage("Checking for Serialised GRAMPS data").ConfigureAwait(false);
                if (DataStore.DS.IsDataLoaded == false)
                {
                    if (CommonLocalSettings.DataSerialised)
                    {
                        await DataStore.CN.ChangeLoadingMessage("Loading GRAMPS Serial data").ConfigureAwait(false);

                        localStoreSerial.DeSerializeRepository();

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

                        UpdateSettings();

                        await localPostLoad.LoadSerialUiItems().ConfigureAwait(false);

                        await DataStore.CN.ChangeLoadingMessage("GRAMPS Serial data load complete").ConfigureAwait(false);

                        // let everybody know we have finished loading data
                        _EventAggregator.GetEvent <DataLoadCompleteEvent>().Publish(null);
                    }
                    else
                    {
                        await DataStore.CN.ChangeLoadingMessage("GRAMPS Serial data load failed.").ConfigureAwait(false);

                        CommonLocalSettings.SetReloadDatabase();
                    }
                }
            }
            catch (Exception ex)
            {
                CommonLocalSettings.DataSerialised = false;

                DataStore.CN.NotifyException("Trying to load existing serialised data", ex);

                CommonLocalSettings.SetReloadDatabase();

                throw;
            }

            _CL.LogRoutineExit("");

            return(false);
        }
        /// <summary>
        /// Loads the data asynchronous.
        /// </summary>
        /// <returns>
        /// Task indicating if the data is loaded successfully.
        /// </returns>
        public async Task <bool> TriggerLoadSerialDataAsync()
        {
            try
            {
                _CL.RoutineEntry("TriggerLoadSerialDataAsync");

                _commonNotifications.DataLogEntryAdd("Checking for Serialised GRAMPS data");
                if (DataStore.Instance.DS.IsDataLoaded == false)
                {
                    if (CommonLocalSettings.DataSerialised)
                    {
                        _commonNotifications.DataLogEntryAdd("Loading GRAMPS Serial data");

                        await _StoreSerial.DeSerializeRepository();

                        UpdateSavedLocalSettings();

                        await _PostLoad.LoadSerialUiItems().ConfigureAwait(false);

                        _commonNotifications.DataLogEntryReplace("GRAMPS Serial data load complete");

                        // let everybody know we have finished loading data
                        App.Current.Services.GetService <IMessenger>().Send(new DataLoadCompleteEvent(true));
                    }
                    else
                    {
                        _commonNotifications.DataLogEntryAdd("GRAMPS Serial data load failed.");

                        CommonLocalSettings.SetReloadDatabase();
                    }
                }
            }
            catch (Exception ex)
            {
                CommonLocalSettings.DataSerialised = false;

                _commonNotifications.NotifyException("Trying to load existing serialised data", ex);

                CommonLocalSettings.SetReloadDatabase();

                throw;
            }

            _CL.RoutineExit("");

            return(false);
        }