1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-09-11 20:12:41 +02:00

ReSharper code cleanup

This commit is contained in:
kay.one 2011-04-09 19:44:01 -07:00
parent 8cade435d1
commit e896af5cd0
138 changed files with 2368 additions and 2218 deletions

70
NzbDrone.5.1.ReSharper Normal file
View File

@ -0,0 +1,70 @@
<Configuration>
<CodeStyleSettings>
<ExternalPath IsNull="False">
</ExternalPath>
<Sharing>SOLUTION</Sharing>
<CSharp>
<FormatSettings>
<MODIFIERS_ORDER IsNull="False">
<Item>public</Item>
<Item>protected</Item>
<Item>internal</Item>
<Item>private</Item>
<Item>new</Item>
<Item>abstract</Item>
<Item>virtual</Item>
<Item>override</Item>
<Item>sealed</Item>
<Item>static</Item>
<Item>readonly</Item>
<Item>extern</Item>
<Item>unsafe</Item>
<Item>volatile</Item>
</MODIFIERS_ORDER>
</FormatSettings>
<UsingsSettings />
<Naming2>
<EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong>
<EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort>
</Naming2>
</CSharp>
<VB>
<FormatSettings />
<ImportsSettings />
<Naming2>
<EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong>
<EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort>
</Naming2>
</VB>
<Web>
<Naming2 />
</Web>
<Xaml>
<Naming2 />
</Xaml>
<XML>
<FormatSettings />
</XML>
<GenerateMemberBody />
<Naming2>
<EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong>
<EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort>
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PrivateStaticReadonly" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="TypesAndNamespaces" />
<PredefinedRule Inspect="True" Prefix="I" Suffix="" Style="AaBb" ElementKind="Interfaces" />
<PredefinedRule Inspect="True" Prefix="T" Suffix="" Style="AaBb" ElementKind="TypeParameters" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="MethodPropertyEvent" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Locals" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="LocalConstants" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Parameters" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PublicFields" />
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateInstanceFields" />
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateStaticFields" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Constants" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AA_BB" ElementKind="PrivateConstants" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="StaticReadonly" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="EnumMember" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Other" />
</Naming2>
</CodeStyleSettings>
</Configuration>

View File

@ -14,9 +14,9 @@ namespace AutoMoq
{
public class AutoMoqer
{
internal Type ResolveType;
private IUnityContainer container;
private IDictionary<Type, object> registeredMocks;
internal Type ResolveType = null;
public AutoMoqer()
{
@ -67,6 +67,45 @@ public virtual void SetConstant<T>(T instance) where T : class
SetMock(instance.GetType(), null);
}
public ISetup<T> Setup<T>(Expression<Action<T>> expression) where T : class
{
return GetMock<T>().Setup(expression);
}
public ISetup<T, TResult> Setup<T, TResult>(Expression<Func<T, TResult>> expression) where T : class
{
return GetMock<T>().Setup(expression);
}
public void Verify<T>(Expression<Action<T>> expression) where T : class
{
GetMock<T>().Verify(expression);
}
public void Verify<T>(Expression<Action<T>> expression, string failMessage) where T : class
{
GetMock<T>().Verify(expression, failMessage);
}
public void Verify<T>(Expression<Action<T>> expression, Times times) where T : class
{
GetMock<T>().Verify(expression, times);
}
public void Verify<T>(Expression<Action<T>> expression, Times times, string failMessage) where T : class
{
GetMock<T>().Verify(expression, times, failMessage);
}
public void VerifyAllMocks()
{
foreach (var registeredMock in registeredMocks)
{
var mock = registeredMock.Value as Mock;
mock.VerifyAll();
}
}
#region private methods
private void SetupAutoMoqer(IUnityContainer container)
@ -107,45 +146,5 @@ private static Type GetTheMockType<T>() where T : class
}
#endregion
public ISetup<T> Setup<T>(Expression<Action<T>> expression) where T : class
{
return GetMock<T>().Setup(expression);
}
public ISetup<T, TResult> Setup<T, TResult>(Expression<Func<T, TResult>> expression) where T : class
{
return GetMock<T>().Setup(expression);
}
public void Verify<T>(Expression<Action<T>> expression) where T : class
{
GetMock<T>().Verify(expression);
}
public void Verify<T>(Expression<Action<T>> expression, string failMessage) where T : class
{
GetMock<T>().Verify(expression, failMessage);
}
public void Verify<T>(Expression<Action<T>> expression, Times times) where T : class
{
GetMock<T>().Verify(expression, times);
}
public void Verify<T>(Expression<Action<T>> expression, Times times, string failMessage) where T : class
{
GetMock<T>().Verify(expression, times, failMessage);
}
public void VerifyAllMocks()
{
foreach (var registeredMock in registeredMocks)
{
var mock = registeredMock.Value as Mock;
mock.VerifyAll();
}
}
}
}

View File

