Added transactions around all of the CUD operations

pull/3049/head
Jamie Rees 5 years ago
parent 135e9842f6
commit 1fa034908c

@ -72,7 +72,11 @@ namespace Ombi.Schedule.Jobs.Couchpotato
if (movies != null)
{
// Let's remove the old cached data
await _ctx.Database.ExecuteSqlCommandAsync("DELETE FROM CouchPotatoCache");
using (var tran = await _ctx.Database.BeginTransactionAsync())
{
await _ctx.Database.ExecuteSqlCommandAsync("DELETE FROM CouchPotatoCache");
tran.Commit();
}
// Save
var movieIds = new List<CouchPotatoCache>();
@ -92,9 +96,14 @@ namespace Ombi.Schedule.Jobs.Couchpotato
_log.LogError("TMDBId is not > 0 for movie {0}", m.title);
}
}
await _ctx.CouchPotatoCache.AddRangeAsync(movieIds);
await _ctx.SaveChangesAsync();
using (var tran = await _ctx.Database.BeginTransactionAsync())
{
await _ctx.CouchPotatoCache.AddRangeAsync(movieIds);
await _ctx.SaveChangesAsync();
tran.Commit();
}
}
}
catch (Exception e)

@ -48,7 +48,11 @@ namespace Ombi.Schedule.Jobs.Lidarr
if (albums != null && albums.Any())
{
// Let's remove the old cached data
await _ctx.Database.ExecuteSqlCommandAsync("DELETE FROM LidarrAlbumCache");
using (var tran = await _ctx.Database.BeginTransactionAsync())
{
await _ctx.Database.ExecuteSqlCommandAsync("DELETE FROM LidarrAlbumCache");
tran.Commit();
}
var albumCache = new List<LidarrAlbumCache>();
foreach (var a in albums)
@ -68,9 +72,14 @@ namespace Ombi.Schedule.Jobs.Lidarr
});
}
}
await _ctx.LidarrAlbumCache.AddRangeAsync(albumCache);
await _ctx.SaveChangesAsync();
using (var tran = await _ctx.Database.BeginTransactionAsync())
{
await _ctx.LidarrAlbumCache.AddRangeAsync(albumCache);
await _ctx.SaveChangesAsync();
tran.Commit();
}
}
}
catch (System.Exception ex)

@ -49,7 +49,11 @@ namespace Ombi.Schedule.Jobs.Lidarr
if (artists != null && artists.Any())
{
// Let's remove the old cached data
await _ctx.Database.ExecuteSqlCommandAsync("DELETE FROM LidarrArtistCache");
using (var tran = await _ctx.Database.BeginTransactionAsync())
{
await _ctx.Database.ExecuteSqlCommandAsync("DELETE FROM LidarrArtistCache");
tran.Commit();
}
var artistCache = new List<LidarrArtistCache>();
foreach (var a in artists)
@ -65,9 +69,14 @@ namespace Ombi.Schedule.Jobs.Lidarr
});
}
}
await _ctx.LidarrArtistCache.AddRangeAsync(artistCache);
await _ctx.SaveChangesAsync();
using (var tran = await _ctx.Database.BeginTransactionAsync())
{
await _ctx.LidarrArtistCache.AddRangeAsync(artistCache);
await _ctx.SaveChangesAsync();
tran.Commit();
}
}
}
catch (Exception ex)

@ -199,7 +199,7 @@ namespace Ombi.Schedule.Jobs.Plex
if (count > 30)
{
await Repo.SaveChangesAsync();
count = 0;
}
}

@ -47,7 +47,11 @@ namespace Ombi.Schedule.Jobs.Radarr
if (movies != null)
{
// Let's remove the old cached data
await _ctx.Database.ExecuteSqlCommandAsync("DELETE FROM RadarrCache");
using (var tran = await _ctx.Database.BeginTransactionAsync())
{
await _ctx.Database.ExecuteSqlCommandAsync("DELETE FROM RadarrCache");
tran.Commit();
}
var movieIds = new List<RadarrCache>();
foreach (var m in movies)
@ -65,9 +69,14 @@ namespace Ombi.Schedule.Jobs.Radarr
Logger.LogError("TMDBId is not > 0 for movie {0}", m.title);
}
}
await _ctx.RadarrCache.AddRangeAsync(movieIds);
await _ctx.SaveChangesAsync();
using (var tran = await _ctx.Database.BeginTransactionAsync())
{
await _ctx.RadarrCache.AddRangeAsync(movieIds);
await _ctx.SaveChangesAsync();
tran.Commit();
}
}
}
catch (System.Exception ex)

