Still need to remove System.Data.Sqlite, prefer an option in OrmLite to pluralize table names.
pull/3113/head
markus101 12 years ago committed by kay.one
parent b9fac94eca
commit 4bb4faf626

@ -123,7 +123,7 @@
<Compile Include="Contract\ReportBase.cs" /> <Compile Include="Contract\ReportBase.cs" />
<Compile Include="Contract\ParseErrorReport.cs" /> <Compile Include="Contract\ParseErrorReport.cs" />
<Compile Include="Model\AuthenticationType.cs" /> <Compile Include="Model\AuthenticationType.cs" />
<Compile Include="PathExtentions.cs" /> <Compile Include="PathExtensions.cs" />
<Compile Include="DiskProvider.cs" /> <Compile Include="DiskProvider.cs" />
<Compile Include="EnvironmentProvider.cs" /> <Compile Include="EnvironmentProvider.cs" />
<Compile Include="Model\ProcessInfo.cs" /> <Compile Include="Model\ProcessInfo.cs" />

@ -3,7 +3,7 @@ using System.IO;
namespace NzbDrone.Common namespace NzbDrone.Common
{ {
public static class PathExtentions public static class PathExtensions
{ {
private const string WEB_FOLDER = "NzbDrone.Web\\"; private const string WEB_FOLDER = "NzbDrone.Web\\";
private const string APP_DATA = "App_Data\\"; private const string APP_DATA = "App_Data\\";
@ -135,5 +135,10 @@ namespace NzbDrone.Common
{ {
return Path.Combine(environmentProvider.ApplicationPath, NZBDRONE_EXE); return Path.Combine(environmentProvider.ApplicationPath, NZBDRONE_EXE);
} }
public static string GetNzbDroneDatabase(this EnvironmentProvider environmentProvider)
{
return Path.Combine(environmentProvider.GetAppDataPath(), NZBDRONE_DB);
}
} }
} }

