From 727e8aba9b179cd3699259c1bbcac7eec941a510 Mon Sep 17 00:00:00 2001 From: Joao Costa Date: Tue, 12 May 2015 14:39:04 +0100 Subject: [PATCH 1/3] added option to deserialize DateTimeOffset from BsonType.Array --- src/Quartz.Impl.MongoDB/DateTimeOffsetSerializer.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Quartz.Impl.MongoDB/DateTimeOffsetSerializer.cs b/src/Quartz.Impl.MongoDB/DateTimeOffsetSerializer.cs index b80e89d..42401bc 100644 --- a/src/Quartz.Impl.MongoDB/DateTimeOffsetSerializer.cs +++ b/src/Quartz.Impl.MongoDB/DateTimeOffsetSerializer.cs @@ -58,12 +58,23 @@ public override object Deserialize( var bsonType = bsonReader.GetCurrentBsonType(); DateTimeOffset value; + long ticks; + TimeSpan offset; + + switch (bsonType) { case BsonType.DateTime: // use an intermediate BsonDateTime so MinValue and MaxValue are handled correctly value = (new BsonDateTime(bsonReader.ReadDateTime())).ToUniversalTime(); break; + case BsonType.Array: + bsonReader.ReadStartArray(); + ticks = bsonReader.ReadInt64(); + offset = TimeSpan.FromMinutes(bsonReader.ReadInt32()); + bsonReader.ReadEndArray(); + value= new DateTimeOffset(ticks, offset); + break; case BsonType.Document: bsonReader.ReadStartDocument(); bsonReader.ReadDateTime("DateTimeUTC"); // ignore value (use Ticks instead) From 51fa4b8662af13bd224ea1d0b5c658992de62818 Mon Sep 17 00:00:00 2001 From: Joao Costa Date: Tue, 12 May 2015 14:58:32 +0100 Subject: [PATCH 2/3] added method CalendarExists && null checks on IsJobGroupPaused and IsTriggerGroupPaused --- src/Quartz.Impl.MongoDB/JobStore.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Quartz.Impl.MongoDB/JobStore.cs b/src/Quartz.Impl.MongoDB/JobStore.cs index 7dcfcd8..ffec75b 100644 --- a/src/Quartz.Impl.MongoDB/JobStore.cs +++ b/src/Quartz.Impl.MongoDB/JobStore.cs @@ -362,7 +362,7 @@ public virtual void StoreJobAndTrigger(IJobDetail newJob, IOperableTrigger newTr public virtual bool IsJobGroupPaused(string groupName) { var result = this.PausedJobGroups.FindOneByIdAs(groupName); - return !result.IsBsonNull; + return result != null && !result.IsBsonNull; } /// @@ -373,7 +373,7 @@ public virtual bool IsJobGroupPaused(string groupName) public virtual bool IsTriggerGroupPaused(string groupName) { var result = this.PausedTriggerGroups.FindOneByIdAs(groupName); - return !result.IsBsonNull; + return result != null && !result.IsBsonNull; } /// @@ -786,6 +786,20 @@ public virtual TriggerState GetTriggerState(TriggerKey triggerKey) } } + /// + /// Determine whether a with the given identifier already + /// exists within the scheduler. + /// + /// calName the identifier to check for + /// true if a Calendar exists with the given identifier + public bool CalendarExists(string calName) + { + lock (lockObject) + { + return this.Calendars.FindOneByIdAs(calName) != null; + } + } + /// /// Store the given . /// From 2c15a557f0f881d915106ea6f6a99567b8939daa Mon Sep 17 00:00:00 2001 From: Joao Costa Date: Tue, 12 May 2015 19:05:55 +0100 Subject: [PATCH 3/3] updated packages version --- src/Quartz.Impl.MongoDB.Tests/App.config | 15 ++++++++++++--- .../Quartz.Impl.MongoDB.Tests.csproj | 7 +++++-- src/Quartz.Impl.MongoDB.Tests/packages.config | 3 ++- src/Quartz.Impl.MongoDB/JobStore.cs | 2 +- .../Quartz.Impl.MongoDB.csproj | 16 ++++++++++------ src/Quartz.Impl.MongoDB/app.config | 11 +++++++++++ src/Quartz.Impl.MongoDB/packages.config | 5 +++-- 7 files changed, 44 insertions(+), 15 deletions(-) create mode 100644 src/Quartz.Impl.MongoDB/app.config diff --git a/src/Quartz.Impl.MongoDB.Tests/App.config b/src/Quartz.Impl.MongoDB.Tests/App.config index 1748af0..a1181d0 100644 --- a/src/Quartz.Impl.MongoDB.Tests/App.config +++ b/src/Quartz.Impl.MongoDB.Tests/App.config @@ -1,6 +1,15 @@ - + - + - + + + + + + + + + + diff --git a/src/Quartz.Impl.MongoDB.Tests/Quartz.Impl.MongoDB.Tests.csproj b/src/Quartz.Impl.MongoDB.Tests/Quartz.Impl.MongoDB.Tests.csproj index 21100e4..f0c4122 100644 --- a/src/Quartz.Impl.MongoDB.Tests/Quartz.Impl.MongoDB.Tests.csproj +++ b/src/Quartz.Impl.MongoDB.Tests/Quartz.Impl.MongoDB.Tests.csproj @@ -33,9 +33,12 @@ 4 - + False - ..\packages\Common.Logging.2.1.2\lib\net40\Common.Logging.dll + ..\packages\Common.Logging.3.0.0\lib\net40\Common.Logging.dll + + + ..\packages\Common.Logging.Core.3.0.0\lib\net40\Common.Logging.Core.dll ..\packages\Machine.Specifications.0.5.10\lib\net40\Machine.Specifications.dll diff --git a/src/Quartz.Impl.MongoDB.Tests/packages.config b/src/Quartz.Impl.MongoDB.Tests/packages.config index 888d42b..4f7a799 100644 --- a/src/Quartz.Impl.MongoDB.Tests/packages.config +++ b/src/Quartz.Impl.MongoDB.Tests/packages.config @@ -1,6 +1,7 @@  - + + \ No newline at end of file diff --git a/src/Quartz.Impl.MongoDB/JobStore.cs b/src/Quartz.Impl.MongoDB/JobStore.cs index ffec75b..7899334 100644 --- a/src/Quartz.Impl.MongoDB/JobStore.cs +++ b/src/Quartz.Impl.MongoDB/JobStore.cs @@ -792,7 +792,7 @@ public virtual TriggerState GetTriggerState(TriggerKey triggerKey) /// /// calName the identifier to check for /// true if a Calendar exists with the given identifier - public bool CalendarExists(string calName) + public virtual bool CalendarExists(string calName) { lock (lockObject) { diff --git a/src/Quartz.Impl.MongoDB/Quartz.Impl.MongoDB.csproj b/src/Quartz.Impl.MongoDB/Quartz.Impl.MongoDB.csproj index 6a13f94..1bb7cd5 100644 --- a/src/Quartz.Impl.MongoDB/Quartz.Impl.MongoDB.csproj +++ b/src/Quartz.Impl.MongoDB/Quartz.Impl.MongoDB.csproj @@ -34,17 +34,20 @@ 4 - + False - ..\packages\Common.Logging.2.1.2\lib\net40\Common.Logging.dll + ..\packages\Common.Logging.3.0.0\lib\net40\Common.Logging.dll - + + ..\packages\Common.Logging.Core.3.0.0\lib\net40\Common.Logging.Core.dll + + False - ..\packages\mongocsharpdriver.1.8.1\lib\net35\MongoDB.Bson.dll + ..\packages\mongocsharpdriver.1.9.2\lib\net35\MongoDB.Bson.dll - + False - ..\packages\mongocsharpdriver.1.8.1\lib\net35\MongoDB.Driver.dll + ..\packages\mongocsharpdriver.1.9.2\lib\net35\MongoDB.Driver.dll False @@ -72,6 +75,7 @@ + diff --git a/src/Quartz.Impl.MongoDB/app.config b/src/Quartz.Impl.MongoDB/app.config new file mode 100644 index 0000000..57ea164 --- /dev/null +++ b/src/Quartz.Impl.MongoDB/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/Quartz.Impl.MongoDB/packages.config b/src/Quartz.Impl.MongoDB/packages.config index 32450d1..0757ff5 100644 --- a/src/Quartz.Impl.MongoDB/packages.config +++ b/src/Quartz.Impl.MongoDB/packages.config @@ -1,6 +1,7 @@  - - + + + \ No newline at end of file