@ -46,8 +46,12 @@ namespace Ombi.Schedule.Jobs.SickRage
{
var srShows = shows.data.Values;
var ids = srShows.Select(x => x.tvdbid);
using (var tran = await _ctx.Database.BeginTransactionAsync())
{
await _ctx.Database.ExecuteSqlCommandAsync("DELETE FROM SickRageCache");
tran.Commit();
}
await _ctx.Database.ExecuteSqlCommandAsync("DELETE FROM SickRageCache");
var entites = ids.Select(id => new SickRageCache { TvDbId = id }).ToList();
await _ctx.SickRageCache.AddRangeAsync(entites);
@ -74,8 +78,12 @@ namespace Ombi.Schedule.Jobs.SickRage
}
await _ctx.SickRageEpisodeCache.AddRangeAsync(episodesToAdd);
await _ctx.SaveChangesAsync();
using (var tran = await _ctx.Database.BeginTransactionAsync())
{
await _ctx.SickRageEpisodeCache.AddRangeAsync(episodesToAdd);
await _ctx.SaveChangesAsync();
tran.Commit();
}
}
}
catch (Exception e)

@ -48,14 +48,22 @@ namespace Ombi.Schedule.Jobs.Sonarr
{
var sonarrSeries = series as ImmutableHashSet<SonarrSeries> ?? series.ToImmutableHashSet();
var ids = sonarrSeries.Select(x => x.tvdbId);
using (var tran = await _ctx.Database.BeginTransactionAsync())
{
await _ctx.Database.ExecuteSqlCommandAsync("DELETE FROM SonarrCache");
tran.Commit();
}
await _ctx.Database.ExecuteSqlCommandAsync("DELETE FROM SonarrCache");
var entites = ids.Select(id => new SonarrCache { TvDbId = id }).ToImmutableHashSet();
await _ctx.SonarrCache.AddRangeAsync(entites);
entites.Clear();
using (var tran = await _ctx.Database.BeginTransactionAsync())
{
await _ctx.Database.ExecuteSqlCommandAsync("DELETE FROM SonarrEpisodeCache");
tran.Commit();
}
await _ctx.Database.ExecuteSqlCommandAsync("DELETE FROM SonarrEpisodeCache");
foreach (var s in sonarrSeries)
{
if (!s.monitored)
@ -68,15 +76,20 @@ namespace Ombi.Schedule.Jobs.Sonarr
// Add to DB
_log.LogDebug("We have the episodes, adding to db transaction");
await _ctx.SonarrEpisodeCache.AddRangeAsync(monitoredEpisodes.Select(episode => new SonarrEpisodeCache
using (var tran = await _ctx.Database.BeginTransactionAsync())
{
EpisodeNumber = episode.episodeNumber,
SeasonNumber = episode.seasonNumber,
TvDbId = s.tvdbId,
HasFile = episode.hasFile
}));
_log.LogDebug("Commiting the transaction");
await _ctx.SaveChangesAsync();
await _ctx.SonarrEpisodeCache.AddRangeAsync(monitoredEpisodes.Select(episode =>
new SonarrEpisodeCache
{
EpisodeNumber = episode.episodeNumber,
SeasonNumber = episode.seasonNumber,
TvDbId = s.tvdbId,
HasFile = episode.hasFile
}));
_log.LogDebug("Commiting the transaction");
await _ctx.SaveChangesAsync();
tran.Commit();
}
}
}

@ -63,7 +63,12 @@ namespace Ombi.Store.Context
{
// VACUUM;
Database.ExecuteSqlCommand("VACUUM;");
SaveChanges();
using (var tran = Database.BeginTransaction())
{
SaveChanges();
tran.Commit();
}
}
}
}

