Добавьте файлы проекта.

This commit is contained in:
Курнат Андрей
2026-04-04 10:52:30 +03:00
parent 9b34a92f15
commit 5a55bc5f4c
30 changed files with 3446 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
using System.Diagnostics;
using System.IO;
using CRAWLER.Models;
namespace CRAWLER.Services;
internal interface IPdfOpener
{
void OpenAttachment(PdfAttachment attachment);
void OpenUri(string uri);
}
internal sealed class PdfShellService : IPdfOpener
{
public void OpenAttachment(PdfAttachment attachment)
{
if (attachment == null)
{
return;
}
if (!string.IsNullOrWhiteSpace(attachment.LocalPath) && File.Exists(attachment.LocalPath))
{
OpenUri(attachment.LocalPath);
return;
}
if (!string.IsNullOrWhiteSpace(attachment.SourceUrl))
{
OpenUri(attachment.SourceUrl);
}
}
public void OpenUri(string uri)
{
if (string.IsNullOrWhiteSpace(uri))
{
return;
}
Process.Start(new ProcessStartInfo(uri)
{
UseShellExecute = true
});
}
}