Merge pull request #1297 from MediaBrowser/master

merge from master
pull/702/head
Luke 9 years ago
commit c1d44bf71b

@ -1,6 +1,7 @@
using MediaBrowser.Model.Events;
using MediaBrowser.Model.Tasks;
using System;
using System.Linq;
using System.Threading;
namespace MediaBrowser.Common.ScheduledTasks
@ -30,16 +31,7 @@ namespace MediaBrowser.Common.ScheduledTasks
/// </value>
public TaskExecutionOptions TaskOptions { get; set; }
/// <summary>
/// Gets or sets the first run delay.
/// </summary>
/// <value>The first run delay.</value>
public TimeSpan FirstRunDelay { get; set; }
public IntervalTrigger()
{
FirstRunDelay = TimeSpan.FromHours(1);
}
private DateTime _lastStartDate;
/// <summary>
/// Stars waiting for the trigger action
@ -50,20 +42,21 @@ namespace MediaBrowser.Common.ScheduledTasks
{
DisposeTimer();
var triggerDate = lastResult != null ?
lastResult.EndTimeUtc.Add(Interval) :
DateTime.UtcNow.Add(FirstRunDelay);
DateTime triggerDate;
if (lastResult == null)
{
// Task has never been completed before
triggerDate = DateTime.UtcNow.AddHours(1);
}
else
{
triggerDate = new[] { lastResult.EndTimeUtc, _lastStartDate }.Max().Add(Interval);
}
if (DateTime.UtcNow > triggerDate)
{
if (isApplicationStartup)
{
triggerDate = DateTime.UtcNow.AddMinutes(1);
}
else
{
triggerDate = DateTime.UtcNow.AddMinutes(1);
}
triggerDate = DateTime.UtcNow.AddMinutes(1);
}
Timer = new Timer(state => OnTriggered(), null, triggerDate - DateTime.UtcNow, TimeSpan.FromMilliseconds(-1));
@ -98,8 +91,11 @@ namespace MediaBrowser.Common.ScheduledTasks
/// </summary>
private void OnTriggered()
{
DisposeTimer();
if (Triggered != null)
{
_lastStartDate = DateTime.UtcNow;
Triggered(this, new GenericEventArgs<TaskExecutionOptions>(TaskOptions));
}
}

@ -4855,6 +4855,9 @@
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\strings\javascript\kk.json">
<Link>Resources\dashboard-ui\strings\javascript\kk.json</Link>
</BundleResource>
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\strings\javascript\ko.json">
<Link>Resources\dashboard-ui\strings\javascript\ko.json</Link>
</BundleResource>
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\strings\javascript\ms.json">
<Link>Resources\dashboard-ui\strings\javascript\ms.json</Link>
</BundleResource>
@ -4924,6 +4927,9 @@
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\thirdparty\headroom.js">
<Link>Resources\dashboard-ui\thirdparty\headroom.js</Link>
</BundleResource>
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\thirdparty\hls.min.js">
<Link>Resources\dashboard-ui\thirdparty\hls.min.js</Link>
</BundleResource>
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\thirdparty\jquery.unveil-custom.js">
<Link>Resources\dashboard-ui\thirdparty\jquery.unveil-custom.js</Link>
</BundleResource>

@ -8,7 +8,7 @@ It features a REST-based api with built-in documention to facilitate client deve
## Emby Apps
- [Android Mobile (Play Store)](https://play.google.com/store/apps/details?id=com.mb.android "Android Mobile (Play Store)")
- [Android Mobile (Amazon)](http://www.amazon.com/Emby-Mobile/dp/B017OSA1QS "Android Mobile (Amazon)")
- [Android Mobile (Amazon)](http://www.amazon.com/Emby-for-Android/dp/B00GVH9O0I "Android Mobile (Amazon)")
- [Android TV](https://play.google.com/store/apps/details?id=tv.emby.embyatv "Android TV")
- [Amazon Fire TV](http://www.amazon.com/Emby-for-Fire-TV/dp/B00VVJKTW8 "Amazon Fire TV")
- [HTML5](http://app.emby.media "HTML5")

Loading…
Cancel
Save