Exemple #1
0
        private void SaveBackup(Document document)
        {
            var path = GetTemporalPath(document.Path);

            Directory.CreateDirectory(path);
            try {
                document.SaveTo(Path.Combine(path, DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")));
            } catch (Exception e) {
                Console.WriteLine($"Error on autosave document '{document.Path}':\n{e}");
            }

            var history = GetHistory(path);

            if (history != null)
            {
                if (!(document == Document.Current && mode == Mode.SaveOriginal))
                {
                    RemoveBackups(history);
                }
            }

            if (lastKnownDocument == document && mode == Mode.Scan)
            {
                mode = Mode.Normal;
            }

            BackupSaved?.Invoke();
        }
Exemple #2
0
        private void SaveBackup(Document document)
        {
            var directory = GetTemporaryPath(document.Path);

            Directory.CreateDirectory(directory);
            try {
                var filePath = Path.Combine(directory,
                                            $"{DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")}.{document.GetFileExtension()}");
                document.ExportToFile(filePath, document.Path);
            } catch (Exception e) {
                Console.WriteLine($"Error on autosave document '{document.Path}':\n{e}");
            }

            var history = GetHistory(directory);

            if (history != null)
            {
                if (!(document == Document.Current && mode == Mode.SaveOriginal))
                {
                    RemoveBackups(history);
                }
            }

            if (lastKnownDocument == document && mode == Mode.Scan)
            {
                mode = Mode.Normal;
            }

            BackupSaved?.Invoke();
        }