@ -1,22 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using AutoMoq;
using FizzWare.NBuilder;
using Gallio.Framework;
using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using Moq;
using Ninject;
using Ninject.Moq;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using SubSonic.Repository;
using TvdbLib.Data;
using SubSonic.Extensions;
namespace NzbDrone.Core.Test
{
@ -117,7 +102,7 @@ public void Resolve_with_constant_concerete_dependency_uses_constant()
//Arrange
var mocker = new AutoMoqer();
var constant = new VirtualDependency() { PropValue = Guid.NewGuid().ToString() };
var constant = new VirtualDependency {PropValue = Guid.NewGuid().ToString()};
mocker.SetConstant(constant);
@ -127,7 +112,6 @@ public void Resolve_with_constant_concerete_dependency_uses_constant()
//Assert
Assert.AreEqual(constant.PropValue, result);
}
}
public class ConcreteClass
@ -138,24 +122,27 @@ public string Do()
}
}
public class Dependency : IDependency { }
public class Dependency : IDependency
{
}
public interface IDependency { }
public interface IDependency
{
}
public class ClassWithDependencies
{
public IDependency Dependency { get; set; }
public ClassWithDependencies(IDependency dependency)
{
Dependency = dependency;
}
public IDependency Dependency { get; set; }
}
public class ClassWithVirtualDependencies
{
private readonly VirtualDependency _virtualDependency;
public IDependency Dependency { get; set; }
public ClassWithVirtualDependencies(IDependency dependency, VirtualDependency virtualDependency)
{
@ -163,6 +150,8 @@ public ClassWithVirtualDependencies(IDependency dependency, VirtualDependency vi
Dependency = dependency;
}
public IDependency Dependency { get; set; }
public string CallVirtualChild()
{
return _virtualDependency.VirtualMethod();
@ -178,19 +167,20 @@ public class VirtualDependency
{
private readonly IDependency _dependency;
public string PropValue { get; set; }
public VirtualDependency() { }
public VirtualDependency()
{
}
public VirtualDependency(IDependency dependency)
{
_dependency = dependency;
}
public string PropValue { get; set; }
public virtual string VirtualMethod()
{
return "hello";
}
}
}

View File

@ -10,9 +10,9 @@ namespace AutoMoq.Unity
{
internal class AutoMockingBuilderStrategy : BuilderStrategy
{
private readonly IUnityContainer container;
private readonly MockFactory mockFactory;
private readonly IEnumerable<Type> registeredTypes;
private readonly IUnityContainer container;
public AutoMockingBuilderStrategy(IEnumerable<Type> registeredTypes, IUnityContainer container)
{
@ -45,7 +45,7 @@ private bool AMockObjectShouldBeCreatedForThisType(Type type)
private static Type GetTheTypeFromTheBuilderContext(IBuilderContext context)
{
return ((NamedTypeBuildKey)context.OriginalBuildKey).Type;
return (context.OriginalBuildKey).Type;
}
private bool TypeIsNotRegistered(Type type)

View File

@ -1,12 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text;
using AutoMoq;
using Gallio.Framework;
using AutoMoq;
using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using Moq;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using SubSonic.Repository;
@ -60,7 +54,8 @@ public void Add_new_value()
//Assert
mocker.GetMock<IRepository>().Verify();
mocker.GetMock<IRepository>().Verify(r => r.Update(It.IsAny<Config>()), Times.Never());
mocker.GetMock<IRepository>().Verify(r => r.Add(It.Is<Config>(c => c.Key == key && c.Value == value)), Times.Once());
mocker.GetMock<IRepository>().Verify(r => r.Add(It.Is<Config>(c => c.Key == key && c.Value == value)),
Times.Once());
}
}
}

View File

@ -1,22 +1,15 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using AutoMoq;
using FizzWare.NBuilder;
using Gallio.Framework;
using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using Moq;
using Ninject;
using Ninject.Moq;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using SubSonic.Repository;
using TvdbLib.Data;
using SubSonic.Extensions;
namespace NzbDrone.Core.Test
{
@ -50,7 +43,6 @@ public void RefreshEpisodeInfo()
//mocker.GetMock<IRepository>().SetReturnsDefault();
//Act
var sw = Stopwatch.StartNew();
mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(seriesId);
@ -90,7 +82,6 @@ public void IsNeededTrue()
//repo.All<EpisodeFile>().Where(c => c.EpisodeId == episode.EpisodeId);
//Act

View File

@ -3,7 +3,6 @@
using MbUnit.Framework;
using NLog;
using NLog.Config;
using System.Linq;
namespace NzbDrone.Core.Test
{
@ -13,27 +12,32 @@ public class Fixtures
[TearDown]
public void TearDown()
{
foreach (var file in Directory.GetFiles(Directory.GetCurrentDirectory(), "*.db", SearchOption.AllDirectories))
foreach (
var file in Directory.GetFiles(Directory.GetCurrentDirectory(), "*.db", SearchOption.AllDirectories))
{
try
{
File.Delete(file);
}
catch
{ }
{
}
}
}
[FixtureTearDown]
public void FixtureTearDown()
{
foreach (var file in Directory.GetFiles(Directory.GetCurrentDirectory(), "*.*", SearchOption.AllDirectories))
foreach (var file in Directory.GetFiles(Directory.GetCurrentDirectory(), "*.*", SearchOption.AllDirectories)
)
{
try
{
File.Delete(file);
}
catch { }
catch
{
}
}
}
@ -42,7 +46,8 @@ public void SetUp()
{
try
{
LogManager.Configuration = new XmlLoggingConfiguration(Path.Combine(CentralDispatch.AppPath, "log.config"), false);
LogManager.Configuration =
new XmlLoggingConfiguration(Path.Combine(CentralDispatch.AppPath, "log.config"), false);
LogManager.ThrowExceptions = true;
}
catch (Exception e)
@ -50,7 +55,5 @@ public void SetUp()
Console.WriteLine("Unable to configure logging. " + e);
}
}
}
}

View File

@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Gallio.Framework;
using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using Moq;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
@ -20,7 +17,14 @@ public class HistoryProviderTest
public void AllItems()
{
//Setup
var indexer = new Indexer { Enabled = true, IndexerId = 0, IndexerName = "NzbMatrix", Order = 1, RssUrl = "http://www.nzbmatrix.com" };
var indexer = new Indexer
{
Enabled = true,
IndexerId = 0,
IndexerName = "NzbMatrix",
Order = 1,
RssUrl = "http://www.nzbmatrix.com"
};
var series = new Series
{
SeriesId = 5656,
@ -74,7 +78,13 @@ public void Exists_True()
{
//Todo: This test fails... Moq Setup doesn't return the expected value
//Setup
var indexer = new Indexer { Enabled = true, IndexerName = "NzbMatrix", Order = 1, RssUrl = "http://www.nzbmatrix.com" };
var indexer = new Indexer
{
Enabled = true,
IndexerName = "NzbMatrix",
Order = 1,
RssUrl = "http://www.nzbmatrix.com"
};
var series = new Series
{
SeriesId = 5656,
@ -113,7 +123,8 @@ public void Exists_True()
var proper = false;
var repo = new Mock<IRepository>();
repo.Setup(r => r.Exists<History>(h => h.EpisodeId == episode.EpisodeId && h.IsProper == proper)).Returns(true);
repo.Setup(r => r.Exists<History>(h => h.EpisodeId == episode.EpisodeId && h.IsProper == proper)).Returns(
true);
var target = new HistoryProvider(repo.Object);
@ -131,7 +142,13 @@ public void Exists_False()
//Todo: This test fails... Moq Setup doesn't return the expected value
//Setup
var indexer = new Indexer { Enabled = true, IndexerName = "NzbMatrix", Order = 1, RssUrl = "http://www.nzbmatrix.com" };
var indexer = new Indexer
{
Enabled = true,
IndexerName = "NzbMatrix",
Order = 1,
RssUrl = "http://www.nzbmatrix.com"
};
var series = new Series
{
SeriesId = 5656,
@ -168,7 +185,8 @@ public void Exists_False()
});
var repo = new Mock<IRepository>();
repo.Setup(r => r.Exists<History>(h => h.Episode == episode && h.IsProper == list[0].IsProper)).Returns(false);
repo.Setup(r => r.Exists<History>(h => h.Episode == episode && h.IsProper == list[0].IsProper)).Returns(
false);
var target = new HistoryProvider(repo.Object);

View File

@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Gallio.Framework;
using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using Moq;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
@ -25,10 +21,14 @@ public void AllIndexers()
//Setup
var list = new List<Indexer>();
list.Add(new Indexer { IndexerName = "Test1", RssUrl = "http://www.test1.com/rss.php", Enabled = true, Order = 1 });
list.Add(new Indexer { IndexerName = "Test2", RssUrl = "http://www.test2.com/rss.php", Enabled = false, Order = 4 });
list.Add(new Indexer { IndexerName = "Test3", RssUrl = "http://www.test3.com/rss.php", Enabled = true, Order = 3 });
list.Add(new Indexer { IndexerName = "Test4", RssUrl = "http://www.test4.com/rss.php", Enabled = false, Order = 2 });
list.Add(new Indexer
{IndexerName = "Test1", RssUrl = "http://www.test1.com/rss.php", Enabled = true, Order = 1});
list.Add(new Indexer
{IndexerName = "Test2", RssUrl = "http://www.test2.com/rss.php", Enabled = false, Order = 4});
list.Add(new Indexer
{IndexerName = "Test3", RssUrl = "http://www.test3.com/rss.php", Enabled = true, Order = 3});
list.Add(new Indexer
{IndexerName = "Test4", RssUrl = "http://www.test4.com/rss.php", Enabled = false, Order = 2});
var repo = new Mock<IRepository>();
var config = new Mock<ConfigProvider>();
@ -53,10 +53,14 @@ public void EnabledIndexers()
//Setup
var list = new List<Indexer>();
list.Add(new Indexer { IndexerName = "Test1", RssUrl = "http://www.test1.com/rss.php", Enabled = true, Order = 1 });
list.Add(new Indexer { IndexerName = "Test2", RssUrl = "http://www.test2.com/rss.php", Enabled = false, Order = 4 });
list.Add(new Indexer { IndexerName = "Test3", RssUrl = "http://www.test3.com/rss.php", Enabled = true, Order = 3 });
list.Add(new Indexer { IndexerName = "Test4", RssUrl = "http://www.test4.com/rss.php", Enabled = false, Order = 2 });
list.Add(new Indexer
{IndexerName = "Test1", RssUrl = "http://www.test1.com/rss.php", Enabled = true, Order = 1});
list.Add(new Indexer
{IndexerName = "Test2", RssUrl = "http://www.test2.com/rss.php", Enabled = false, Order = 4});
list.Add(new Indexer
{IndexerName = "Test3", RssUrl = "http://www.test3.com/rss.php", Enabled = true, Order = 3});
list.Add(new Indexer
{IndexerName = "Test4", RssUrl = "http://www.test4.com/rss.php", Enabled = false, Order = 2});
var repo = new Mock<IRepository>();
var config = new Mock<ConfigProvider>();

View File

@ -1,16 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using AutoMoq;
using FizzWare.NBuilder;
using Gallio.Framework;
using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using Moq;
using Ninject;
using Ninject.Moq;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
@ -23,7 +16,6 @@ namespace NzbDrone.Core.Test
// ReSharper disable InconsistentNaming
public class MediaFileProviderTests
{
[Test]
[Description("Verifies that a new file imported properly")]
public void import_new_file()
@ -45,12 +37,13 @@ public void import_new_file()
var mocker = new AutoMoqer();
mocker.GetMock<IRepository>()
.Setup(r => r.Exists<EpisodeFile>(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(false).Verifiable();
.Setup(r => r.Exists(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(false).Verifiable();
mocker.GetMock<IRepository>()
.Setup(r => r.Add(It.IsAny<EpisodeFile>())).Returns(0).Verifiable();
mocker.GetMock<EpisodeProvider>()
.Setup(e => e.GetEpisode(fakeSeries.SeriesId, seasonNumber, episodeNumner)).Returns(fakeEpisode).Verifiable();
.Setup(e => e.GetEpisode(fakeSeries.SeriesId, seasonNumber, episodeNumner)).Returns(fakeEpisode).
Verifiable();
mocker.GetMock<DiskProvider>()
.Setup(e => e.GetSize(fileName)).Returns(12345).Verifiable();
@ -62,7 +55,7 @@ public void import_new_file()
//Assert
Assert.IsNotNull(result);
mocker.GetMock<IRepository>().VerifyAll();
mocker.GetMock<IRepository>().Verify(r => r.Add<EpisodeFile>(result), Times.Once());
mocker.GetMock<IRepository>().Verify(r => r.Add(result), Times.Once());
mocker.GetMock<EpisodeProvider>().VerifyAll();
mocker.GetMock<DiskProvider>().VerifyAll();
@ -96,7 +89,7 @@ public void import_existing_file()
var mocker = new AutoMoqer();
mocker.GetMock<IRepository>(MockBehavior.Strict)
.Setup(r => r.Exists<EpisodeFile>(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(true).Verifiable();
.Setup(r => r.Exists(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(true).Verifiable();
mocker.GetMock<EpisodeProvider>(MockBehavior.Strict);
mocker.GetMock<DiskProvider>(MockBehavior.Strict);
@ -109,7 +102,7 @@ public void import_existing_file()
mocker.GetMock<EpisodeProvider>().VerifyAll();
mocker.GetMock<DiskProvider>(MockBehavior.Strict).VerifyAll();
Assert.IsNull(result);
mocker.GetMock<IRepository>().Verify(r => r.Add<EpisodeFile>(result), Times.Never());
mocker.GetMock<IRepository>().Verify(r => r.Add(result), Times.Never());
}
[Test]
@ -130,10 +123,11 @@ public void import_file_with_no_episode()
//Mocks
var mocker = new AutoMoqer();
mocker.GetMock<IRepository>(MockBehavior.Strict)
.Setup(r => r.Exists<EpisodeFile>(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(false).Verifiable();
.Setup(r => r.Exists(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(false).Verifiable();
mocker.GetMock<EpisodeProvider>(MockBehavior.Strict)
.Setup(e => e.GetEpisode(fakeSeries.SeriesId, seasonNumber, episodeNumner)).Returns<Episode>(null).Verifiable();
.Setup(e => e.GetEpisode(fakeSeries.SeriesId, seasonNumber, episodeNumner)).Returns<Episode>(null).
Verifiable();
mocker.GetMock<DiskProvider>(MockBehavior.Strict);
@ -144,12 +138,7 @@ public void import_file_with_no_episode()
//Assert
mocker.VerifyAllMocks();
Assert.IsNull(result);
mocker.GetMock<IRepository>().Verify(r => r.Add<EpisodeFile>(result), Times.Never());
mocker.GetMock<IRepository>().Verify(r => r.Add(result), Times.Never());
}
}
}

View File

@ -1,45 +1,23 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using FizzWare.NBuilder;
using Moq;
using NLog;
using NzbDrone.Core.Instrumentation;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using SubSonic.DataProviders;
using SubSonic.Repository;
using TvdbLib;
namespace NzbDrone.Core.Test
{
/// <summary>
/// Provides the standard Mocks needed for a typical test
/// </summary>
static class MockLib
internal static class MockLib
{
public static string[] StandardSeries
{
get { return new string[] { "c:\\tv\\the simpsons", "c:\\tv\\family guy", "c:\\tv\\southpark", "c:\\tv\\24" }; }
}
public static IRepository GetEmptyRepository()
{
return GetEmptyRepository(true);
}
public static IRepository GetEmptyRepository(bool enableLogging)
{
Console.WriteLine("Creating an empty SQLite database");
var provider = ProviderFactory.GetProvider("Data Source=" + Guid.NewGuid() + ".db;Version=3;New=True", "System.Data.SQLite");
if (enableLogging)
{
provider.Log = new NlogWriter();
}
return new SimpleRepository(provider, SimpleRepositoryOptions.RunMigrations);
get { return new[] {"c:\\tv\\the simpsons", "c:\\tv\\family guy", "c:\\tv\\southpark", "c:\\tv\\24"}; }
}
public static ConfigProvider StandardConfig
@ -52,6 +30,23 @@ public static ConfigProvider StandardConfig
}
}
public static IRepository GetEmptyRepository()
{
return GetEmptyRepository(true);
}
public static IRepository GetEmptyRepository(bool enableLogging)
{
Console.WriteLine("Creating an empty SQLite database");
var provider = ProviderFactory.GetProvider("Data Source=" + Guid.NewGuid() + ".db;Version=3;New=True",
"System.Data.SQLite");
if (enableLogging)
{
provider.Log = new NlogWriter();
}
return new SimpleRepository(provider, SimpleRepositoryOptions.RunMigrations);
}
public static DiskProvider GetStandardDisk(int seasons, int episodes)
{
var mock = new Mock<DiskProvider>();

View File

@ -21,7 +21,10 @@ public static IBindingWhenInNamedWithOrOnSyntax<T> ToMock<T>(this IBindingToSynt
var haveBinding = builder as IHaveBinding;
if (haveBinding == null)
throw new NotSupportedException(String.Format("The binding builder for {0} is of type {1}, which does not implement IHaveBinding and is therefore not extensible.", typeof(T), builder.GetType()));
throw new NotSupportedException(
String.Format(
"The binding builder for {0} is of type {1}, which does not implement IHaveBinding and is therefore not extensible.",
typeof (T), builder.GetType()));
IBinding binding = haveBinding.Binding;

View File

@ -11,20 +11,8 @@ namespace Ninject.Moq
/// </summary>
public class MockProvider : IProvider
{
private static readonly Dictionary<Type, ConstructorInjector> _injectors = new Dictionary<Type, ConstructorInjector>();
/// <summary>
/// Gets the type (or prototype) of instances the provider creates.
/// </summary>
public Type Type
{
get { return typeof(Mock<>); }
}
/// <summary>
/// Gets the injector factory component.
/// </summary>
public IInjectorFactory InjectorFactory { get; private set; }
private static readonly Dictionary<Type, ConstructorInjector> _injectors =
new Dictionary<Type, ConstructorInjector>();
/// <summary>
/// Initializes a new instance of the <see cref = "MockProvider" /> class.
@ -35,6 +23,21 @@ public MockProvider(IInjectorFactory injectorFactory)
InjectorFactory = injectorFactory;
}
/// <summary>
/// Gets the injector factory component.
/// </summary>
public IInjectorFactory InjectorFactory { get; private set; }
#region IProvider Members
/// <summary>
/// Gets the type (or prototype) of instances the provider creates.
/// </summary>
public Type Type
{
get { return typeof (Mock<>); }
}
/// <summary>
/// Creates an instance within the specified context.
/// </summary>
@ -47,6 +50,8 @@ public object Create(IContext context)
return mock.Object;
}
#endregion
private ConstructorInjector GetInjector(Type service)
{
lock (_injectors)

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using Gallio.Framework;
using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using MbUnit.Framework;
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Core.Test
@ -82,7 +77,6 @@ public void episode_multipart_parse(string path, int season, int[] episodes)
}
[Test]
[Row(@"c:\test\", @"c:\test")]
[Row(@"c:\\test\\", @"c:\test")]

View File

@ -1,12 +1,10 @@
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Reflection;
using System.Runtime.InteropServices;
using MbUnit.Framework;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("NzbDrone.Core.Test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
@ -19,9 +17,11 @@
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("699aed1b-015e-4f0d-9c81-d5557b05d260")]
// Version information for an assembly consists of the following four values:
@ -34,5 +34,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,36 +1,30 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using FizzWare.NBuilder;
using MbUnit.Framework;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using System.Linq;
using TvdbLib.Data;
namespace NzbDrone.Core.Test
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class QualityProfileTest
{
///<summary>
/// Test_s the storage.
///</summary>
///
///
[Test]
public void Test_Storage()
{
//Arrange
var repo = MockLib.GetEmptyRepository();
var testProfile = new QualityProfile
{
Name = Guid.NewGuid().ToString(),
Cutoff = QualityTypes.TV,
Allowed = new List<QualityTypes>() { QualityTypes.HDTV, QualityTypes.DVD },
Allowed = new List<QualityTypes> {QualityTypes.HDTV, QualityTypes.DVD},
};
//Act
@ -54,7 +48,7 @@ public void Test_Series_Quality()
{
Name = Guid.NewGuid().ToString(),
Cutoff = QualityTypes.TV,
Allowed = new List<QualityTypes>() { QualityTypes.HDTV, QualityTypes.DVD },
Allowed = new List<QualityTypes> {QualityTypes.HDTV, QualityTypes.DVD},
};

View File

@ -3,10 +3,10 @@
using FizzWare.NBuilder;
using MbUnit.Framework;
using NLog;
using NLog.Config;
using NzbDrone.Core.Instrumentation;
using NzbDrone.Core.Repository;
using LogLevel = NzbDrone.Core.Instrumentation.LogLevel;
using NLog.Config;
using LogLevel = NLog.LogLevel;
namespace NzbDrone.Core.Test
{
@ -38,7 +38,9 @@ public void to_many__series_to_episode()
}
[Test]
[Description("This test confirms that the tvdb id stored in the db is preserved rather than being replaced by an auto incrementing value")]
[Description(
"This test confirms that the tvdb id stored in the db is preserved rather than being replaced by an auto incrementing value"
)]
public void tvdbid_is_preserved([RandomNumbers(Minimum = 100, Maximum = 999, Count = 1)] int tvdbId)
{
//Arrange
@ -72,7 +74,7 @@ public void write_log()
var sonicTarget = new SubsonicTarget(sonicRepo);
LogManager.Configuration.AddTarget("DbLogger", sonicTarget);
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", NLog.LogLevel.Info, sonicTarget));
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Info, sonicTarget));
LogManager.Configuration.Reload();
Logger Logger = LogManager.GetCurrentClassLogger();
@ -89,7 +91,7 @@ public void write_log()
Assert.AreEqual(message, logItem.Message);
Assert.AreEqual(Logger.Name, logItem.Logger);
Assert.AreEqual(Logger.Name, logItem.Logger);
Assert.AreEqual(LogLevel.Info, logItem.Level);
Assert.AreEqual(Instrumentation.LogLevel.Info, logItem.Level);
}
[Test]
@ -102,7 +104,7 @@ public void write_log_exception()
var sonicTarget = new SubsonicTarget(sonicRepo);
LogManager.Configuration.AddTarget("DbLogger", sonicTarget);
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", NLog.LogLevel.Info, sonicTarget));
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Info, sonicTarget));
LogManager.Configuration.Reload();
Logger Logger = LogManager.GetCurrentClassLogger();
@ -120,7 +122,7 @@ public void write_log_exception()
Assert.AreNotEqual(new DateTime(), logItem.Time);
Assert.AreEqual(message, logItem.Message);
Assert.AreEqual(Logger.Name, logItem.Logger);
Assert.AreEqual(LogLevel.Error, logItem.Level);
Assert.AreEqual(Instrumentation.LogLevel.Error, logItem.Level);
Assert.AreEqual(ex.GetType().ToString(), logItem.ExceptionType);
Assert.AreEqual(ex.ToString(), logItem.ExceptionString);
Assert.AreEqual(ex.Message, logItem.ExceptionMessage);
@ -136,7 +138,7 @@ public void write_log_exception_no_message_should_use_exception_message()
var sonicTarget = new SubsonicTarget(sonicRepo);
LogManager.Configuration.AddTarget("DbLogger", sonicTarget);
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", NLog.LogLevel.Info, sonicTarget));
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Info, sonicTarget));
LogManager.Configuration.Reload();
Logger Logger = LogManager.GetCurrentClassLogger();
@ -154,7 +156,7 @@ public void write_log_exception_no_message_should_use_exception_message()
Assert.AreNotEqual(new DateTime(), logItem.Time);
Assert.AreEqual(ex.Message, logItem.Message);
Assert.AreEqual(Logger.Name, logItem.Logger);
Assert.AreEqual(LogLevel.Error, logItem.Level);
Assert.AreEqual(Instrumentation.LogLevel.Error, logItem.Level);
Assert.AreEqual(ex.GetType().ToString(), logItem.ExceptionType);
Assert.AreEqual(ex.ToString(), logItem.ExceptionString);
Assert.AreEqual(ex.Message, logItem.ExceptionMessage);

View File

@ -1,12 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq;
using AutoMoq;
using Gallio.Framework;
using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using Moq;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
using SubSonic.Repository;

View File

@ -1,22 +1,13 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.ServiceModel.Syndication;
using System.Text;
using System.Xml;
using AutoMoq;
using Gallio.Framework;
using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using Moq;
using Ninject;
using Ninject.Moq;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.Feed;
using NzbDrone.Core.Repository;
using SubSonic.Repository;
namespace NzbDrone.Core.Test
{
@ -25,7 +16,6 @@ public class RssProviderTest
// ReSharper disable InconsistentNaming
{
[Test]
public void Download_feed_test()
{
var mocker = new AutoMoqer();
@ -38,12 +28,13 @@ public void Download_feed_test()
mocker.Resolve<MockFeedProvider>().Fetch();
}
}
public class MockFeedProvider : FeedProviderBase
{
public MockFeedProvider(SeriesProvider seriesProvider, SeasonProvider seasonProvider, EpisodeProvider episodeProvider, ConfigProvider configProvider, HttpProvider httpProvider)
public MockFeedProvider(SeriesProvider seriesProvider, SeasonProvider seasonProvider,
EpisodeProvider episodeProvider, ConfigProvider configProvider,
HttpProvider httpProvider)
: base(seriesProvider, seasonProvider, episodeProvider, configProvider, httpProvider)
{
}

View File

@ -1,15 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using AutoMoq;
using Gallio.Framework;
using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using Moq;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using SubSonic.Repository;
namespace NzbDrone.Core.Test
{
@ -49,11 +43,15 @@ public void AddByUrlSuccess()
.Returns(category);
mocker.GetMock<HttpProvider>()
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=addurl&name=http://www.nzbclub.com/nzb_download.aspx?mid=1950232&priority=0&cat=tv&nzbname=This+is+an+Nzb&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Setup(
s =>
s.DownloadString(
"http://192.168.5.55:2222/api?mode=addurl&name=http://www.nzbclub.com/nzb_download.aspx?mid=1950232&priority=0&cat=tv&nzbname=This+is+an+Nzb&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Returns("ok");
//Act
bool result = mocker.Resolve<SabProvider>().AddByUrl("http://www.nzbclub.com/nzb_download.aspx?mid=1950232", "This is an Nzb");
bool result = mocker.Resolve<SabProvider>().AddByUrl(
"http://www.nzbclub.com/nzb_download.aspx?mid=1950232", "This is an Nzb");
//Assert
Assert.AreEqual(true, result);
@ -83,11 +81,15 @@ public void AddByUrlError()
fakeConfig.Setup(c => c.GetValue("SabTvCategory", String.Empty, true)).Returns(category);
mocker.GetMock<HttpProvider>()
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=addurl&name=http://www.nzbclub.com/nzb_download.aspx?mid=1950232&priority=0&cat=tv&nzbname=This+is+an+Nzb&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Setup(
s =>
s.DownloadString(
"http://192.168.5.55:2222/api?mode=addurl&name=http://www.nzbclub.com/nzb_download.aspx?mid=1950232&priority=0&cat=tv&nzbname=This+is+an+Nzb&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Returns("error");
//Act
bool result = mocker.Resolve<SabProvider>().AddByUrl("http://www.nzbclub.com/nzb_download.aspx?mid=1950232", "This is an Nzb");
bool result = mocker.Resolve<SabProvider>().AddByUrl(
"http://www.nzbclub.com/nzb_download.aspx?mid=1950232", "This is an Nzb");
//Assert
Assert.AreEqual(false, result);
@ -113,7 +115,10 @@ public void IsInQueue_True()
fakeConfig.Setup(c => c.GetValue("SabPassword", String.Empty, false)).Returns(password);
mocker.GetMock<HttpProvider>()
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=queue&output=xml&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Setup(
s =>
s.DownloadString(
"http://192.168.5.55:2222/api?mode=queue&output=xml&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Returns(new StreamReader(@".\Files\Queue.xml").ReadToEnd());
//Act
@ -143,7 +148,10 @@ public void IsInQueue_False_Empty()
fakeConfig.Setup(c => c.GetValue("SabPassword", String.Empty, false)).Returns(password);
mocker.GetMock<HttpProvider>()
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=queue&output=xml&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Setup(
s =>
s.DownloadString(
"http://192.168.5.55:2222/api?mode=queue&output=xml&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Returns(new StreamReader(@".\Files\QueueEmpty.xml").ReadToEnd());
//Act
@ -173,7 +181,10 @@ public void IsInQueue_False_Error()
fakeConfig.Setup(c => c.GetValue("SabPassword", String.Empty, false)).Returns(password);
mocker.GetMock<HttpProvider>()
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=queue&output=xml&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Setup(
s =>
s.DownloadString(
"http://192.168.5.55:2222/api?mode=queue&output=xml&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Returns(new StreamReader(@".\Files\QueueError.xml").ReadToEnd());

View File

@ -1,24 +1,18 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Linq;
using AutoMoq;
using FizzWare.NBuilder;
using Gallio.Framework;
using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using Moq;
using Ninject;
using Ninject.Moq;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using SubSonic.Repository;
using TvdbLib.Data;
using System.Linq;
// ReSharper disable InconsistentNaming
namespace NzbDrone.Core.Test
{
[TestFixture]
@ -65,7 +59,6 @@ public void Map_path_to_series()
[Test]
public void Add_new_series()
{
var mocker = new AutoMoqer();
mocker.SetConstant(MockLib.GetEmptyRepository());
@ -85,11 +78,9 @@ public void Add_new_series()
Assert.AreEqual(path, series.First().Path);
Assert.AreEqual(tvDbId, series.First().SeriesId);
Assert.AreEqual(qualityProfileId, series.First().QualityProfileId);
}
[Test]
[Row(new object[] {"That's Life - 2x03 -The Devil and Miss DeLucca", "That's Life"})]
[Row(new object[] {"Van.Duin.Op.Zn.Best.S02E05.DUTCH.WS.PDTV.XViD-DiFFERENT", "Van Duin Op Zn Best"})]
@ -128,7 +119,6 @@ public void Test_is_monitored()
}
[Test]
[Row(12, QualityTypes.TV, true)]
[Row(12, QualityTypes.Unknown, false)]
@ -139,7 +129,7 @@ public void Test_is_monitored()
public void QualityWanted(int seriesId, QualityTypes qualityTypes, Boolean result)
{
var quality = Builder<QualityProfile>.CreateNew()
.With(q => q.Allowed = new List<QualityTypes>() { QualityTypes.BDRip, QualityTypes.DVD, QualityTypes.TV })
.With(q => q.Allowed = new List<QualityTypes> {QualityTypes.BDRip, QualityTypes.DVD, QualityTypes.TV})
.With(q => q.Cutoff = QualityTypes.DVD)
.Build();

View File

@ -1,15 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using AutoMoq;
using Gallio.Framework;
using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using Moq;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using SubSonic.Repository;
namespace NzbDrone.Core.Test
{

View File

@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;
using Gallio.Framework;
using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using NzbDrone.Core.Providers;
namespace NzbDrone.Core.Test
@ -85,8 +81,5 @@ public void no_result_title_lookup()
//assert
Assert.IsNull(result);
}
}
}

View File

@ -2,22 +2,16 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Web;
using System.Web.Hosting;
using Ninject;
using NLog.Config;
using NLog.Targets;
using NLog;
using NzbDrone.Core.Instrumentation;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.Fakes;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using SubSonic.DataProviders;
using SubSonic.Query;
using SubSonic.Repository;
using NLog;
using System.Linq;
namespace NzbDrone.Core
{
@ -28,6 +22,45 @@ public static class CentralDispatch
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private static string _startupPath;
public static String AppPath
{
get
{
if (!String.IsNullOrWhiteSpace(HostingEnvironment.ApplicationPhysicalPath))
{
return HostingEnvironment.ApplicationPhysicalPath;
}
return Directory.GetCurrentDirectory();
}
}
public static string ExecutablePath
{
get
{
//var uri = new Uri(Assembly.EscapedCodeBase);
//return Path.GetDirectoryName(uri.LocalPath);
return Directory.GetCurrentDirectory();
}
}
public static string StartupPath
{
get { return _startupPath; }
}
public static StandardKernel NinjectKernel
{
get
{
if (_kernel == null)
{
BindKernel();
}
return _kernel;
}
}
public static void BindKernel()
{
lock (KernelLock)
@ -42,10 +75,12 @@ public static void BindKernel()
var AppDataPath = new DirectoryInfo(Path.Combine(AppPath, "App_Data", "nzbdrone.db"));
if (!AppDataPath.Exists) AppDataPath.Create();
string connectionString = String.Format("Data Source={0};Version=3;", Path.Combine(AppDataPath.FullName, "nzbdrone.db"));
string connectionString = String.Format("Data Source={0};Version=3;",
Path.Combine(AppDataPath.FullName, "nzbdrone.db"));
var dbProvider = ProviderFactory.GetProvider(connectionString, "System.Data.SQLite");
string logConnectionString = String.Format("Data Source={0};Version=3;", Path.Combine(AppDataPath.FullName, "log.db"));
string logConnectionString = String.Format("Data Source={0};Version=3;",
Path.Combine(AppDataPath.FullName, "log.db"));
var logDbProvider = ProviderFactory.GetProvider(logConnectionString, "System.Data.SQLite");
@ -80,9 +115,11 @@ public static void BindKernel()
_kernel.Bind<LogProvider>().ToSelf().InSingletonScope();
_kernel.Bind<MediaFileProvider>().ToSelf().InSingletonScope();
_kernel.Bind<TimerProvider>().ToSelf().InSingletonScope();
_kernel.Bind<IRepository>().ToMethod(c => new SimpleRepository(dbProvider, SimpleRepositoryOptions.RunMigrations)).InSingletonScope();
_kernel.Bind<IRepository>().ToMethod(
c => new SimpleRepository(dbProvider, SimpleRepositoryOptions.RunMigrations)).InSingletonScope();
_kernel.Bind<IRepository>().ToConstant(logRepository).WhenInjectedInto<SubsonicTarget>().InSingletonScope();
_kernel.Bind<IRepository>().ToConstant(logRepository).WhenInjectedInto<SubsonicTarget>().
InSingletonScope();
_kernel.Bind<IRepository>().ToConstant(logRepository).WhenInjectedInto<LogProvider>().InSingletonScope();
ForceMigration(_kernel.Get<IRepository>());
@ -97,46 +134,6 @@ public static void BindKernel()
}
}
public static String AppPath
{
get
{
if (!String.IsNullOrWhiteSpace(HostingEnvironment.ApplicationPhysicalPath))
{
return HostingEnvironment.ApplicationPhysicalPath;
}
return Directory.GetCurrentDirectory();
}
}
public static string ExecutablePath
{
get
{
//var uri = new Uri(Assembly.EscapedCodeBase);
//return Path.GetDirectoryName(uri.LocalPath);
return Directory.GetCurrentDirectory();
}
}
public static string StartupPath
{
get { return _startupPath; }
}
public static StandardKernel NinjectKernel
{
get
{
if (_kernel == null)
{
BindKernel();
}
return _kernel;
}
}
private static void ForceMigration(IRepository repository)
{
repository.GetPaged<Series>(0, 1);
@ -155,7 +152,8 @@ public static void DedicateToHost()
try
{
Logger.Debug("Attaching to parent process for automatic termination.");
var pc = new PerformanceCounter("Process", "Creating Process ID", Process.GetCurrentProcess().ProcessName);
var pc = new PerformanceCounter("Process", "Creating Process ID",
Process.GetCurrentProcess().ProcessName);
var pid = (int) pc.NextValue();
var hostProcess = Process.GetProcessById(pid);
@ -184,8 +182,10 @@ private static void SetupIndexers(IRepository repository)
{
//Setup the default providers in the Providers table
string nzbMatrixRss = "http://rss.nzbmatrix.com/rss.php?page=download&username={USERNAME}&apikey={APIKEY}&subcat=6,41&english=1";
string nzbMatrixApi = "http://rss.nzbmatrix.com/rss.php?page=download&username={USERNAME}&apikey={APIKEY}&subcat=6,41&english=1&age={AGE}&term={TERM}";
string nzbMatrixRss =
"http://rss.nzbmatrix.com/rss.php?page=download&username={USERNAME}&apikey={APIKEY}&subcat=6,41&english=1";
string nzbMatrixApi =
"http://rss.nzbmatrix.com/rss.php?page=download&username={USERNAME}&apikey={APIKEY}&subcat=6,41&english=1&age={AGE}&term={TERM}";
string nzbsOrgRss = "http://nzbs.org/rss.php?type=1&dl=1&num=100&i={UID}&h={HASH}";
string nzbsOrgApi = String.Empty;
string nzbsrusRss = "http://www.nzbsrus.com/rssfeed.php?cat=91,75&i={UID}&h={HASH}";
@ -282,7 +282,9 @@ private static void SetupDefaultQualityProfiles(IRepository repository)
var hd = new QualityProfile
{
Name = "HD",
Allowed = new List<QualityTypes> { QualityTypes.HDTV, QualityTypes.WEBDL, QualityTypes.BDRip, QualityTypes.Bluray720 },
Allowed =
new List<QualityTypes>
{QualityTypes.HDTV, QualityTypes.WEBDL, QualityTypes.BDRip, QualityTypes.Bluray720},
Cutoff = QualityTypes.HDTV
};

View File

@ -8,23 +8,68 @@ public static class EpisodeSortingHelper
{
private static readonly List<EpisodeSortingType> SeparatorStyles = new List<EpisodeSortingType>
{
new EpisodeSortingType {Id = 0, Name = "Dash", Pattern = " - "},
new EpisodeSortingType {Id = 1, Name = "Space", Pattern = " "}
new EpisodeSortingType
{
Id = 0,
Name = "Dash",
Pattern = " - "
},
new EpisodeSortingType
{
Id = 1,
Name = "Space",
Pattern = " "
}
};
private static readonly List<EpisodeSortingType> NumberStyles = new List<EpisodeSortingType>
{
new EpisodeSortingType { Id = 0, Name = "1x05", Pattern = "%sx%0e"},
new EpisodeSortingType { Id = 1, Name = "01x05", Pattern = "%0sx%0e"},
new EpisodeSortingType { Id = 2, Name = "S01E05", Pattern = "S%0sE%0e"},
new EpisodeSortingType { Id = 3, Name = "s01e05", Pattern = "s%0se%0e"}
new EpisodeSortingType
{
Id = 0,
Name = "1x05",
Pattern = "%sx%0e"
},
new EpisodeSortingType
{
Id = 1,
Name = "01x05",
Pattern = "%0sx%0e"
},
new EpisodeSortingType
{
Id = 2,
Name = "S01E05",
Pattern = "S%0sE%0e"
},
new EpisodeSortingType
{
Id = 3,
Name = "s01e05",
Pattern = "s%0se%0e"
}
};
private static readonly List<EpisodeSortingType> MultiEpisodeStyles = new List<EpisodeSortingType>
{
new EpisodeSortingType { Id = 0, Name = "Extend", Pattern = "" },
new EpisodeSortingType { Id = 1, Name = "Duplicate", Pattern = "" },
new EpisodeSortingType { Id = 2, Name = "Repeat", Pattern = "" }
new EpisodeSortingType
{
Id = 0,
Name = "Extend",
Pattern = ""
},
new EpisodeSortingType
{
Id = 1,
Name = "Duplicate",
Pattern = ""
},
new EpisodeSortingType
{
Id = 2,
Name = "Repeat",
Pattern = ""
}
};
public static List<EpisodeSortingType> GetSeparatorStyles()

View File

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NzbDrone.Core.Model;
namespace NzbDrone.Core.Helpers
@ -10,68 +9,300 @@ public static class SceneNameHelper
{
private static readonly List<SceneNameModel> SceneNameMappings = new List<SceneNameModel>
{
new SceneNameModel { SeriesId = 72546, Name = "CSI" },
new SceneNameModel { SeriesId = 73696, Name = "CSI New York" },
new SceneNameModel { SeriesId = 73696, Name = "CSI NY" },
new SceneNameModel { SeriesId = 110381, Name = "Archer" },
new SceneNameModel { SeriesId = 83897, Name = "Life After People The Series" },
new SceneNameModel { SeriesId = 83897, Name = "Life After People" },
new SceneNameModel { SeriesId = 80552, Name = "Kitchen Nightmares US" },
new SceneNameModel { SeriesId = 71256, Name = "The Daily Show" },
new SceneNameModel { SeriesId = 71256, Name = "The Daily Show with Jon Stewart" },
new SceneNameModel { SeriesId = 75692, Name = "Law and Order SVU" },
new SceneNameModel { SeriesId = 75692, Name = "Law and Order Special Victims Unit" },
new SceneNameModel { SeriesId = 71489, Name = "Law and Order Criminal Intent" },
new SceneNameModel { SeriesId = 71489, Name = "Law and Order CI" },
new SceneNameModel { SeriesId = 79590, Name = "Dancing With The Stars US" },
new SceneNameModel { SeriesId = 73387, Name = "Craig Ferguson" },
new SceneNameModel { SeriesId = 85355, Name = "Jimmy Fallon" },
new SceneNameModel { SeriesId = 75088, Name = "David Letterman" },
new SceneNameModel { SeriesId = 76706, Name = "Big Brother US" },
new SceneNameModel { SeriesId = 105521, Name = "The Colony" },
new SceneNameModel { SeriesId = 105521, Name = "The Colony US" },
new SceneNameModel { SeriesId = 76235, Name = "Americas Funniest Home Videos" },
new SceneNameModel { SeriesId = 76235, Name = "AFHV" },
new SceneNameModel { SeriesId = 139941, Name = "Childrens Hospital US" },
new SceneNameModel { SeriesId = 139941, Name = "Childrens Hospital" },
new SceneNameModel { SeriesId = 83123, Name = "Merlin" },
new SceneNameModel { SeriesId = 83123, Name = "Merlin 2008" },
new SceneNameModel { SeriesId = 76779, Name = "WWE Monday Night RAW" },
new SceneNameModel { SeriesId = 164951, Name = "Shit My Dad Says" },
new SceneNameModel { SeriesId = 83714, Name = "Genius with Dave Gorman" },
new SceneNameModel { SeriesId = 168161, Name = "Law and Order Los Angeles" },
new SceneNameModel { SeriesId = 168161, Name = "Law and Order LA" },
new SceneNameModel { SeriesId = 77526, Name = "Star Trek TOS" },
new SceneNameModel { SeriesId = 72073, Name = "Star Trek DS9" },
new SceneNameModel { SeriesId = 72194, Name = "Ellen Degeneres" },
new SceneNameModel { SeriesId = 72194, Name = "Ellen Degeneres" },
new SceneNameModel { SeriesId = 195831, Name = "Drinking Made Easy" },
new SceneNameModel { SeriesId = 195831, Name = "Zane Lampreys Drinking Made Easy" },
new SceneNameModel { SeriesId = 76133, Name = "Poirot" },
new SceneNameModel { SeriesId = 76133, Name = "Agatha Christies Poirot" },
new SceneNameModel { SeriesId = 70870, Name = "The Real World Road Rules Challenge" },
new SceneNameModel { SeriesId = 70870, Name = "The Challenge Cutthroat" },
new SceneNameModel { SeriesId = 77444, Name = "This Old House Program" },
new SceneNameModel { SeriesId = 73290, Name = "60 Minutes US" },
new SceneNameModel { SeriesId = 194751, Name = "Conan" },
new SceneNameModel { SeriesId = 194751, Name = "Conan 2010" },
new SceneNameModel { SeriesId = 164451, Name = "Carlos 2010" },
new SceneNameModel { SeriesId = 70726, Name = "Babalon 5" },
new SceneNameModel { SeriesId = 70726, Name = "Babalon5" },
new SceneNameModel { SeriesId = 83714, Name = "Genius" },
new SceneNameModel { SeriesId = 83714, Name = "Genius With Dave Gormand" },
new SceneNameModel { SeriesId = 212571, Name = "Come Fly With Me 2010" },
new SceneNameModel { SeriesId = 81563, Name = "Border Security" },
new SceneNameModel { SeriesId = 81563, Name = "Border Security Australias Frontline" },
new SceneNameModel { SeriesId = 172381, Name = "Silent Library US" },
new SceneNameModel { SeriesId = 131791, Name = "Sci-Fi Science" },
new SceneNameModel { SeriesId = 80646, Name = "Frontline" },
new SceneNameModel { SeriesId = 80646, Name = "Frontline US" },
new SceneNameModel { SeriesId = 189931, Name = "RBT AU" },
new SceneNameModel { SeriesId = 73255, Name = "House" },
new SceneNameModel { SeriesId = 73255, Name = "House MD" },
new SceneNameModel { SeriesId = 73244, Name = "The Office" },
new SceneNameModel { SeriesId = 73244, Name = "The Office US" },
new SceneNameModel
{SeriesId = 72546, Name = "CSI"},
new SceneNameModel
{
SeriesId = 73696,
Name = "CSI New York"
},
new SceneNameModel
{SeriesId = 73696, Name = "CSI NY"},
new SceneNameModel
{
SeriesId = 110381,
Name = "Archer"
},
new SceneNameModel
{
SeriesId = 83897,
Name =
"Life After People The Series"
},
new SceneNameModel
{
SeriesId = 83897,
Name = "Life After People"
},
new SceneNameModel
{
SeriesId = 80552,
Name = "Kitchen Nightmares US"
},
new SceneNameModel
{
SeriesId = 71256,
Name = "The Daily Show"
},
new SceneNameModel
{
SeriesId = 71256,
Name =
"The Daily Show with Jon Stewart"
},
new SceneNameModel
{
SeriesId = 75692,
Name = "Law and Order SVU"
},
new SceneNameModel
{
SeriesId = 75692,
Name =
"Law and Order Special Victims Unit"
},
new SceneNameModel
{
SeriesId = 71489,
Name =
"Law and Order Criminal Intent"
},
new SceneNameModel
{
SeriesId = 71489,
Name = "Law and Order CI"
},
new SceneNameModel
{
SeriesId = 79590,
Name = "Dancing With The Stars US"
},
new SceneNameModel
{
SeriesId = 73387,
Name = "Craig Ferguson"
},
new SceneNameModel
{
SeriesId = 85355,
Name = "Jimmy Fallon"
},
new SceneNameModel
{
SeriesId = 75088,
Name = "David Letterman"
},
new SceneNameModel
{
SeriesId = 76706,
Name = "Big Brother US"
},
new SceneNameModel
{
SeriesId = 105521,
Name = "The Colony"
},
new SceneNameModel
{
SeriesId = 105521,
Name = "The Colony US"
},
new SceneNameModel
{
SeriesId = 76235,
Name =
"Americas Funniest Home Videos"
},
new SceneNameModel
{SeriesId = 76235, Name = "AFHV"},
new SceneNameModel
{
SeriesId = 139941,
Name = "Childrens Hospital US"
},
new SceneNameModel
{
SeriesId = 139941,
Name = "Childrens Hospital"
},
new SceneNameModel
{SeriesId = 83123, Name = "Merlin"},
new SceneNameModel
{
SeriesId = 83123,
Name = "Merlin 2008"
},
new SceneNameModel
{
SeriesId = 76779,
Name = "WWE Monday Night RAW"
},
new SceneNameModel
{
SeriesId = 164951,
Name = "Shit My Dad Says"
},
new SceneNameModel
{
SeriesId = 83714,
Name = "Genius with Dave Gorman"
},
new SceneNameModel
{
SeriesId = 168161,
Name = "Law and Order Los Angeles"
},
new SceneNameModel
{
SeriesId = 168161,
Name = "Law and Order LA"
},
new SceneNameModel
{
SeriesId = 77526,
Name = "Star Trek TOS"
},
new SceneNameModel
{
SeriesId = 72073,
Name = "Star Trek DS9"
},
new SceneNameModel
{
SeriesId = 72194,
Name = "Ellen Degeneres"
},
new SceneNameModel
{
SeriesId = 72194,
Name = "Ellen Degeneres"
},
new SceneNameModel
{
SeriesId = 195831,
Name = "Drinking Made Easy"
},
new SceneNameModel
{
SeriesId = 195831,
Name =
"Zane Lampreys Drinking Made Easy"
},
new SceneNameModel
{SeriesId = 76133, Name = "Poirot"},
new SceneNameModel
{
SeriesId = 76133,
Name = "Agatha Christies Poirot"
},
new SceneNameModel
{
SeriesId = 70870,
Name =
"The Real World Road Rules Challenge"
},
new SceneNameModel
{
SeriesId = 70870,
Name = "The Challenge Cutthroat"
},
new SceneNameModel
{
SeriesId = 77444,
Name = "This Old House Program"
},
new SceneNameModel
{
SeriesId = 73290,
Name = "60 Minutes US"
},
new SceneNameModel
{SeriesId = 194751, Name = "Conan"},
new SceneNameModel
{
SeriesId = 194751,
Name = "Conan 2010"
},
new SceneNameModel
{
SeriesId = 164451,
Name = "Carlos 2010"
},
new SceneNameModel
{
SeriesId = 70726,
Name = "Babalon 5"
},
new SceneNameModel
{
SeriesId = 70726,
Name = "Babalon5"
},
new SceneNameModel
{SeriesId = 83714, Name = "Genius"},
new SceneNameModel
{
SeriesId = 83714,
Name = "Genius With Dave Gormand"
},
new SceneNameModel
{
SeriesId = 212571,
Name = "Come Fly With Me 2010"
},
new SceneNameModel
{
SeriesId = 81563,
Name = "Border Security"
},
new SceneNameModel
{
SeriesId = 81563,
Name =
"Border Security Australias Frontline"
},
new SceneNameModel
{
SeriesId = 172381,
Name = "Silent Library US"
},
new SceneNameModel
{
SeriesId = 131791,
Name = "Sci-Fi Science"
},
new SceneNameModel
{
SeriesId = 80646,
Name = "Frontline"
},
new SceneNameModel
{
SeriesId = 80646,
Name = "Frontline US"
},
new SceneNameModel
{
SeriesId = 189931,
Name = "RBT AU"
},
new SceneNameModel
{SeriesId = 73255, Name = "House"},
new SceneNameModel
{
SeriesId = 73255,
Name = "House MD"
},
new SceneNameModel
{
SeriesId = 73244,
Name = "The Office"
},
new SceneNameModel
{
SeriesId = 73244,
Name = "The Office US"
},
};
public static int FindByName(string cleanSeriesName)
@ -95,6 +326,5 @@ public static List<String> FindById(int seriesId)
return results;
}
}
}

View File

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
namespace NzbDrone.Core.Helpers
{

View File

@ -11,7 +11,8 @@ public class ExceptioneerTarget : Target
protected override void Write(LogEventInfo logEvent)
{
if (logEvent.Exception == null)
throw new InvalidOperationException(@"Missing Exception Object.. Please Use Logger.FatalException() or Logger.ErrorException() rather
throw new InvalidOperationException(
@"Missing Exception Object.. Please Use Logger.FatalException() or Logger.ErrorException() rather
than Logger.Fatal() and Logger.Error()");
if (!Debugger.IsAttached)

View File

@ -1,8 +1,8 @@
using System.Diagnostics;
using System.IO;
using Ninject;
using NLog;
using NLog.Config;
using Ninject;
namespace NzbDrone.Core.Instrumentation
{
@ -15,7 +15,8 @@ public static void Setup()
LogManager.ThrowExceptions = true;
}
LogManager.Configuration = new XmlLoggingConfiguration(Path.Combine(CentralDispatch.AppPath, "log.config"), false);
LogManager.Configuration = new XmlLoggingConfiguration(Path.Combine(CentralDispatch.AppPath, "log.config"),
false);
LogManager.ConfigurationReloaded += ((s, e) => BindCustomLoggers());
BindCustomLoggers();
}
@ -35,9 +36,5 @@ private static void BindCustomLoggers()
LogManager.Configuration.Reload();
}
}
}

View File

@ -1,13 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq;
using NLog;
using SubSonic.Repository;
namespace NzbDrone.Core.Instrumentation
{
public class LogProvider
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();

View File

@ -8,6 +8,11 @@ public class NlogWriter : TextWriter
{
private static readonly Logger Logger = LogManager.GetLogger("NzbDrone.SubSonic");
public override Encoding Encoding
{
get { return Encoding.Default; }
}
public override void Write(char[] buffer, int index, int count)
{
@ -23,10 +28,5 @@ private static void DbAction(string value)
{
Logger.Trace(value);
}
public override Encoding Encoding
{
get { return Encoding.Default; }
}
}
}

View File

@ -1,11 +1,7 @@
using System;
using System.Diagnostics;
using Exceptioneer.WindowsFormsClient;
using NLog;
using NLog.Targets;
using SubSonic.Repository;
using Ninject;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Instrumentation
{

View File

@ -19,8 +19,8 @@ public class EpisodeParseResult
public override string ToString()
{
return string.Format("Series:{0} Season:{1} Episode:{2}", SeriesTitle, SeasonNumber, String.Join(",", Episodes));
}
return string.Format("Series:{0} Season:{1} Episode:{2}", SeriesTitle, SeasonNumber,
String.Join(",", Episodes));
}
}
}

View File

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Model
{

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model
namespace NzbDrone.Core.Model
{
public class EpisodeSortingType
{

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model
namespace NzbDrone.Core.Model
{
public enum EpisodeStatusType
{

View File

@ -41,10 +41,7 @@ public ProgressNotification(string title)
/// <value>The percent complete.</value>
public int PercentComplete
{
get
{
return Convert.ToInt32(Convert.ToDouble(ProgressValue) / Convert.ToDouble(ProgressMax) * 100);
}
get { return Convert.ToInt32(Convert.ToDouble(ProgressValue)/Convert.ToDouble(ProgressMax)*100); }
}
/// <summary>
@ -65,6 +62,8 @@ public int PercentComplete
/// <value>The status.</value>
public ProgressNotificationStatus Status { get; set; }
#region IDisposable Members
public void Dispose()
{
if (Status == ProgressNotificationStatus.InProgress)
@ -73,5 +72,7 @@ public void Dispose()
Status = ProgressNotificationStatus.Failed;
}
}
#endregion
}
}

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Core.Model
{

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model
namespace NzbDrone.Core.Model
{
public class SceneNameModel
{

View File

@ -14,6 +14,5 @@ public override string ToString()
{
return string.Format("Series:{0} Season:{1}", SeriesTitle, SeasonNumber);
}
}
}

View File

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Model

View File

@ -1,12 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Core
@ -17,16 +14,25 @@ internal static class Parser
private static readonly Regex[] ReportTitleRegex = new[]
{
new Regex(@"(?<title>.+?)?\W?(?<year>\d+?)?\WS?(?<season>\d+)(?:\-|\.|[a-z])(?<episode>\d+)\W(?!\\)", RegexOptions.IgnoreCase | RegexOptions.Compiled),
new Regex(@"(?<title>.+?)?\W?(?<year>\d+?)?\WS?(?<season>\d+)(?<episode>\d{2})\W(?!\\)", RegexOptions.IgnoreCase | RegexOptions.Compiled) //Supports 103/113 naming
new Regex(
@"(?<title>.+?)?\W?(?<year>\d+?)?\WS?(?<season>\d+)(?:\-|\.|[a-z])(?<episode>\d+)\W(?!\\)",
RegexOptions.IgnoreCase | RegexOptions.Compiled),
new Regex(
@"(?<title>.+?)?\W?(?<year>\d+?)?\WS?(?<season>\d+)(?<episode>\d{2})\W(?!\\)",
RegexOptions.IgnoreCase | RegexOptions.Compiled)
//Supports 103/113 naming
};
private static readonly Regex[] SeasonReportTitleRegex = new[]
{
new Regex(@"(?<title>.+?)?\W?(?<year>\d{4}?)?\W(?:S|Season)?\W?(?<season>\d+)(?!\\)", RegexOptions.IgnoreCase | RegexOptions.Compiled),
new Regex(
@"(?<title>.+?)?\W?(?<year>\d{4}?)?\W(?:S|Season)?\W?(?<season>\d+)(?!\\)",
RegexOptions.IgnoreCase |
RegexOptions.Compiled),
};
private static readonly Regex NormalizeRegex = new Regex(@"((\s|^)the(\s|$))|((\s|^)and(\s|$))|[^a-z]", RegexOptions.IgnoreCase | RegexOptions.Compiled);
private static readonly Regex NormalizeRegex = new Regex(@"((\s|^)the(\s|$))|((\s|^)and(\s|$))|[^a-z]",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
/// <summary>
/// Parses a post title into list of episodes it contains
@ -64,7 +70,6 @@ internal static EpisodeParseResult ParseEpisodeInfo(string title)
foreach (Match matchGroup in match)
{
parsedEpisode.Episodes.Add(Convert.ToInt32(matchGroup.Groups["episode"].Value));
}
parsedEpisode.Quality = ParseQuality(title);
@ -255,7 +260,5 @@ public static string NormalizePath(string path)
return info.FullName.Trim('/', '\\', ' ');
}
}
}

View File

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Providers
{
@ -13,6 +10,7 @@ public virtual bool StartSearch()
{
throw new NotImplementedException();
}
public virtual bool StartSearch(int seriesId)
{
throw new NotImplementedException();

View File

@ -5,8 +5,6 @@ namespace NzbDrone.Core.Providers.Core
{
public class DiskProvider
{
#region IDiskProvider Members
public virtual bool FolderExists(string path)
{
return Directory.Exists(path);
@ -48,7 +46,5 @@ public virtual void RenameFile(string sourcePath, string destinationPath)
{
File.Move(sourcePath, destinationPath);
}
#endregion
}
}

View File

@ -47,7 +47,6 @@ public virtual void DownloadFile(string request, string filename)
{
var webClient = new WebClient();
webClient.DownloadFile(request, filename);
}
catch (Exception ex)
{
@ -55,8 +54,6 @@ public virtual void DownloadFile(string request, string filename)
Logger.TraceException(ex.Message, ex);
throw;
}
}
public virtual void DownloadFile(string request, string filename, string username, string password)

View File

@ -1,7 +1,6 @@
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Linq;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository;
@ -13,13 +12,13 @@ public class EpisodeProvider
{
//TODO: Remove parsing of the series name, it should be done in series provider
private readonly IRepository _sonicRepo;
private readonly SeriesProvider _series;
private readonly SeasonProvider _seasons;
private readonly TvDbProvider _tvDb;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly HistoryProvider _history;
private readonly QualityProvider _quality;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly SeasonProvider _seasons;
private readonly SeriesProvider _series;
private readonly IRepository _sonicRepo;
private readonly TvDbProvider _tvDb;
public EpisodeProvider(IRepository sonicRepo, SeriesProvider seriesProvider,
SeasonProvider seasonProvider, TvDbProvider tvDbProvider,
@ -35,7 +34,6 @@ public EpisodeProvider(IRepository sonicRepo, SeriesProvider seriesProvider,
public EpisodeProvider()
{
}
public virtual Episode GetEpisode(long id)
@ -45,7 +43,9 @@ public virtual Episode GetEpisode(long id)
public virtual Episode GetEpisode(int seriesId, int seasonNumber, int episodeNumber)
{
return _sonicRepo.Single<Episode>(c => c.SeriesId == seriesId && c.SeasonNumber == seasonNumber && c.EpisodeNumber == episodeNumber);
return
_sonicRepo.Single<Episode>(
c => c.SeriesId == seriesId && c.SeasonNumber == seasonNumber && c.EpisodeNumber == episodeNumber);
}
public virtual IList<Episode> GetEpisodeBySeries(long seriesId)
@ -116,7 +116,6 @@ public virtual bool IsNeeded(EpisodeParseResult parsedReport)
}
return false;
}
public virtual void RefreshEpisodeInfo(int seriesId)
@ -145,8 +144,9 @@ public virtual void RefreshEpisodeInfo(int seriesId)
if (episode.FirstAired < new DateTime(1753, 1, 1))
episode.FirstAired = new DateTime(1753, 1, 1);
Logger.Trace("Updating info for series:{0} - episode:{1}", targetSeries.SeriesName, episode.EpisodeNumber);
var newEpisode = new Episode()
Logger.Trace("Updating info for series:{0} - episode:{1}", targetSeries.SeriesName,
episode.EpisodeNumber);
var newEpisode = new Episode
{
AirDate = episode.FirstAired,
EpisodeId = episode.Id,
@ -172,7 +172,8 @@ public virtual void RefreshEpisodeInfo(int seriesId)
}
catch (Exception e)
{
Logger.FatalException(String.Format("An error has occurred while updating episode info for series {0}", seriesId), e);
Logger.FatalException(
String.Format("An error has occurred while updating episode info for series {0}", seriesId), e);
failCount++;
}
}
@ -180,12 +181,14 @@ public virtual void RefreshEpisodeInfo(int seriesId)
_sonicRepo.AddMany(newList);
_sonicRepo.UpdateMany(updateList);
Logger.Debug("Finished episode refresh for series:{0}. Successful:{1} - Failed:{2} ", targetSeries.SeriesName, successCount, failCount);
Logger.Debug("Finished episode refresh for series:{0}. Successful:{1} - Failed:{2} ",
targetSeries.SeriesName, successCount, failCount);
}
public virtual void RefreshEpisodeInfo(Season season)
{
Logger.Info("Starting episode info refresh for season {0} of series:{1}", season.SeasonNumber, season.SeriesId);
Logger.Info("Starting episode info refresh for season {0} of series:{1}", season.SeasonNumber,
season.SeriesId);
int successCount = 0;
int failCount = 0;
var targetSeries = _tvDb.GetSeries(season.SeriesId, true);
@ -204,8 +207,9 @@ public virtual void RefreshEpisodeInfo(Season season)
if (episode.FirstAired < new DateTime(1753, 1, 1))
episode.FirstAired = new DateTime(1753, 1, 1);
Logger.Trace("Updating info for series:{0} - episode:{1}", targetSeries.SeriesName, episode.EpisodeNumber);
var newEpisode = new Episode()
Logger.Trace("Updating info for series:{0} - episode:{1}", targetSeries.SeriesName,
episode.EpisodeNumber);
var newEpisode = new Episode
{
AirDate = episode.FirstAired,
EpisodeId = episode.Id,
@ -231,7 +235,9 @@ public virtual void RefreshEpisodeInfo(Season season)
}
catch (Exception e)
{
Logger.FatalException(String.Format("An error has occurred while updating episode info for season {0} of series {1}", season.SeasonNumber, season.SeriesId), e);
Logger.FatalException(
String.Format("An error has occurred while updating episode info for season {0} of series {1}",
season.SeasonNumber, season.SeriesId), e);
failCount++;
}
}
@ -239,7 +245,8 @@ public virtual void RefreshEpisodeInfo(Season season)
_sonicRepo.AddMany(newList);
_sonicRepo.UpdateMany(updateList);
Logger.Debug("Finished episode refresh for series:{0}. Successful:{1} - Failed:{2} ", targetSeries.SeriesName, successCount, failCount);
Logger.Debug("Finished episode refresh for series:{0}. Successful:{1} - Failed:{2} ",
targetSeries.SeriesName, successCount, failCount);
}
public virtual void DeleteEpisode(int episodeId)
@ -251,6 +258,5 @@ public virtual void UpdateEpisode(Episode episode)
{
_sonicRepo.Update(episode);
}
}
}

View File

@ -1,29 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NLog;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Providers
{
public class ExternalNotificationProvider
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly ConfigProvider _configProvider;
private readonly XbmcProvider _xbmcProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public ExternalNotificationProvider(ConfigProvider configProvider, XbmcProvider xbmcProvider)
{
_configProvider = configProvider;
_xbmcProvider = xbmcProvider;
}
#region ExternalNotificationProvider Members
public virtual void OnGrab(string message)
{
var header = "NzbDrone [TV] - Grabbed";
@ -100,6 +94,5 @@ public virtual void OnRename(EpisodeRenameModel erm)
throw new NotImplementedException();
}
#endregion
}
}

View File

@ -4,24 +4,19 @@
namespace NzbDrone.Core.Providers.Fakes
{
class FakeNotificationProvider
internal class FakeNotificationProvider
{
private readonly Dictionary<Guid, BasicNotification> _basicNotifications = new Dictionary<Guid, BasicNotification>();
private readonly Dictionary<Guid, ProgressNotification> _progressNotification = new Dictionary<Guid, ProgressNotification>();
private readonly Dictionary<Guid, BasicNotification> _basicNotifications =
new Dictionary<Guid, BasicNotification>();
private readonly Object _lock = new object();
private readonly Dictionary<Guid, ProgressNotification> _progressNotification =
new Dictionary<Guid, ProgressNotification>();
ProgressNotification fakeNotification = new ProgressNotification("Updating Series");
ProgressNotification fakeNotification2 = new ProgressNotification("Updating Series2");
public void Register(ProgressNotification notification)
{
_progressNotification.Add(notification.Id, notification);
}
public void Register(BasicNotification notification)
{
_basicNotifications.Add(notification.Id, notification);
}
private readonly ProgressNotification fakeNotification = new ProgressNotification("Updating Series");
private readonly ProgressNotification fakeNotification2 = new ProgressNotification("Updating Series2");
public List<BasicNotification> BasicNotifications
{
@ -30,7 +25,6 @@ public List<BasicNotification> BasicNotifications
public List<ProgressNotification> GetProgressNotifications
{
get
{
fakeNotification.Status = ProgressNotificationStatus.InProgress;
@ -41,6 +35,16 @@ public List<ProgressNotification> GetProgressNotifications
}
}
public void Register(ProgressNotification notification)
{
_progressNotification.Add(notification.Id, notification);
}
public void Register(BasicNotification notification)
{
_basicNotifications.Add(notification.Id, notification);
}
public void Dismiss(Guid notificationId)
{
lock (_lock)

View File

@ -1,5 +1,4 @@
using System.ServiceModel.Syndication;
using System.Xml;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
@ -8,15 +7,16 @@ namespace NzbDrone.Core.Providers.Feed
{
public abstract class FeedProviderBase
{
protected readonly SeriesProvider _seriesProvider;
protected readonly SeasonProvider _seasonProvider;
protected readonly EpisodeProvider _episodeProvider;
protected readonly ConfigProvider _configProvider;
private readonly HttpProvider _httpProvider;
protected static readonly Logger Logger = LogManager.GetCurrentClassLogger();
protected readonly ConfigProvider _configProvider;
protected readonly EpisodeProvider _episodeProvider;
private readonly HttpProvider _httpProvider;
protected readonly SeasonProvider _seasonProvider;
protected readonly SeriesProvider _seriesProvider;
public FeedProviderBase(SeriesProvider seriesProvider, SeasonProvider seasonProvider,
EpisodeProvider episodeProvider, ConfigProvider configProvider, HttpProvider httpProvider)
EpisodeProvider episodeProvider, ConfigProvider configProvider,
HttpProvider httpProvider)
{
_seriesProvider = seriesProvider;
_seasonProvider = seasonProvider;
@ -66,11 +66,9 @@ protected EpisodeParseResult ParseFeed(SyndicationItem item)
Logger.Debug("Unable to map {0} to any of series in database", episodeParseResult.SeriesTitle);
return null;
}
/// <summary>
/// Fetches RSS feed and process each news item.
/// </summary>
@ -122,5 +120,4 @@ private void ProcessItem(SyndicationItem feedItem)
}
}
}
}

View File

@ -1,15 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.Syndication;
using System.Text;
using System.ServiceModel.Syndication;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers.Feed
{
class NzbsOrgFeedProvider : FeedProviderBase
internal class NzbsOrgFeedProvider : FeedProviderBase
{
public NzbsOrgFeedProvider(SeriesProvider seriesProvider, SeasonProvider seasonProvider, EpisodeProvider episodeProvider, ConfigProvider configProvider, HttpProvider httpProvider)
public NzbsOrgFeedProvider(SeriesProvider seriesProvider, SeasonProvider seasonProvider,
EpisodeProvider episodeProvider, ConfigProvider configProvider,
HttpProvider httpProvider)
: base(seriesProvider, seasonProvider, episodeProvider, configProvider, httpProvider)
{
}
@ -18,7 +16,11 @@ protected override string[] URL
{
get
{
return new[] { string.Format("http://nzbs.org/rss.php?type=1&i={0}&h={1}", _configProvider.NzbsOrgUId, _configProvider.NzbsOrgHash) };
return new[]
{
string.Format("http://nzbs.org/rss.php?type=1&i={0}&h={1}", _configProvider.NzbsOrgUId,
_configProvider.NzbsOrgHash)
};
}
}

View File

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NLog;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
@ -11,9 +10,8 @@ namespace NzbDrone.Core.Providers
{
public class HistoryProvider
{
private readonly IRepository _sonicRepo;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly IRepository _sonicRepo;
public HistoryProvider(IRepository sonicRepo)
{
@ -24,8 +22,6 @@ public HistoryProvider()
{
}
#region HistoryProvider Members
public virtual List<History> AllItems()
{
return _sonicRepo.All<History>().ToList();
@ -54,13 +50,11 @@ public virtual void Insert(History item)
public virtual bool Exists(int episodeId, QualityTypes quality, bool proper)
{
//Looks for the existance of this episode in History
if (_sonicRepo.Exists<History>(h => h.EpisodeId == episodeId && (QualityTypes)h.Quality == quality && h.IsProper == proper))
if (_sonicRepo.Exists<History>(h => h.EpisodeId == episodeId && h.Quality == quality && h.IsProper == proper))
return true;
Logger.Debug("Episode not in History: {0}", episodeId);
return false;
}
#endregion
}
}

View File

@ -1,21 +1,17 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using SubSonic.Repository;
using NzbDrone.Core.Repository;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers
{
public class IndexerProvider
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly IRepository _sonicRepo;
private readonly ConfigProvider _configProvider;
private readonly IRepository _sonicRepo;
public IndexerProvider(IRepository sonicRepo, ConfigProvider configProvider)
{
@ -23,8 +19,6 @@ public IndexerProvider(IRepository sonicRepo, ConfigProvider configProvider)
_configProvider = configProvider;
}
#region IndexerProvider Members
public virtual List<Indexer> AllIndexers()
{
return _sonicRepo.All<Indexer>().OrderBy(i => i.Order).ToList();
@ -44,7 +38,5 @@ public virtual Indexer Single(int indexerId)
{
return _sonicRepo.Single<Indexer>(indexerId);
}
#endregion
}
}

View File

@ -2,10 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using SubSonic.Repository;
@ -14,25 +11,22 @@ namespace NzbDrone.Core.Providers
{
public class MediaFileProvider
{
private readonly IRepository _repository;
private readonly ConfigProvider _configProvider;
private readonly DiskProvider _diskProvider;
private readonly EpisodeProvider _episodeProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private static readonly string[] MediaExtentions = new[] { "*.mkv", "*.avi", "*.wmv" };
private readonly DiskProvider _diskProvider;
private readonly EpisodeProvider _episodeProvider;
private readonly IRepository _repository;
public MediaFileProvider(IRepository repository, ConfigProvider configProvider, DiskProvider diskProvider, EpisodeProvider episodeProvider)
public MediaFileProvider(IRepository repository, DiskProvider diskProvider,
EpisodeProvider episodeProvider)
{
_repository = repository;
_configProvider = configProvider;
_diskProvider = diskProvider;
_episodeProvider = episodeProvider;
}
public MediaFileProvider()
{
}
/// <summary>
@ -84,7 +78,8 @@ public EpisodeFile ImportFile(Series series, string filePath)
foreach (var episodeNumber in episodesInFile.Episodes)
{
var episode = _episodeProvider.GetEpisode(series.SeriesId, episodesInFile.SeasonNumber, episodeNumber);
var episode = _episodeProvider.GetEpisode(series.SeriesId, episodesInFile.SeasonNumber,
episodeNumber);
if (episode != null)
{
@ -92,7 +87,8 @@ public EpisodeFile ImportFile(Series series, string filePath)
}
else
Logger.Warn("Unable to find Series:{0} Season:{1} Episode:{2} in the database. File:{3}", series.Title, episodesInFile.SeasonNumber, episodeNumber, filePath);
Logger.Warn("Unable to find Series:{0} Season:{1} Episode:{2} in the database. File:{3}",
series.Title, episodesInFile.SeasonNumber, episodeNumber, filePath);
}
//Return null if no Episodes exist in the DB for the parsed episodes from file
@ -125,7 +121,8 @@ public EpisodeFile ImportFile(Series series, string filePath)
_episodeProvider.UpdateEpisode(ep);
episodeList += String.Format(", {0}", ep.EpisodeId).Trim(' ', ',');
}
Logger.Trace("File {0}:{1} attached to episode(s): '{2}'", episodeFile.EpisodeFileId, filePath, episodeList);
Logger.Trace("File {0}:{1} attached to episode(s): '{2}'", episodeFile.EpisodeFileId, filePath,
episodeList);
return episodeFile;
}

View File

@ -1,25 +1,19 @@
using System;
using System.Linq;
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Model.Notification;
namespace NzbDrone.Core.Providers
{
public class NotificationProvider
{
private readonly Dictionary<Guid, BasicNotification> _basicNotifications = new Dictionary<Guid, BasicNotification>();
private Dictionary<Guid, ProgressNotification> _progressNotification = new Dictionary<Guid, ProgressNotification>();
private readonly Dictionary<Guid, BasicNotification> _basicNotifications =
new Dictionary<Guid, BasicNotification>();
private readonly Object _lock = new object();
public virtual void Register(ProgressNotification notification)
{
_progressNotification.Add(notification.Id, notification);
}
public virtual void Register(BasicNotification notification)
{
_basicNotifications.Add(notification.Id, notification);
}
private readonly Dictionary<Guid, ProgressNotification> _progressNotification =
new Dictionary<Guid, ProgressNotification>();
public virtual List<BasicNotification> BasicNotifications
{
@ -30,10 +24,22 @@ public virtual List<ProgressNotification> GetProgressNotifications
{
get
{
return new List<ProgressNotification>(_progressNotification.Values.Where(p => p.Status == ProgressNotificationStatus.InProgress));
return
new List<ProgressNotification>(
_progressNotification.Values.Where(p => p.Status == ProgressNotificationStatus.InProgress));
}
}
public virtual void Register(ProgressNotification notification)
{
_progressNotification.Add(notification.Id, notification);
}
public virtual void Register(BasicNotification notification)
{
_basicNotifications.Add(notification.Id, notification);
}
public virtual void Dismiss(Guid notificationId)
{
lock (_lock)

View File

@ -1,19 +1,10 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers
namespace NzbDrone.Core.Providers
{
public class PostProcessingProvider
{
private readonly SeriesProvider _seriesProvider;
private readonly MediaFileProvider _mediaFileProvider;
private readonly RenameProvider _renameProvider;
private readonly SeriesProvider _seriesProvider;
public PostProcessingProvider(SeriesProvider seriesProvider,
MediaFileProvider mediaFileProvider, RenameProvider renameProvider)
@ -23,8 +14,6 @@ public PostProcessingProvider(SeriesProvider seriesProvider,
_renameProvider = renameProvider;
}
#region PostProcessingProvider Members
public virtual void ProcessEpisode(string dir, string nzbName)
{
var parsedSeries = Parser.ParseSeriesName(nzbName);
@ -42,7 +31,5 @@ public virtual void ProcessEpisode(string dir, string nzbName)
_renameProvider.RenameEpisodeFile(file.EpisodeFileId, true);
}
}
#endregion
}
}

View File

@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using NLog;
using NzbDrone.Core.Repository.Quality;
using SubSonic.Repository;
@ -11,12 +9,11 @@ namespace NzbDrone.Core.Providers
{
public class QualityProvider
{
private IRepository _sonicRepo;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly IRepository _sonicRepo;
public QualityProvider()
{
}
public QualityProvider(IRepository sonicRepo)
@ -24,8 +21,6 @@ public QualityProvider(IRepository sonicRepo)
_sonicRepo = sonicRepo;
}
#region IQualityProvider Members
public virtual void Add(QualityProfile profile)
{
_sonicRepo.Add(profile);
@ -58,7 +53,5 @@ public virtual QualityProfile Find(int profileId)
{
return _sonicRepo.Single<QualityProfile>(q => q.QualityProfileId == profileId);
}
#endregion
}
}

View File

@ -2,30 +2,27 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using NLog;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Providers
{
public class RenameProvider
{
private readonly SeriesProvider _seriesProvider;
private readonly SeasonProvider _seasonProvider;
private readonly EpisodeProvider _episodeProvider;
private readonly MediaFileProvider _mediaFileProvider;
private readonly DiskProvider _diskProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly ConfigProvider _configProvider;
private readonly DiskProvider _diskProvider;
private readonly EpisodeProvider _episodeProvider;
private readonly List<EpisodeRenameModel> _epsToRename = new List<EpisodeRenameModel>();
private readonly ExternalNotificationProvider _externalNotificationProvider;
private readonly MediaFileProvider _mediaFileProvider;
private readonly SeasonProvider _seasonProvider;
private readonly SeriesProvider _seriesProvider;
private Thread _renameThread;
private List<EpisodeRenameModel> _epsToRename = new List<EpisodeRenameModel>();
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public RenameProvider(SeriesProvider seriesProvider, SeasonProvider seasonProvider,
EpisodeProvider episodeProvider, MediaFileProvider mediaFileProvider,
@ -41,7 +38,6 @@ public RenameProvider(SeriesProvider seriesProvider, SeasonProvider seasonProvid
_externalNotificationProvider = extenalNotificationProvider;
}
#region RenameProvider Members
public virtual void RenameAll()
{
//Get a list of all episode files/episodes and rename them
@ -49,12 +45,14 @@ public virtual void RenameAll()
foreach (var episodeFile in _mediaFileProvider.GetEpisodeFiles())
{
var series = _seriesProvider.GetSeries(episodeFile.SeriesId);
var erm = new EpisodeRenameModel();
erm.SeriesName = series.Title;
erm.Folder = series.Path;
var erm = new EpisodeRenameModel {SeriesName = series.Title, Folder = series.Path};
if (series.SeasonFolder)
erm.Folder += Path.DirectorySeparatorChar + EpisodeRenameHelper.GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber, _configProvider.GetValue("Sorting_SeasonFolderFormat", "Season %s", true));
erm.Folder += Path.DirectorySeparatorChar +
EpisodeRenameHelper.GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber,
_configProvider.GetValue(
"Sorting_SeasonFolderFormat", "Season %s",
true));
erm.EpisodeFile = episodeFile;
_epsToRename.Add(erm);
@ -70,13 +68,14 @@ public virtual void RenameSeries(int seriesId)
foreach (var episodeFile in _mediaFileProvider.GetEpisodeFiles().Where(s => s.SeriesId == seriesId))
{
var erm = new EpisodeRenameModel();
erm.SeriesName = series.Title;
erm.Folder = series.Path;
var erm = new EpisodeRenameModel {SeriesName = series.Title, Folder = series.Path};
if (series.SeasonFolder)
erm.Folder += Path.DirectorySeparatorChar + EpisodeRenameHelper.GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber, _configProvider.GetValue("Sorting_SeasonFolderFormat", "Season %s", true));
erm.Folder += Path.DirectorySeparatorChar +
EpisodeRenameHelper.GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber,
_configProvider.GetValue(
"Sorting_SeasonFolderFormat", "Season %s",
true));
erm.EpisodeFile = episodeFile;
_epsToRename.Add(erm);
@ -90,15 +89,17 @@ public virtual void RenameSeason(int seasonId)
var season = _seasonProvider.GetSeason(seasonId);
var series = _seriesProvider.GetSeries(season.SeriesId);
foreach (var episodeFile in _mediaFileProvider.GetEpisodeFiles().Where(s => s.Episodes[0].SeasonId == seasonId))
foreach (
var episodeFile in _mediaFileProvider.GetEpisodeFiles().Where(s => s.Episodes[0].SeasonId == seasonId))
{
var erm = new EpisodeRenameModel();
erm.SeriesName = series.Title;
erm.Folder = series.Path;
var erm = new EpisodeRenameModel {SeriesName = series.Title, Folder = series.Path};
if (series.SeasonFolder)
erm.Folder += Path.DirectorySeparatorChar + EpisodeRenameHelper.GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber, _configProvider.GetValue("Sorting_SeasonFolderFormat", "Season %s", true));
erm.Folder += Path.DirectorySeparatorChar +
EpisodeRenameHelper.GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber,
_configProvider.GetValue(
"Sorting_SeasonFolderFormat", "Season %s",
true));
erm.EpisodeFile = episodeFile;
_epsToRename.Add(erm);
@ -112,15 +113,16 @@ public virtual void RenameEpisode(int episodeId)
var episode = _episodeProvider.GetEpisode(episodeId);
var series = _seriesProvider.GetSeries(episode.SeriesId);
var episodeFile = _mediaFileProvider.GetEpisodeFiles().Where(s => s.Episodes.Contains(episode)).FirstOrDefault();
var episodeFile =
_mediaFileProvider.GetEpisodeFiles().Where(s => s.Episodes.Contains(episode)).FirstOrDefault();
var erm = new EpisodeRenameModel();
erm.SeriesName = series.Title;
erm.Folder = series.Path;
var erm = new EpisodeRenameModel {SeriesName = series.Title, Folder = series.Path};
if (series.SeasonFolder)
erm.Folder += Path.DirectorySeparatorChar + EpisodeRenameHelper.GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber, _configProvider.GetValue("Sorting_SeasonFolderFormat", "Season %s", true));
erm.Folder += Path.DirectorySeparatorChar +
EpisodeRenameHelper.GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber,
_configProvider.GetValue(
"Sorting_SeasonFolderFormat", "Season %s", true));
erm.EpisodeFile = episodeFile;
_epsToRename.Add(erm);
@ -133,21 +135,19 @@ public virtual void RenameEpisodeFile(int episodeFileId, bool newDownload)
var episodeFile = _mediaFileProvider.GetEpisodeFile(episodeFileId);
var series = _seriesProvider.GetSeries(episodeFile.Series.SeriesId);
var erm = new EpisodeRenameModel();
erm.SeriesName = series.Title;
erm.Folder = series.Path;
var erm = new EpisodeRenameModel {SeriesName = series.Title, Folder = series.Path};
if (series.SeasonFolder)
erm.Folder += Path.DirectorySeparatorChar + EpisodeRenameHelper.GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber, _configProvider.GetValue("Sorting_SeasonFolderFormat", "Season %s", true));
erm.Folder += Path.DirectorySeparatorChar +
EpisodeRenameHelper.GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber,
_configProvider.GetValue(
"Sorting_SeasonFolderFormat", "Season %s", true));
erm.EpisodeFile = episodeFile;
_epsToRename.Add(erm);
StartRename();
}
#endregion
private void StartRename()
{
Logger.Debug("Episode Rename Starting");
@ -203,7 +203,6 @@ private void RenameFile(EpisodeRenameModel erm)
else
_externalNotificationProvider.OnRename(erm);
}
catch (Exception ex)
{

View File

@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NzbDrone.Core.Repository;
using SubSonic.Repository;

View File

@ -1,15 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Providers
namespace NzbDrone.Core.Providers
{
public class RssSyncProvider
{
public virtual void Begin()
{
}
}
}

View File

@ -9,19 +9,16 @@ namespace NzbDrone.Core.Providers
{
public class SabProvider
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly ConfigProvider _config;
private readonly HttpProvider _http;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public SabProvider(ConfigProvider config, HttpProvider http)
{
_config = config;
_http = http;
}
#region IDownloadProvider Members
public virtual bool AddByUrl(string url, string title)
{
const string mode = "addurl";
@ -31,7 +28,8 @@ public virtual bool AddByUrl(string url, string title)
string name = url.Replace("&", "%26");
string nzbName = HttpUtility.UrlEncode(title);
string action = string.Format("mode={0}&name={1}&priority={2}&cat={3}&nzbname={4}", mode, name, priority, cat, nzbName);
string action = string.Format("mode={0}&name={1}&priority={2}&cat={3}&nzbname={4}", mode, name, priority,
cat, nzbName);
string request = GetSabRequest(action);
Logger.Debug("Adding report [{0}] to the queue.", nzbName);
@ -61,7 +59,10 @@ public virtual bool IsInQueue(string title)
return false;
//Get the Count of Items in Queue where 'filename' is Equal to goodName, if not zero, return true (isInQueue)))
if ((xDoc.Descendants("slot").Where(s => s.Element("filename").Value.Equals(title, StringComparison.InvariantCultureIgnoreCase))).Count() != 0)
if (
(xDoc.Descendants("slot").Where(
s => s.Element("filename").Value.Equals(title, StringComparison.InvariantCultureIgnoreCase))).Count() !=
0)
{
Logger.Debug("Episode in queue - '{0}'", title);
@ -81,7 +82,8 @@ public virtual bool AddById(string id, string title)
string priority = _config.GetValue("SabTvPriority", String.Empty, false);
string nzbName = HttpUtility.UrlEncode(title);
string action = string.Format("mode={0}&name={1}&priority={2}&cat={3}&nzbname={4}", mode, id, priority, cat, nzbName);
string action = string.Format("mode={0}&name={1}&priority={2}&cat={3}&nzbname={4}", mode, id, priority, cat,
nzbName);
string request = GetSabRequest(action);
Logger.Debug("Adding report [{0}] to the queue.", nzbName);
@ -95,16 +97,17 @@ public virtual bool AddById(string id, string title)
return false;
}
#endregion
private string GetSabRequest(string action)
{
string sabnzbdInfo = _config.GetValue("SabHost", String.Empty, false) + ":" + _config.GetValue("SabPort", String.Empty, false);
string sabnzbdInfo = _config.GetValue("SabHost", String.Empty, false) + ":" +
_config.GetValue("SabPort", String.Empty, false);
string username = _config.GetValue("SabUsername", String.Empty, false);
string password = _config.GetValue("SabPassword", String.Empty, false);
string apiKey = _config.GetValue("SabApiKey", String.Empty, false);
return string.Format(@"http://{0}/api?$Action&apikey={1}&ma_username={2}&ma_password={3}", sabnzbdInfo, apiKey, username, password).Replace("$Action", action);
return
string.Format(@"http://{0}/api?$Action&apikey={1}&ma_username={2}&ma_password={3}", sabnzbdInfo, apiKey,
username, password).Replace("$Action", action);
}
}
}

View File

@ -1,29 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository;
using SubSonic.Repository;
using System.Linq;
namespace NzbDrone.Core.Providers
{
public class SeasonProvider
{
private readonly IRepository _sonicRepo;
private readonly SeriesProvider _seriesProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly IRepository _sonicRepo;
public SeasonProvider(IRepository dataRepository, SeriesProvider seriesProvider)
public SeasonProvider(IRepository dataRepository)
{
_sonicRepo = dataRepository;
_seriesProvider = seriesProvider;
}
public SeasonProvider()
{
}
public virtual Season GetSeason(int seasonId)
@ -51,16 +46,17 @@ public virtual void EnsureSeason(int seriesId, int seasonId, int seasonNumber)
if (_sonicRepo.Exists<Season>(s => s.SeasonId == seasonId))
return;
//TODO: Calculate Season Folder
Logger.Trace("Adding Season To DB. [SeriesID:{0} SeasonID:{1} SeasonNumber:{2}]", seriesId, seasonId, seasonNumber, "????");
Logger.Trace("Adding Season To DB. [SeriesID:{0} SeasonID:{1} SeasonNumber:{2}]", seriesId, seasonId,
seasonNumber, "????");
var newSeason = new Season()
var newSeason = new Season
{
Monitored = true,
SeasonId = seasonId,
SeasonNumber = seasonNumber,
SeriesId = seriesId
};
_sonicRepo.Add<Season>(newSeason);
_sonicRepo.Add(newSeason);
}
public virtual int SaveSeason(Season season)

View File

@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Ninject;
using NLog;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
@ -19,11 +16,11 @@ public class SeriesProvider
//Trims all white spaces and separators from the end of the title.
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly ConfigProvider _config;
private readonly QualityProvider _quality;
private readonly IRepository _sonioRepo;
private readonly TvDbProvider _tvDb;
private readonly QualityProvider _quality;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public SeriesProvider(ConfigProvider configProvider,
IRepository dataRepository, TvDbProvider tvDbProvider, QualityProvider quality)
@ -38,8 +35,6 @@ public SeriesProvider()
{
}
#region SeriesProvider Members
public virtual IQueryable<Series> GetAllSeries()
{
return _sonioRepo.All<Series>();
@ -149,7 +144,6 @@ public virtual void DeleteSeries(int seriesId)
_sonioRepo.Delete<Series>(seriesId);
Logger.Info("Successfully deleted Series [{0}]", seriesId);
}
catch (Exception e)
{
@ -165,8 +159,5 @@ public virtual bool SeriesPathExists(string cleanPath)
return false;
}
#endregion
}
}

View File

@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers.Core;
@ -13,17 +11,16 @@ namespace NzbDrone.Core.Providers
{
public class SyncProvider
{
private readonly SeriesProvider _seriesProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly DiskProvider _diskProvider;
private readonly EpisodeProvider _episodeProvider;
private readonly MediaFileProvider _mediaFileProvider;
private readonly NotificationProvider _notificationProvider;
private readonly DiskProvider _diskProvider;
private readonly SeriesProvider _seriesProvider;
private ProgressNotification _seriesSyncNotification;
private Thread _seriesSyncThread;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public SyncProvider(SeriesProvider seriesProvider, EpisodeProvider episodeProvider,
MediaFileProvider mediaFileProvider, NotificationProvider notificationProvider,
DiskProvider diskProvider)
@ -35,8 +32,6 @@ public SyncProvider(SeriesProvider seriesProvider, EpisodeProvider episodeProvid
_diskProvider = diskProvider;
}
#region ISyncProvider Members
public List<String> GetUnmappedFolders(string path)
{
Logger.Debug("Generating list of unmapped folders");
@ -64,8 +59,6 @@ public List<String> GetUnmappedFolders(string path)
return results;
}
#endregion
public bool BeginUpdateNewSeries()
{
Logger.Debug("User has requested a scan of new series");
@ -120,8 +113,6 @@ private void SyncNewSeries()
private void ScanSeries()
{
var syncList = _seriesProvider.GetAllSeries().Where(s => s.LastInfoSync == null).ToList();
if (syncList.Count == 0) return;
@ -131,13 +122,16 @@ private void ScanSeries()
{
try
{
_seriesSyncNotification.CurrentStatus = String.Format("Searching For: {0}", new DirectoryInfo(currentSeries.Path).Name);
_seriesSyncNotification.CurrentStatus = String.Format("Searching For: {0}",
new DirectoryInfo(currentSeries.Path).Name);
var updatedSeries = _seriesProvider.UpdateSeriesInfo(currentSeries.SeriesId);
_seriesSyncNotification.CurrentStatus = String.Format("Downloading episode info For: {0}", updatedSeries.Title);
_seriesSyncNotification.CurrentStatus = String.Format("Downloading episode info For: {0}",
updatedSeries.Title);
_episodeProvider.RefreshEpisodeInfo(updatedSeries.SeriesId);
_seriesSyncNotification.CurrentStatus = String.Format("Scanning series folder {0}", updatedSeries.Path);
_seriesSyncNotification.CurrentStatus = String.Format("Scanning series folder {0}",
updatedSeries.Path);
_mediaFileProvider.Scan(_seriesProvider.GetSeries(updatedSeries.SeriesId));
//Todo: Launch Backlog search for this series _backlogProvider.StartSearch(mappedSeries.Id);

View File

@ -1,27 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;
using NLog;
using NzbDrone.Core.Model.Notification;
namespace NzbDrone.Core.Providers
{
public class TimerProvider
{
private readonly RssSyncProvider _rssSyncProvider;
private readonly SeriesProvider _seriesProvider;
private readonly SeasonProvider _seasonProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly EpisodeProvider _episodeProvider;
private readonly MediaFileProvider _mediaFileProvider;
private Timer _rssSyncTimer;
private Timer _minuteTimer;
private readonly Timer _minuteTimer;
private readonly RssSyncProvider _rssSyncProvider;
private readonly Timer _rssSyncTimer;
private readonly SeasonProvider _seasonProvider;
private readonly SeriesProvider _seriesProvider;
private DateTime _rssSyncNextInterval;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public TimerProvider(RssSyncProvider rssSyncProvider, SeriesProvider seriesProvider, SeasonProvider seasonProvider, EpisodeProvider episodeProvider, MediaFileProvider mediaFileProvider)
public TimerProvider(RssSyncProvider rssSyncProvider, SeriesProvider seriesProvider,
SeasonProvider seasonProvider, EpisodeProvider episodeProvider,
MediaFileProvider mediaFileProvider)
{
_rssSyncProvider = rssSyncProvider;
_seriesProvider = seriesProvider;
@ -33,8 +31,6 @@ public TimerProvider(RssSyncProvider rssSyncProvider, SeriesProvider seriesProvi
_minuteTimer = new Timer(60000);
}
#region TimerProvider Members
public virtual void ResetRssSyncTimer()
{
double interval = _rssSyncTimer.Interval;
@ -43,13 +39,14 @@ public virtual void ResetRssSyncTimer()
public virtual void StartRssSyncTimer()
{
if (_rssSyncTimer.Interval < 900000) //If Timer is less than 15 minutes, throw an error! This should also be handled when saving the config, though a user could by-pass it by editing the DB directly... TNO (Trust No One)
if (_rssSyncTimer.Interval < 900000)
//If Timer is less than 15 minutes, throw an error! This should also be handled when saving the config, though a user could by-pass it by editing the DB directly... TNO (Trust No One)
{
Logger.Error("RSS Sync Frequency is invalid, please set the interval first");
throw new InvalidOperationException("RSS Sync Frequency Invalid");
}
_rssSyncTimer.Elapsed += new ElapsedEventHandler(RunRssSync);
_rssSyncTimer.Elapsed += RunRssSync;
_rssSyncTimer.Start();
_rssSyncNextInterval = DateTime.Now.AddMilliseconds(_rssSyncTimer.Interval);
}
@ -77,7 +74,7 @@ public virtual DateTime NextRssSyncTime()
public virtual void StartMinuteTimer()
{
_minuteTimer.Elapsed += new ElapsedEventHandler(MinuteTimer_Elapsed);
_minuteTimer.Elapsed += MinuteTimer_Elapsed;
_minuteTimer.Start();
}
@ -86,8 +83,6 @@ public virtual void StopMinuteTimer()
_minuteTimer.Stop();
}
#endregion
private void RunRssSync(object obj, ElapsedEventArgs args)
{
_rssSyncNextInterval = DateTime.Now.AddMilliseconds(_rssSyncTimer.Interval);

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using NLog;
using TvdbLib;
@ -11,10 +10,12 @@ namespace NzbDrone.Core.Providers
{
public class TvDbProvider
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private static readonly Regex CleanUpRegex = new Regex(@"((\s|^)the(\s|$))|((\s|^)and(\s|$))|[^a-z]", RegexOptions.IgnoreCase | RegexOptions.Compiled);
private const string TVDB_APIKEY = "5D2D188E86E07F4F";
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private static readonly Regex CleanUpRegex = new Regex(@"((\s|^)the(\s|$))|((\s|^)and(\s|$))|[^a-z]",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
private readonly TvdbHandler _handler;
public TvDbProvider()
@ -22,8 +23,6 @@ public TvDbProvider()
_handler = new TvdbHandler(new XmlCacheProvider(CentralDispatch.AppPath + @"\cache\tvdb"), TVDB_APIKEY);
}
#region TvDbProvider Members
public virtual IList<TvdbSearchResult> SearchSeries(string title)
{
Logger.Debug("Searching TVDB for '{0}'", title);
@ -85,8 +84,6 @@ public virtual TvdbSeries GetSeries(int id, bool loadEpisodes)
/// </returns>
public static bool IsTitleMatch(string directoryName, string tvdbTitle)
{
var result = false;
if (String.IsNullOrEmpty(directoryName))
@ -98,14 +95,13 @@ public static bool IsTitleMatch(string directoryName, string tvdbTitle)
{
result = true;
}
else if (String.Equals(CleanUpRegex.Replace(directoryName, ""), CleanUpRegex.Replace(tvdbTitle, ""), StringComparison.InvariantCultureIgnoreCase))
else if (String.Equals(CleanUpRegex.Replace(directoryName, ""), CleanUpRegex.Replace(tvdbTitle, ""),
StringComparison.InvariantCultureIgnoreCase))
result = true;
Logger.Debug("Match between '{0}' and '{1}' was {2}", tvdbTitle, directoryName, result);
return result;
}
#endregion
}
}

View File

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository;
using SubSonic.Repository;
@ -10,18 +9,18 @@ namespace NzbDrone.Core.Providers
{
public class UpcomingEpisodesProvider
{
private IRepository _sonicRepo;
private readonly IRepository _sonicRepo;
public UpcomingEpisodesProvider(IRepository sonicRepo)
{
_sonicRepo = sonicRepo;
}
#region UpcomingEpisodesProvider Members
public virtual UpcomingEpisodesModel Upcoming()
{
var allEps = _sonicRepo.All<Episode>().Where(e => e.AirDate >= DateTime.Today.AddDays(-1) && e.AirDate < DateTime.Today.AddDays(8));
var allEps =
_sonicRepo.All<Episode>().Where(
e => e.AirDate >= DateTime.Today.AddDays(-1) && e.AirDate < DateTime.Today.AddDays(8));
var yesterday = allEps.Where(e => e.AirDate == DateTime.Today.AddDays(-1)).ToList();
var today = allEps.Where(e => e.AirDate == DateTime.Today).ToList();
@ -42,9 +41,9 @@ public virtual List<Episode> Today()
public virtual List<Episode> Week()
{
return _sonicRepo.All<Episode>().Where(e => e.AirDate > DateTime.Today && e.AirDate < DateTime.Today.AddDays(8)).ToList();
}
#endregion
return
_sonicRepo.All<Episode>().Where(e => e.AirDate > DateTime.Today && e.AirDate < DateTime.Today.AddDays(8))
.ToList();
}
}
}

View File

@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using NLog;
using NzbDrone.Core.Helpers;
@ -12,19 +10,16 @@ namespace NzbDrone.Core.Providers
{
public class XbmcProvider
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly ConfigProvider _configProvider;
private readonly HttpProvider _httpProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public XbmcProvider(ConfigProvider configProvider, HttpProvider httpProvider)
{
_configProvider = configProvider;
_httpProvider = httpProvider;
}
#region XbmcProvider Members
public virtual void Notify(string header, string message)
{
//Get time in seconds and convert to ms
@ -55,7 +50,8 @@ public virtual void Update(int seriesId)
var xbmcSeriesPath = GetXbmcSeriesPath(host, seriesId);
//If the path is not found & the user wants to update the entire library, do it now.
if (String.IsNullOrEmpty(xbmcSeriesPath) && Convert.ToBoolean(_configProvider.GetValue("XbmcFullUpdate", false, true)))
if (String.IsNullOrEmpty(xbmcSeriesPath) &&
Convert.ToBoolean(_configProvider.GetValue("XbmcFullUpdate", false, true)))
{
//Update the entire library
Logger.Trace("Series [{0}] doesn't exist on XBMC host: {1}, Updating Entire Library", seriesId, host);
@ -78,8 +74,6 @@ public virtual void Clean()
}
}
#endregion
private string SendCommand(string host, string command)
{
var username = _configProvider.GetValue("XbmcUsername", String.Empty, true);
@ -96,10 +90,14 @@ private string SendCommand(string host, string command)
private string GetXbmcSeriesPath(string host, int seriesId)
{
var query = String.Format("select path.strPath from path, tvshow, tvshowlinkpath where tvshow.c12 = {0} and tvshowlinkpath.idShow = tvshow.idShow and tvshowlinkpath.idPath = path.idPath", seriesId);
var query =
String.Format(
"select path.strPath from path, tvshow, tvshowlinkpath where tvshow.c12 = {0} and tvshowlinkpath.idShow = tvshow.idShow and tvshowlinkpath.idPath = path.idPath",
seriesId);
var command = String.Format("QueryVideoDatabase({0})", query);
var setResponseCommand = "SetResponseFormat(webheader;false;webfooter;false;header;<xml>;footer;</xml>;opentag;<tag>;closetag;</tag>;closefinaltag;false)";
var setResponseCommand =
"SetResponseFormat(webheader;false;webfooter;false;header;<xml>;footer;</xml>;opentag;<tag>;closetag;</tag>;closefinaltag;false)";
var resetResponseCommand = "SetResponseFormat()";
SendCommand(host, setResponseCommand);

View File

@ -9,6 +9,7 @@ public class Episode
{
[SubSonicPrimaryKey(false)]
public virtual int EpisodeId { get; set; }
public virtual int SeriesId { get; set; }
public virtual int EpisodeFileId { get; set; }
public virtual int SeasonId { get; set; }
@ -16,8 +17,10 @@ public class Episode
public int EpisodeNumber { get; set; }
public string Title { get; set; }
public DateTime AirDate { get; set; }
[SubSonicLongString]
public string Overview { get; set; }
public string Language { get; set; }
public EpisodeStatusType Status { get; set; }

View File

@ -9,6 +9,7 @@ public class EpisodeFile
{
[SubSonicPrimaryKey]
public virtual int EpisodeFileId { get; set; }
public virtual int SeriesId { get; set; }
public string Path { get; set; }
public QualityTypes Quality { get; set; }

View File

@ -8,6 +8,7 @@ public class History
{
[SubSonicPrimaryKey]
public virtual int HistoryId { get; set; }
public virtual int EpisodeId { get; set; }
public virtual int IndexerId { get; set; }
public string NzbTitle { get; set; }

View File

@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using SubSonic.SqlGeneration.Schema;
namespace NzbDrone.Core.Repository
@ -19,6 +15,7 @@ public class Indexer
[SubSonicNullStringAttribute]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public string ApiUrl { get; set; }
public bool Enabled { get; set; }
public int Order { get; set; }

View File

@ -15,6 +15,7 @@ public class QualityProfile
[DisplayName("Name")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public string Name { get; set; }
public bool UserProfile { get; set; } //Allows us to tell the difference between default and user profiles
[SubSonicIgnore]

View File

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SubSonic.SqlGeneration.Schema;
using SubSonic.SqlGeneration.Schema;
namespace NzbDrone.Core.Repository
{

View File

@ -8,6 +8,7 @@ public class Season
{
[SubSonicPrimaryKey(false)]
public virtual int SeasonId { get; set; }
public virtual int SeriesId { get; set; }
public virtual int SeasonNumber { get; set; }
public bool Monitored { get; set; }

View File

@ -1,21 +1,18 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Xml;
using System.Xml.Linq;
namespace NzbDrone.PostProcessor
{
class Program
internal class Program
{
private static string _host = "localhost";
private static int _port = 8989;
private static string _apiKey = String.Empty;
static void Main(string[] args)
private static void Main(string[] args)
{
try
{
@ -35,7 +32,8 @@ static void Main(string[] args)
var hostString = _host + ":" + _port;
var url = String.Format("http://{0}/?apiKey={1}&dir={2}&nzbName={3}&category={4}", hostString, _apiKey, dir, nzbName, category);
var url = String.Format("http://{0}/?apiKey={1}&dir={2}&nzbName={3}&category={4}", hostString, _apiKey,
dir, nzbName, category);
var webClient = new WebClient();
webClient.DownloadString(url);
@ -46,7 +44,7 @@ static void Main(string[] args)
}
}
static bool LoadConfig()
private static bool LoadConfig()
{
var configFile = "PostProcessor.xml";
if (!File.Exists(configFile))
@ -65,8 +63,10 @@ static bool LoadConfig()
}
var hostNode = config.Descendants("Host").FirstOrDefault();
var portNode = config.Descendants("Port").FirstOrDefault(); ;
var apiKeyNode = config.Descendants("ApiKey").FirstOrDefault(); ;
var portNode = config.Descendants("Port").FirstOrDefault();
;
var apiKeyNode = config.Descendants("ApiKey").FirstOrDefault();
;
if (hostNode == null || portNode == null || apiKeyNode == null)
{

View File

@ -1,10 +1,10 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("NzbDrone.PostProcessor")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
@ -17,9 +17,11 @@
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("6521fcb0-15dc-4324-b08a-f18f87d78859")]
// Version information for an assembly consists of the following four values:
@ -32,5 +34,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
@ -12,16 +10,17 @@ namespace NzbDrone.Web.Controllers
{
public class AddSeriesController : Controller
{
private readonly SyncProvider _syncProvider;
private readonly RootDirProvider _rootFolderProvider;
private readonly ConfigProvider _configProvider;
private readonly QualityProvider _qualityProvider;
private readonly TvDbProvider _tvDbProvider;
private readonly RootDirProvider _rootFolderProvider;
private readonly SeriesProvider _seriesProvider;
private readonly SyncProvider _syncProvider;
private readonly TvDbProvider _tvDbProvider;
public AddSeriesController(SyncProvider syncProvider, RootDirProvider rootFolderProvider, ConfigProvider configProvider,
QualityProvider qualityProvider, TvDbProvider tvDbProvider, SeriesProvider seriesProvider)
public AddSeriesController(SyncProvider syncProvider, RootDirProvider rootFolderProvider,
ConfigProvider configProvider,
QualityProvider qualityProvider, TvDbProvider tvDbProvider,
SeriesProvider seriesProvider)
{
_syncProvider = syncProvider;
_rootFolderProvider = rootFolderProvider;
@ -78,7 +77,6 @@ public ActionResult AddExisting()
public ActionResult RenderPartial(string path)
{
var suggestions = GetSuggestionList(new DirectoryInfo(path).Name);
ViewData["guid"] = Guid.NewGuid();
@ -92,10 +90,10 @@ public ActionResult RenderPartial(string path)
qualityProfiles,
"QualityProfileId",
"Name",
defaultQuality); ;
defaultQuality);
;
return PartialView("AddSeriesItem", suggestions);
}
public JsonResult AddSeries(string path, int seriesId, int qualityProfileId)
@ -104,9 +102,11 @@ public JsonResult AddSeries(string path, int seriesId, int qualityProfileId)
//Create new folder for series
//Add the new series to the Database
_seriesProvider.AddSeries(path.Replace('|', Path.DirectorySeparatorChar).Replace('^', Path.VolumeSeparatorChar), seriesId, qualityProfileId);
_seriesProvider.AddSeries(
path.Replace('|', Path.DirectorySeparatorChar).Replace('^', Path.VolumeSeparatorChar), seriesId,
qualityProfileId);
ScanNewSeries();
return new JsonResult() { Data = "ok" };
return new JsonResult {Data = "ok"};
}
[HttpPost]
@ -133,6 +133,5 @@ public SelectList GetSuggestionList(string searchString)
return new SelectList(dataVal, "Id", "SeriesName", selectId);
}
}
}

View File

@ -1,11 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Xml.Linq;
using System.Web.Mvc;
using NLog;
using NzbDrone.Core;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
@ -13,10 +7,9 @@ namespace NzbDrone.Web.Controllers
{
public class ApiController : Controller
{
private readonly PostProcessingProvider _postProcessingProvider;
private readonly ConfigProvider _configProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly ConfigProvider _configProvider;
private readonly PostProcessingProvider _postProcessingProvider;
public ApiController(PostProcessingProvider postProcessingProvider, ConfigProvider configProvider)
{

View File

@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Linq;
using System.Web.Mvc;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Web.Models;
using Telerik.Web.Mvc;
@ -12,7 +8,7 @@ namespace NzbDrone.Web.Controllers
{
public class HistoryController : Controller
{
private HistoryProvider _historyProvider;
private readonly HistoryProvider _historyProvider;
public HistoryController(HistoryProvider historyProvider)
{

View File

@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc;
using NzbDrone.Core.Instrumentation;
using SubSonic.Repository;
using Telerik.Web.Mvc;
namespace NzbDrone.Web.Controllers
@ -28,7 +23,6 @@ public ActionResult Clear()
{
_logProvider.DeleteAll();
return RedirectToAction("Index");
}
[GridAction]

View File

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc;
using NzbDrone.Core.Providers;
namespace NzbDrone.Web.Controllers
@ -29,6 +25,5 @@ public JsonResult Index()
return Json(message, JsonRequestBehavior.AllowGet);
}
}
}

View File

@ -1,34 +1,27 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.Mvc;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Web.Models;
using Telerik.Web.Mvc;
using TvdbLib.Data;
using EpisodeModel = NzbDrone.Web.Models.EpisodeModel;
namespace NzbDrone.Web.Controllers
{
[HandleError]
public class SeriesController : Controller
{
private readonly SeriesProvider _seriesProvider;
private readonly EpisodeProvider _episodeProvider;
private readonly SyncProvider _syncProvider;
private readonly RssSyncProvider _rssSyncProvider;
private readonly QualityProvider _qualityProvider;
private readonly MediaFileProvider _mediaFileProvider;
private readonly QualityProvider _qualityProvider;
private readonly RenameProvider _renameProvider;
private readonly RootDirProvider _rootDirProvider;
private readonly RssSyncProvider _rssSyncProvider;
private readonly SeriesProvider _seriesProvider;
private readonly SyncProvider _syncProvider;
private readonly TvDbProvider _tvDbProvider;
//
// GET: /Series/
@ -57,9 +50,6 @@ public ActionResult Index()
}
public ActionResult RssSync()
{
_rssSyncProvider.Begin();
@ -68,7 +58,7 @@ public ActionResult RssSync()
public ActionResult UnMapped(string path)
{
return View(_syncProvider.GetUnmappedFolders(path).Select(c => new MappingModel() { Id = 1, Path = c }).ToList());
return View(_syncProvider.GetUnmappedFolders(path).Select(c => new MappingModel {Id = 1, Path = c}).ToList());
}
public ActionResult LoadEpisodes(int seriesId)
@ -76,24 +66,32 @@ public ActionResult LoadEpisodes(int seriesId)
_episodeProvider.RefreshEpisodeInfo(seriesId);
return RedirectToAction("Details", new
{
seriesId = seriesId
seriesId
});
}
[GridAction]
public ActionResult _AjaxSeasonGrid(int seasonId)
{
var episodes = _episodeProvider.GetEpisodeBySeason(seasonId).Select(c => new EpisodeModel()
var episodes = _episodeProvider.GetEpisodeBySeason(seasonId).Select(c => new EpisodeModel
{
EpisodeId = c.EpisodeId,
EpisodeNumber = c.EpisodeNumber,
SeasonNumber = c.SeasonNumber,
EpisodeNumber =
c.EpisodeNumber,
SeasonNumber =
c.SeasonNumber,
Title = c.Title,
Overview = c.Overview,
AirDate = c.AirDate,
Path = GetEpisodePath(c.EpisodeFile),
Quality = c.EpisodeFile == null ? String.Empty : c.EpisodeFile.Quality.ToString()
Path =
GetEpisodePath(
c.EpisodeFile),
Quality =
c.EpisodeFile == null
? String.Empty
: c.EpisodeFile.
Quality.
ToString()
});
return View(new GridModel(episodes));
}
@ -163,7 +161,6 @@ public ActionResult SearchForSeries(string seriesName)
private IEnumerable<Episode> GetData(GridCommand command)
{
return null;
/*
IQueryable<Episode> data = .Orders;

View File

@ -1,11 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.Mvc;
using NLog;
using NzbDrone.Core;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
@ -19,14 +16,13 @@ namespace NzbDrone.Web.Controllers
[HandleError]
public class SettingsController : Controller
{
private ConfigProvider _configProvider;
private IndexerProvider _indexerProvider;
private QualityProvider _qualityProvider;
private RootDirProvider _rootDirProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private const string SETTINGS_SAVED = "Settings Saved.";
private const string SETTINGS_FAILED = "Error Saving Settings, please fix any errors";
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly ConfigProvider _configProvider;
private readonly IndexerProvider _indexerProvider;
private readonly QualityProvider _qualityProvider;
private readonly RootDirProvider _rootDirProvider;
public SettingsController(ConfigProvider configProvider, IndexerProvider indexerProvider,
QualityProvider qualityProvider, RootDirProvider rootDirProvider)
@ -63,8 +59,10 @@ public ActionResult Indexers()
ViewData["viewName"] = "Indexers";
return View("Index", new IndexerSettingsModel
{
NzbMatrixUsername = _configProvider.GetValue("NzbMatrixUsername", String.Empty, true),
NzbMatrixApiKey = _configProvider.GetValue("NzbMatrixApiKey", String.Empty, true),
NzbMatrixUsername =
_configProvider.GetValue("NzbMatrixUsername", String.Empty, true),
NzbMatrixApiKey =
_configProvider.GetValue("NzbMatrixApiKey", String.Empty, true),
NzbsOrgUId = _configProvider.GetValue("NzbsOrgUId", String.Empty, true),
NzbsOrgHash = _configProvider.GetValue("NzbsOrgHash", String.Empty, true),
NzbsrusUId = _configProvider.GetValue("NzbsrusUId", String.Empty, true),
@ -80,7 +78,8 @@ public ActionResult Downloads()
var model = new DownloadSettingsModel
{
SyncFrequency = Convert.ToInt32(_configProvider.GetValue("SyncFrequency", "15", true)),
DownloadPropers = Convert.ToBoolean(_configProvider.GetValue("DownloadPropers", "false", true)),
DownloadPropers =
Convert.ToBoolean(_configProvider.GetValue("DownloadPropers", "false", true)),
Retention = Convert.ToInt32(_configProvider.GetValue("Retention", "500", true)),
SabHost = _configProvider.GetValue("SabHost", "localhost", true),
SabPort = Convert.ToInt32(_configProvider.GetValue("SabPort", "8080", true)),
@ -88,7 +87,10 @@ public ActionResult Downloads()
SabUsername = _configProvider.GetValue("SabUsername", String.Empty, true),
SabPassword = _configProvider.GetValue("SabPassword", String.Empty, true),
SabTvCategory = _configProvider.GetValue("SabTvCategory", String.Empty, true),
SabTvPriority = (SabnzbdPriorityType)Enum.Parse(typeof(SabnzbdPriorityType), _configProvider.GetValue("SabTvPriority", "Normal", true)),
SabTvPriority =
(SabnzbdPriorityType)
Enum.Parse(typeof (SabnzbdPriorityType),
_configProvider.GetValue("SabTvPriority", "Normal", true)),
UseBlackHole = Convert.ToBoolean(_configProvider.GetValue("UseBlackHole", true, true)),
BlackholeDirectory = _configProvider.GetValue("BlackholeDirectory", String.Empty, true)
};
@ -112,7 +114,8 @@ public ActionResult Quality()
var userProfiles = _qualityProvider.GetAllProfiles().Where(q => q.UserProfile).ToList();
var profiles = _qualityProvider.GetAllProfiles().ToList();
var defaultQualityQualityProfileId = Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", profiles[0].QualityProfileId, true));
var defaultQualityQualityProfileId =
Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", profiles[0].QualityProfileId, true));
var selectList = new SelectList(profiles, "QualityProfileId", "Name");
@ -134,16 +137,25 @@ public ActionResult Notifications()
var model = new NotificationSettingsModel
{
XbmcEnabled = Convert.ToBoolean(_configProvider.GetValue("XbmcEnabled", false, true)),
XbmcNotifyOnGrab = Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnGrab", false, true)),
XbmcNotifyOnDownload = Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnDownload", false, true)),
XbmcNotifyOnRename = Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnRename", false, true)),
XbmcNotificationImage = Convert.ToBoolean(_configProvider.GetValue("XbmcNotificationImage", false, true)),
XbmcNotifyOnGrab =
Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnGrab", false, true)),
XbmcNotifyOnDownload =
Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnDownload", false, true)),
XbmcNotifyOnRename =
Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnRename", false, true)),
XbmcNotificationImage =
Convert.ToBoolean(_configProvider.GetValue("XbmcNotificationImage", false, true)),
XbmcDisplayTime = Convert.ToInt32(_configProvider.GetValue("XbmcDisplayTime", 3, true)),
XbmcUpdateOnDownload = Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnDownload ", false, true)),
XbmcUpdateOnRename = Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnRename", false, true)),
XbmcFullUpdate = Convert.ToBoolean(_configProvider.GetValue("XbmcFullUpdate", false, true)),
XbmcCleanOnDownload = Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnDownload", false, true)),
XbmcCleanOnRename = Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnRename", false, true)),
XbmcUpdateOnDownload =
Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnDownload ", false, true)),
XbmcUpdateOnRename =
Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnRename", false, true)),
XbmcFullUpdate =
Convert.ToBoolean(_configProvider.GetValue("XbmcFullUpdate", false, true)),
XbmcCleanOnDownload =
Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnDownload", false, true)),
XbmcCleanOnRename =
Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnRename", false, true)),
XbmcHosts = _configProvider.GetValue("XbmcHosts", "localhost:80", true),
XbmcUsername = _configProvider.GetValue("XbmcUsername", String.Empty, true),
XbmcPassword = _configProvider.GetValue("XbmcPassword", String.Empty, true)
@ -203,7 +215,8 @@ public ActionResult SubMenu()
public QualityModel GetUpdatedProfileList()
{
var profiles = _qualityProvider.GetAllProfiles().ToList();
var defaultQualityQualityProfileId = Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", profiles[0].QualityProfileId, true));
var defaultQualityQualityProfileId =
Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", profiles[0].QualityProfileId, true));
var selectList = new SelectList(profiles, "QualityProfileId", "Name");
return new QualityModel {DefaultQualityProfileId = defaultQualityQualityProfileId, SelectList = selectList};

View File

@ -1,15 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc;
using NzbDrone.Core.Providers;
namespace NzbDrone.Web.Controllers
{
public class SharedController : Controller
{
private TimerProvider _timerProvider;
private readonly TimerProvider _timerProvider;
public SharedController(TimerProvider timerProvider)
{

View File

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Linq;
using System.Web.Mvc;
using NzbDrone.Core.Providers;
using NzbDrone.Web.Models;
@ -11,7 +8,7 @@ namespace NzbDrone.Web.Controllers
{
public class UpcomingController : Controller
{
private UpcomingEpisodesProvider _upcomingEpisodesProvider;
private readonly UpcomingEpisodesProvider _upcomingEpisodesProvider;
public UpcomingController(UpcomingEpisodesProvider upcomingEpisodesProvider)
{

View File

@ -1,6 +1,5 @@
using System;
using System.Data.SQLite;
using System.Diagnostics;
using System.Reflection;
using System.Threading;
using System.Web;
@ -11,7 +10,6 @@
using NLog;
using NzbDrone.Core;
using NzbDrone.Core.Instrumentation;
using SubSonic.Repository;
namespace NzbDrone.Web
{
@ -21,7 +19,6 @@ public class MvcApplication : NinjectHttpApplication
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{*robotstxt}", new {robotstxt = @"(.*/)?robots.txt(/.*)?"});
routes.IgnoreRoute("{*favicon}", new {favicon = @"(.*/)?favicon.ico(/.*)?"});
@ -85,15 +82,11 @@ protected void Application_Error(object sender, EventArgs e)
Logger.Warn("Restarting application");
HttpRuntime.UnloadAppDomain();
}
}
protected void Application_BeginRequest()
{
Thread.CurrentThread.Name = "UI";
}
}
}

View File

@ -1,7 +1,7 @@
using System;
using System.Web.Mvc;
using System.Web;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
namespace NzbDrone.Web.Helpers
{
@ -15,7 +15,9 @@ public static IDisposable BeginCollectionItem(this HtmlHelper html, string colle
string itemIndex = idsToReuse.Count > 0 ? idsToReuse.Dequeue() : Guid.NewGuid().ToString();
// autocomplete="off" is needed to work around a very annoying Chrome behaviour whereby it reuses old values after the user clicks "Back", which causes the xyz.index and xyz[...] values to get out of sync.
html.ViewContext.Writer.WriteLine(string.Format("<input type=\"hidden\" name=\"{0}.index\" autocomplete=\"off\" value=\"{1}\" />", collectionName, itemIndex));
html.ViewContext.Writer.WriteLine(
string.Format("<input type=\"hidden\" name=\"{0}.index\" autocomplete=\"off\" value=\"{1}\" />",
collectionName, itemIndex));
return BeginHtmlFieldPrefixScope(html, string.Format("{0}[{1}]", collectionName, itemIndex));
}
@ -31,7 +33,8 @@ private static Queue<string> GetIdsToReuse(HttpContextBase httpContext, string c
// otherwise the framework won't render the validation error messages next to each item.
string key = idsToReuseKey + collectionName;
var queue = (Queue<string>) httpContext.Items[key];
if (queue == null) {
if (queue == null)
{
httpContext.Items[key] = queue = new Queue<string>();
var previouslyUsedIds = httpContext.Request[collectionName + ".index"];
if (!string.IsNullOrEmpty(previouslyUsedIds))
@ -41,10 +44,12 @@ private static Queue<string> GetIdsToReuse(HttpContextBase httpContext, string c
return queue;
}
#region Nested type: HtmlFieldPrefixScope
private class HtmlFieldPrefixScope : IDisposable
{
private readonly TemplateInfo templateInfo;
private readonly string previousHtmlFieldPrefix;
private readonly TemplateInfo templateInfo;
public HtmlFieldPrefixScope(TemplateInfo templateInfo, string htmlFieldPrefix)
{
@ -54,10 +59,16 @@ public HtmlFieldPrefixScope(TemplateInfo templateInfo, string htmlFieldPrefix)
templateInfo.HtmlFieldPrefix = htmlFieldPrefix;
}
#region IDisposable Members
public void Dispose()
{
templateInfo.HtmlFieldPrefix = previousHtmlFieldPrefix;
}
}
#endregion
}
#endregion
}
}

View File

@ -1,11 +1,11 @@
using System;
using System.Web.Mvc;
using System.Web.Mvc.Html;
namespace Helpers
{
public static class IsCurrentActionHelper
{
private static bool IsCurrentController(HtmlHelper helper, string actionName, string controllerName)
{
var currentControllerName = (string) helper.ViewContext.RouteData.Values["controller"];
@ -16,7 +16,8 @@ private static bool IsCurrentController(HtmlHelper helper, string actionName, st
return false;
}
public static string CurrentActionLink(this HtmlHelper helper, string text, string actionName, string controllerName)
public static string CurrentActionLink(this HtmlHelper helper, string text, string actionName,
string controllerName)
{
string result;
@ -30,7 +31,6 @@ public static string CurrentActionLink(this HtmlHelper helper, string text, stri
}
return result + helper.ActionLink(text, actionName, controllerName).ToHtmlString() + @"</li>";
}
}
}

View File

@ -1,18 +1,16 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
namespace NzbDrone.Web.Models
{
#region Models
[PropertiesMustMatch("NewPassword", "ConfirmPassword", ErrorMessage = "The new password and confirmation password do not match.")]
[PropertiesMustMatch("NewPassword", "ConfirmPassword",
ErrorMessage = "The new password and confirmation password do not match.")]
public class ChangePasswordModel
{
[Required]
@ -47,7 +45,8 @@ public class LogOnModel
public bool RememberMe { get; set; }
}
[PropertiesMustMatch("Password", "ConfirmPassword", ErrorMessage = "The password and confirmation password do not match.")]
[PropertiesMustMatch("Password", "ConfirmPassword",
ErrorMessage = "The password and confirmation password do not match.")]
public class RegisterModel
{
[Required]
@ -70,9 +69,11 @@ public class RegisterModel
[DisplayName("Confirm password")]
public string ConfirmPassword { get; set; }
}
#endregion
#region Services
// The FormsAuthentication type is sealed and contains static members, so it is difficult to
// unit test code that calls its members. The interface and helper class below demonstrate
// how to create an abstract wrapper around such a type in order to make the AccountController
@ -101,26 +102,29 @@ public AccountMembershipService(MembershipProvider provider)
_provider = provider ?? Membership.Provider;
}
#region IMembershipService Members
public int MinPasswordLength
{
get
{
return _provider.MinRequiredPasswordLength;
}
get { return _provider.MinRequiredPasswordLength; }
}
public bool ValidateUser(string userName, string password)
{
if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", "userName");
if (String.IsNullOrEmpty(password)) throw new ArgumentException("Value cannot be null or empty.", "password");
if (String.IsNullOrEmpty(userName))
throw new ArgumentException("Value cannot be null or empty.", "userName");
if (String.IsNullOrEmpty(password))
throw new ArgumentException("Value cannot be null or empty.", "password");
return _provider.ValidateUser(userName, password);
}
public MembershipCreateStatus CreateUser(string userName, string password, string email)
{
if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", "userName");
if (String.IsNullOrEmpty(password)) throw new ArgumentException("Value cannot be null or empty.", "password");
if (String.IsNullOrEmpty(userName))
throw new ArgumentException("Value cannot be null or empty.", "userName");
if (String.IsNullOrEmpty(password))
throw new ArgumentException("Value cannot be null or empty.", "password");
if (String.IsNullOrEmpty(email)) throw new ArgumentException("Value cannot be null or empty.", "email");
MembershipCreateStatus status;
@ -130,9 +134,12 @@ public MembershipCreateStatus CreateUser(string userName, string password, strin
public bool ChangePassword(string userName, string oldPassword, string newPassword)
{
if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", "userName");
if (String.IsNullOrEmpty(oldPassword)) throw new ArgumentException("Value cannot be null or empty.", "oldPassword");
if (String.IsNullOrEmpty(newPassword)) throw new ArgumentException("Value cannot be null or empty.", "newPassword");
if (String.IsNullOrEmpty(userName))
throw new ArgumentException("Value cannot be null or empty.", "userName");
if (String.IsNullOrEmpty(oldPassword))
throw new ArgumentException("Value cannot be null or empty.", "oldPassword");
if (String.IsNullOrEmpty(newPassword))
throw new ArgumentException("Value cannot be null or empty.", "newPassword");
// The underlying ChangePassword() will throw an exception rather
// than return false in certain failure scenarios.
@ -150,6 +157,8 @@ public bool ChangePassword(string userName, string oldPassword, string newPasswo
return false;
}
}
#endregion
}
public interface IFormsAuthenticationService
@ -160,9 +169,12 @@ public interface IFormsAuthenticationService
public class FormsAuthenticationService : IFormsAuthenticationService
{
#region IFormsAuthenticationService Members
public void SignIn(string userName, bool createPersistentCookie)
{
if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", "userName");
if (String.IsNullOrEmpty(userName))
throw new ArgumentException("Value cannot be null or empty.", "userName");
FormsAuthentication.SetAuthCookie(userName, createPersistentCookie);
}
@ -171,10 +183,14 @@ public void SignOut()
{
FormsAuthentication.SignOut();
}
#endregion
}
#endregion
#region Validation
public static class AccountValidation
{
public static string ErrorCodeToString(MembershipCreateStatus createStatus)
@ -205,13 +221,16 @@ public static string ErrorCodeToString(MembershipCreateStatus createStatus)
return "The user name provided is invalid. Please check the value and try again.";
case MembershipCreateStatus.ProviderError:
return "The authentication provider returned an error. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
return
"The authentication provider returned an error. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
case MembershipCreateStatus.UserRejected:
return "The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
return
"The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
default:
return "An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
return
"An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
}
}
}
@ -234,10 +253,7 @@ public PropertiesMustMatchAttribute(string originalProperty, string confirmPrope
public override object TypeId
{
get
{
return _typeId;
}
get { return _typeId; }
}
public override string FormatErrorMessage(string name)
@ -251,7 +267,7 @@ public override bool IsValid(object value)
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(value);
object originalValue = properties.Find(OriginalProperty, true /* ignoreCase */).GetValue(value);
object confirmValue = properties.Find(ConfirmProperty, true /* ignoreCase */).GetValue(value);
return Object.Equals(originalValue, confirmValue);
return Equals(originalValue, confirmValue);
}
}
@ -278,6 +294,6 @@ public override bool IsValid(object value)
return (valueAsString != null && valueAsString.Length >= _minCharacters);
}
}
#endregion
#endregion
}

View File

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Web;
using System.ComponentModel;
using System.Web.Mvc;
namespace NzbDrone.Web.Models

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace NzbDrone.Web.Models
namespace NzbDrone.Web.Models
{
public class AddExistingSeriesModel
{

View File

@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NzbDrone.Core.Repository;

View File

@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NzbDrone.Core.Model;
@ -11,110 +8,63 @@ namespace NzbDrone.Web.Models
{
public class DownloadSettingsModel
{
public SelectList PrioritySelectList =
new SelectList(new[] {"Default", "Paused", "Low", "Normal", "High", "Top"});
[Required]
[Range(15, 120, ErrorMessage = "Must be between 15 and 120 minutes")]
[DataType(DataType.Text)]
[DisplayName("Sync Frequency")]
public int SyncFrequency
{
get;
set;
}
public int SyncFrequency { get; set; }
[DisplayName("Download Propers")]
public bool DownloadPropers
{
get;
set;
}
public bool DownloadPropers { get; set; }
[Required(ErrorMessage = "Please enter a valid number")]
[DataType(DataType.Text)]
[DisplayName("Retention")]
public int Retention
{
get;
set;
}
public int Retention { get; set; }
[Required(ErrorMessage = "Please enter a valid host")]
[DataType(DataType.Text)]
[DisplayName("SABnzbd Host")]
public String SabHost
{
get;
set;
}
public String SabHost { get; set; }
[Required(ErrorMessage = "Please enter a valid port")]
[DataType(DataType.Text)]
[DisplayName("SABnzbd Port")]
public int SabPort
{
get;
set;
}
public int SabPort { get; set; }
[DataType(DataType.Text)]
[DisplayName("SABnzbd API Key")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String SabApiKey
{
get;
set;
}
public String SabApiKey { get; set; }
[DataType(DataType.Text)]
[DisplayName("SABnzbd Username")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String SabUsername
{
get;
set;
}
public String SabUsername { get; set; }
[DataType(DataType.Text)]
[DisplayName("SABnzbd Password")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String SabPassword
{
get;
set;
}
public String SabPassword { get; set; }
[DataType(DataType.Text)]
[DisplayFormat(ConvertEmptyStringToNull = false)]
[DisplayName("SABnzbd TV Category")]
public String SabTvCategory
{
get;
set;
}
public String SabTvCategory { get; set; }
[Required(ErrorMessage = "Please select a valid priority")]
[DisplayName("SABnzbd Priority")]
public SabnzbdPriorityType SabTvPriority
{
get;
set;
}
public SabnzbdPriorityType SabTvPriority { get; set; }
[DisplayName("Use Blackhole")]
public bool UseBlackHole
{
get;
set;
}
public bool UseBlackHole { get; set; }
[DataType(DataType.Text)]
[DisplayFormat(ConvertEmptyStringToNull = false)]
[DisplayName("Blackhole Directory")]
public String BlackholeDirectory
{
get;
set;
}
public SelectList PrioritySelectList = new SelectList(new string[] { "Default", "Paused", "Low", "Normal", "High", "Top" });
public String BlackholeDirectory { get; set; }
}
}

View File

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Web.Models
{

View File

@ -1,11 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NzbDrone.Core.Model;
namespace NzbDrone.Web.Models
{

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Web.Models
{

View File

@ -2,8 +2,6 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using NzbDrone.Core.Repository;
namespace NzbDrone.Web.Models
@ -13,61 +11,33 @@ public class IndexerSettingsModel
[DataType(DataType.Text)]
[DisplayName("NZBMatrix Username")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String NzbMatrixUsername
{
get;
set;
}
public String NzbMatrixUsername { get; set; }
[DataType(DataType.Text)]
[DisplayName("NZBMatrix API Key")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String NzbMatrixApiKey
{
get;
set;
}
public String NzbMatrixApiKey { get; set; }
[DataType(DataType.Text)]
[DisplayName("NZBs.Org UID")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String NzbsOrgUId
{
get;
set;
}
public String NzbsOrgUId { get; set; }
[DataType(DataType.Text)]
[DisplayName("NZBs.Org Hash")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String NzbsOrgHash
{
get;
set;
}
public String NzbsOrgHash { get; set; }
[DataType(DataType.Text)]
[DisplayName("NZBsRus UID")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String NzbsrusUId
{
get;
set;
}
public String NzbsrusUId { get; set; }
[DataType(DataType.Text)]
[DisplayName("NZBsRus Hash")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String NzbsrusHash
{
get;
set;
}
public String NzbsrusHash { get; set; }
public List<Indexer> Indexers
{
get;
set;
}
public List<Indexer> Indexers { get; set; }
}
}

View File

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Web.Models
{

View File

@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
namespace NzbDrone.Web.Models
{

View File

@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NzbDrone.Core.Repository.Quality;

Some files were not shown because too many files have changed in this diff Show More