pull/3598/head
Jamie Rees 5 years ago
parent 0cec163324
commit 77f8d76590

@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.SignalR;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Ombi.Api.Emby;
using Ombi.Api.TheMovieDb;
@ -83,13 +85,13 @@ namespace Ombi.Schedule.Jobs.Ombi
private async Task StartPlex()
{
// Ensure we check that we have not linked this item to a request
var allMovies = _plexRepo.GetAll().Where(x =>
x.Type == PlexMediaTypeEntity.Movie && x.RequestId == null && (x.TheMovieDbId == null || x.ImdbId == null));
var allMovies = await _plexRepo.GetAll().Where(x =>
x.Type == PlexMediaTypeEntity.Movie && x.RequestId == null && (x.TheMovieDbId == null || x.ImdbId == null)).ToListAsync();
await StartPlexMovies(allMovies);
// Now Tv
var allTv = _plexRepo.GetAll().Where(x =>
x.Type == PlexMediaTypeEntity.Show && x.RequestId == null && (x.TheMovieDbId == null || x.ImdbId == null || x.TvDbId == null));
var allTv = await _plexRepo.GetAll().Where(x =>
x.Type == PlexMediaTypeEntity.Show && x.RequestId == null && (x.TheMovieDbId == null || x.ImdbId == null || x.TvDbId == null)).ToListAsync();
await StartPlexTv(allTv);
}
@ -100,7 +102,7 @@ namespace Ombi.Schedule.Jobs.Ombi
await StartEmbyTv();
}
private async Task StartPlexTv(IQueryable<PlexServerContent> allTv)
private async Task StartPlexTv(List<PlexServerContent> allTv)
{
foreach (var show in allTv)
{
@ -138,8 +140,8 @@ namespace Ombi.Schedule.Jobs.Ombi
private async Task StartEmbyTv()
{
var allTv = _embyRepo.GetAll().Where(x =>
x.Type == EmbyMediaType.Series && (!x.TheMovieDbId.HasValue() || !x.ImdbId.HasValue() || !x.TvDbId.HasValue()));
var allTv = await _embyRepo.GetAll().Where(x =>
x.Type == EmbyMediaType.Series && (!x.TheMovieDbId.HasValue() || !x.ImdbId.HasValue() || !x.TvDbId.HasValue())).ToListAsync();
foreach (var show in allTv)
{
@ -171,7 +173,7 @@ namespace Ombi.Schedule.Jobs.Ombi
}
}
private async Task StartPlexMovies(IQueryable<PlexServerContent> allMovies)
private async Task StartPlexMovies(List<PlexServerContent> allMovies)
{
foreach (var movie in allMovies)
{
@ -203,8 +205,8 @@ namespace Ombi.Schedule.Jobs.Ombi
private async Task StartEmbyMovies(EmbySettings settings)
{
var allMovies = _embyRepo.GetAll().Where(x =>
x.Type == EmbyMediaType.Movie && (!x.TheMovieDbId.HasValue() || !x.ImdbId.HasValue()));
var allMovies = await _embyRepo.GetAll().Where(x =>
x.Type == EmbyMediaType.Movie && (!x.TheMovieDbId.HasValue() || !x.ImdbId.HasValue())).ToListAsync();
foreach (var movie in allMovies)
{
movie.ImdbId.HasValue();

@ -80,7 +80,7 @@ namespace Ombi.Store.Repository
public async Task ExecuteSql(string sql)
{
await _ctx.Database.ExecuteSqlCommandAsync(sql);
await _ctx.Database.ExecuteSqlRawAsync(sql);
}
protected async Task<int> InternalSaveChanges()
@ -96,10 +96,10 @@ namespace Ombi.Store.Repository
var result = await policy.ExecuteAndCaptureAsync(async () =>
{
using (var tran = await _ctx.Database.BeginTransactionAsync())
//using (var tran = await _ctx.Database.BeginTransactionAsync())
{
var r = await _ctx.SaveChangesAsync();
tran.Commit();
//tran.Commit();
return r;
}
});

Loading…
Cancel
Save