@ -89,18 +89,23 @@ namespace Ombi.Store.Context
public void Seed()
{
// Make sure we have the API User
var apiUserExists = Users.Any(x => x.UserName.Equals("Api", StringComparison.CurrentCultureIgnoreCase));
if (!apiUserExists)
using (var tran = Database.BeginTransaction())
{
Users.Add(new OmbiUser
// Make sure we have the API User
var apiUserExists = Users.Any(x => x.UserName.Equals("Api", StringComparison.CurrentCultureIgnoreCase));
if (!apiUserExists)
{
UserName = "Api",
UserType = UserType.SystemUser,
NormalizedUserName = "API",
Users.Add(new OmbiUser
{
UserName = "Api",
UserType = UserType.SystemUser,
NormalizedUserName = "API",
});
SaveChanges();
});
SaveChanges();
tran.Commit();
}
}
//Check if templates exist
@ -238,7 +243,12 @@ namespace Ombi.Store.Context
if (needToSave)
{
SaveChanges();
using (var tran = Database.BeginTransaction())
{
SaveChanges();
tran.Commit();
}
}
}
}

@ -33,36 +33,44 @@ namespace Ombi.Store.Context
public void Seed()
{
// Add the tokens
var fanArt = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.FanartTv);
if (fanArt == null)
using (var tran = Database.BeginTransaction())
{
ApplicationConfigurations.Add(new ApplicationConfiguration
// Add the tokens
var fanArt = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.FanartTv);
if (fanArt == null)
{
Type = ConfigurationTypes.FanartTv,
Value = "4b6d983efa54d8f45c68432521335f15"
});
SaveChanges();
}
var movieDb = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.FanartTv);
if (movieDb == null)
{
ApplicationConfigurations.Add(new ApplicationConfiguration
ApplicationConfigurations.Add(new ApplicationConfiguration
{
Type = ConfigurationTypes.FanartTv,
Value = "4b6d983efa54d8f45c68432521335f15"
});
SaveChanges();
}
var movieDb = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.FanartTv);
if (movieDb == null)
{
Type = ConfigurationTypes.TheMovieDb,
Value = "b8eabaf5608b88d0298aa189dd90bf00"
});
SaveChanges();
}
var notification = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.Notification);
if (notification == null)
{
ApplicationConfigurations.Add(new ApplicationConfiguration
ApplicationConfigurations.Add(new ApplicationConfiguration
{
Type = ConfigurationTypes.TheMovieDb,
Value = "b8eabaf5608b88d0298aa189dd90bf00"
});
SaveChanges();
}
var notification =
ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.Notification);
if (notification == null)
{
Type = ConfigurationTypes.Notification,
Value = "4f0260c4-9c3d-41ab-8d68-27cb5a593f0e"
});
SaveChanges();
ApplicationConfigurations.Add(new ApplicationConfiguration
{
Type = ConfigurationTypes.Notification,
Value = "4f0260c4-9c3d-41ab-8d68-27cb5a593f0e"
});
SaveChanges();
}
tran.Commit();
}
}
}

@ -24,16 +24,20 @@ namespace Ombi.Store.Repository
public async Task Record(AuditType type, AuditArea area, string description, string user)
{
await Ctx.Audit.AddAsync(new Audit
using (var tran = await Ctx.Database.BeginTransactionAsync())
{
User = user,
AuditArea = area,
AuditType = type,
DateTime = DateTime.UtcNow,
Description = description
});
await Ctx.Audit.AddAsync(new Audit
{
User = user,
AuditArea = area,
AuditType = type,
DateTime = DateTime.UtcNow,
Description = description
});
await Ctx.SaveChangesAsync();
await Ctx.SaveChangesAsync();
tran.Commit();
}
}
}
}

@ -94,7 +94,15 @@ namespace Ombi.Store.Repository
TimeSpan.FromSeconds(3)
});
var result = await policy.ExecuteAndCaptureAsync(async () => await _ctx.SaveChangesAsync());
var result = await policy.ExecuteAndCaptureAsync(async () =>
{
using (var tran = await _ctx.Database.BeginTransactionAsync())
{
var r = await _ctx.SaveChangesAsync();
tran.Commit();
return r;
}
});
return result.Result;
}

@ -8,9 +8,9 @@ using Ombi.Store.Entities.Requests;
namespace Ombi.Store.Repository.Requests
{
public class TvRequestRepository : ITvRequestRepository
public class TvRequestRepository : BaseRepository<TvRequests, IOmbiContext>, ITvRequestRepository
{
public TvRequestRepository(IOmbiContext ctx)
public TvRequestRepository(IOmbiContext ctx) : base(ctx)
{
Db = ctx;
}
@ -151,10 +151,5 @@ namespace Ombi.Store.Repository.Requests
await InternalSaveChanges();
}
private async Task<int> InternalSaveChanges()
{
return await Db.SaveChangesAsync();
}
}
}

@ -24,17 +24,28 @@ namespace Ombi.Store.Repository
public GlobalSettings Insert(GlobalSettings entity)
{
//_cache.Remove(GetName(entity.SettingsName));
var settings = Db.Settings.Add(entity);
Db.SaveChanges();
return settings.Entity;
using (var tran = Db.Database.BeginTransaction())
{
var settings = Db.Settings.Add(entity);
Db.SaveChanges();
tran.Commit();
return settings.Entity;
}
}
public async Task<GlobalSettings> InsertAsync(GlobalSettings entity)
{
//_cache.Remove(GetName(entity.SettingsName));
var settings = await Db.Settings.AddAsync(entity).ConfigureAwait(false);
await Db.SaveChangesAsync().ConfigureAwait(false);
return settings.Entity;
using (var tran = Db.Database.BeginTransaction())
{
//_cache.Remove(GetName(entity.SettingsName));
var settings = await Db.Settings.AddAsync(entity);
await Db.SaveChangesAsync();
tran.Commit();
return settings.Entity;
}
}
@ -43,8 +54,8 @@ namespace Ombi.Store.Repository
//return _cache.GetOrCreate(GetName(pageName), entry =>
//{
// entry.AbsoluteExpiration = DateTimeOffset.Now.AddHours(1);
var entity = Db.Settings.AsNoTracking().FirstOrDefault(x => x.SettingsName == pageName);
return entity;
var entity = Db.Settings.AsNoTracking().FirstOrDefault(x => x.SettingsName == pageName);
return entity;
//});
}
@ -52,9 +63,9 @@ namespace Ombi.Store.Repository
{
//return await _cache.GetOrCreateAsync(GetName(settingsName), async entry =>
//{
//entry.AbsoluteExpiration = DateTimeOffset.Now.AddHours(1);
var obj = await Db.Settings.AsNoTracking().FirstOrDefaultAsync(x => x.SettingsName == settingsName);
return obj;
//entry.AbsoluteExpiration = DateTimeOffset.Now.AddHours(1);
var obj = await Db.Settings.AsNoTracking().FirstOrDefaultAsync(x => x.SettingsName == settingsName);
return obj;
//});
}
@ -75,15 +86,24 @@ namespace Ombi.Store.Repository
public void Delete(GlobalSettings entity)
{
//_cache.Remove(GetName(entity.SettingsName));
Db.Settings.Remove(entity);
Db.SaveChanges();
using (var tran = Db.Database.BeginTransaction())
{
Db.Settings.Remove(entity);
Db.SaveChanges();
tran.Commit();
}
}
public void Update(GlobalSettings entity)
{
Db.Update(entity);
//_cache.Remove(GetName(entity.SettingsName));
Db.SaveChanges();
using (var tran = Db.Database.BeginTransaction())
{
Db.Update(entity);
//_cache.Remove(GetName(entity.SettingsName));
Db.SaveChanges();
tran.Commit();
}
}
private string GetName(string entity)
@ -93,7 +113,13 @@ namespace Ombi.Store.Repository
private async Task<int> InternalSaveChanges()
{
return await Db.SaveChangesAsync();
using (var tran = Db.Database.BeginTransaction())
{
var r = await Db.SaveChangesAsync();
tran.Commit();
return r;
}
}
private bool _disposed;

@ -8,9 +8,9 @@ using Ombi.Helpers;
namespace Ombi.Store.Repository
{
public class TokenRepository : ITokenRepository
public class TokenRepository : BaseRepository<Tokens, IOmbiContext>, ITokenRepository
{
public TokenRepository(IOmbiContext db)
public TokenRepository(IOmbiContext db) : base(db)
{
Db = db;
}
@ -27,9 +27,5 @@ namespace Ombi.Store.Repository
{
return Db.Tokens.Where(x => x.Token == tokenId);
}
private async Task<int> InternalSaveChanges()
{
return await Db.SaveChangesAsync();
}
}
}

