Пример #1
0
 public static Task ExecuteAsync(BackupFile backupFile, IBackupFileService backupFileService, string filePath)
 {
     return(Task.Run(() =>
     {
         backupFile?.Database.TagMaps.RemoveAll(x => x.TagId == 1);
         backupFileService.WriteNewDatabase(backupFile, filePath, filePath);
     }));
 }
Пример #2
0
        private void MergeFiles()
        {
            var destPath = _fileOpenSaveService.GetSaveFilePath(GetSaveDialogTitle());

            if (!string.IsNullOrWhiteSpace(destPath))
            {
                IsBusy = true;

                Task.Run(() =>
                {
                    DebugSleep();
                    PrepareForMerge();
                    try
                    {
                        var schemaFilePath = GetSuitableFilePathForSchema();

                        if (schemaFilePath != null)
                        {
                            var mergedFile = _backupFileService.Merge(Files.Select(x => x.BackupFile).ToArray());
                            _backupFileService.WriteNewDatabase(mergedFile, destPath, schemaFilePath);
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Logger.Error(ex, "Could not merge");
                    }
                    finally
                    {
                        // we need to ensure the files are back to normal after
                        // applying any merge parameters.
                        ReloadFiles();
                    }
                }).ContinueWith(previousTask =>
                {
                    DispatcherHelper.CheckBeginInvokeOnUI(() =>
                    {
                        IsBusy = false;
                    });
                });
            }
        }
Пример #3
0
        public static async Task ExecuteAsync(
            BackupFile backupFile,
            IBackupFileService backupFileService,
            string backupFilePath,
            string importFilePath,
            ImportBibleNotesParams options)
        {
            await Task.Run(() =>
            {
                var file = new BibleNotesFile(importFilePath);

                backupFileService.ImportBibleNotes(
                    backupFile,
                    file.GetNotes(),
                    file.GetBibleKeySymbol(),
                    file.GetMepsLanguageId(),
                    options);

                backupFileService.WriteNewDatabase(backupFile, backupFilePath, backupFilePath);
            });
        }
Пример #4
0
        public static Task ExecuteAsync(
            List<Note> notes, IRedactService redactService, BackupFile backupFile, IBackupFileService backupFileService, string filePath)
        {
            return Task.Run(() =>
            {
                foreach (var note in notes)
                {
                    if (!string.IsNullOrEmpty(note.Title))
                    {
                        note.Title = redactService.GetNoteTitle(note.Title.Length);
                    }

                    if (!string.IsNullOrEmpty(note.Content))
                    {
                        note.Content = redactService.GenerateNoteContent(note.Content.Length);
                    }
                }

                backupFileService.WriteNewDatabase(backupFile, filePath, filePath);
            });
        }