@ -78,7 +78,7 @@ namespace NzbDrone.Core.Test.JobTests
[Test] [Test]
public void running_scheduled_jobs_should_updates_last_execution_time() public void running_scheduled_jobs_should_updates_last_execution_time()
{ {
GivenPendingJob(new List<JobDefinition> { new JobDefinition { TypeName = _fakeJob.GetType().FullName } }); GivenPendingJob(new List<JobDefinition> { new JobDefinition { Type = _fakeJob.GetType().FullName } });
Subject.EnqueueScheduled(); Subject.EnqueueScheduled();
WaitForQueue(); WaitForQueue();
@ -91,7 +91,7 @@ namespace NzbDrone.Core.Test.JobTests
[Test] [Test]
public void failing_scheduled_job_should_mark_job_as_failed() public void failing_scheduled_job_should_mark_job_as_failed()
{ {
GivenPendingJob(new List<JobDefinition> { new JobDefinition { TypeName = _brokenJob.GetType().FullName } }); GivenPendingJob(new List<JobDefinition> { new JobDefinition { Type = _brokenJob.GetType().FullName } });
Subject.EnqueueScheduled(); Subject.EnqueueScheduled();
WaitForQueue(); WaitForQueue();
@ -193,7 +193,7 @@ namespace NzbDrone.Core.Test.JobTests
[Test] [Test]
public void Item_added_to_queue_while_scheduler_runs_should_be_executed() public void Item_added_to_queue_while_scheduler_runs_should_be_executed()
{ {
GivenPendingJob(new List<JobDefinition> { new JobDefinition { TypeName = _slowJob.GetType().FullName } }); GivenPendingJob(new List<JobDefinition> { new JobDefinition { Type = _slowJob.GetType().FullName } });
var jobThread = new Thread(Subject.EnqueueScheduled); var jobThread = new Thread(Subject.EnqueueScheduled);
jobThread.Start(); jobThread.Start();
@ -219,7 +219,7 @@ namespace NzbDrone.Core.Test.JobTests
[Test] [Test]
public void scheduled_job_should_have_scheduler_as_source() public void scheduled_job_should_have_scheduler_as_source()
{ {
GivenPendingJob(new List<JobDefinition> { new JobDefinition { TypeName = _slowJob.GetType().FullName }, new JobDefinition { TypeName = _slowJob2.GetType().FullName } }); GivenPendingJob(new List<JobDefinition> { new JobDefinition { Type = _slowJob.GetType().FullName }, new JobDefinition { Type = _slowJob2.GetType().FullName } });
Subject.EnqueueScheduled(); Subject.EnqueueScheduled();
Subject.Queue.Should().OnlyContain(c => c.Source == JobQueueItem.JobSourceType.Scheduler); Subject.Queue.Should().OnlyContain(c => c.Source == JobQueueItem.JobSourceType.Scheduler);

@ -43,7 +43,7 @@ namespace NzbDrone.Core.Test.JobTests
Storage.All().Should().HaveCount(1); Storage.All().Should().HaveCount(1);
StoredModel.Interval.Should().Be((Int32)_fakeJob.DefaultInterval.TotalMinutes); StoredModel.Interval.Should().Be((Int32)_fakeJob.DefaultInterval.TotalMinutes);
StoredModel.Name.Should().Be(_fakeJob.Name); StoredModel.Name.Should().Be(_fakeJob.Name);
StoredModel.TypeName.Should().Be(_fakeJob.GetType().ToString()); StoredModel.Type.Should().Be(_fakeJob.GetType().ToString());
StoredModel.LastExecution.Should().HaveYear(DateTime.Now.Year); StoredModel.LastExecution.Should().HaveYear(DateTime.Now.Year);
StoredModel.LastExecution.Should().HaveMonth(DateTime.Now.Month); StoredModel.LastExecution.Should().HaveMonth(DateTime.Now.Month);
StoredModel.LastExecution.Should().HaveDay(DateTime.Today.Day); StoredModel.LastExecution.Should().HaveDay(DateTime.Today.Day);
@ -66,7 +66,7 @@ namespace NzbDrone.Core.Test.JobTests
Subject.Init(); Subject.Init();
AllStoredModels.Should().HaveCount(1); AllStoredModels.Should().HaveCount(1);
AllStoredModels.Should().NotContain(c => c.TypeName == deletedJob.TypeName); AllStoredModels.Should().NotContain(c => c.Type == deletedJob.Type);
} }
[Test] [Test]
@ -88,7 +88,7 @@ namespace NzbDrone.Core.Test.JobTests
AllStoredModels.Should().HaveCount(1); AllStoredModels.Should().HaveCount(1);
AllStoredModels.Should().NotContain(c => c.TypeName == deletedJob.TypeName); AllStoredModels.Should().NotContain(c => c.Type == deletedJob.Type);
} }
[Test] [Test]
@ -98,7 +98,7 @@ namespace NzbDrone.Core.Test.JobTests
var oldJob = Builder<JobDefinition>.CreateNew() var oldJob = Builder<JobDefinition>.CreateNew()
.With(c => c.Id = 0) .With(c => c.Id = 0)
.With(c => c.Name = "OldName") .With(c => c.Name = "OldName")
.With(c => c.TypeName = typeof(FakeJob).ToString()) .With(c => c.Type = typeof(FakeJob).ToString())
.With(c => c.Interval = 0) .With(c => c.Interval = 0)
.With(c => c.Enable = true) .With(c => c.Enable = true)
.With(c => c.Success = true) .With(c => c.Success = true)
@ -116,7 +116,7 @@ namespace NzbDrone.Core.Test.JobTests
AllStoredModels.Should().HaveCount(1); AllStoredModels.Should().HaveCount(1);
StoredModel.TypeName.Should().Be(newJob.GetType().FullName); StoredModel.Type.Should().Be(newJob.GetType().FullName);
StoredModel.Name.Should().Be(newJob.Name); StoredModel.Name.Should().Be(newJob.Name);
StoredModel.Interval.Should().Be((int)newJob.DefaultInterval.TotalMinutes); StoredModel.Interval.Should().Be((int)newJob.DefaultInterval.TotalMinutes);
StoredModel.Enable.Should().Be(true); StoredModel.Enable.Should().Be(true);

@ -7,7 +7,6 @@ namespace NzbDrone.Core.Configuration
{ {
[Index(Unique = true)] [Index(Unique = true)]
public string Key { get; set; } public string Key { get; set; }
public string Value { get; set; } public string Value { get; set; }
} }
} }

@ -24,7 +24,6 @@ namespace NzbDrone.Core
containerBuilder.InitDatabase(); containerBuilder.InitDatabase();
containerBuilder.RegisterModule<LogInjectionModule>(); containerBuilder.RegisterModule<LogInjectionModule>();
} }
@ -53,22 +52,16 @@ namespace NzbDrone.Core
{ {
logger.Info("Registering Database..."); logger.Info("Registering Database...");
var appDataPath = new EnvironmentProvider().GetAppDataPath(); var environmentProvider = new EnvironmentProvider();
var appDataPath = environmentProvider.GetAppDataPath();
if (!Directory.Exists(appDataPath)) Directory.CreateDirectory(appDataPath); if (!Directory.Exists(appDataPath)) Directory.CreateDirectory(appDataPath);
container.Register(c => container.Register(c =>
{ {
return c.Resolve<IDbFactory>().Create(); return c.Resolve<IDbFactory>().Create(environmentProvider.GetNzbDroneDatabase());
}).As<IDbConnection>().SingleInstance();
container.Register(c =>
{
return c.Resolve<IDbFactory>().Create();
}).As<IDbConnection>().SingleInstance(); }).As<IDbConnection>().SingleInstance();
container.RegisterGeneric(typeof(BasicRepository<>)).As(typeof(IBasicRepository<>)); container.RegisterGeneric(typeof(BasicRepository<>)).As(typeof(IBasicRepository<>));
} }
} }
} }

@ -28,6 +28,8 @@ namespace NzbDrone.Core.Datastore
connectionString = GetConnectionString(dbPath); connectionString = GetConnectionString(dbPath);
} }
MigrationHelper.MigrateToLatest(connectionString, MigrationType.Main);
OrmLiteConfig.DialectProvider = new SqliteOrmLiteDialectProvider(); OrmLiteConfig.DialectProvider = new SqliteOrmLiteDialectProvider();
var dbFactory = new OrmLiteConnectionFactory(connectionString); var dbFactory = new OrmLiteConnectionFactory(connectionString);
var connection = dbFactory.Open(); var connection = dbFactory.Open();

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using FluentMigrator;
using FluentMigrator.Runner;
using FluentMigrator.Runner.Initialization;
namespace NzbDrone.Core.Datastore
{
public static class MigrationHelper
{
public static void MigrateToLatest(string connectionString, MigrationType migrationType)
{
var announcer = new NlogAnnouncer();
var assembly = Assembly.GetExecutingAssembly();
var migrationContext = new RunnerContext(announcer)
{
Namespace = "NzbDrone.Core.Datastore.Migrations",
ApplicationContext = migrationType
};
var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
var factory = new FluentMigrator.Runner.Processors.Sqlite.SqliteProcessorFactory();
var processor = factory.Create(connectionString, announcer, options);
var runner = new MigrationRunner(assembly, migrationContext, processor);
runner.MigrateUp(true);
}
}
public class MigrationOptions : IMigrationProcessorOptions
{
public bool PreviewOnly { get; set; }
public int Timeout { get; set; }
}
}

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Datastore
{
public enum MigrationType
{
Main,
Log
}
}