@ -62,15 +62,25 @@ namespace Ombi
Type = ConfigurationTypes.Url,
Value = "http://*:5000"
};
using (var tran = ctx.Database.BeginTransaction())
{
ctx.ApplicationConfigurations.Add(url);
ctx.SaveChanges();
tran.Commit();
}
ctx.ApplicationConfigurations.Add(url);
ctx.SaveChanges();
urlValue = url.Value;
}
if (!url.Value.Equals(host))
{
url.Value = UrlArgs;
ctx.SaveChanges();
using (var tran = ctx.Database.BeginTransaction())
{
ctx.SaveChanges();
tran.Commit();
}
urlValue = url.Value;
}
@ -83,16 +93,26 @@ namespace Ombi
Type = ConfigurationTypes.BaseUrl,
Value = baseUrl
};
ctx.ApplicationConfigurations.Add(dbBaseUrl);
ctx.SaveChanges();
using (var tran = ctx.Database.BeginTransaction())
{
ctx.ApplicationConfigurations.Add(dbBaseUrl);
ctx.SaveChanges();
tran.Commit();
}
}
}
else if (baseUrl.HasValue() && !baseUrl.Equals(dbBaseUrl.Value))
{
dbBaseUrl.Value = baseUrl;
ctx.SaveChanges();
using (var tran = ctx.Database.BeginTransaction())
{
ctx.SaveChanges();
tran.Commit();
}
}
Console.WriteLine($"We are running on {urlValue}");
CreateWebHostBuilder(args).Build().Run();
@ -130,25 +150,30 @@ namespace Ombi
try
{
if (ombi.Settings.Any() && !settings.Settings.Any())
using (var tran = settings.Database.BeginTransaction())
{
// OK migrate it!
var allSettings = ombi.Settings.ToList();
settings.Settings.AddRange(allSettings);
doneGlobal = true;
}
if (ombi.Settings.Any() && !settings.Settings.Any())
{
// OK migrate it!
var allSettings = ombi.Settings.ToList();
settings.Settings.AddRange(allSettings);
doneGlobal = true;
}
// Check for any application settings
// Check for any application settings
if (ombi.ApplicationConfigurations.Any() && !settings.ApplicationConfigurations.Any())
{
// OK migrate it!
var allSettings = ombi.ApplicationConfigurations.ToList();
settings.ApplicationConfigurations.AddRange(allSettings);
doneConfig = true;
}
if (ombi.ApplicationConfigurations.Any() && !settings.ApplicationConfigurations.Any())
{
// OK migrate it!
var allSettings = ombi.ApplicationConfigurations.ToList();
settings.ApplicationConfigurations.AddRange(allSettings);
doneConfig = true;
}
settings.SaveChanges();
settings.SaveChanges();
tran.Commit();
}
}
catch (Exception e)
{
@ -156,81 +181,100 @@ namespace Ombi
throw;
}
// Now delete the old stuff
if (doneGlobal)
ombi.Database.ExecuteSqlCommand("DELETE FROM GlobalSettings");
if (doneConfig)
ombi.Database.ExecuteSqlCommand("DELETE FROM ApplicationConfiguration");
using (var tran = ombi.Database.BeginTransaction())
{
// Now delete the old stuff
if (doneGlobal)
ombi.Database.ExecuteSqlCommand("DELETE FROM GlobalSettings");
if (doneConfig)
ombi.Database.ExecuteSqlCommand("DELETE FROM ApplicationConfiguration");
tran.Commit();
}
// Now migrate all the external stuff
var external = new ExternalContext();
try
{
if (ombi.PlexEpisode.Any())
{
external.PlexEpisode.AddRange(ombi.PlexEpisode.ToList());
ombi.Database.ExecuteSqlCommand("DELETE FROM PlexEpisode");
}
if (ombi.PlexSeasonsContent.Any())
{
external.PlexSeasonsContent.AddRange(ombi.PlexSeasonsContent.ToList());
ombi.Database.ExecuteSqlCommand("DELETE FROM PlexSeasonsContent");
}
if (ombi.PlexServerContent.Any())
using (var tran = external.Database.BeginTransaction())
{
external.PlexServerContent.AddRange(ombi.PlexServerContent.ToList());
ombi.Database.ExecuteSqlCommand("DELETE FROM PlexServerContent");
}
if (ombi.EmbyEpisode.Any())
{
external.EmbyEpisode.AddRange(ombi.EmbyEpisode.ToList());
ombi.Database.ExecuteSqlCommand("DELETE FROM EmbyEpisode");
}
if (ombi.PlexEpisode.Any())
{
external.PlexEpisode.AddRange(ombi.PlexEpisode.ToList());
ombi.Database.ExecuteSqlCommand("DELETE FROM PlexEpisode");
}
if (ombi.EmbyContent.Any())
{
external.EmbyContent.AddRange(ombi.EmbyContent.ToList());
ombi.Database.ExecuteSqlCommand("DELETE FROM EmbyContent");
}
if (ombi.RadarrCache.Any())
{
external.RadarrCache.AddRange(ombi.RadarrCache.ToList());
ombi.Database.ExecuteSqlCommand("DELETE FROM RadarrCache");
}
if (ombi.SonarrCache.Any())
{
external.SonarrCache.AddRange(ombi.SonarrCache.ToList());
ombi.Database.ExecuteSqlCommand("DELETE FROM SonarrCache");
}
if (ombi.LidarrAlbumCache.Any())
{
external.LidarrAlbumCache.AddRange(ombi.LidarrAlbumCache.ToList());
ombi.Database.ExecuteSqlCommand("DELETE FROM LidarrAlbumCache");
}
if (ombi.LidarrArtistCache.Any())
{
external.LidarrArtistCache.AddRange(ombi.LidarrArtistCache.ToList());
ombi.Database.ExecuteSqlCommand("DELETE FROM LidarrArtistCache");
}
if (ombi.SickRageEpisodeCache.Any())
{
external.SickRageEpisodeCache.AddRange(ombi.SickRageEpisodeCache.ToList());
ombi.Database.ExecuteSqlCommand("DELETE FROM SickRageEpisodeCache");
}
if (ombi.SickRageCache.Any())
{
external.SickRageCache.AddRange(ombi.SickRageCache.ToList());
ombi.Database.ExecuteSqlCommand("DELETE FROM SickRageCache");
}
if (ombi.CouchPotatoCache.Any())
{
external.CouchPotatoCache.AddRange(ombi.CouchPotatoCache.ToList());
ombi.Database.ExecuteSqlCommand("DELETE FROM CouchPotatoCache");
}
if (ombi.PlexSeasonsContent.Any())
{
external.PlexSeasonsContent.AddRange(ombi.PlexSeasonsContent.ToList());
ombi.Database.ExecuteSqlCommand("DELETE FROM PlexSeasonsContent");
}
if (ombi.PlexServerContent.Any())
{
external.PlexServerContent.AddRange(ombi.PlexServerContent.ToList());
ombi.Database.ExecuteSqlCommand("DELETE FROM PlexServerContent");
}
external.SaveChanges();
if (ombi.EmbyEpisode.Any())
{
external.EmbyEpisode.AddRange(ombi.EmbyEpisode.ToList());
ombi.Database.ExecuteSqlCommand("DELETE FROM EmbyEpisode");
}
if (ombi.EmbyContent.Any())
{
external.EmbyContent.AddRange(ombi.EmbyContent.ToList());
ombi.Database.ExecuteSqlCommand("DELETE FROM EmbyContent");
}
if (ombi.RadarrCache.Any())
{
external.RadarrCache.AddRange(ombi.RadarrCache.ToList());
ombi.Database.ExecuteSqlCommand("DELETE FROM RadarrCache");
}
if (ombi.SonarrCache.Any())
{
external.SonarrCache.AddRange(ombi.SonarrCache.ToList());
ombi.Database.ExecuteSqlCommand("DELETE FROM SonarrCache");
}
if (ombi.LidarrAlbumCache.Any())
{
external.LidarrAlbumCache.AddRange(ombi.LidarrAlbumCache.ToList());
ombi.Database.ExecuteSqlCommand("DELETE FROM LidarrAlbumCache");
}
if (ombi.LidarrArtistCache.Any())
{
external.LidarrArtistCache.AddRange(ombi.LidarrArtistCache.ToList());
ombi.Database.ExecuteSqlCommand("DELETE FROM LidarrArtistCache");
}
if (ombi.SickRageEpisodeCache.Any())
{
external.SickRageEpisodeCache.AddRange(ombi.SickRageEpisodeCache.ToList());
ombi.Database.ExecuteSqlCommand("DELETE FROM SickRageEpisodeCache");
}
if (ombi.SickRageCache.Any())
{
external.SickRageCache.AddRange(ombi.SickRageCache.ToList());
ombi.Database.ExecuteSqlCommand("DELETE FROM SickRageCache");
}
if (ombi.CouchPotatoCache.Any())
{
external.CouchPotatoCache.AddRange(ombi.CouchPotatoCache.ToList());
ombi.Database.ExecuteSqlCommand("DELETE FROM CouchPotatoCache");
}
external.SaveChanges();
tran.Commit();
}
}
catch (Exception e)
{

Loading…
Cancel
Save