mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-05 02:22:31 +01:00
Merge branch 'master' of git://github.com/kayone/NzbDrone
This commit is contained in:
commit
938fa24a8e
3
.gitignore
vendored
3
.gitignore
vendored
@ -33,4 +33,5 @@ _ReSharper*/
|
||||
#NZBDrone specific
|
||||
*.db
|
||||
*Web.Publish.xml
|
||||
NzbDrone.Web/NzbDrone.Web.Publish.xml
|
||||
NzbDrone.Web/NzbDrone.Web.Publish.xml
|
||||
*.sdf
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -4,9 +4,14 @@
|
||||
<name>Migrator.Providers</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:Migrator.Providers.SQLite.SQLiteTransformationProvider">
|
||||
<member name="T:Migrator.Providers.SqlServer.SqlServerCeTransformationProvider">
|
||||
<summary>
|
||||
Summary description for SQLiteTransformationProvider.
|
||||
Migration transformations provider for Microsoft SQL Server Compact Edition.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Migrator.Providers.SqlServer.SqlServerTransformationProvider">
|
||||
<summary>
|
||||
Migration transformations provider for Microsoft SQL Server.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Migrator.Providers.TransformationProvider">
|
||||
@ -185,23 +190,6 @@
|
||||
The list of Migrations currently applied to the database.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Migrator.Providers.SQLite.SQLiteTransformationProvider.ParseSqlForColumnNames(System.String)">
|
||||
<summary>
|
||||
Turn something like 'columnName INTEGER NOT NULL' into just 'columnName'
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Migrator.Providers.SQLite.SQLiteTransformationProvider.ExtractNameFromColumnDef(System.String)">
|
||||
<summary>
|
||||
Name is the first value before the space.
|
||||
</summary>
|
||||
<param name="columnDef"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Migrator.Providers.NoOpTransformationProvider">
|
||||
<summary>
|
||||
No Op (Null Object Pattern) implementation of the ITransformationProvider
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Migrator.Providers.Dialect">
|
||||
<summary>
|
||||
Defines the implementations specific details for a particular database.
|
||||
@ -263,16 +251,6 @@
|
||||
<param name="type">The DbType</param>
|
||||
<returns>True if the database type has an unsigned variant, otherwise false</returns>
|
||||
</member>
|
||||
<member name="T:Migrator.Providers.SqlServer.SqlServerCeTransformationProvider">
|
||||
<summary>
|
||||
Migration transformations provider for Microsoft SQL Server.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Migrator.Providers.SqlServer.SqlServerTransformationProvider">
|
||||
<summary>
|
||||
Migration transformations provider for Microsoft SQL Server.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Migrator.Providers.PostgreSQL.PostgreSQLTransformationProvider">
|
||||
<summary>
|
||||
Migration transformations provider for PostgreSql (using NPGSql .Net driver)
|
||||
@ -385,5 +363,27 @@
|
||||
Summary description for MySqlTransformationProvider.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Migrator.Providers.SQLite.SQLiteTransformationProvider">
|
||||
<summary>
|
||||
Summary description for SQLiteTransformationProvider.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Migrator.Providers.SQLite.SQLiteTransformationProvider.ParseSqlForColumnNames(System.String)">
|
||||
<summary>
|
||||
Turn something like 'columnName INTEGER NOT NULL' into just 'columnName'
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Migrator.Providers.SQLite.SQLiteTransformationProvider.ExtractNameFromColumnDef(System.String)">
|
||||
<summary>
|
||||
Name is the first value before the space.
|
||||
</summary>
|
||||
<param name="columnDef"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Migrator.Providers.NoOpTransformationProvider">
|
||||
<summary>
|
||||
No Op (Null Object Pattern) implementation of the ITransformationProvider
|
||||
</summary>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
|
124
Libraries/Migrator.NET/Migrator.XML
Normal file
124
Libraries/Migrator.NET/Migrator.XML
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Migrator</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:Migrator.MigrationTypeComparer">
|
||||
<summary>
|
||||
Comparer of Migration by their version attribute.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Migrator.BaseMigrate.NextMigration">
|
||||
<summary>
|
||||
Finds the next migration available to be applied. Only returns
|
||||
migrations that have NOT already been applied.
|
||||
</summary>
|
||||
<returns>The migration number of the next available Migration.</returns>
|
||||
</member>
|
||||
<member name="M:Migrator.BaseMigrate.PreviousMigration">
|
||||
<summary>
|
||||
Finds the previous migration that has been applied. Only returns
|
||||
migrations that HAVE already been applied.
|
||||
</summary>
|
||||
<returns>The most recently applied Migration.</returns>
|
||||
</member>
|
||||
<member name="T:Migrator.Migrator">
|
||||
<summary>
|
||||
Migrations mediator.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Migrator.Migrator.MigrateToLastVersion">
|
||||
<summary>
|
||||
Run all migrations up to the latest. Make no changes to database if
|
||||
dryrun is true.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Migrator.Migrator.MigrateTo(System.Int64)">
|
||||
<summary>
|
||||
Migrate the database to a specific version.
|
||||
Runs all migration between the actual version and the
|
||||
specified version.
|
||||
If <c>version</c> is greater then the current version,
|
||||
the <c>Up()</c> method will be invoked.
|
||||
If <c>version</c> lower then the current version,
|
||||
the <c>Down()</c> method of previous migration will be invoked.
|
||||
If <c>dryrun</c> is set, don't write any changes to the database.
|
||||
</summary>
|
||||
<param name="version">The version that must became the current one</param>
|
||||
</member>
|
||||
<member name="P:Migrator.Migrator.MigrationsTypes">
|
||||
<summary>
|
||||
Returns registered migration <see cref="T:System.Type">types</see>.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Migrator.Migrator.AppliedMigrations">
|
||||
<summary>
|
||||
Returns the current migrations applied to the database.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Migrator.Migrator.Logger">
|
||||
<summary>
|
||||
Get or set the event logger.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Migrator.MigrationLoader">
|
||||
<summary>
|
||||
Handles inspecting code to find all of the Migrations in assemblies and reading
|
||||
other metadata such as the last revision, etc.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Migrator.MigrationLoader.CheckForDuplicatedVersion">
|
||||
<summary>
|
||||
Check for duplicated version in migrations.
|
||||
</summary>
|
||||
<exception cref="M:Migrator.MigrationLoader.CheckForDuplicatedVersion">CheckForDuplicatedVersion</exception>
|
||||
</member>
|
||||
<member name="M:Migrator.MigrationLoader.GetMigrationTypes(System.Reflection.Assembly)">
|
||||
<summary>
|
||||
Collect migrations in one <c>Assembly</c>.
|
||||
</summary>
|
||||
<param name="asm">The <c>Assembly</c> to browse.</param>
|
||||
<returns>The migrations collection</returns>
|
||||
</member>
|
||||
<member name="M:Migrator.MigrationLoader.GetMigrationVersion(System.Type)">
|
||||
<summary>
|
||||
Returns the version of the migration
|
||||
<see cref="T:Migrator.Framework.MigrationAttribute">MigrationAttribute</see>.
|
||||
</summary>
|
||||
<param name="t">Migration type.</param>
|
||||
<returns>Version number sepcified in the attribute</returns>
|
||||
</member>
|
||||
<member name="P:Migrator.MigrationLoader.MigrationsTypes">
|
||||
<summary>
|
||||
Returns registered migration <see cref="T:System.Type">types</see>.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Migrator.MigrationLoader.LastVersion">
|
||||
<summary>
|
||||
Returns the last version of the migrations.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Migrator.IrreversibleMigrationException">
|
||||
<summary>
|
||||
Exception thrown in a migration <c>Down()</c> method
|
||||
when changes can't be undone.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Migrator.DuplicatedVersionException">
|
||||
<summary>
|
||||
Exception thrown when a migration number is not unique.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Migrator.ProviderFactory">
|
||||
<summary>
|
||||
Handles loading Provider implementations
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Migrator.MigrateAnywhere">
|
||||
<summary>
|
||||
Description of MigrateAnywhere.
|
||||
</summary>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Libraries/System.Data.SqlServerCe.dll
Normal file
BIN
Libraries/System.Data.SqlServerCe.dll
Normal file
Binary file not shown.
2892
Libraries/System.Data.SqlServerCe.xml
Normal file
2892
Libraries/System.Data.SqlServerCe.xml
Normal file
File diff suppressed because it is too large
Load Diff
@ -70,4 +70,75 @@
|
||||
<Abbreviation Text="SQ" />
|
||||
</Naming2>
|
||||
</CodeStyleSettings>
|
||||
<CustomStructuralPatterns>
|
||||
<Pattern Severity="SUGGESTION">
|
||||
<Comment>Replace with FluentAssertion</Comment>
|
||||
<ReplacePattern>$arg$.Should().BeTrue();</ReplacePattern>
|
||||
<SearchPattern><![CDATA[Assert.IsTrue($arg$);
|
||||
]]></SearchPattern>
|
||||
<Params />
|
||||
<Placeholders>
|
||||
<ArgumentPlaceholder Name="excpected" Minimal="1" Maximal="1" />
|
||||
</Placeholders>
|
||||
</Pattern>
|
||||
<Pattern Severity="SUGGESTION">
|
||||
<Comment>Replace with FluentAssertion</Comment>
|
||||
<ReplacePattern>$arg$.Should().BeFalse();</ReplacePattern>
|
||||
<SearchPattern><![CDATA[Assert.IsFalse($arg$);
|
||||
]]></SearchPattern>
|
||||
<Params />
|
||||
<Placeholders>
|
||||
<ArgumentPlaceholder Name="excpected" Minimal="1" Maximal="1" />
|
||||
</Placeholders>
|
||||
</Pattern>
|
||||
<Pattern Severity="SUGGESTION">
|
||||
<ReplacePattern>$actual$.Should().Be($excpected$);</ReplacePattern>
|
||||
<SearchPattern><![CDATA[Assert.AreEqual($actual$, $excpected$);
|
||||
]]></SearchPattern>
|
||||
<Params>
|
||||
<IgnoreBracesInSingleStatementBlocks>False</IgnoreBracesInSingleStatementBlocks>
|
||||
<IgnoreParanthesisInExpressions>False</IgnoreParanthesisInExpressions>
|
||||
<SmartMatchAssociativeExpressions>False</SmartMatchAssociativeExpressions>
|
||||
<TreatReversedBinaryExpressionsEquivalent>Never</TreatReversedBinaryExpressionsEquivalent>
|
||||
</Params>
|
||||
<Placeholders>
|
||||
<ArgumentPlaceholder Name="excpected" Minimal="1" Maximal="1" />
|
||||
<ArgumentPlaceholder Name="actual" Minimal="1" Maximal="1" />
|
||||
</Placeholders>
|
||||
</Pattern>
|
||||
<Pattern Severity="HINT">
|
||||
<ReplacePattern>$excpected$.Should().Be($actual$);</ReplacePattern>
|
||||
<SearchPattern><![CDATA[$actual$.Should().Be($excpected$);
|
||||
]]></SearchPattern>
|
||||
<Params />
|
||||
<Placeholders>
|
||||
<ArgumentPlaceholder Name="excpected" Minimal="1" Maximal="1" />
|
||||
<ArgumentPlaceholder Name="actual" Minimal="1" Maximal="1" />
|
||||
</Placeholders>
|
||||
</Pattern>
|
||||
<Pattern Severity="SUGGESTION">
|
||||
<ReplacePattern>$arg$.Should().NotBeNull();</ReplacePattern>
|
||||
<SearchPattern>Assert.IsNotNull($arg$);</SearchPattern>
|
||||
<Params />
|
||||
<Placeholders>
|
||||
<ArgumentPlaceholder Name="arg" Minimal="1" Maximal="1" />
|
||||
</Placeholders>
|
||||
</Pattern>
|
||||
<Pattern Severity="SUGGESTION">
|
||||
<ReplacePattern>$arg$.Should().NotBeEmpty();</ReplacePattern>
|
||||
<SearchPattern>Assert.IsNotEmpty($arg$);</SearchPattern>
|
||||
<Params />
|
||||
<Placeholders>
|
||||
<ArgumentPlaceholder Name="arg" Minimal="1" Maximal="1" />
|
||||
</Placeholders>
|
||||
</Pattern>
|
||||
<Pattern Severity="SUGGESTION">
|
||||
<ReplacePattern>$arg$.Should().BeEmpty();</ReplacePattern>
|
||||
<SearchPattern>Assert.IsEmpty($arg$);</SearchPattern>
|
||||
<Params />
|
||||
<Placeholders>
|
||||
<ArgumentPlaceholder Name="arg" Minimal="1" Maximal="1" />
|
||||
</Placeholders>
|
||||
</Pattern>
|
||||
</CustomStructuralPatterns>
|
||||
</Configuration>
|
@ -284,6 +284,46 @@ public void RefreshEpisodeInfo_emptyRepo()
|
||||
mocker.VerifyAllMocks();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RefreshEpisodeInfo_should_set_older_than_1900_to_null()
|
||||
{
|
||||
//Arrange
|
||||
const int seriesId = 71663;
|
||||
|
||||
var fakeEpisodes = Builder<TvdbSeries>.CreateNew().With(
|
||||
c => c.Episodes =
|
||||
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(10).
|
||||
WhereAll()
|
||||
.Have(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||
.WhereTheFirst(7).Have(e => e.FirstAired = new DateTime(1800, 1, 1))
|
||||
.AndTheRemaining().Have(e => e.FirstAired = DateTime.Now)
|
||||
.Build())
|
||||
).With(c => c.Id = seriesId).Build();
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(c => c.SeriesId = seriesId).Build();
|
||||
|
||||
|
||||
var mocker = new AutoMoqer();
|
||||
|
||||
mocker.SetConstant(MockLib.GetEmptyDatabase());
|
||||
|
||||
mocker.GetMock<TvDbProvider>()
|
||||
.Setup(c => c.GetSeries(seriesId, true))
|
||||
.Returns(fakeEpisodes);
|
||||
|
||||
|
||||
//Act
|
||||
mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
||||
|
||||
//Assert
|
||||
var storedEpisodes = mocker.Resolve<EpisodeProvider>().GetEpisodeBySeries(seriesId).ToList();
|
||||
storedEpisodes.Should().HaveCount(10);
|
||||
storedEpisodes.Where(e => e.AirDate == null).Should().HaveCount(7);
|
||||
storedEpisodes.Where(e => e.AirDate != null).Should().HaveCount(3);
|
||||
|
||||
mocker.VerifyAllMocks();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void new_episodes_only_calls_Insert()
|
||||
{
|
||||
@ -595,7 +635,7 @@ public void GetEpisode_by_Season_Episode_none_existing()
|
||||
var db = MockLib.GetEmptyDatabase();
|
||||
mocker.SetConstant(db);
|
||||
|
||||
|
||||
|
||||
//Act
|
||||
var episode = mocker.Resolve<EpisodeProvider>().GetEpisode(1, 1, 1);
|
||||
|
||||
@ -660,7 +700,7 @@ public void GetEpisode_by_Season_Episode_without_EpisodeFile()
|
||||
episode.EpisodeFile.Should().BeNull();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[Test]
|
||||
@ -683,7 +723,7 @@ public void GetEpisode_by_AirDate_with_EpisodeFile()
|
||||
.Returns(fakeSeries);
|
||||
|
||||
//Act
|
||||
var episode = mocker.Resolve<EpisodeProvider>().GetEpisode(1, fakeEpisodes[0].AirDate);
|
||||
var episode = mocker.Resolve<EpisodeProvider>().GetEpisode(1, fakeEpisodes[0].AirDate.Value);
|
||||
|
||||
//Assert
|
||||
episode.ShouldHave().AllPropertiesBut(e => e.Series, e => e.EpisodeFile).EqualTo(fakeEpisodes.First());
|
||||
@ -709,7 +749,7 @@ public void GetEpisode_by_AirDate_without_EpisodeFile()
|
||||
.Returns(fakeSeries);
|
||||
|
||||
//Act
|
||||
var episode = mocker.Resolve<EpisodeProvider>().GetEpisode(1, fakeEpisodes[0].AirDate);
|
||||
var episode = mocker.Resolve<EpisodeProvider>().GetEpisode(1, fakeEpisodes[0].AirDate.Value);
|
||||
|
||||
//Assert
|
||||
episode.ShouldHave().AllPropertiesBut(e => e.Series).EqualTo(fakeEpisodes.First());
|
||||
@ -718,6 +758,6 @@ public void GetEpisode_by_AirDate_without_EpisodeFile()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
// ReSharper disable RedundantUsingDirective
|
||||
using System;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Repository;
|
||||
@ -107,14 +108,14 @@ public void ignored_episode(int offsetDays, bool ignored, bool hasEpisodes, Epis
|
||||
public void low_air_date()
|
||||
{
|
||||
Episode episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.AirDate = DateTime.Now.AddYears(-200))
|
||||
.With(e => e.AirDate = DateTime.Now.AddDays(20))
|
||||
.With(e => e.Ignored = false)
|
||||
.With(e => e.EpisodeFileId = 0)
|
||||
.With(e => e.GrabDate = null)
|
||||
.Build();
|
||||
|
||||
|
||||
Assert.AreEqual(EpisodeStatusType.NotAired, episode.Status);
|
||||
episode.Status.Should().Be(EpisodeStatusType.NotAired);
|
||||
}
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ public class Fixtures
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
var filesToDelete = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.db", SearchOption.AllDirectories);
|
||||
var filesToDelete = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.sdf", SearchOption.AllDirectories);
|
||||
foreach (var file in filesToDelete)
|
||||
{
|
||||
try
|
||||
|
@ -29,7 +29,7 @@ public static IDatabase GetEmptyDatabase(bool enableLogging = false, string file
|
||||
|
||||
if (String.IsNullOrWhiteSpace(fileName))
|
||||
{
|
||||
fileName = Guid.NewGuid() + ".db";
|
||||
fileName = Guid.NewGuid() + ".sdf";
|
||||
}
|
||||
|
||||
var connectionString = Connection.GetConnectionString(fileName);
|
||||
|
@ -145,14 +145,13 @@ public void GetBestQualityInHistory_single_result()
|
||||
var result = mocker.Resolve<HistoryProvider>().GetBestQualityInHistory(history.EpisodeId);
|
||||
|
||||
//Assert
|
||||
Assert.IsNotNull(result);
|
||||
result.Should().NotBeNull();
|
||||
result.QualityType.Should().Be(QualityTypes.Bluray720p);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void add_item()
|
||||
{
|
||||
//Arange
|
||||
var mocker = new AutoMoqer();
|
||||
var db = MockLib.GetEmptyDatabase();
|
||||
|
||||
@ -181,13 +180,14 @@ public void add_item()
|
||||
var storedHistory = db.Fetch<History>();
|
||||
|
||||
storedHistory.Should().HaveCount(1);
|
||||
Assert.AreEqual(history.Date, storedHistory.First().Date);
|
||||
Assert.AreEqual(history.EpisodeId, storedHistory.First().EpisodeId);
|
||||
Assert.AreEqual(history.SeriesId, storedHistory.First().SeriesId);
|
||||
Assert.AreEqual(history.NzbTitle, storedHistory.First().NzbTitle);
|
||||
Assert.AreEqual(history.Indexer, storedHistory.First().Indexer);
|
||||
Assert.AreEqual(history.Quality, storedHistory.First().Quality);
|
||||
Assert.AreEqual(history.IsProper, storedHistory.First().IsProper);
|
||||
history.Date.Should().BeWithin(TimeSpan.FromMinutes(1)).Before(storedHistory.First().Date);
|
||||
|
||||
history.EpisodeId.Should().Be(storedHistory.First().EpisodeId);
|
||||
history.SeriesId.Should().Be(storedHistory.First().SeriesId);
|
||||
history.NzbTitle.Should().Be(storedHistory.First().NzbTitle);
|
||||
history.Indexer.Should().Be(storedHistory.First().Indexer);
|
||||
history.Quality.Should().Be(storedHistory.First().Quality);
|
||||
history.IsProper.Should().Be(storedHistory.First().IsProper);
|
||||
}
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
using System.Collections.Generic;
|
||||
using AutoMoq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Model;
|
||||
@ -193,7 +194,7 @@ public void IsQualityNeeded_lesser_file_in_history_should_be_downloaded()
|
||||
bool result = mocker.Resolve<InventoryProvider>().IsQualityNeeded(parseResultSingle);
|
||||
|
||||
//Assert
|
||||
Assert.IsTrue(result);
|
||||
result.Should().BeTrue();
|
||||
mocker.VerifyAllMocks();
|
||||
}
|
||||
|
||||
@ -219,7 +220,7 @@ public void IsQualityNeeded_file_not_in_history_should_be_downloaded()
|
||||
bool result = mocker.Resolve<InventoryProvider>().IsQualityNeeded(parseResultSingle);
|
||||
|
||||
//Assert
|
||||
Assert.IsTrue(result);
|
||||
result.Should().BeTrue();
|
||||
mocker.VerifyAllMocks();
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ public void Run_Jobs_Updates_Last_Execution()
|
||||
var settings = timerProvider.All();
|
||||
Assert.IsNotEmpty(settings);
|
||||
Assert.AreNotEqual(DateTime.MinValue, settings[0].LastExecution);
|
||||
Assert.IsTrue(settings[0].Success);
|
||||
settings[0].Success.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -75,9 +75,8 @@ public void can_run_job_again()
|
||||
var firstRun = timerProvider.RunScheduled();
|
||||
var secondRun = timerProvider.RunScheduled();
|
||||
|
||||
Assert.IsTrue(firstRun);
|
||||
Assert.IsTrue(secondRun);
|
||||
|
||||
firstRun.Should().BeTrue();
|
||||
secondRun.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -97,9 +96,8 @@ public void can_run_async_job_again()
|
||||
Thread.Sleep(2000);
|
||||
var secondRun = timerProvider.QueueJob(typeof(FakeJob));
|
||||
|
||||
Assert.IsTrue(firstRun);
|
||||
Assert.IsTrue(secondRun);
|
||||
|
||||
firstRun.Should().BeTrue();
|
||||
secondRun.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -142,8 +140,8 @@ public void can_run_broken_async_job_again()
|
||||
Thread.Sleep(2000);
|
||||
var secondRun = timerProvider.QueueJob(typeof(BrokenJob));
|
||||
|
||||
Assert.IsTrue(firstRun);
|
||||
Assert.IsTrue(secondRun);
|
||||
firstRun.Should().BeTrue();
|
||||
secondRun.Should().BeTrue();
|
||||
Thread.Sleep(2000);
|
||||
ExceptionVerification.ExcpectedErrors(2);
|
||||
}
|
||||
@ -174,7 +172,7 @@ public void can_run_two_jobs_at_the_same_time()
|
||||
thread1.Join();
|
||||
thread2.Join();
|
||||
|
||||
Assert.IsTrue(firstRun);
|
||||
firstRun.Should().BeTrue();
|
||||
Assert.IsFalse(secondRun);
|
||||
|
||||
}
|
||||
@ -230,13 +228,11 @@ public void Init_Jobs()
|
||||
//Assert
|
||||
|
||||
timers.Should().HaveCount(1);
|
||||
Assert.AreEqual(fakeTimer.DefaultInterval, timers[0].Interval);
|
||||
Assert.AreEqual(fakeTimer.Name, timers[0].Name);
|
||||
Assert.AreEqual(fakeTimer.GetType().ToString(), timers[0].TypeName);
|
||||
Assert.AreEqual(DateTime.MinValue, timers[0].LastExecution);
|
||||
Assert.IsTrue(timers[0].Enable);
|
||||
|
||||
|
||||
timers[0].Interval.Should().Be(fakeTimer.DefaultInterval);
|
||||
timers[0].Name.Should().Be(fakeTimer.Name);
|
||||
timers[0].TypeName.Should().Be(fakeTimer.GetType().ToString());
|
||||
timers[0].LastExecution.Should().HaveYear(2000);
|
||||
timers[0].Enable.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -267,7 +263,7 @@ public void Init_Timers_only_registers_once()
|
||||
|
||||
//Assert
|
||||
timers.Should().HaveCount(1);
|
||||
Assert.IsTrue(timers[0].Enable);
|
||||
timers[0].Enable.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -364,8 +360,8 @@ public void SingleId_do_not_update_last_execution()
|
||||
|
||||
//Assert
|
||||
var settings = timerProvider.All();
|
||||
Assert.IsNotEmpty(settings);
|
||||
Assert.AreEqual(DateTime.MinValue, settings[0].LastExecution);
|
||||
settings.Should().NotBeEmpty();
|
||||
settings[0].LastExecution.Should().HaveYear(2000);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -39,11 +39,10 @@ public void write_log()
|
||||
//Assert
|
||||
db.Fetch<Log>().Should().HaveCount(1);
|
||||
|
||||
var logItem = db.Fetch<Log>().First();
|
||||
var logItem = db.Fetch<Log>().First();
|
||||
Assert.AreNotEqual(new DateTime(), logItem.Time);
|
||||
Assert.AreEqual(message, logItem.Message);
|
||||
Assert.AreEqual(Logger.Name, logItem.Logger);
|
||||
Assert.AreEqual(Logger.Name, logItem.Logger);
|
||||
Assert.AreEqual(LogLevel.Info.Name, logItem.Level);
|
||||
Assert.AreEqual("write_log", logItem.Method);
|
||||
}
|
||||
@ -149,14 +148,14 @@ public void write_log_exception_no_message_should_use_exception_message()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[Test]
|
||||
public void null_string_as_arg_should_not_fail()
|
||||
{
|
||||
//setup
|
||||
|
||||
|
||||
Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
var epFile = new EpisodeFile();
|
||||
Logger.Trace("File {0} no longer exists on disk. removing from database.", epFile.Path);
|
||||
|
@ -72,10 +72,6 @@
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Data.SQLite, Version=1.0.72.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
|
||||
<HintPath>..\Libraries\System.Data.SQLite.dll</HintPath>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.Xml" />
|
||||
@ -175,7 +171,8 @@
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>copy "$(SolutionDir)\Libraries\SQLite.Interop.dll" "$(TargetDir)"</PreBuildEvent>
|
||||
<PreBuildEvent>
|
||||
</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
@ -1,4 +1,5 @@
|
||||
using NUnit.Framework;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
@ -55,9 +56,9 @@ public void equal_operand()
|
||||
var first = new Quality(QualityTypes.Bluray1080p, true);
|
||||
var second = new Quality(QualityTypes.Bluray1080p, true);
|
||||
|
||||
Assert.IsTrue(first == second);
|
||||
Assert.IsTrue(first >= second);
|
||||
Assert.IsTrue(first <= second);
|
||||
(first == second).Should().BeTrue();
|
||||
(first >= second).Should().BeTrue();
|
||||
(first <= second).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -66,7 +67,7 @@ public void equal_operand_false()
|
||||
var first = new Quality(QualityTypes.Bluray1080p, true);
|
||||
var second = new Quality(QualityTypes.Unknown, true);
|
||||
|
||||
Assert.IsFalse(first == second);
|
||||
(first == second).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -75,7 +76,7 @@ public void equal_operand_false_proper()
|
||||
var first = new Quality(QualityTypes.Bluray1080p, true);
|
||||
var second = new Quality(QualityTypes.Bluray1080p, false);
|
||||
|
||||
Assert.IsFalse(first == second);
|
||||
(first == second).Should().BeFalse();
|
||||
}
|
||||
|
||||
|
||||
@ -94,7 +95,7 @@ public void not_equal_operand_false()
|
||||
var first = new Quality(QualityTypes.Bluray1080p, true);
|
||||
var second = new Quality(QualityTypes.Unknown, true);
|
||||
|
||||
Assert.IsTrue(first != second);
|
||||
(first != second).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -103,7 +104,7 @@ public void not_equal_operand_false_proper()
|
||||
var first = new Quality(QualityTypes.Bluray1080p, true);
|
||||
var second = new Quality(QualityTypes.Bluray1080p, false);
|
||||
|
||||
Assert.IsTrue(first != second);
|
||||
(first != second).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -112,8 +113,8 @@ public void greater_operand()
|
||||
var first = new Quality(QualityTypes.DVD, true);
|
||||
var second = new Quality(QualityTypes.Bluray1080p, true);
|
||||
|
||||
Assert.IsTrue(first < second);
|
||||
Assert.IsTrue(first <= second);
|
||||
(first < second).Should().BeTrue();
|
||||
(first <= second).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -122,8 +123,8 @@ public void lesser_operand()
|
||||
var first = new Quality(QualityTypes.DVD, true);
|
||||
var second = new Quality(QualityTypes.Bluray1080p, true);
|
||||
|
||||
Assert.IsTrue(second > first);
|
||||
Assert.IsTrue(second >= first);
|
||||
(second > first).Should().BeTrue();
|
||||
(second >= first).Should().BeTrue();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -54,10 +54,9 @@ public void AddRootDir(string path)
|
||||
|
||||
//Assert
|
||||
var rootDirs = rootDirProvider.GetAll();
|
||||
Assert.IsNotEmpty(rootDirs);
|
||||
|
||||
rootDirs.Should().NotBeEmpty();
|
||||
rootDirs.Should().HaveCount(1);
|
||||
Assert.AreEqual(path, rootDirs.First().Path);
|
||||
path.Should().Be(rootDirs.First().Path);
|
||||
}
|
||||
|
||||
|
||||
@ -77,9 +76,8 @@ public void UpdateRootDir(string newPath)
|
||||
|
||||
//Assert
|
||||
var rootDirs = rootDirProvider.GetAll();
|
||||
Assert.IsNotEmpty(rootDirs);
|
||||
rootDirs.Should().HaveCount(1);
|
||||
Assert.AreEqual(newPath, rootDirs.First().Path);
|
||||
newPath.Should().Be(rootDirs.First().Path);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -115,8 +113,8 @@ public void GetRootDir()
|
||||
|
||||
//Assert
|
||||
var rootDir = rootDirProvider.GetRootDir(id);
|
||||
Assert.AreEqual(1, rootDir.Id);
|
||||
Assert.AreEqual(path, rootDir.Path);
|
||||
rootDir.Id.Should().Be(1);
|
||||
rootDir.Path.Should().Be(path);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -130,8 +128,8 @@ public void None_existing_folder_returns_empty_list()
|
||||
|
||||
var result = mocker.Resolve<RootDirProvider>().GetUnmappedFolders(path);
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsEmpty(result);
|
||||
result.Should().NotBeNull();
|
||||
result.Should().BeEmpty();
|
||||
|
||||
mocker.VerifyAllMocks();
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
using System.Linq;
|
||||
using AutoMoq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Model;
|
||||
@ -63,7 +64,7 @@ public void AddByUrlSuccess()
|
||||
"http://www.nzbclub.com/nzb_download.aspx?mid=1950232", "This is an Nzb");
|
||||
|
||||
//Assert
|
||||
Assert.IsTrue(result);
|
||||
result.Should().BeTrue();
|
||||
}
|
||||
|
||||
|
||||
@ -110,7 +111,7 @@ public void AddByUrlNewzbin()
|
||||
"http://www.newzbin.com/browse/post/6107863/nzb", "This is an Nzb");
|
||||
|
||||
//Assert
|
||||
Assert.IsTrue(result);
|
||||
result.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -187,7 +188,7 @@ public void IsInQueue_True()
|
||||
bool result = mocker.Resolve<SabProvider>().IsInQueue("Ubuntu Test");
|
||||
|
||||
//Assert
|
||||
Assert.IsTrue(result);
|
||||
result.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -332,7 +333,7 @@ public void AddNewzbingByUrlSuccess()
|
||||
"http://www.newzbin.com/browse/post/6107863/nzb", "Added by unit tests.");
|
||||
|
||||
//Assert
|
||||
Assert.IsTrue(result);
|
||||
result.Should().BeTrue();
|
||||
}
|
||||
}
|
||||
}
|
@ -202,7 +202,7 @@ public void is_monitored()
|
||||
|
||||
//Act, Assert
|
||||
var provider = mocker.Resolve<SeriesProvider>();
|
||||
Assert.IsTrue(provider.IsMonitored(12));
|
||||
provider.IsMonitored(12).Should().BeTrue();
|
||||
Assert.IsFalse(provider.IsMonitored(11));
|
||||
Assert.IsFalse(provider.IsMonitored(1));
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Data.SQLite;
|
||||
using System.Data.SqlServerCe;
|
||||
using System.IO;
|
||||
using MvcMiniProfiler.Data;
|
||||
using PetaPoco;
|
||||
@ -21,14 +21,15 @@ static Connection()
|
||||
|
||||
public static string GetConnectionString(string path)
|
||||
{
|
||||
return String.Format("Data Source={0};Version=3;Cache Size=30000;Pooling=true;Default Timeout=2", path);
|
||||
//return String.Format("Data Source={0};Version=3;Cache Size=30000;Pooling=true;Default Timeout=2", path);
|
||||
return String.Format("Data Source={0}", path);
|
||||
}
|
||||
|
||||
public static String MainConnectionString
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetConnectionString(Path.Combine(AppDataPath.FullName, "nzbdrone.db"));
|
||||
return GetConnectionString(Path.Combine(AppDataPath.FullName, "nzbdrone.sdf"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,7 +37,7 @@ public static String LogConnectionString
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetConnectionString(Path.Combine(AppDataPath.FullName, "log.db"));
|
||||
return GetConnectionString(Path.Combine(AppDataPath.FullName, "log.sdf"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,9 +45,9 @@ public static String LogConnectionString
|
||||
public static IDatabase GetPetaPocoDb(string connectionString, Boolean profiled = true)
|
||||
{
|
||||
MigrationsHelper.Run(connectionString, true);
|
||||
var sqliteConnection = new SQLiteConnection(connectionString);
|
||||
var sqliteConnection = new SqlCeConnection(connectionString);
|
||||
DbConnection connection = sqliteConnection;
|
||||
|
||||
|
||||
if (profiled)
|
||||
{
|
||||
connection = ProfiledDbConnection.Get(sqliteConnection);
|
||||
|
@ -1,24 +0,0 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
|
||||
[Migration(20110619)]
|
||||
public class Migration20110619 : Migration
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
if (Database.TableExists("Histories"))
|
||||
{
|
||||
Database.RemoveTable("Histories");
|
||||
}
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -5,8 +5,8 @@
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
|
||||
[Migration(20110604)]
|
||||
public class Migration20110616 : Migration
|
||||
[Migration(20110622)]
|
||||
public class Migration20110622 : Migration
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
@ -17,12 +17,12 @@ public override void Up()
|
||||
new Column("CleanTitle", DbType.String, ColumnProperty.Null),
|
||||
new Column("Status", DbType.String, ColumnProperty.Null),
|
||||
new Column("Overview", DbType.String, ColumnProperty.Null),
|
||||
new Column("AirsDayOfWeek", DbType.Int16, ColumnProperty.Null),
|
||||
new Column("AirsDayOfWeek", DbType.Int32, ColumnProperty.Null),
|
||||
new Column("AirTimes", DbType.String, ColumnProperty.Null),
|
||||
new Column("Language", DbType.String, ColumnProperty.Null),
|
||||
new Column("Path", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("Monitored", DbType.Boolean, ColumnProperty.NotNull),
|
||||
new Column("QualityProfileId", DbType.Int16, ColumnProperty.NotNull),
|
||||
new Column("QualityProfileId", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("SeasonFolder", DbType.Boolean, ColumnProperty.NotNull),
|
||||
new Column("LastInfoSync", DbType.DateTime, ColumnProperty.Null),
|
||||
new Column("LastDiskSync", DbType.DateTime, ColumnProperty.Null)
|
||||
@ -33,8 +33,8 @@ public override void Up()
|
||||
new Column("EpisodeId", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
|
||||
new Column("TvDbEpisodeId", DbType.Int32, ColumnProperty.Null),
|
||||
new Column("SeriesId", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("SeasonNumber", DbType.Int16, ColumnProperty.NotNull),
|
||||
new Column("EpisodeNumber", DbType.Int16, ColumnProperty.NotNull),
|
||||
new Column("SeasonNumber", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("EpisodeNumber", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("Title", DbType.String, ColumnProperty.Null),
|
||||
new Column("Overview", DbType.String, ColumnProperty.Null),
|
||||
new Column("Ignored", DbType.Boolean, ColumnProperty.NotNull),
|
||||
@ -50,11 +50,11 @@ public override void Up()
|
||||
ColumnProperty.PrimaryKeyWithIdentity),
|
||||
new Column("SeriesId", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("Path", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("Quality", DbType.Int16, ColumnProperty.NotNull),
|
||||
new Column("Proper", DbType.Int16, ColumnProperty.NotNull),
|
||||
new Column("Quality", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("Proper", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("Size", DbType.Int64, ColumnProperty.NotNull),
|
||||
new Column("DateAdded", DbType.DateTime, ColumnProperty.NotNull),
|
||||
new Column("SeasonNumber", DbType.Int16, ColumnProperty.NotNull)
|
||||
new Column("SeasonNumber", DbType.Int32, ColumnProperty.NotNull)
|
||||
});
|
||||
|
||||
|
||||
@ -73,25 +73,25 @@ public override void Up()
|
||||
|
||||
Database.AddTable("History", new[]
|
||||
{
|
||||
new Column("HistoryId", DbType.Int64, ColumnProperty.PrimaryKey),
|
||||
new Column("HistoryId", DbType.Int64, ColumnProperty.PrimaryKeyWithIdentity),
|
||||
new Column("EpisodeId", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("SeriesId", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("NzbTitle", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("Date", DbType.DateTime, ColumnProperty.NotNull),
|
||||
new Column("Quality", DbType.Int16, ColumnProperty.NotNull),
|
||||
new Column("Quality", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("IsProper", DbType.Boolean, ColumnProperty.NotNull),
|
||||
new Column("Indexer", DbType.String, ColumnProperty.NotNull)
|
||||
});
|
||||
|
||||
Database.AddTable("RootDirs", new[]
|
||||
{
|
||||
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKey),
|
||||
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
|
||||
new Column("Path", DbType.String, ColumnProperty.NotNull)
|
||||
});
|
||||
|
||||
Database.AddTable("ExternalNotificationSettings", new[]
|
||||
{
|
||||
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKey),
|
||||
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
|
||||
new Column("Enabled", DbType.Boolean, ColumnProperty.NotNull),
|
||||
new Column("NotifierName", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("Name", DbType.String, ColumnProperty.NotNull)
|
||||
@ -99,7 +99,7 @@ public override void Up()
|
||||
|
||||
Database.AddTable("JobSettings", new[]
|
||||
{
|
||||
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKey),
|
||||
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
|
||||
new Column("Enable", DbType.Boolean, ColumnProperty.NotNull),
|
||||
new Column("TypeName", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("Name", DbType.String, ColumnProperty.NotNull),
|
||||
@ -110,7 +110,7 @@ public override void Up()
|
||||
|
||||
Database.AddTable("QualityProfiles", new[]
|
||||
{
|
||||
new Column("QualityProfileId", DbType.Int32, ColumnProperty.PrimaryKey),
|
||||
new Column("QualityProfileId", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
|
||||
new Column("Name", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("Cutoff", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("SonicAllowed", DbType.String, ColumnProperty.NotNull),
|
||||
@ -118,7 +118,7 @@ public override void Up()
|
||||
|
||||
Database.AddTable("Logs", new[]
|
||||
{
|
||||
new Column("LogId", DbType.Int64, ColumnProperty.PrimaryKey),
|
||||
new Column("LogId", DbType.Int64, ColumnProperty.PrimaryKeyWithIdentity),
|
||||
new Column("Message", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("Time", DbType.DateTime, ColumnProperty.NotNull),
|
||||
new Column("Logger", DbType.String, ColumnProperty.NotNull),
|
||||
@ -130,7 +130,7 @@ public override void Up()
|
||||
|
||||
Database.AddTable("IndexerSettings", new[]
|
||||
{
|
||||
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKey),
|
||||
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
|
||||
new Column("Enable", DbType.Boolean, ColumnProperty.NotNull),
|
||||
new Column("IndexProviderType", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("Name", DbType.String, ColumnProperty.NotNull),
|
@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlServerCe;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using NLog;
|
||||
|
||||
@ -16,6 +18,8 @@ public static void Run(string connetionString, bool trace)
|
||||
if (_migrated.ContainsKey(connetionString)) return;
|
||||
_migrated.Add(connetionString, string.Empty);
|
||||
|
||||
EnsureDatabase(connetionString);
|
||||
|
||||
Logger.Info("Preparing run database migration");
|
||||
|
||||
try
|
||||
@ -23,11 +27,11 @@ public static void Run(string connetionString, bool trace)
|
||||
Migrator.Migrator migrator;
|
||||
if (trace)
|
||||
{
|
||||
migrator = new Migrator.Migrator("Sqlite", connetionString, Assembly.GetAssembly(typeof(MigrationsHelper)), true, new MigrationLogger());
|
||||
migrator = new Migrator.Migrator("sqlserverce", connetionString, Assembly.GetAssembly(typeof(MigrationsHelper)), true, new MigrationLogger());
|
||||
}
|
||||
else
|
||||
{
|
||||
migrator = new Migrator.Migrator("Sqlite", connetionString, Assembly.GetAssembly(typeof(MigrationsHelper)));
|
||||
migrator = new Migrator.Migrator("sqlserverce", connetionString, Assembly.GetAssembly(typeof(MigrationsHelper)));
|
||||
}
|
||||
|
||||
|
||||
@ -46,8 +50,18 @@ public static void Run(string connetionString, bool trace)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void EnsureDatabase(string constr)
|
||||
{
|
||||
var connection = new SqlCeConnection(constr);
|
||||
if (!File.Exists(connection.Database))
|
||||
{
|
||||
var engine = new SqlCeEngine(constr);
|
||||
engine.CreateDatabase();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -24,6 +24,7 @@
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using MvcMiniProfiler;
|
||||
|
||||
namespace PetaPoco
|
||||
{
|
||||
@ -316,7 +317,7 @@ enum DBType
|
||||
Oracle,
|
||||
SQLite
|
||||
}
|
||||
DBType _dbType = DBType.SQLite;
|
||||
DBType _dbType = DBType.SqlServerCE;
|
||||
|
||||
// Common initialization
|
||||
private void CommonConstruct()
|
||||
@ -645,28 +646,31 @@ public int Execute(string sql, params object[] args)
|
||||
|
||||
public int Execute(Sql sql)
|
||||
{
|
||||
try
|
||||
using (MiniProfiler.StepStatic("Peta Execute SQL"))
|
||||
{
|
||||
OpenSharedConnection();
|
||||
try
|
||||
{
|
||||
using (var cmd = CreateCommand(_sharedConnection, sql))
|
||||
OpenSharedConnection();
|
||||
try
|
||||
{
|
||||
var result = cmd.ExecuteNonQuery();
|
||||
OnExecutedCommand(cmd);
|
||||
return result;
|
||||
using (var cmd = CreateCommand(_sharedConnection, sql))
|
||||
{
|
||||
var result = cmd.ExecuteNonQuery();
|
||||
OnExecutedCommand(cmd);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
CloseSharedConnection();
|
||||
}
|
||||
}
|
||||
finally
|
||||
catch (Exception x)
|
||||
{
|
||||
CloseSharedConnection();
|
||||
OnException(x);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
OnException(x);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// Execute and cast a scalar property
|
||||
@ -677,28 +681,31 @@ public T ExecuteScalar<T>(string sql, params object[] args)
|
||||
|
||||
public T ExecuteScalar<T>(Sql sql)
|
||||
{
|
||||
try
|
||||
using (MiniProfiler.StepStatic("Peta ExecuteScalar<T>"))
|
||||
{
|
||||
OpenSharedConnection();
|
||||
try
|
||||
{
|
||||
using (var cmd = CreateCommand(_sharedConnection, sql))
|
||||
OpenSharedConnection();
|
||||
try
|
||||
{
|
||||
object val = cmd.ExecuteScalar();
|
||||
OnExecutedCommand(cmd);
|
||||
return (T)Convert.ChangeType(val, typeof(T));
|
||||
using (var cmd = CreateCommand(_sharedConnection, sql))
|
||||
{
|
||||
object val = cmd.ExecuteScalar();
|
||||
OnExecutedCommand(cmd);
|
||||
return (T)Convert.ChangeType(val, typeof(T));
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
CloseSharedConnection();
|
||||
}
|
||||
}
|
||||
finally
|
||||
catch (Exception x)
|
||||
{
|
||||
CloseSharedConnection();
|
||||
OnException(x);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
OnException(x);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
Regex rxSelect = new Regex(@"\A\s*(SELECT|EXECUTE|CALL)\s", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.IgnoreCase | RegexOptions.Multiline);
|
||||
@ -887,50 +894,55 @@ public IEnumerable<T> Query<T>(string sql, params object[] args)
|
||||
|
||||
public IEnumerable<T> Query<T>(Sql sql)
|
||||
{
|
||||
OpenSharedConnection();
|
||||
try
|
||||
using (MiniProfiler.StepStatic("Peta Query SQL"))
|
||||
{
|
||||
using (var cmd = CreateCommand(_sharedConnection, sql))
|
||||
OpenSharedConnection();
|
||||
try
|
||||
{
|
||||
IDataReader r;
|
||||
var pd = PocoData.ForType(typeof(T));
|
||||
try
|
||||
using (var cmd = CreateCommand(_sharedConnection, sql))
|
||||
{
|
||||
r = cmd.ExecuteReader();
|
||||
OnExecutedCommand(cmd);
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
OnException(x);
|
||||
throw;
|
||||
}
|
||||
|
||||
using (r)
|
||||
{
|
||||
var factory = pd.GetFactory(cmd.CommandText, _sharedConnection.ConnectionString, ForceDateTimesToUtc, 0, r.FieldCount, r) as Func<IDataReader, T>;
|
||||
while (true)
|
||||
IDataReader r;
|
||||
var pd = PocoData.ForType(typeof(T));
|
||||
try
|
||||
{
|
||||
T poco;
|
||||
try
|
||||
{
|
||||
if (!r.Read())
|
||||
yield break;
|
||||
poco = factory(r);
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
OnException(x);
|
||||
throw;
|
||||
}
|
||||
r = cmd.ExecuteReader();
|
||||
OnExecutedCommand(cmd);
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
OnException(x);
|
||||
throw;
|
||||
}
|
||||
|
||||
yield return poco;
|
||||
using (r)
|
||||
{
|
||||
var factory =
|
||||
pd.GetFactory(cmd.CommandText, _sharedConnection.ConnectionString, ForceDateTimesToUtc, 0, r.FieldCount, r)
|
||||
as Func<IDataReader, T>;
|
||||
while (true)
|
||||
{
|
||||
T poco;
|
||||
try
|
||||
{
|
||||
if (!r.Read())
|
||||
yield break;
|
||||
poco = factory(r);
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
OnException(x);
|
||||
throw;
|
||||
}
|
||||
|
||||
yield return poco;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
CloseSharedConnection();
|
||||
finally
|
||||
{
|
||||
CloseSharedConnection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1181,62 +1193,65 @@ Func<IDataReader, object, TRet> GetMultiPocoFactory<TRet>(Type[] types, string s
|
||||
// Actual implementation of the multi-poco query
|
||||
public IEnumerable<TRet> Query<TRet>(Type[] types, object cb, string sql, params object[] args)
|
||||
{
|
||||
OpenSharedConnection();
|
||||
try
|
||||
using (MiniProfiler.StepStatic("Peta Query Type[]"))
|
||||
{
|
||||
using (var cmd = CreateCommand(_sharedConnection, sql, args))
|
||||
OpenSharedConnection();
|
||||
try
|
||||
{
|
||||
IDataReader r;
|
||||
try
|
||||
using (var cmd = CreateCommand(_sharedConnection, sql, args))
|
||||
{
|
||||
r = cmd.ExecuteReader();
|
||||
OnExecutedCommand(cmd);
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
OnException(x);
|
||||
throw;
|
||||
}
|
||||
var factory = GetMultiPocoFactory<TRet>(types, sql, r);
|
||||
if (cb == null)
|
||||
cb = GetAutoMapper(types.ToArray());
|
||||
bool bNeedTerminator = false;
|
||||
using (r)
|
||||
{
|
||||
while (true)
|
||||
IDataReader r;
|
||||
try
|
||||
{
|
||||
TRet poco;
|
||||
try
|
||||
{
|
||||
if (!r.Read())
|
||||
break;
|
||||
poco = factory(r, cb);
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
OnException(x);
|
||||
throw;
|
||||
}
|
||||
|
||||
if (poco != null)
|
||||
yield return poco;
|
||||
else
|
||||
bNeedTerminator = true;
|
||||
r = cmd.ExecuteReader();
|
||||
OnExecutedCommand(cmd);
|
||||
}
|
||||
if (bNeedTerminator)
|
||||
catch (Exception x)
|
||||
{
|
||||
var poco = (TRet)(cb as Delegate).DynamicInvoke(new object[types.Length]);
|
||||
if (poco != null)
|
||||
yield return poco;
|
||||
else
|
||||
yield break;
|
||||
OnException(x);
|
||||
throw;
|
||||
}
|
||||
var factory = GetMultiPocoFactory<TRet>(types, sql, r);
|
||||
if (cb == null)
|
||||
cb = GetAutoMapper(types.ToArray());
|
||||
bool bNeedTerminator = false;
|
||||
using (r)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
TRet poco;
|
||||
try
|
||||
{
|
||||
if (!r.Read())
|
||||
break;
|
||||
poco = factory(r, cb);
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
OnException(x);
|
||||
throw;
|
||||
}
|
||||
|
||||
if (poco != null)
|
||||
yield return poco;
|
||||
else
|
||||
bNeedTerminator = true;
|
||||
}
|
||||
if (bNeedTerminator)
|
||||
{
|
||||
var poco = (TRet)(cb as Delegate).DynamicInvoke(new object[types.Length]);
|
||||
if (poco != null)
|
||||
yield return poco;
|
||||
else
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
CloseSharedConnection();
|
||||
finally
|
||||
{
|
||||
CloseSharedConnection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1355,172 +1370,175 @@ public object Insert(string tableName, string primaryKeyName, object poco)
|
||||
// the new id is returned.
|
||||
public object Insert(string tableName, string primaryKeyName, bool autoIncrement, object poco)
|
||||
{
|
||||
try
|
||||
using (MiniProfiler.StepStatic("Peta Insert " + tableName))
|
||||
{
|
||||
OpenSharedConnection();
|
||||
try
|
||||
{
|
||||
using (var cmd = CreateCommand(_sharedConnection, ""))
|
||||
OpenSharedConnection();
|
||||
try
|
||||
{
|
||||
var pd = PocoData.ForObject(poco, primaryKeyName);
|
||||
var names = new List<string>();
|
||||
var values = new List<string>();
|
||||
var index = 0;
|
||||
var versionName = "";
|
||||
|
||||
foreach (var i in pd.Columns)
|
||||
using (var cmd = CreateCommand(_sharedConnection, ""))
|
||||
{
|
||||
// Don't insert result columns
|
||||
if (i.Value.ResultColumn)
|
||||
continue;
|
||||
var pd = PocoData.ForObject(poco, primaryKeyName);
|
||||
var names = new List<string>();
|
||||
var values = new List<string>();
|
||||
var index = 0;
|
||||
var versionName = "";
|
||||
|
||||
// Don't insert the primary key (except under oracle where we need bring in the next sequence value)
|
||||
if (autoIncrement && primaryKeyName != null && string.Compare(i.Key, primaryKeyName, true) == 0)
|
||||
foreach (var i in pd.Columns)
|
||||
{
|
||||
if (_dbType == DBType.Oracle && !string.IsNullOrEmpty(pd.TableInfo.SequenceName))
|
||||
// Don't insert result columns
|
||||
if (i.Value.ResultColumn)
|
||||
continue;
|
||||
|
||||
// Don't insert the primary key (except under oracle where we need bring in the next sequence value)
|
||||
if (autoIncrement && primaryKeyName != null && string.Compare(i.Key, primaryKeyName, true) == 0)
|
||||
{
|
||||
names.Add(i.Key);
|
||||
values.Add(string.Format("{0}.nextval", pd.TableInfo.SequenceName));
|
||||
if (_dbType == DBType.Oracle && !string.IsNullOrEmpty(pd.TableInfo.SequenceName))
|
||||
{
|
||||
names.Add(i.Key);
|
||||
values.Add(string.Format("{0}.nextval", pd.TableInfo.SequenceName));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
|
||||
names.Add(EscapeSqlIdentifier(i.Key));
|
||||
values.Add(string.Format("{0}{1}", _paramPrefix, index++));
|
||||
|
||||
object val = i.Value.GetValue(poco);
|
||||
if (i.Value.VersionColumn)
|
||||
{
|
||||
val = 1;
|
||||
versionName = i.Key;
|
||||
}
|
||||
|
||||
AddParam(cmd, val, _paramPrefix);
|
||||
}
|
||||
|
||||
names.Add(EscapeSqlIdentifier(i.Key));
|
||||
values.Add(string.Format("{0}{1}", _paramPrefix, index++));
|
||||
|
||||
object val = i.Value.GetValue(poco);
|
||||
if (i.Value.VersionColumn)
|
||||
{
|
||||
val = 1;
|
||||
versionName = i.Key;
|
||||
}
|
||||
|
||||
AddParam(cmd, val, _paramPrefix);
|
||||
}
|
||||
|
||||
cmd.CommandText = string.Format("INSERT INTO {0} ({1}) VALUES ({2})",
|
||||
EscapeTableName(tableName),
|
||||
string.Join(",", names.ToArray()),
|
||||
string.Join(",", values.ToArray())
|
||||
cmd.CommandText = string.Format("INSERT INTO {0} ({1}) VALUES ({2})",
|
||||
EscapeTableName(tableName),
|
||||
string.Join(",", names.ToArray()),
|
||||
string.Join(",", values.ToArray())
|
||||
);
|
||||
|
||||
if (!autoIncrement)
|
||||
{
|
||||
DoPreExecute(cmd);
|
||||
cmd.ExecuteNonQuery();
|
||||
OnExecutedCommand(cmd);
|
||||
return true;
|
||||
}
|
||||
|
||||
object id;
|
||||
|
||||
switch (_dbType)
|
||||
{
|
||||
case DBType.SqlServerCE:
|
||||
if (!autoIncrement)
|
||||
{
|
||||
DoPreExecute(cmd);
|
||||
cmd.ExecuteNonQuery();
|
||||
OnExecutedCommand(cmd);
|
||||
id = ExecuteScalar<object>("SELECT @@@IDENTITY AS NewID;");
|
||||
break;
|
||||
case DBType.SqlServer:
|
||||
cmd.CommandText += ";\nSELECT SCOPE_IDENTITY() AS NewID;";
|
||||
DoPreExecute(cmd);
|
||||
id = cmd.ExecuteScalar();
|
||||
OnExecutedCommand(cmd);
|
||||
break;
|
||||
case DBType.PostgreSQL:
|
||||
if (primaryKeyName != null)
|
||||
{
|
||||
cmd.CommandText += string.Format("returning {0} as NewID", EscapeSqlIdentifier(primaryKeyName));
|
||||
return true;
|
||||
}
|
||||
|
||||
object id;
|
||||
|
||||
switch (_dbType)
|
||||
{
|
||||
case DBType.SqlServerCE:
|
||||
DoPreExecute(cmd);
|
||||
cmd.ExecuteNonQuery();
|
||||
OnExecutedCommand(cmd);
|
||||
id = ExecuteScalar<object>("SELECT @@@IDENTITY AS NewID;");
|
||||
break;
|
||||
case DBType.SqlServer:
|
||||
cmd.CommandText += ";\nSELECT SCOPE_IDENTITY() AS NewID;";
|
||||
DoPreExecute(cmd);
|
||||
id = cmd.ExecuteScalar();
|
||||
}
|
||||
else
|
||||
{
|
||||
id = -1;
|
||||
DoPreExecute(cmd);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
OnExecutedCommand(cmd);
|
||||
break;
|
||||
case DBType.Oracle:
|
||||
if (primaryKeyName != null)
|
||||
{
|
||||
cmd.CommandText += string.Format(" returning {0} into :newid", EscapeSqlIdentifier(primaryKeyName));
|
||||
var param = cmd.CreateParameter();
|
||||
param.ParameterName = ":newid";
|
||||
param.Value = DBNull.Value;
|
||||
param.Direction = ParameterDirection.ReturnValue;
|
||||
param.DbType = DbType.Int64;
|
||||
cmd.Parameters.Add(param);
|
||||
DoPreExecute(cmd);
|
||||
cmd.ExecuteNonQuery();
|
||||
id = param.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
id = -1;
|
||||
DoPreExecute(cmd);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
OnExecutedCommand(cmd);
|
||||
break;
|
||||
case DBType.SQLite:
|
||||
if (primaryKeyName != null)
|
||||
{
|
||||
cmd.CommandText += ";\nSELECT last_insert_rowid();";
|
||||
OnExecutedCommand(cmd);
|
||||
break;
|
||||
case DBType.PostgreSQL:
|
||||
if (primaryKeyName != null)
|
||||
{
|
||||
cmd.CommandText += string.Format("returning {0} as NewID", EscapeSqlIdentifier(primaryKeyName));
|
||||
DoPreExecute(cmd);
|
||||
id = cmd.ExecuteScalar();
|
||||
}
|
||||
else
|
||||
{
|
||||
id = -1;
|
||||
DoPreExecute(cmd);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
OnExecutedCommand(cmd);
|
||||
break;
|
||||
case DBType.Oracle:
|
||||
if (primaryKeyName != null)
|
||||
{
|
||||
cmd.CommandText += string.Format(" returning {0} into :newid", EscapeSqlIdentifier(primaryKeyName));
|
||||
var param = cmd.CreateParameter();
|
||||
param.ParameterName = ":newid";
|
||||
param.Value = DBNull.Value;
|
||||
param.Direction = ParameterDirection.ReturnValue;
|
||||
param.DbType = DbType.Int64;
|
||||
cmd.Parameters.Add(param);
|
||||
DoPreExecute(cmd);
|
||||
cmd.ExecuteNonQuery();
|
||||
id = param.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
id = -1;
|
||||
DoPreExecute(cmd);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
OnExecutedCommand(cmd);
|
||||
break;
|
||||
case DBType.SQLite:
|
||||
if (primaryKeyName != null)
|
||||
{
|
||||
cmd.CommandText += ";\nSELECT last_insert_rowid();";
|
||||
DoPreExecute(cmd);
|
||||
id = cmd.ExecuteScalar();
|
||||
}
|
||||
else
|
||||
{
|
||||
id = -1;
|
||||
DoPreExecute(cmd);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
OnExecutedCommand(cmd);
|
||||
break;
|
||||
default:
|
||||
cmd.CommandText += ";\nSELECT @@IDENTITY AS NewID;";
|
||||
DoPreExecute(cmd);
|
||||
id = cmd.ExecuteScalar();
|
||||
}
|
||||
else
|
||||
OnExecutedCommand(cmd);
|
||||
break;
|
||||
}
|
||||
|
||||
// Assign the ID back to the primary key property
|
||||
if (primaryKeyName != null)
|
||||
{
|
||||
PocoColumn pc;
|
||||
if (pd.Columns.TryGetValue(primaryKeyName, out pc))
|
||||
{
|
||||
id = -1;
|
||||
DoPreExecute(cmd);
|
||||
cmd.ExecuteNonQuery();
|
||||
pc.SetValue(poco, pc.ChangeType(id));
|
||||
}
|
||||
OnExecutedCommand(cmd);
|
||||
break;
|
||||
default:
|
||||
cmd.CommandText += ";\nSELECT @@IDENTITY AS NewID;";
|
||||
DoPreExecute(cmd);
|
||||
id = cmd.ExecuteScalar();
|
||||
OnExecutedCommand(cmd);
|
||||
break;
|
||||
}
|
||||
|
||||
// Assign the ID back to the primary key property
|
||||
if (primaryKeyName != null)
|
||||
{
|
||||
PocoColumn pc;
|
||||
if (pd.Columns.TryGetValue(primaryKeyName, out pc))
|
||||
{
|
||||
pc.SetValue(poco, pc.ChangeType(id));
|
||||
}
|
||||
}
|
||||
|
||||
// Assign the Version column
|
||||
if (!string.IsNullOrEmpty(versionName))
|
||||
{
|
||||
PocoColumn pc;
|
||||
if (pd.Columns.TryGetValue(versionName, out pc))
|
||||
// Assign the Version column
|
||||
if (!string.IsNullOrEmpty(versionName))
|
||||
{
|
||||
pc.SetValue(poco, pc.ChangeType(1));
|
||||
PocoColumn pc;
|
||||
if (pd.Columns.TryGetValue(versionName, out pc))
|
||||
{
|
||||
pc.SetValue(poco, pc.ChangeType(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return id;
|
||||
return id;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
CloseSharedConnection();
|
||||
}
|
||||
}
|
||||
finally
|
||||
catch (Exception x)
|
||||
{
|
||||
CloseSharedConnection();
|
||||
OnException(x);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
OnException(x);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// Insert an annotated poco object
|
||||
@ -1546,95 +1564,102 @@ public void InsertMany<T>(IEnumerable<T> pocoList)
|
||||
// Update a record with values from a poco. primary key value can be either supplied or read from the poco
|
||||
public int Update(string tableName, string primaryKeyName, object poco, object primaryKeyValue)
|
||||
{
|
||||
try
|
||||
using (MiniProfiler.StepStatic("Peta Update " + tableName))
|
||||
{
|
||||
OpenSharedConnection();
|
||||
try
|
||||
{
|
||||
using (var cmd = CreateCommand(_sharedConnection, ""))
|
||||
OpenSharedConnection();
|
||||
try
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
var index = 0;
|
||||
var pd = PocoData.ForObject(poco, primaryKeyName);
|
||||
string versionName = null;
|
||||
object versionValue = null;
|
||||
|
||||
var primaryKeyValuePairs = GetPrimaryKeyValues(primaryKeyName, primaryKeyValue);
|
||||
|
||||
foreach (var i in pd.Columns)
|
||||
using (var cmd = CreateCommand(_sharedConnection, ""))
|
||||
{
|
||||
// Don't update the primary key, but grab the value if we don't have it
|
||||
if (primaryKeyValue == null && primaryKeyValuePairs.ContainsKey(i.Key))
|
||||
var sb = new StringBuilder();
|
||||
var index = 0;
|
||||
var pd = PocoData.ForObject(poco, primaryKeyName);
|
||||
string versionName = null;
|
||||
object versionValue = null;
|
||||
|
||||
var primaryKeyValuePairs = GetPrimaryKeyValues(primaryKeyName, primaryKeyValue);
|
||||
|
||||
foreach (var i in pd.Columns)
|
||||
{
|
||||
primaryKeyValuePairs[i.Key] = i.Value.PropertyInfo.GetValue(poco, null);
|
||||
continue;
|
||||
// Don't update the primary key, but grab the value if we don't have it
|
||||
if (primaryKeyValue == null && primaryKeyValuePairs.ContainsKey(i.Key))
|
||||
{
|
||||
primaryKeyValuePairs[i.Key] = i.Value.PropertyInfo.GetValue(poco, null);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Dont update result only columns
|
||||
if (i.Value.ResultColumn)
|
||||
continue;
|
||||
|
||||
object value = i.Value.PropertyInfo.GetValue(poco, null);
|
||||
|
||||
if (i.Value.VersionColumn)
|
||||
{
|
||||
versionName = i.Key;
|
||||
versionValue = value;
|
||||
value = Convert.ToInt64(value) + 1;
|
||||
}
|
||||
|
||||
// Build the sql
|
||||
if (index > 0)
|
||||
sb.Append(", ");
|
||||
sb.AppendFormat("{0} = {1}{2}", EscapeSqlIdentifier(i.Key), _paramPrefix, index++);
|
||||
|
||||
// Store the parameter in the command
|
||||
AddParam(cmd, value, _paramPrefix);
|
||||
}
|
||||
|
||||
// Dont update result only columns
|
||||
if (i.Value.ResultColumn)
|
||||
continue;
|
||||
cmd.CommandText = string.Format("UPDATE {0} SET {1} WHERE {2}",
|
||||
EscapeSqlIdentifier(tableName), sb.ToString(),
|
||||
BuildPrimaryKeySql(primaryKeyValuePairs, ref index));
|
||||
|
||||
object value = i.Value.PropertyInfo.GetValue(poco, null);
|
||||
|
||||
if (i.Value.VersionColumn)
|
||||
foreach (var keyValue in primaryKeyValuePairs)
|
||||
{
|
||||
versionName = i.Key;
|
||||
versionValue = value;
|
||||
value = Convert.ToInt64(value) + 1;
|
||||
AddParam(cmd, keyValue.Value, _paramPrefix);
|
||||
}
|
||||
|
||||
// Build the sql
|
||||
if (index > 0)
|
||||
sb.Append(", ");
|
||||
sb.AppendFormat("{0} = {1}{2}", EscapeSqlIdentifier(i.Key), _paramPrefix, index++);
|
||||
|
||||
// Store the parameter in the command
|
||||
AddParam(cmd, value, _paramPrefix);
|
||||
}
|
||||
|
||||
cmd.CommandText = string.Format("UPDATE {0} SET {1} WHERE {2}",
|
||||
EscapeSqlIdentifier(tableName), sb.ToString(), BuildPrimaryKeySql(primaryKeyValuePairs, ref index));
|
||||
|
||||
foreach (var keyValue in primaryKeyValuePairs)
|
||||
{
|
||||
AddParam(cmd, keyValue.Value, _paramPrefix);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(versionName))
|
||||
{
|
||||
cmd.CommandText += string.Format(" AND {0} = {1}{2}", EscapeSqlIdentifier(versionName), _paramPrefix, index++);
|
||||
AddParam(cmd, versionValue, _paramPrefix);
|
||||
}
|
||||
|
||||
DoPreExecute(cmd);
|
||||
|
||||
// Do it
|
||||
var result = cmd.ExecuteNonQuery();
|
||||
OnExecutedCommand(cmd);
|
||||
|
||||
// Set Version
|
||||
if (!string.IsNullOrEmpty(versionName))
|
||||
{
|
||||
PocoColumn pc;
|
||||
if (pd.Columns.TryGetValue(versionName, out pc))
|
||||
if (!string.IsNullOrEmpty(versionName))
|
||||
{
|
||||
pc.PropertyInfo.SetValue(poco, Convert.ChangeType(Convert.ToInt64(versionValue) + 1, pc.PropertyInfo.PropertyType), null);
|
||||
cmd.CommandText += string.Format(" AND {0} = {1}{2}", EscapeSqlIdentifier(versionName), _paramPrefix,
|
||||
index++);
|
||||
AddParam(cmd, versionValue, _paramPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
DoPreExecute(cmd);
|
||||
|
||||
// Do it
|
||||
var result = cmd.ExecuteNonQuery();
|
||||
OnExecutedCommand(cmd);
|
||||
|
||||
// Set Version
|
||||
if (!string.IsNullOrEmpty(versionName))
|
||||
{
|
||||
PocoColumn pc;
|
||||
if (pd.Columns.TryGetValue(versionName, out pc))
|
||||
{
|
||||
pc.PropertyInfo.SetValue(poco,
|
||||
Convert.ChangeType(Convert.ToInt64(versionValue) + 1,
|
||||
pc.PropertyInfo.PropertyType), null);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
CloseSharedConnection();
|
||||
}
|
||||
}
|
||||
finally
|
||||
catch (Exception x)
|
||||
{
|
||||
CloseSharedConnection();
|
||||
OnException(x);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
OnException(x);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private string BuildPrimaryKeySql(Dictionary<string, object> primaryKeyValuePair, ref int index)
|
||||
|
@ -1,10 +1,12 @@
|
||||
using System;
|
||||
using NLog;
|
||||
using NLog.Targets;
|
||||
using NLog.Targets.Wrappers;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.Instrumentation
|
||||
{
|
||||
|
||||
public class SubsonicTarget : Target
|
||||
{
|
||||
private readonly IDatabase _database;
|
||||
@ -14,6 +16,8 @@ public SubsonicTarget(IDatabase database)
|
||||
_database = database;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected override void Write(LogEventInfo logEvent)
|
||||
{
|
||||
var log = new Log();
|
||||
|
@ -7,14 +7,14 @@ namespace NzbDrone.Core.Model
|
||||
public class EpisodeParseResult
|
||||
{
|
||||
internal string CleanTitle { get; set; }
|
||||
|
||||
|
||||
public string EpisodeTitle { get; set; }
|
||||
|
||||
internal int SeasonNumber { get; set; }
|
||||
|
||||
internal List<int> EpisodeNumbers { get; set; }
|
||||
|
||||
internal DateTime AirDate { get; set; }
|
||||
internal DateTime? AirDate { get; set; }
|
||||
|
||||
public Quality Quality { get; set; }
|
||||
|
||||
@ -30,11 +30,14 @@ public class EpisodeParseResult
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (EpisodeNumbers == null)
|
||||
return string.Format("{0} - {1} {2}", CleanTitle, AirDate.ToShortDateString(), Quality);
|
||||
if (AirDate != null && EpisodeNumbers == null)
|
||||
return string.Format("{0} - {1} {2}", CleanTitle, AirDate.Value.ToShortDateString(), Quality);
|
||||
|
||||
return string.Format("{0} - S{1:00}E{2} {3}", CleanTitle, SeasonNumber,
|
||||
String.Join("-", EpisodeNumbers), Quality);
|
||||
if (EpisodeNumbers != null)
|
||||
return string.Format("{0} - S{1:00}E{2} {3}", CleanTitle, SeasonNumber,
|
||||
String.Join("-", EpisodeNumbers), Quality);
|
||||
|
||||
return NzbTitle;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -155,9 +155,10 @@
|
||||
<Reference Include="System.configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Data.SQLite, Version=1.0.72.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
|
||||
<Reference Include="System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libraries\System.Data.SQLite.dll</HintPath>
|
||||
<HintPath>..\Libraries\System.Data.SqlServerCe.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
@ -176,8 +177,7 @@
|
||||
<Compile Include="Datastore\MigrationLogger.cs" />
|
||||
<Compile Include="Datastore\MigrationsHelper.cs" />
|
||||
<Compile Include="Datastore\CustomeMapper.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20110619.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20110616.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20110622.cs" />
|
||||
<Compile Include="Datastore\SqliteProvider.cs" />
|
||||
<Compile Include="Fluent.cs" />
|
||||
<Compile Include="Helpers\EpisodeSortingHelper.cs" />
|
||||
|
@ -278,7 +278,7 @@ public virtual string GetValue(string key, object defaultValue)
|
||||
{
|
||||
string value;
|
||||
|
||||
var dbValue = _database.SingleOrDefault<Config>("WHERE Key=@0", key);
|
||||
var dbValue = _database.SingleOrDefault<Config>("WHERE [Key] =@0", key);
|
||||
|
||||
if (dbValue != null && !String.IsNullOrEmpty(dbValue.Value))
|
||||
return dbValue.Value;
|
||||
@ -308,7 +308,7 @@ public virtual void SetValue(string key, string value)
|
||||
|
||||
Logger.Debug("Writing Setting to file. Key:'{0}' Value:'{1}'", key, value);
|
||||
|
||||
var dbValue = _database.SingleOrDefault<Config>("WHERE KEY=@0", key);
|
||||
var dbValue = _database.SingleOrDefault<Config>("WHERE [KEY]=@0", key);
|
||||
|
||||
if (dbValue == null)
|
||||
{
|
||||
@ -317,7 +317,11 @@ public virtual void SetValue(string key, string value)
|
||||
else
|
||||
{
|
||||
dbValue.Value = value;
|
||||
_database.Update(dbValue);
|
||||
using (var tran = _database.GetTransaction())
|
||||
{
|
||||
_database.Update(dbValue);
|
||||
tran.Complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -113,9 +113,9 @@ public virtual IList<Episode> GetEpisodesByParseResult(EpisodeParseResult parseR
|
||||
foreach (var episodeNumber in parseResult.EpisodeNumbers)
|
||||
{
|
||||
var episodeInfo = GetEpisode(parseResult.Series.SeriesId, parseResult.SeasonNumber, episodeNumber);
|
||||
if (episodeInfo == null)
|
||||
if (episodeInfo == null && parseResult.AirDate != null)
|
||||
{
|
||||
episodeInfo = GetEpisode(parseResult.Series.SeriesId, parseResult.AirDate);
|
||||
episodeInfo = GetEpisode(parseResult.Series.SeriesId, parseResult.AirDate.Value);
|
||||
}
|
||||
//if still null we should add the temp episode
|
||||
if (episodeInfo == null && autoAddNew)
|
||||
@ -209,12 +209,16 @@ public virtual void RefreshEpisodeInfo(Series series)
|
||||
|
||||
episodeToUpdate.SeriesId = series.SeriesId;
|
||||
episodeToUpdate.TvDbEpisodeId = episode.Id;
|
||||
episodeToUpdate.AirDate = episode.FirstAired.Date;
|
||||
episodeToUpdate.EpisodeNumber = episode.EpisodeNumber;
|
||||
episodeToUpdate.SeasonNumber = episode.SeasonNumber;
|
||||
episodeToUpdate.Title = episode.EpisodeName;
|
||||
episodeToUpdate.Overview = episode.Overview;
|
||||
|
||||
if (episode.FirstAired.Year > 1900)
|
||||
{
|
||||
episodeToUpdate.AirDate = episode.FirstAired.Date;
|
||||
}
|
||||
|
||||
successCount++;
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -292,7 +292,7 @@ public virtual void Initialize()
|
||||
TypeName = timer.GetType().ToString(),
|
||||
Name = timerProviderLocal.Name,
|
||||
Interval = timerProviderLocal.DefaultInterval,
|
||||
LastExecution = DateTime.MinValue
|
||||
LastExecution = new DateTime(2000, 1, 1)
|
||||
};
|
||||
|
||||
SaveSettings(settings);
|
||||
|
@ -72,7 +72,7 @@ public virtual Tuple<int, int> GetEpisodeFilesCount(int seriesId)
|
||||
{
|
||||
var allEpisodes = _episodeProvider.GetEpisodeBySeries(seriesId).ToList();
|
||||
|
||||
var episodeTotal = allEpisodes.Where(e => !e.Ignored && e.AirDate <= DateTime.Today && e.AirDate.Year > 1900).ToList();
|
||||
var episodeTotal = allEpisodes.Where(e => !e.Ignored && e.AirDate != null && e.AirDate <= DateTime.Today).ToList();
|
||||
var avilableEpisodes = episodeTotal.Where(e => e.EpisodeFileId > 0).ToList();
|
||||
|
||||
return new Tuple<int, int>(avilableEpisodes.Count, episodeTotal.Count);
|
||||
|
@ -49,14 +49,15 @@ public virtual IList<Series> GetAllSeriesWithEpisodeCount(bool ignoreSpecialsInS
|
||||
if (!ignoreSpecialsInSeasonCount)
|
||||
seasonNumber = -1;
|
||||
|
||||
var series = _database.Fetch<Series, QualityProfile>(@"SELECT Series.*, COUNT (NULLIF(Ignored, 1)) AS EpisodeCount,
|
||||
SUM(CASE WHEN Ignored = 0 AND EpisodeFileId > 0 THEN 1 ELSE 0 END) as EpisodeFileCount,
|
||||
COUNT (DISTINCT(NULLIF(SeasonNumber, @0))) as SeasonCount,
|
||||
QualityProfiles.*
|
||||
FROM Series
|
||||
INNER JOIN QualityProfiles ON Series.QualityProfileId = QualityProfiles.QualityProfileId
|
||||
JOIN Episodes ON Series.SeriesId = Episodes.SeriesId
|
||||
GROUP BY seriesId", seasonNumber);
|
||||
var series = _database
|
||||
.Fetch<Series, QualityProfile>(@"SELECT Series.*, SUM(CASE WHEN Ignored = 0 THEN 1 ELSE 0 END) AS EpisodeCount,
|
||||
SUM(CASE WHEN Ignored = 0 AND EpisodeFileId > 0 THEN 1 ELSE 0 END) as EpisodeFileCount,
|
||||
COUNT (DISTINCT(CASE WHEN SeasonNumber = 0 THEN null ELSE SeasonNumber END)) as SeasonCount,
|
||||
QualityProfiles.*
|
||||
FROM Series
|
||||
INNER JOIN QualityProfiles ON Series.QualityProfileId = QualityProfiles.QualityProfileId
|
||||
JOIN Episodes ON Series.SeriesId = Episodes.SeriesId
|
||||
GROUP BY seriesId");
|
||||
|
||||
return series;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ public class Episode
|
||||
public int SeasonNumber { get; set; }
|
||||
public int EpisodeNumber { get; set; }
|
||||
public string Title { get; set; }
|
||||
public DateTime AirDate { get; set; }
|
||||
public DateTime? AirDate { get; set; }
|
||||
|
||||
public string Overview { get; set; }
|
||||
|
||||
@ -47,7 +47,7 @@ public EpisodeStatusType Status
|
||||
|
||||
if (Ignored) return EpisodeStatusType.Ignored;
|
||||
|
||||
if (AirDate.Date.Year > 1900 && DateTime.Now.Date >= AirDate.Date)
|
||||
if (AirDate != null && AirDate.Value.Date < DateTime.Now)
|
||||
{
|
||||
return EpisodeStatusType.Missing;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public ActionResult _AjaxBinding()
|
||||
EpisodeTitle = e.Title,
|
||||
Overview = e.Overview,
|
||||
SeriesTitle = e.Series.Title,
|
||||
AirDate = e.AirDate,
|
||||
AirDate = e.AirDate.Value,
|
||||
});
|
||||
|
||||
return View(new GridModel(missing));
|
||||
|
@ -3,6 +3,7 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using MvcMiniProfiler;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Jobs;
|
||||
using NzbDrone.Core.Repository;
|
||||
@ -119,8 +120,11 @@ public ActionResult _DeleteAjaxSeriesEditing(int id)
|
||||
[GridAction]
|
||||
public ActionResult _AjaxSeasonGrid(int seriesId, int seasonNumber)
|
||||
{
|
||||
var episodes = GetEpisodeModels(_episodeProvider.GetEpisodesBySeason(seriesId, seasonNumber));
|
||||
return View(new GridModel(episodes));
|
||||
using (MiniProfiler.StepStatic("Controller"))
|
||||
{
|
||||
var episodes = GetEpisodeModels(_episodeProvider.GetEpisodesBySeason(seriesId, seasonNumber));
|
||||
return View(new GridModel(episodes));
|
||||
}
|
||||
}
|
||||
|
||||
public ActionResult SearchForSeries(string seriesName)
|
||||
@ -240,7 +244,7 @@ private List<EpisodeModel> GetEpisodeModels(IList<Episode> episodesInDb)
|
||||
SeasonNumber = e.SeasonNumber,
|
||||
Title = e.Title,
|
||||
Overview = e.Overview,
|
||||
AirDate = e.AirDate,
|
||||
AirDate = e.AirDate.Value,
|
||||
Path = episodePath,
|
||||
EpisodeFileId = episodeFileId,
|
||||
Status = e.Status.ToString(),
|
||||
|
@ -37,7 +37,7 @@ public ActionResult _AjaxBindingYesterday()
|
||||
EpisodeNumber = u.EpisodeNumber,
|
||||
Title = u.Title,
|
||||
Overview = u.Overview,
|
||||
AirDate = u.AirDate.Add(Convert.ToDateTime(u.Series.AirTimes).TimeOfDay)
|
||||
AirDate = u.AirDate.Value.Add(Convert.ToDateTime(u.Series.AirTimes).TimeOfDay)
|
||||
});
|
||||
|
||||
return View(new GridModel(upcoming));
|
||||
@ -55,7 +55,7 @@ public ActionResult _AjaxBindingToday()
|
||||
EpisodeNumber = u.EpisodeNumber,
|
||||
Title = u.Title,
|
||||
Overview = u.Overview,
|
||||
AirDate = u.AirDate.Add(Convert.ToDateTime(u.Series.AirTimes).TimeOfDay)
|
||||
AirDate = u.AirDate.Value.Add(Convert.ToDateTime(u.Series.AirTimes).TimeOfDay)
|
||||
});
|
||||
|
||||
return View(new GridModel(upcoming));
|
||||
@ -73,7 +73,7 @@ public ActionResult _AjaxBindingTomorrow()
|
||||
EpisodeNumber = u.EpisodeNumber,
|
||||
Title = u.Title,
|
||||
Overview = u.Overview,
|
||||
AirDate = u.AirDate.Add(Convert.ToDateTime(u.Series.AirTimes).TimeOfDay)
|
||||
AirDate = u.AirDate.Value.Add(Convert.ToDateTime(u.Series.AirTimes).TimeOfDay)
|
||||
});
|
||||
|
||||
return View(new GridModel(upcoming));
|
||||
@ -91,7 +91,7 @@ public ActionResult _AjaxBindingWeek()
|
||||
EpisodeNumber = u.EpisodeNumber,
|
||||
Title = u.Title,
|
||||
Overview = u.Overview,
|
||||
AirDate = u.AirDate.Add(Convert.ToDateTime(u.Series.AirTimes).TimeOfDay)
|
||||
AirDate = u.AirDate.Value.Add(Convert.ToDateTime(u.Series.AirTimes).TimeOfDay)
|
||||
});
|
||||
|
||||
return View(new GridModel(upcoming));
|
||||
|
@ -12,6 +12,7 @@
|
||||
using NLog;
|
||||
using NzbDrone.Core;
|
||||
using NzbDrone.Core.Instrumentation;
|
||||
using Telerik.Web.Mvc;
|
||||
|
||||
namespace NzbDrone.Web
|
||||
{
|
||||
@ -36,7 +37,7 @@ public static void RegisterRoutes(RouteCollection routes)
|
||||
protected override void OnApplicationStarted()
|
||||
{
|
||||
base.OnApplicationStarted();
|
||||
|
||||
WebAssetDefaultSettings.UseTelerikContentDeliveryNetwork = true;
|
||||
RegisterRoutes(RouteTable.Routes);
|
||||
//base.OnApplicationStarted();
|
||||
AreaRegistration.RegisterAllAreas();
|
||||
|
@ -913,7 +913,7 @@
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>copy "$(SolutionDir)\Libraries\SQLite.Interop.dll" "$(TargetDir)"
|
||||
EXIT 0</PreBuildEvent>
|
||||
<PreBuildEvent>
|
||||
</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
@ -6,36 +6,7 @@
|
||||
Series
|
||||
}
|
||||
|
||||
<script type="text/javascript" src="../../Scripts/doTimeout.js"></script>
|
||||
<script>
|
||||
(function ($) {
|
||||
$.fn.episodeProgress = function (episodes, totalEpisodes) {
|
||||
return this.each(
|
||||
function () {
|
||||
var div = $(this);
|
||||
var progressBar = div.find(".progress");
|
||||
|
||||
var width = Math.round(episodes / totalEpisodes * 100);
|
||||
|
||||
progressBar.css("width", width + "%");
|
||||
|
||||
if (width > 97) {
|
||||
progressBar.css("-khtml-border-top-right-radius", "7px");
|
||||
progressBar.css("border-top-right-radius", "7px");
|
||||
progressBar.css("-moz-border-top-right-radius", "7px");
|
||||
progressBar.css("-webkit-border-top-right-radius", "7px");
|
||||
|
||||
progressBar.css("-khtml-border-bottom-right-radius", "7px");
|
||||
progressBar.css("border-bottom-right-radius", "7px");
|
||||
progressBar.css("-moz-border-bottom-right-radius", "7px");
|
||||
progressBar.css("-webkit-border-bottom-right-radius", "7px");
|
||||
}
|
||||
|
||||
div.find(".progressText").html(episodes + " / " + totalEpisodes);
|
||||
});
|
||||
};
|
||||
})(jQuery);
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/* progress bar container */
|
||||
@ -191,4 +162,35 @@
|
||||
|
||||
$("#progressbar_" + seriesId).episodeProgress(episodeFileCount, episodeCount);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" src="../../Scripts/doTimeout.js"></script>
|
||||
<script>
|
||||
(function ($) {
|
||||
$.fn.episodeProgress = function (episodes, totalEpisodes) {
|
||||
return this.each(
|
||||
function () {
|
||||
var div = $(this);
|
||||
var progressBar = div.find(".progress");
|
||||
|
||||
var width = Math.round(episodes / totalEpisodes * 100);
|
||||
|
||||
progressBar.css("width", width + "%");
|
||||
|
||||
if (width > 97) {
|
||||
progressBar.css("-khtml-border-top-right-radius", "7px");
|
||||
progressBar.css("border-top-right-radius", "7px");
|
||||
progressBar.css("-moz-border-top-right-radius", "7px");
|
||||
progressBar.css("-webkit-border-top-right-radius", "7px");
|
||||
|
||||
progressBar.css("-khtml-border-bottom-right-radius", "7px");
|
||||
progressBar.css("border-bottom-right-radius", "7px");
|
||||
progressBar.css("-moz-border-bottom-right-radius", "7px");
|
||||
progressBar.css("-webkit-border-bottom-right-radius", "7px");
|
||||
}
|
||||
|
||||
div.find(".progressText").html(episodes + " / " + totalEpisodes);
|
||||
});
|
||||
};
|
||||
})(jQuery);
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user