@ -0,0 +1,168 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentMigrator;
namespace NzbDrone.Core.Datastore.Migrations
{
[Tags("")]
[Migration(20130324)]
public class Migration20130324 : NzbDroneMigration
{
protected override void MainDbUpgrade()
{
Create.Table("Config")
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
.WithColumn("Key").AsString().PrimaryKey()
.WithColumn("Value").AsString().NotNullable();
Create.Table("EpisodeFiles")
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
.WithColumn("SeriesId").AsInt32().NotNullable()
.WithColumn("Path").AsString().NotNullable()
.WithColumn("Quality").AsInt32().NotNullable()
.WithColumn("Proper").AsBoolean().NotNullable()
.WithColumn("Size").AsInt64().NotNullable()
.WithColumn("DateAdded").AsDateTime().NotNullable()
.WithColumn("SeasonNumber").AsInt32().NotNullable()
.WithColumn("SceneName").AsString().Nullable()
.WithColumn("ReleaseGroup").AsString().Nullable();
Create.Table("Episodes")
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
.WithColumn("TvdbId").AsInt32().Nullable()
.WithColumn("SeriesId").AsInt32().NotNullable()
.WithColumn("SeasonNumber").AsInt32().NotNullable()
.WithColumn("EpisodeNumber").AsInt32().NotNullable()
.WithColumn("Title").AsString().Nullable()
.WithColumn("Overview").AsString().Nullable()
.WithColumn("Ignored").AsBoolean().Nullable()
.WithColumn("EpisodeFileId").AsInt32().Nullable()
.WithColumn("AirDate").AsDateTime().Nullable()
.WithColumn("GrabDate").AsDateTime().Nullable()
.WithColumn("PostDownloadStatus").AsInt32().Nullable()
.WithColumn("AbsoluteEpisodeNumber").AsInt32().Nullable()
.WithColumn("SceneAbsoluteEpisodeNumber").AsInt32().Nullable()
.WithColumn("SceneSeasonNumber").AsInt32().Nullable()
.WithColumn("SceneEpisodeNumber").AsInt32().Nullable();
Create.Table("ExternalNotificationDefinitions")
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
.WithColumn("Enable").AsBoolean().NotNullable()
.WithColumn("Type").AsString().NotNullable()
.WithColumn("Name").AsString().NotNullable();
Create.Table("History")
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
.WithColumn("EpisodeId").AsInt32().NotNullable()
.WithColumn("SeriesId").AsInt32().NotNullable()
.WithColumn("NzbTitle").AsString().NotNullable()
.WithColumn("Date").AsDateTime().NotNullable()
.WithColumn("Quality").AsInt32().NotNullable()
.WithColumn("Proper").AsBoolean().NotNullable()
.WithColumn("Indexer").AsString().NotNullable()
.WithColumn("NzbInfoUrl").AsString().Nullable()
.WithColumn("ReleaseGroup").AsString().Nullable();
Create.Table("IndexerDefinitions")
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
.WithColumn("Enable").AsBoolean().NotNullable()
.WithColumn("Type").AsString().NotNullable()
.WithColumn("Name").AsString().NotNullable();
Create.Table("JobDefinitions")
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
.WithColumn("Enable").AsBoolean().NotNullable()
.WithColumn("Type").AsString().NotNullable()
.WithColumn("Name").AsString().NotNullable()
.WithColumn("Interval").AsInt32().NotNullable()
.WithColumn("LastExecution").AsDateTime().NotNullable()
.WithColumn("Success").AsBoolean().NotNullable();
Create.Table("MetadataDefinitions")
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
.WithColumn("Enable").AsBoolean().NotNullable()
.WithColumn("Type").AsString().NotNullable()
.WithColumn("Name").AsString().NotNullable();
Create.Table("NewznabDefinitions")
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
.WithColumn("Enable").AsBoolean().NotNullable()
.WithColumn("Name").AsString().NotNullable()
.WithColumn("Url").AsString().NotNullable()
.WithColumn("ApiKey").AsString().Nullable()
.WithColumn("BuiltIn").AsBoolean().NotNullable();
Create.Table("QualityProfiles")
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
.WithColumn("Name").AsString().NotNullable()
.WithColumn("Cutoff").AsInt32().NotNullable()
.WithColumn("Allowed").AsString().NotNullable();
Create.Table("QualitySizes")
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
.WithColumn("QualityId").AsInt32().NotNullable().Unique()
.WithColumn("Name").AsString().NotNullable()
.WithColumn("MinSize").AsInt32().NotNullable()
.WithColumn("MaxSize").AsInt32().NotNullable();
Create.Table("RootFolders")
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
.WithColumn("Path").AsString().NotNullable();
Create.Table("SceneMappings")
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
.WithColumn("CleanTitle").AsString().NotNullable()
.WithColumn("SceneName").AsString().NotNullable()
.WithColumn("SeriesId").AsInt32().NotNullable()
.WithColumn("SeasonNumber").AsInt32().NotNullable();
Create.Table("Seasons")
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
.WithColumn("SeriesId").AsInt32().NotNullable()
.WithColumn("SeasonNumber").AsInt32().NotNullable()
.WithColumn("Ignored").AsBoolean().NotNullable();
Create.Table("Series")
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
.WithColumn("TvdbId").AsInt32().NotNullable()
.WithColumn("Title").AsString().NotNullable()
.WithColumn("CleanTitle").AsString().NotNullable()
.WithColumn("Status").AsInt32().NotNullable()
.WithColumn("Overview").AsString().NotNullable()
.WithColumn("AirTime").AsString().Nullable()
.WithColumn("Language").AsString().NotNullable()
.WithColumn("Path").AsString().NotNullable()
.WithColumn("Monitored").AsBoolean().NotNullable()
.WithColumn("QualityProfileId").AsString().NotNullable()
.WithColumn("SeasonFolder").AsBoolean().NotNullable()
.WithColumn("LastInfoSync").AsDateTime().Nullable()
.WithColumn("LastDiskSync").AsDateTime().Nullable()
.WithColumn("Runtime").AsInt32().NotNullable()
.WithColumn("BannerUrl").AsString().NotNullable()
.WithColumn("SeriesType").AsInt32().NotNullable()
.WithColumn("BacklogSetting").AsInt32().NotNullable()
.WithColumn("Network").AsString().NotNullable()
.WithColumn("CustomStartDate").AsDateTime().Nullable()
.WithColumn("UseSceneNumbering").AsBoolean().NotNullable()
.WithColumn("TvRageId").AsInt32().Nullable()
.WithColumn("TvRageTitle").AsString().NotNullable()
.WithColumn("UtcOffSet").AsInt32().NotNullable()
.WithColumn("FirstAired").AsDateTime().Nullable();
}
protected override void LogDbUpgrade()
{
Create.Table("Logs")
.WithColumn("LogId").AsInt64().PrimaryKey().Identity()
.WithColumn("Message").AsString().NotNullable()
.WithColumn("Time").AsDateTime().NotNullable()
.WithColumn("Logger").AsString().NotNullable()
.WithColumn("Method").AsString().NotNullable()
.WithColumn("Exception").AsString().Nullable()
.WithColumn("ExceptionType").AsString().Nullable()
.WithColumn("Level").AsString().NotNullable();
}
}
}

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentMigrator;
using NzbDrone.Common;
namespace NzbDrone.Core.Datastore.Migrations
{
public abstract class NzbDroneMigration : Migration
{
protected virtual void MainDbUpgrade()
{
}
protected virtual void LogDbUpgrade()
{
}
public override void Up()
{
if ((MigrationType)this.ApplicationContext == MigrationType.Main)
{
MainDbUpgrade();
}
else if ((MigrationType)this.ApplicationContext == MigrationType.Log)
{
LogDbUpgrade();
}
else
{
LogDbUpgrade();
MainDbUpgrade();
}
}
public override void Down()
{
throw new NotImplementedException();
}
}
}

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentMigrator.Runner.Announcers;
using NLog;
namespace NzbDrone.Core.Datastore
{
public class NlogAnnouncer : Announcer
{
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public override void Write(string message, bool escaped)
{
logger.Info(message);
}
}
}

@ -1,9 +1,11 @@
using System; using System;
using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore;
using ServiceStack.DataAnnotations;
namespace NzbDrone.Core.Indexers namespace NzbDrone.Core.Indexers
{ {
[Alias("IndexerDefinitions")]
public class Indexer : ModelBase public class Indexer : ModelBase
{ {
public Boolean Enable { get; set; } public Boolean Enable { get; set; }

@ -1,12 +1,14 @@
using System; using System;
using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore;
using ServiceStack.DataAnnotations;
namespace NzbDrone.Core.Indexers namespace NzbDrone.Core.Indexers
{ {
[Alias("NewznabDefinitions")]
public class NewznabDefinition : ModelBase public class NewznabDefinition : ModelBase
{ {
public Boolean Enabled { get; set; } public Boolean Enable { get; set; }
public String Name { get; set; } public String Name { get; set; }
public String Url { get; set; } public String Url { get; set; }
public String ApiKey { get; set; } public String ApiKey { get; set; }

@ -20,7 +20,7 @@ namespace NzbDrone.Core.Indexers
public IEnumerable<NewznabDefinition> Enabled() public IEnumerable<NewznabDefinition> Enabled()
{ {
return Where(n => n.Enabled); return Where(n => n.Enable);
} }
} }
} }

@ -79,9 +79,9 @@ namespace NzbDrone.Core.Indexers
{ {
var newznabIndexers = new List<NewznabDefinition> var newznabIndexers = new List<NewznabDefinition>
{ {
new NewznabDefinition { Enabled = false, Name = "Nzbs.org", Url = "http://nzbs.org", BuiltIn = true }, new NewznabDefinition { Enable = false, Name = "Nzbs.org", Url = "http://nzbs.org", BuiltIn = true },
new NewznabDefinition { Enabled = false, Name = "Nzb.su", Url = "https://nzb.su", BuiltIn = true }, new NewznabDefinition { Enable = false, Name = "Nzb.su", Url = "https://nzb.su", BuiltIn = true },
new NewznabDefinition { Enabled = false, Name = "Dognzb.cr", Url = "https://dognzb.cr", BuiltIn = true } new NewznabDefinition { Enable = false, Name = "Dognzb.cr", Url = "https://dognzb.cr", BuiltIn = true }
}; };
_logger.Debug("Initializing Newznab indexers. Count {0}", newznabIndexers); _logger.Debug("Initializing Newznab indexers. Count {0}", newznabIndexers);
@ -108,7 +108,7 @@ namespace NzbDrone.Core.Indexers
{ {
var definition = new NewznabDefinition var definition = new NewznabDefinition
{ {
Enabled = false, Enable = false,
Name = indexerLocal.Name, Name = indexerLocal.Name,
Url = indexerLocal.Url, Url = indexerLocal.Url,
ApiKey = indexerLocal.ApiKey, ApiKey = indexerLocal.ApiKey,

@ -42,10 +42,8 @@ namespace NzbDrone.Core.Jobs
Task.Factory.StartNew(ProcessQueue, _cancellationTokenSource.Token); Task.Factory.StartNew(ProcessQueue, _cancellationTokenSource.Token);
} }
public bool IsProcessing { get; private set; } public bool IsProcessing { get; private set; }
public IEnumerable<JobQueueItem> Queue public IEnumerable<JobQueueItem> Queue
{ {
get get
@ -63,7 +61,7 @@ namespace NzbDrone.Core.Jobs
} }
var pendingJobs = _jobRepository.GetPendingJobs() var pendingJobs = _jobRepository.GetPendingJobs()
.Select(c => _jobs.Single(t => t.GetType().ToString() == c.TypeName) .Select(c => _jobs.Single(t => t.GetType().ToString() == c.Type)
.GetType()).ToList(); .GetType()).ToList();
@ -99,7 +97,6 @@ namespace NzbDrone.Core.Jobs
} }
public bool Enqueue(string jobTypeString) public bool Enqueue(string jobTypeString)
{ {
var type = Type.GetType(jobTypeString); var type = Type.GetType(jobTypeString);

@ -1,21 +1,18 @@
using System; using System;
using System.Linq; using System.Linq;
using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore;
using ServiceStack.DataAnnotations;
namespace NzbDrone.Core.Jobs namespace NzbDrone.Core.Jobs
{ {
[Alias("JobDefinitions")]
public class JobDefinition : ModelBase public class JobDefinition : ModelBase
{ {
public Boolean Enable { get; set; } public Boolean Enable { get; set; }
public String Type { get; set; }
public String TypeName { get; set; }
public String Name { get; set; } public String Name { get; set; }
public Int32 Interval { get; set; } public Int32 Interval { get; set; }
public DateTime LastExecution { get; set; } public DateTime LastExecution { get; set; }
public Boolean Success { get; set; } public Boolean Success { get; set; }
} }
} }

@ -28,7 +28,7 @@ namespace NzbDrone.Core.Jobs
public JobDefinition GetDefinition(Type type) public JobDefinition GetDefinition(Type type)
{ {
return Single(c => c.TypeName == type.FullName); return Single(c => c.Type == type.FullName);
} }
@ -39,12 +39,12 @@ namespace NzbDrone.Core.Jobs
public void Init() public void Init()
{ {
var currentJobs = All(); var currentJobs = All().ToList();
_logger.Debug("Initializing jobs. Available: {0} Existing:{1}", _jobs.Count(), currentJobs.Count()); _logger.Debug("Initializing jobs. Available: {0} Existing:{1}", _jobs.Count(), currentJobs.Count());
foreach (var currentJob in currentJobs) foreach (var currentJob in currentJobs)
{ {
if (_jobs.All(c => c.GetType().ToString() != currentJob.TypeName)) if (_jobs.All(c => c.GetType().ToString() != currentJob.Type))
{ {
_logger.Debug("Removing job from database '{0}'", currentJob.Name); _logger.Debug("Removing job from database '{0}'", currentJob.Name);
Delete(currentJob.Id); Delete(currentJob.Id);
@ -53,13 +53,13 @@ namespace NzbDrone.Core.Jobs
foreach (var job in _jobs) foreach (var job in _jobs)
{ {
var jobDefinition = currentJobs.SingleOrDefault(c => c.TypeName == job.GetType().ToString()); var jobDefinition = currentJobs.SingleOrDefault(c => c.Type == job.GetType().ToString());
if (jobDefinition == null) if (jobDefinition == null)
{ {
jobDefinition = new JobDefinition jobDefinition = new JobDefinition
{ {
TypeName = job.GetType().ToString(), Type = job.GetType().ToString(),
LastExecution = DateTime.Now LastExecution = DateTime.Now
}; };
} }

@ -55,7 +55,7 @@ namespace NzbDrone.Core.MetadataSource
series.Title = tvDbSeries.SeriesName; series.Title = tvDbSeries.SeriesName;
series.AirTime = CleanAirsTime(tvDbSeries.Airs_Time); series.AirTime = CleanAirsTime(tvDbSeries.Airs_Time);
series.Overview = tvDbSeries.Overview; series.Overview = tvDbSeries.Overview;
series.Status = tvDbSeries.Status; series.Status = tvDbSeries.Status == "Continuing" ? SeriesStatusType.Continuing : SeriesStatusType.Ended ;
series.Language = tvDbSeries.Language ?? string.Empty; series.Language = tvDbSeries.Language ?? string.Empty;
series.CleanTitle = Parser.NormalizeTitle(tvDbSeries.SeriesName); series.CleanTitle = Parser.NormalizeTitle(tvDbSeries.SeriesName);
series.LastInfoSync = DateTime.Now; series.LastInfoSync = DateTime.Now;

@ -127,6 +127,12 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.dll</HintPath> <HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.dll</HintPath>
</Reference> </Reference>
<Reference Include="FluentMigrator">
<HintPath>..\packages\FluentMigrator.1.0.6.0\lib\40\FluentMigrator.dll</HintPath>
</Reference>
<Reference Include="FluentMigrator.Runner">
<HintPath>..\packages\FluentMigrator.1.0.6.0\tools\FluentMigrator.Runner.dll</HintPath>
</Reference>
<Reference Include="Growl.Connector"> <Reference Include="Growl.Connector">
<HintPath>..\packages\Growl.0.6\lib\Growl.Connector.dll</HintPath> <HintPath>..\packages\Growl.0.6\lib\Growl.Connector.dll</HintPath>
</Reference> </Reference>
@ -181,6 +187,14 @@
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Data.SQLite, Version=1.0.84.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\System.Data.SQLite.x64.1.0.84.0\lib\net40\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.Data.SQLite.Linq, Version=1.0.84.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\System.Data.SQLite.x64.1.0.84.0\lib\net40\System.Data.SQLite.Linq.dll</HintPath>
</Reference>
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.ServiceModel" /> <Reference Include="System.ServiceModel" />
<Reference Include="System.Web" /> <Reference Include="System.Web" />
@ -201,9 +215,14 @@
<Compile Include="Constants.cs" /> <Compile Include="Constants.cs" />
<Compile Include="ContainerExtensions.cs" /> <Compile Include="ContainerExtensions.cs" />
<Compile Include="Datastore\DbFactory.cs" /> <Compile Include="Datastore\DbFactory.cs" />
<Compile Include="Datastore\MigrationHelper.cs" />
<Compile Include="Datastore\Migration.cs" /> <Compile Include="Datastore\Migration.cs" />
<Compile Include="Datastore\Migrations\Migration20130324.cs" />
<Compile Include="Datastore\Migrations\NzbDroneMigration.cs" />
<Compile Include="Datastore\MigrationType.cs" />
<Compile Include="Datastore\ModelBase.cs" /> <Compile Include="Datastore\ModelBase.cs" />
<Compile Include="Datastore\BasicRepository.cs" /> <Compile Include="Datastore\BasicRepository.cs" />
<Compile Include="Datastore\NlogAnnouncer.cs" />
<Compile Include="DecisionEngine\DownloadDecision.cs" /> <Compile Include="DecisionEngine\DownloadDecision.cs" />
<Compile Include="DecisionEngine\IFetchableSpecification.cs" /> <Compile Include="DecisionEngine\IFetchableSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\AcceptableSizeSpecification.cs" /> <Compile Include="DecisionEngine\Specifications\AcceptableSizeSpecification.cs" />
@ -530,6 +549,7 @@
<Compile Include="Tvdb\TvdbServerTime.cs" /> <Compile Include="Tvdb\TvdbServerTime.cs" />
<Compile Include="Tvdb\TvdbUpdate.cs" /> <Compile Include="Tvdb\TvdbUpdate.cs" />
<Compile Include="Tvdb\TvdbUpdateItems.cs" /> <Compile Include="Tvdb\TvdbUpdateItems.cs" />
<Compile Include="Tv\SeriesStatusType.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client"> <BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client">

@ -1,9 +1,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore;
using ServiceStack.DataAnnotations;
namespace NzbDrone.Core.Qualities namespace NzbDrone.Core.Qualities
{ {
[Alias("QualityProfiles")]
public class QualityProfile : ModelBase public class QualityProfile : ModelBase
{ {
public string Name { get; set; } public string Name { get; set; }

@ -1,9 +1,11 @@
using System.Linq; using System.Linq;
using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore;
using ServiceStack.DataAnnotations;
namespace NzbDrone.Core.Qualities namespace NzbDrone.Core.Qualities
{ {
[Alias("QualitySizes")]
public class QualitySize : ModelBase public class QualitySize : ModelBase
{ {
public int QualityId { get; set; } public int QualityId { get; set; }

@ -1,8 +1,10 @@
using System.Linq; using System.Linq;
using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore;
using ServiceStack.DataAnnotations;
namespace NzbDrone.Core.ReferenceData namespace NzbDrone.Core.ReferenceData
{ {
[Alias("SceneMappings")]
public class SceneMapping : ModelBase public class SceneMapping : ModelBase
{ {
public string CleanTitle { get; set; } public string CleanTitle { get; set; }

@ -4,7 +4,7 @@ using System;
using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
using NzbDrone.Core.Qualities; using NzbDrone.Core.Qualities;
using ServiceStack.DataAnnotations;
namespace NzbDrone.Core.Tv namespace NzbDrone.Core.Tv
@ -21,11 +21,8 @@ namespace NzbDrone.Core.Tv
public int TvDbId { get; set; } public int TvDbId { get; set; }
public string Title { get; set; } public string Title { get; set; }
public string CleanTitle { get; set; } public string CleanTitle { get; set; }
public string Status { get; set; } public SeriesStatusType Status { get; set; }
public string Overview { get; set; } public string Overview { get; set; }
public String AirTime { get; set; } public String AirTime { get; set; }
public string Language { get; set; } public string Language { get; set; }
public string Path { get; set; } public string Path { get; set; }

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Tv
{
public enum SeriesStatusType
{
Continuing = 0,
Ended = 1
}
}

@ -2,6 +2,7 @@
<packages> <packages>
<package id="Autofac" version="3.0.1" targetFramework="net40" /> <package id="Autofac" version="3.0.1" targetFramework="net40" />
<package id="DotNetZip" version="1.9.1.8" /> <package id="DotNetZip" version="1.9.1.8" />
<package id="FluentMigrator" version="1.0.6.0" targetFramework="net40" />
<package id="Growl" version="0.6" /> <package id="Growl" version="0.6" />
<package id="MediaInfoNet" version="0.3" targetFramework="net40" /> <package id="MediaInfoNet" version="0.3" targetFramework="net40" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" /> <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" />
@ -14,5 +15,6 @@
<package id="ServiceStack.Text" version="3.9.42" targetFramework="net40" /> <package id="ServiceStack.Text" version="3.9.42" targetFramework="net40" />
<package id="SignalR.Hosting.Common" version="0.5.3" targetFramework="net40" /> <package id="SignalR.Hosting.Common" version="0.5.3" targetFramework="net40" />
<package id="SignalR.Server" version="0.5.3" targetFramework="net40" /> <package id="SignalR.Server" version="0.5.3" targetFramework="net40" />
<package id="System.Data.SQLite.x86" version="1.0.84.0" targetFramework="net40" />
<package id="twitterizer" version="2.4.0.26532" /> <package id="twitterizer" version="2.4.0.26532" />
</packages> </packages>

@ -89,6 +89,14 @@
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Data.SQLite, Version=1.0.84.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\System.Data.SQLite.x86.1.0.84.0\lib\net40\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.Data.SQLite.Linq, Version=1.0.84.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\System.Data.SQLite.x86.1.0.84.0\lib\net40\System.Data.SQLite.Linq.dll</HintPath>
</Reference>
<Reference Include="System.ServiceProcess" /> <Reference Include="System.ServiceProcess" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

@ -9,4 +9,5 @@
<package id="NLog" version="2.0.0.2000" /> <package id="NLog" version="2.0.0.2000" />
<package id="NLog.Config" version="2.0.0.2000" targetFramework="net40" /> <package id="NLog.Config" version="2.0.0.2000" targetFramework="net40" />
<package id="NLog.Schema" version="2.0.0.2000" targetFramework="net40" /> <package id="NLog.Schema" version="2.0.0.2000" targetFramework="net40" />
<package id="System.Data.SQLite.x86" version="1.0.84.0" targetFramework="net40" />
</packages> </packages>
Loading…
Cancel
Save