v0.7.3 - The Quality of Life Update (#2036)
* Version bump * Okay this should be the last (#2037) * Fixed improper date visualization for reading list detail page. * Correct not-read badge position (#2034) --------- Co-authored-by: Andre Smith <Hobogrammer@users.noreply.github.com> * Bump versions by dotnet-bump-version. * Merged develop in --------- Co-authored-by: Andre Smith <Hobogrammer@users.noreply.github.com>
This commit is contained in:
parent
51e23b7eca
commit
1b3866568f
235 changed files with 14827 additions and 21948 deletions
67
API/Services/MediaErrorService.cs
Normal file
67
API/Services/MediaErrorService.cs
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using API.Data;
|
||||
using API.Helpers.Builders;
|
||||
using Hangfire;
|
||||
|
||||
namespace API.Services;
|
||||
|
||||
public enum MediaErrorProducer
|
||||
{
|
||||
BookService = 0,
|
||||
ArchiveService = 1
|
||||
|
||||
}
|
||||
|
||||
public interface IMediaErrorService
|
||||
{
|
||||
Task ReportMediaIssueAsync(string filename, MediaErrorProducer producer, string errorMessage, string details);
|
||||
void ReportMediaIssue(string filename, MediaErrorProducer producer, string errorMessage, string details);
|
||||
Task ReportMediaIssueAsync(string filename, MediaErrorProducer producer, string errorMessage, Exception ex);
|
||||
void ReportMediaIssue(string filename, MediaErrorProducer producer, string errorMessage, Exception ex);
|
||||
}
|
||||
|
||||
public class MediaErrorService : IMediaErrorService
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
public MediaErrorService(IUnitOfWork unitOfWork)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
public async Task ReportMediaIssueAsync(string filename, MediaErrorProducer producer, string errorMessage, Exception ex)
|
||||
{
|
||||
await ReportMediaIssueAsync(filename, producer, errorMessage, ex.Message);
|
||||
}
|
||||
|
||||
public void ReportMediaIssue(string filename, MediaErrorProducer producer, string errorMessage, Exception ex)
|
||||
{
|
||||
// To avoid overhead on commits, do async. We don't need to wait.
|
||||
BackgroundJob.Enqueue(() => ReportMediaIssueAsync(filename, producer, errorMessage, ex.Message));
|
||||
}
|
||||
|
||||
public void ReportMediaIssue(string filename, MediaErrorProducer producer, string errorMessage, string details)
|
||||
{
|
||||
// To avoid overhead on commits, do async. We don't need to wait.
|
||||
BackgroundJob.Enqueue(() => ReportMediaIssueAsync(filename, producer, errorMessage, details));
|
||||
}
|
||||
|
||||
public async Task ReportMediaIssueAsync(string filename, MediaErrorProducer producer, string errorMessage, string details)
|
||||
{
|
||||
var error = new MediaErrorBuilder(filename)
|
||||
.WithComment(errorMessage)
|
||||
.WithDetails(details)
|
||||
.Build();
|
||||
|
||||
if (await _unitOfWork.MediaErrorRepository.ExistsAsync(error))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
_unitOfWork.MediaErrorRepository.Attach(error);
|
||||
await _unitOfWork.CommitAsync();
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue