Beispiel #1
0
        public int Run(ContactOptions opts)
        {
            _logger.LogInformation("Starting {Command}", nameof(ContactCommand));

            var appContext = _appContext
                             .SetBackupMetadataInputPaths(opts.InputFolder)
                             .LoadBackupMetadata()
                             .SetVersionsFromMetadata();

            _backupFileProvider = new BackupFileProvider(opts.InputFolder, appContext.ManifestVersion.Major);

            var input = _backupFileProvider.GetPath(KnownDomains.HomeDomain, KnownFiles.AddressBook);

            List <ContactDbEntry> items = default;

            _logger.LogInformation("Opening contacts database '{Source}'", input);
            using (var repository = new ContactRepository(SqliteRepository.GetConnectionString(input)))
            {
                items = repository.GetAllItems().ToList();

                foreach (var item in items)
                {
                    ContactAsVCard.Save(item);
                    //break;
                }
            }

            _logger.LogInformation("Completed {Command}", nameof(ContactCommand));
            return(0);
        }
        private IEnumerable <ManifestEntry> GetManifestDbFileEntries()
        {
            using (var repository = new ManifestRepository(SqliteRepository.GetConnectionString(_path)))
            {
                var items = repository.GetAllItems();

                foreach (var item in items)
                {
                    var result = item.ConvertToManifestEntry(ManifestEntryType.File, _isEncryptedBackup);
                    if (result != null)
                    {
                        yield return(result);
                    }
                }
            }
        }
Beispiel #3
0
        public int Run(MessageOptions opts)
        {
            _logger.LogInformation("Starting {Command}", nameof(MessageCommand));

            var appContext = _appContext
                             .SetBackupMetadataInputPaths(opts.InputFolder)
                             .LoadBackupMetadata()
                             .SetVersionsFromMetadata();

            _backupFileProvider = new BackupFileProvider(opts.InputFolder, appContext.ManifestVersion.Major);

            var input = _backupFileProvider.GetPath(KnownDomains.HomeDomain, KnownFiles.Messages);

            _logger.LogInformation("Opening message database '{Source}'", input);
            using (var repository = new SmsRepository(SqliteRepository.GetConnectionString(input)))
            {
                var items = repository.GetAllItems().ToList();

                if (items.Any())
                {
                    HtmlGenerator.SaveCss(opts.OutputFolder, "bootstrap.min.css");
                    HtmlGenerator.SaveCss(opts.OutputFolder, "bootstrap-theme.min.css");
                    HtmlGenerator.SaveCss(opts.OutputFolder, "site.css");

                    foreach (var item in items)
                    {
                        if (item.CacheHasAttachments)
                        {
                            item.Attachments = repository.GetMessageAttachments(item.Id).ToArray();

                            SaveAttachments(item.Attachments, opts.OutputFolder);
                        }
                    }

                    var generator = new HtmlGenerator("Message Index", () =>
                    {
                        return(ProcessMessagesByChatIdentifier(items, opts.OutputFolder));
                    });

                    generator.SaveAs(opts.OutputFolder, "index.html");
                }
            }

            _logger.LogInformation("Completed {Command}", nameof(MessageCommand));
            return(0);
        }
Beispiel #4
0
        public int Run(MessageOptions opts)
        {
            _logger.LogInformation("Starting {Command}", nameof(MessageCommand));

            var appContext = _appContext
                             .SetBackupMetadataInputPaths(opts.InputFolder)
                             .LoadBackupMetadata()
                             .SetVersionsFromMetadata()
                             .SetManifestEntriesFileInputPath(opts.InputFolder)
                             .AddManifestEntries();

            var backupFileProvider = new BackupFileProvider(opts.InputFolder, appContext.ManifestVersion.Major);

            var input = backupFileProvider.GetPath("3d0d7e5fb2ce288813306e4d4636395e047a3d28");

            _logger.LogInformation("Opening SMS database '{Source}'", input);
            using (var repository = new SmsRepository(SqliteRepository.GetConnectionString(input)))
            {
                var items = repository.GetAllItems().ToList();

                if (items.Any())
                {
                    HtmlGenerator.SaveCss(opts.OutputFolder, "bootstrap.min.css");
                    HtmlGenerator.SaveCss(opts.OutputFolder, "bootstrap-theme.min.css");
                    HtmlGenerator.SaveCss(opts.OutputFolder, "site.css");

                    foreach (var item in items)
                    {
                        if (item.CacheHasAttachments)
                        {
                            item.Attachments = repository.GetMessageAttachments(item.Id).ToArray();

                            foreach (var attachment in item.Attachments)
                            {
                                string fileName = attachment.FileName;

                                if (string.IsNullOrEmpty(fileName) == false && fileName.StartsWith("~/"))
                                {
                                    string toHash = KnownDomains.MediaDomain + KnownDomains.DomainSeparator + fileName.Remove(0, 2);

                                    var hash = CommonHelpers.Sha1HashAsHexString(toHash);

                                    var inputFile = backupFileProvider.GetPath(hash);

                                    HtmlGenerator.SaveAttachmentAs(inputFile, opts.OutputFolder, attachment.TransferName);
                                }
                            }
                        }
                    }

                    var generator = new HtmlGenerator("Message Index", () =>
                    {
                        return(ProcessMessagesByChatIdentifier(items, opts.OutputFolder));
                    });

                    generator.SaveAs(opts.OutputFolder, "index.html");
                }
            }

            _logger.LogInformation("Completed {Command}", nameof(MessageCommand));
            return(0);
        }