pull/848/head
Jamie.Rees 8 years ago
parent 2d7ded325f
commit 698356d55e

@ -40,6 +40,17 @@ namespace Ombi.Core.SettingModels
[JsonIgnore]
public IEnumerable<string> CustomUsersEmailAddresses => CustomUsers.SplitEmailsByDelimiter(';');
public IEnumerable<string> CustomUsersEmailAddresses
{
get
{
var retVal = (IEnumerable<string>)new List<string>();
if (!string.IsNullOrEmpty(CustomUsers))
{
retVal = CustomUsers.SplitEmailsByDelimiter(';');
}
return retVal;
}
}
}
}

@ -25,6 +25,7 @@
// ************************************************************************/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -77,15 +78,17 @@ namespace Ombi.Helpers
var delimiterIndex = 0;
while (delimiterIndex >= 0)
{
if (input != null)
{
delimiterIndex = input.IndexOf(delimiter, startIndex);
string substring = input;
var substring = input;
if (delimiterIndex > 0)
{
substring = input.Substring(0, delimiterIndex).Trim();
}
if (!substring.Contains("\"") || substring.IndexOf("\"") != substring.LastIndexOf("\""))
if (!substring.Contains("\"") || substring.IndexOf("\"", StringComparison.Ordinal) != substring.LastIndexOf("\"", StringComparison.Ordinal))
{
yield return substring;
input = input.Substring(delimiterIndex + 1).Trim();
@ -99,3 +102,4 @@ namespace Ombi.Helpers
}
}
}
}

@ -234,16 +234,34 @@ namespace Ombi.Services.Jobs
var movies = GetPlexMovies(results);
// Time to destroy the plex movies from the DB
PlexContent.Custom(connection =>
//// Time to destroy the plex movies from the DB
//PlexContent.Custom(connection =>
//{
// connection.Open();
// connection.Query("delete from PlexContent where type = @type", new { type = 0 });
// return new List<PlexContent>();
//});
foreach (var m in movies)
{
if (string.IsNullOrEmpty(m.ProviderId))
{
Log.Error("Provider Id on movie {0} is null",m.Title);
continue;
}
// Check if it exists
var item = PlexContent.Custom(connection =>
{
connection.Open();
connection.Query("delete from PlexContent where type = @type", new { type = 0 });
return new List<PlexContent>();
var media = connection.QueryFirstOrDefault<PlexContent>("select * from PlexContent where ProviderId = @ProviderId and type = @type", new { m.ProviderId, type = 0 });
connection.Dispose();
return media;
});
foreach (var m in movies)
if (item == null)
{
// Doesn't exist, insert it
PlexContent.Insert(new PlexContent
{
ProviderId = m.ProviderId,
@ -253,15 +271,35 @@ namespace Ombi.Services.Jobs
Url = m.Url
});
}
}
var tv = GetPlexTvShows(results);
// Time to destroy the plex tv from the DB
PlexContent.Custom(connection =>
//// Time to destroy the plex tv from the DB
//PlexContent.Custom(connection =>
//{
// connection.Open();
// connection.Query("delete from PlexContent where type = @type", new { type = 1 });
// return new List<PlexContent>();
//});
foreach (var t in tv)
{
if (string.IsNullOrEmpty(t.ProviderId))
{
Log.Error("Provider Id on tv {0} is null", t.Title);
continue;
}
// Check if it exists
var item = PlexContent.Custom(connection =>
{
connection.Open();
connection.Query("delete from PlexContent where type = @type", new { type = 1 });
return new List<PlexContent>();
var media = connection.QueryFirstOrDefault<PlexContent>("select * from PlexContent where ProviderId = @ProviderId and type = @type", new { t.ProviderId, type = 1 });
connection.Dispose();
return media;
});
foreach (var t in tv)
if (item == null)
{
PlexContent.Insert(new PlexContent
{
@ -273,17 +311,38 @@ namespace Ombi.Services.Jobs
Seasons = ByteConverterHelper.ReturnBytes(t.Seasons)
});
}
}
var albums = GetPlexAlbums(results);
// Time to destroy the plex movies from the DB
PlexContent.Custom(connection =>
//// Time to destroy the plex movies from the DB
//PlexContent.Custom(connection =>
//{
// connection.Open();
// connection.Query("delete from PlexContent where type = @type", new { type = 2 });
// return new List<PlexContent>();
//});
foreach (var a in albums)
{
if (string.IsNullOrEmpty(a.ProviderId))
{
Log.Error("Provider Id on album {0} is null", a.Title);
continue;
}
// Check if it exists
var item = PlexContent.Custom(connection =>
{
connection.Open();
connection.Query("delete from PlexContent where type = @type", new { type = 2 });
return new List<PlexContent>();
var media = connection.QueryFirstOrDefault<PlexContent>("select * from PlexContent where ProviderId = @ProviderId and type = @type", new { a.ProviderId, type = 2 });
connection.Dispose();
return media;
});
foreach (var a in albums)
if (item == null)
{
PlexContent.Insert(new PlexContent
{
ProviderId = a.ProviderId,
@ -295,6 +354,7 @@ namespace Ombi.Services.Jobs
}
}
}
}
catch (Exception ex)
{
Log.Error(ex, "Failed to obtain Plex libraries");

@ -471,11 +471,14 @@ namespace Ombi.Services.Jobs
&& newletterSettings.CustomUsersEmailAddresses.Any())
{
foreach (var user in newletterSettings.CustomUsersEmailAddresses)
{
if (!string.IsNullOrEmpty(user))
{
message.Bcc.Add(new MailboxAddress(user, user));
}
}
}
}
message.Bcc.Add(new MailboxAddress(settings.EmailUsername, settings.RecipientEmail)); // Include the admin

@ -81,8 +81,12 @@ namespace Ombi.Services.Notification
continue;
}
// Make sure we do not already have the user
if (!selectedUsers.Contains(requestUser))
{
selectedUsers.Add(requestUser);
}
}
//var selectedUsers = users.Select(x => x.Username).Intersect(model.RequestedUsers, StringComparer.CurrentCultureIgnoreCase);
foreach (var user in selectedUsers)

@ -65,6 +65,14 @@ namespace Ombi.Store.Repository
}
}
public T Custom(Func<IDbConnection, T> func)
{
using (var cnn = Connection)
{
return func(cnn);
}
}
public async Task<IEnumerable<T>> CustomAsync(Func<IDbConnection, Task<IEnumerable<T>>> func)
{
using (var cnn = Connection)
@ -72,6 +80,13 @@ namespace Ombi.Store.Repository
return await func(cnn);
}
}
public async Task<T> CustomAsync(Func<IDbConnection, Task<T>> func)
{
using (var cnn = Connection)
{
return await func(cnn);
}
}
public long Insert(T entity)
{

@ -87,5 +87,8 @@ namespace Ombi.Store.Repository
Task<IEnumerable<T>> CustomAsync(Func<IDbConnection, Task<IEnumerable<T>>> func);
void DeleteAll(string tableName);
Task DeleteAllAsync(string tableName);
T Custom(Func<IDbConnection, T> func);
Task<T> CustomAsync(Func<IDbConnection, Task<T>> func);
}
}

Loading…
Cancel
Save