Merge pull request #2254 from MediaBrowser/dev

Dev
pull/702/head
Luke 8 years ago committed by GitHub
commit 931f5f2e6a

@ -9,6 +9,7 @@ using System.Linq;
using System.Threading.Tasks;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.IO;
using MediaBrowser.Model.IO;
namespace MediaBrowser.Api.Dlna
{

@ -1,5 +1,4 @@
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Tasks;
using ServiceStack;
@ -198,17 +197,13 @@ namespace MediaBrowser.Api.ScheduledTasks
throw new ResourceNotFoundException("Task not found");
}
var hasKey = task.ScheduledTask as IHasKey;
if (hasKey != null)
if (string.Equals(task.ScheduledTask.Key, "SystemUpdateTask", StringComparison.OrdinalIgnoreCase))
{
if (string.Equals(hasKey.Key, "SystemUpdateTask", StringComparison.OrdinalIgnoreCase))
// This is a hack for now just to get the update application function to work when auto-update is disabled
if (!_config.Configuration.EnableAutoUpdate)
{
// This is a hack for now just to get the update application function to work when auto-update is disabled
if (!_config.Configuration.EnableAutoUpdate)
{
_config.Configuration.EnableAutoUpdate = true;
_config.SaveConfiguration();
}
_config.Configuration.EnableAutoUpdate = true;
_config.SaveConfiguration();
}
}
@ -252,7 +247,7 @@ namespace MediaBrowser.Api.ScheduledTasks
var triggerInfos = request;
task.Triggers = triggerInfos.Select(ScheduledTaskHelpers.GetTrigger);
task.Triggers = triggerInfos.ToArray();
}
}
}

@ -1,5 +1,4 @@
using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Events;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Tasks;

@ -26,11 +26,16 @@ using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Implementations.Cryptography;
using MediaBrowser.Common.IO;
using MediaBrowser.Model.Cryptography;
using MediaBrowser.Model.Tasks;
namespace MediaBrowser.Common.Implementations
{
@ -67,7 +72,7 @@ namespace MediaBrowser.Common.Implementations
/// Gets or sets the plugins.
/// </summary>
/// <value>The plugins.</value>
public IEnumerable<IPlugin> Plugins { get; protected set; }
public IPlugin[] Plugins { get; protected set; }
/// <summary>
/// Gets or sets the log manager.
@ -174,6 +179,8 @@ namespace MediaBrowser.Common.Implementations
/// <value><c>true</c> if this instance is running as service; otherwise, <c>false</c>.</value>
public abstract bool IsRunningAsService { get; }
protected ICryptographyProvider CryptographyProvider = new CryptographyProvider();
private DeviceId _deviceId;
public string SystemId
{
@ -202,7 +209,10 @@ namespace MediaBrowser.Common.Implementations
ILogManager logManager,
IFileSystem fileSystem)
{
XmlSerializer = new XmlSerializer (fileSystem, logManager.GetLogger("XmlSerializer"));
// hack alert, until common can target .net core
BaseExtensions.CryptographyProvider = CryptographyProvider;
XmlSerializer = new XmlSerializer (fileSystem, logManager.GetLogger("XmlSerializer"));
FailedAssemblies = new List<string>();
ApplicationPaths = applicationPaths;
@ -430,7 +440,36 @@ namespace MediaBrowser.Common.Implementations
RegisterModules();
ConfigurationManager.AddParts(GetExports<IConfigurationFactory>());
Plugins = GetExports<IPlugin>();
Plugins = GetExports<IPlugin>().Select(LoadPlugin).Where(i => i != null).ToArray();
}
private IPlugin LoadPlugin(IPlugin plugin)
{
try
{
var assemblyPlugin = plugin as IPluginAssembly;
if (assemblyPlugin != null)
{
var assembly = plugin.GetType().Assembly;
var assemblyName = assembly.GetName();
var attribute = (GuidAttribute)assembly.GetCustomAttributes(typeof(GuidAttribute), true)[0];
var assemblyId = new Guid(attribute.Value);
var assemblyFileName = assemblyName.Name + ".dll";
var assemblyFilePath = Path.Combine(ApplicationPaths.PluginsPath, assemblyFileName);
assemblyPlugin.SetAttributes(assemblyFilePath, assemblyFileName, assemblyName.Version, assemblyId);
}
}
catch (Exception ex)
{
Logger.ErrorException("Error loading plugin {0}", ex, plugin.GetType().FullName);
return null;
}
return plugin;
}
/// <summary>
@ -565,7 +604,7 @@ namespace MediaBrowser.Common.Implementations
}
catch (Exception ex)
{
Logger.ErrorException("Error creating {0}", ex, type.Name);
Logger.ErrorException("Error creating {0}", ex, type.FullName);
throw;
}
@ -584,7 +623,7 @@ namespace MediaBrowser.Common.Implementations
}
catch (Exception ex)
{
Logger.ErrorException("Error creating {0}", ex, type.Name);
Logger.ErrorException("Error creating {0}", ex, type.FullName);
// Don't blow up in release mode
return null;
}
@ -747,7 +786,7 @@ namespace MediaBrowser.Common.Implementations
{
var list = Plugins.ToList();
list.Remove(plugin);
Plugins = list;
Plugins = list.ToArray();
}
/// <summary>

@ -0,0 +1,18 @@
using System;
using System.Security.Cryptography;
using System.Text;
using MediaBrowser.Model.Cryptography;
namespace MediaBrowser.Common.Implementations.Cryptography
{
public class CryptographyProvider : ICryptographyProvider
{
public Guid GetMD5(string str)
{
using (var provider = MD5.Create())
{
return new Guid(provider.ComputeHash(Encoding.Unicode.GetBytes(str)));
}
}
}
}

@ -18,6 +18,7 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Model.IO;
namespace MediaBrowser.Common.Implementations.HttpClientManager
{

@ -1,5 +1,6 @@
using System.IO;
using MediaBrowser.Common.IO;
using MediaBrowser.Model.IO;
using Microsoft.IO;
namespace MediaBrowser.Common.Implementations.IO

@ -91,6 +91,7 @@
<Compile Include="BaseApplicationPaths.cs" />
<Compile Include="Configuration\BaseConfigurationManager.cs" />
<Compile Include="Configuration\ConfigurationHelper.cs" />
<Compile Include="Cryptography\CryptographyProvider.cs" />
<Compile Include="Devices\DeviceId.cs" />
<Compile Include="HttpClientManager\HttpClientInfo.cs" />
<Compile Include="HttpClientManager\HttpClientManager.cs" />
@ -101,11 +102,16 @@
<Compile Include="Logging\NlogManager.cs" />
<Compile Include="Networking\BaseNetworkManager.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ScheduledTasks\DailyTrigger.cs" />
<Compile Include="ScheduledTasks\IntervalTrigger.cs" />
<Compile Include="ScheduledTasks\ScheduledTaskWorker.cs" />
<Compile Include="ScheduledTasks\StartupTrigger.cs" />
<Compile Include="ScheduledTasks\SystemEventTrigger.cs" />
<Compile Include="ScheduledTasks\TaskManager.cs" />
<Compile Include="ScheduledTasks\Tasks\DeleteCacheFileTask.cs" />
<Compile Include="ScheduledTasks\Tasks\DeleteLogFileTask.cs" />
<Compile Include="ScheduledTasks\Tasks\ReloadLoggerFileTask.cs" />
<Compile Include="ScheduledTasks\WeeklyTrigger.cs" />
<Compile Include="Security\MbAdmin.cs" />
<Compile Include="Security\MBLicenseFile.cs" />
<Compile Include="Security\PluginSecurityManager.cs" />

@ -232,13 +232,12 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
/// <summary>
/// The _triggers
/// </summary>
private List<ITaskTrigger> _triggers;
private Tuple<TaskTriggerInfo,ITaskTrigger>[] _triggers;
/// <summary>
/// Gets the triggers that define when the task will run
/// </summary>
/// <value>The triggers.</value>
/// <exception cref="System.ArgumentNullException">value</exception>
public IEnumerable<ITaskTrigger> Triggers
private Tuple<TaskTriggerInfo, ITaskTrigger>[] InternalTriggers
{
get
{
@ -257,11 +256,33 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
DisposeTriggers();
}
_triggers = value.ToList();
_triggers = value.ToArray();
ReloadTriggerEvents(false);
}
}
SaveTriggers(_triggers);
/// <summary>
/// Gets the triggers that define when the task will run
/// </summary>
/// <value>The triggers.</value>
/// <exception cref="System.ArgumentNullException">value</exception>
public TaskTriggerInfo[] Triggers
{
get
{
return InternalTriggers.Select(i => i.Item1).ToArray();
}
set
{
if (value == null)
{
throw new ArgumentNullException("value");
}
SaveTriggers(value);
InternalTriggers = value.Select(i => new Tuple<TaskTriggerInfo, ITaskTrigger>(i, GetTrigger(i))).ToArray();
}
}
@ -304,8 +325,10 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
/// <param name="isApplicationStartup">if set to <c>true</c> [is application startup].</param>
private void ReloadTriggerEvents(bool isApplicationStartup)
{
foreach (var trigger in Triggers)
foreach (var triggerInfo in InternalTriggers)
{
var trigger = triggerInfo.Item2;
trigger.Stop();
trigger.Triggered -= trigger_Triggered;
@ -507,23 +530,29 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
/// Loads the triggers.
/// </summary>
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
private List<ITaskTrigger> LoadTriggers()
private Tuple<TaskTriggerInfo, ITaskTrigger>[] LoadTriggers()
{
var settings = LoadTriggerSettings();
return settings.Select(i => new Tuple<TaskTriggerInfo, ITaskTrigger>(i, GetTrigger(i))).ToArray();
}
private TaskTriggerInfo[] LoadTriggerSettings()
{
try
{
return JsonSerializer.DeserializeFromFile<IEnumerable<TaskTriggerInfo>>(GetConfigurationFilePath())
.Select(ScheduledTaskHelpers.GetTrigger)
.ToList();
.ToArray();
}
catch (FileNotFoundException)
{
// File doesn't exist. No biggie. Return defaults.
return ScheduledTask.GetDefaultTriggers().ToList();
return ScheduledTask.GetDefaultTriggers().ToArray();
}
catch (DirectoryNotFoundException)
{
// File doesn't exist. No biggie. Return defaults.
return ScheduledTask.GetDefaultTriggers().ToList();
return ScheduledTask.GetDefaultTriggers().ToArray();
}
}
@ -531,13 +560,13 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
/// Saves the triggers.
/// </summary>
/// <param name="triggers">The triggers.</param>
private void SaveTriggers(IEnumerable<ITaskTrigger> triggers)
private void SaveTriggers(TaskTriggerInfo[] triggers)
{
var path = GetConfigurationFilePath();
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
JsonSerializer.SerializeToFile(triggers.Select(ScheduledTaskHelpers.GetTriggerInfo), path);
JsonSerializer.SerializeToFile(triggers, path);
}
/// <summary>
@ -561,11 +590,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
Id = Id
};
var hasKey = ScheduledTask as IHasKey;
if (hasKey != null)
{
result.Key = hasKey.Key;
}
result.Key = ScheduledTask.Key;
if (ex != null)
{
@ -655,13 +680,98 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
}
}
/// <summary>
/// Converts a TaskTriggerInfo into a concrete BaseTaskTrigger
/// </summary>
/// <param name="info">The info.</param>
/// <returns>BaseTaskTrigger.</returns>
/// <exception cref="System.ArgumentNullException"></exception>
/// <exception cref="System.ArgumentException">Invalid trigger type: + info.Type</exception>
public static ITaskTrigger GetTrigger(TaskTriggerInfo info)
{
var options = new TaskExecutionOptions
{
MaxRuntimeMs = info.MaxRuntimeMs
};
if (info.Type.Equals(typeof(DailyTrigger).Name, StringComparison.OrdinalIgnoreCase))
{
if (!info.TimeOfDayTicks.HasValue)
{
throw new ArgumentNullException();
}
return new DailyTrigger
{
TimeOfDay = TimeSpan.FromTicks(info.TimeOfDayTicks.Value),
TaskOptions = options
};
}
if (info.Type.Equals(typeof(WeeklyTrigger).Name, StringComparison.OrdinalIgnoreCase))
{
if (!info.TimeOfDayTicks.HasValue)
{
throw new ArgumentNullException();
}
if (!info.DayOfWeek.HasValue)
{
throw new ArgumentNullException();
}
return new WeeklyTrigger
{
TimeOfDay = TimeSpan.FromTicks(info.TimeOfDayTicks.Value),
DayOfWeek = info.DayOfWeek.Value,
TaskOptions = options
};
}
if (info.Type.Equals(typeof(IntervalTrigger).Name, StringComparison.OrdinalIgnoreCase))
{
if (!info.IntervalTicks.HasValue)
{
throw new ArgumentNullException();
}
return new IntervalTrigger
{
Interval = TimeSpan.FromTicks(info.IntervalTicks.Value),
TaskOptions = options
};
}
if (info.Type.Equals(typeof(SystemEventTrigger).Name, StringComparison.OrdinalIgnoreCase))
{
if (!info.SystemEvent.HasValue)
{
throw new ArgumentNullException();
}
return new SystemEventTrigger
{
SystemEvent = info.SystemEvent.Value,
TaskOptions = options
};
}
if (info.Type.Equals(typeof(StartupTrigger).Name, StringComparison.OrdinalIgnoreCase))
{
return new StartupTrigger();
}
throw new ArgumentException("Unrecognized trigger type: " + info.Type);
}
/// <summary>
/// Disposes each trigger
/// </summary>
private void DisposeTriggers()
{
foreach (var trigger in Triggers)
foreach (var triggerInfo in InternalTriggers)
{
var trigger = triggerInfo.Item2;
trigger.Triggered -= trigger_Triggered;
trigger.Stop();
}

@ -8,6 +8,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Model.Tasks;
namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks
{
@ -40,13 +41,12 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks
/// Creates the triggers that define when the task will run
/// </summary>
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
public IEnumerable<ITaskTrigger> GetDefaultTriggers()
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{
// Until we can vary these default triggers per server and MBT, we need something that makes sense for both
return new ITaskTrigger[] {
return new[] {
// Every so often
new IntervalTrigger { Interval = TimeSpan.FromHours(24)}
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks}
};
}
@ -95,7 +95,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks
/// <param name="progress">The progress.</param>
private void DeleteCacheFilesFromDirectory(CancellationToken cancellationToken, string directory, DateTime minDateModified, IProgress<double> progress)
{
var filesToDelete = _fileSystem.GetFiles(directory, true)
var filesToDelete = _fileSystem.GetFiles(directory, true)
.Where(f => _fileSystem.GetLastWriteTimeUtc(f) < minDateModified)
.ToList();
@ -168,6 +168,11 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks
get { return "Cache file cleanup"; }
}
public string Key
{
get { return "DeleteCacheFiles"; }
}
/// <summary>
/// Gets the description.
/// </summary>
@ -202,5 +207,10 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks
{
get { return true; }
}
public bool IsLogged
{
get { return true; }
}
}
}

@ -6,6 +6,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Model.Tasks;
namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks
{
@ -36,13 +37,12 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks
/// Creates the triggers that define when the task will run
/// </summary>
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
public IEnumerable<ITaskTrigger> GetDefaultTriggers()
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{
// Until we can vary these default triggers per server and MBT, we need something that makes sense for both
return new ITaskTrigger[] {
return new[] {
// Every so often
new IntervalTrigger { Interval = TimeSpan.FromHours(24)}
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks}
};
}
@ -82,6 +82,11 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks
return Task.FromResult(true);
}
public string Key
{
get { return "CleanLogFiles"; }
}
/// <summary>
/// Gets the name of the task
/// </summary>
@ -125,5 +130,10 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks
{
get { return true; }
}
public bool IsLogged
{
get { return true; }
}
}
}

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Tasks;
namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks
{
@ -39,9 +40,9 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks
/// Gets the default triggers.
/// </summary>
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
public IEnumerable<ITaskTrigger> GetDefaultTriggers()
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{
var trigger = new DailyTrigger { TimeOfDay = TimeSpan.FromHours(0) }; //12am
var trigger = new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerDaily, TimeOfDayTicks = TimeSpan.FromHours(0).Ticks }; //12am
return new[] { trigger };
}
@ -74,6 +75,8 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks
get { return "Start new log file"; }
}
public string Key { get; }
/// <summary>
/// Gets the description.
/// </summary>
@ -101,5 +104,10 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks
{
get { return true; }
}
public bool IsLogged
{
get { return true; }
}
}
}

@ -1,9 +1,7 @@
using System;
using System.Globalization;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using MediaBrowser.Model.Cryptography;
namespace MediaBrowser.Common.Extensions
{
@ -12,6 +10,7 @@ namespace MediaBrowser.Common.Extensions
/// </summary>
public static class BaseExtensions
{
public static ICryptographyProvider CryptographyProvider { get; set; }
/// <summary>
/// Strips the HTML.
@ -26,15 +25,6 @@ namespace MediaBrowser.Common.Extensions
return Regex.Replace(htmlString, pattern, string.Empty).Trim();
}
public static string RemoveDiacritics(this string text)
{
return String.Concat(
text.Normalize(NormalizationForm.FormD)
.Where(ch => CharUnicodeInfo.GetUnicodeCategory(ch) !=
UnicodeCategory.NonSpacingMark)
).Normalize(NormalizationForm.FormC);
}
/// <summary>
/// Gets the M d5.
/// </summary>
@ -42,10 +32,7 @@ namespace MediaBrowser.Common.Extensions
/// <returns>Guid.</returns>
public static Guid GetMD5(this string str)
{
using (var provider = MD5.Create())
{
return new Guid(provider.ComputeHash(Encoding.Unicode.GetBytes(str)));
}
return CryptographyProvider.GetMD5(str);
}
/// <summary>

@ -142,7 +142,7 @@ namespace MediaBrowser.Common
/// Gets the plugins.
/// </summary>
/// <value>The plugins.</value>
IEnumerable<IPlugin> Plugins { get; }
IPlugin[] Plugins { get; }
/// <summary>
/// Removes the plugin.

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -13,7 +13,8 @@
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -57,9 +58,7 @@
<Compile Include="Extensions\BaseExtensions.cs" />
<Compile Include="Extensions\ResourceNotFoundException.cs" />
<Compile Include="IDependencyContainer.cs" />
<Compile Include="IO\IMemoryStreamProvider.cs" />
<Compile Include="IO\ProgressStream.cs" />
<Compile Include="IO\StreamDefaults.cs" />
<Compile Include="Configuration\IApplicationPaths.cs" />
<Compile Include="Net\HttpRequestOptions.cs" />
<Compile Include="Net\HttpResponseInfo.cs" />
@ -69,22 +68,8 @@
<Compile Include="Plugins\IDependencyModule.cs" />
<Compile Include="Plugins\IPlugin.cs" />
<Compile Include="Progress\ActionableProgress.cs" />
<Compile Include="ScheduledTasks\IConfigurableScheduledTask.cs" />
<Compile Include="ScheduledTasks\IHasKey.cs" />
<Compile Include="ScheduledTasks\IScheduledTask.cs" />
<Compile Include="ScheduledTasks\IScheduledTaskWorker.cs" />
<Compile Include="ScheduledTasks\ITaskManager.cs" />
<Compile Include="ScheduledTasks\ITaskTrigger.cs" />
<Compile Include="ScheduledTasks\ScheduledTaskHelpers.cs" />
<Compile Include="ScheduledTasks\StartupTrigger.cs" />
<Compile Include="ScheduledTasks\SystemEventTrigger.cs" />
<Compile Include="Plugins\BasePlugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ScheduledTasks\DailyTrigger.cs" />
<Compile Include="ScheduledTasks\IntervalTrigger.cs" />
<Compile Include="ScheduledTasks\TaskCompletionEventArgs.cs" />
<Compile Include="ScheduledTasks\TaskExecutionOptions.cs" />
<Compile Include="ScheduledTasks\WeeklyTrigger.cs" />
<Compile Include="Security\IRequiresRegistration.cs" />
<Compile Include="Security\ISecurityManager.cs" />
<Compile Include="Security\PaymentRequiredException.cs" />

@ -3,8 +3,6 @@ using MediaBrowser.Model.Plugins;
using MediaBrowser.Model.Serialization;
using System;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
namespace MediaBrowser.Common.Plugins
{
@ -12,7 +10,7 @@ namespace MediaBrowser.Common.Plugins
/// Provides a common base class for all plugins
/// </summary>
/// <typeparam name="TConfigurationType">The type of the T configuration type.</typeparam>
public abstract class BasePlugin<TConfigurationType> : IPlugin
public abstract class BasePlugin<TConfigurationType> : IPlugin, IPluginAssembly
where TConfigurationType : BasePluginConfiguration
{
/// <summary>
@ -57,69 +55,33 @@ namespace MediaBrowser.Common.Plugins
get { return typeof(TConfigurationType); }
}
/// <summary>
/// The _assembly name
/// </summary>
private AssemblyName _assemblyName;
/// <summary>
/// Gets the name of the assembly.
/// </summary>
/// <value>The name of the assembly.</value>
protected AssemblyName AssemblyName
public void SetAttributes(string assemblyFilePath, string assemblyFileName, Version assemblyVersion, Guid assemblyId)
{
get
{
return _assemblyName ?? (_assemblyName = GetType().Assembly.GetName());
}
}
AssemblyFilePath = assemblyFilePath;
AssemblyFileName = assemblyFileName;
Version = assemblyVersion;
Id = assemblyId;
/// <summary>
/// The _unique id
/// </summary>
private Guid? _uniqueId;
IsFirstRun = !File.Exists(ConfigurationFilePath);
}
/// <summary>
/// Gets the unique id.
/// </summary>
/// <value>The unique id.</value>
public Guid Id
{
get
{
if (!_uniqueId.HasValue)
{
var attribute = (GuidAttribute)GetType().Assembly.GetCustomAttributes(typeof(GuidAttribute), true)[0];
_uniqueId = new Guid(attribute.Value);
}
return _uniqueId.Value;
}
}
public Guid Id { get; private set; }
/// <summary>
/// Gets the plugin version
/// </summary>
/// <value>The version.</value>
public Version Version
{
get
{
return AssemblyName.Version;
}
}
public Version Version { get; private set; }
/// <summary>
/// Gets the name the assembly file
/// </summary>
/// <value>The name of the assembly file.</value>
public string AssemblyFileName
{
get
{
return AssemblyName.Name + ".dll";
}
}
protected string AssemblyFileName { get; private set; }
/// <summary>
/// Gets the last date modified of the configuration
@ -136,29 +98,11 @@ namespace MediaBrowser.Common.Plugins
}
}
/// <summary>
/// Gets the last date modified of the plugin
/// </summary>
/// <value>The assembly date last modified.</value>
public DateTime AssemblyDateLastModified
{
get
{
return File.GetLastWriteTimeUtc(AssemblyFilePath);
}
}
/// <summary>
/// Gets the path to the assembly file
/// </summary>
/// <value>The assembly file path.</value>
public string AssemblyFilePath
{
get
{
return Path.Combine(ApplicationPaths.PluginsPath, AssemblyFileName);
}
}
public string AssemblyFilePath { get; private set; }
/// <summary>
/// The _configuration sync lock
@ -272,8 +216,6 @@ namespace MediaBrowser.Common.Plugins
{
ApplicationPaths = applicationPaths;
XmlSerializer = xmlSerializer;
IsFirstRun = !File.Exists(ConfigurationFilePath);
}
/// <summary>
@ -349,4 +291,9 @@ namespace MediaBrowser.Common.Plugins
get { return Configuration; }
}
}
public interface IPluginAssembly
{
void SetAttributes(string assemblyFilePath, string assemblyFileName, Version assemblyVersion, Guid assemblyId);
}
}

@ -38,12 +38,6 @@ namespace MediaBrowser.Common.Plugins
/// <value>The version.</value>
Version Version { get; }
/// <summary>
/// Gets the name the assembly file
/// </summary>
/// <value>The name of the assembly file.</value>
string AssemblyFileName { get; }
/// <summary>
/// Gets a value indicating whether this instance is first run.
/// </summary>
@ -56,12 +50,6 @@ namespace MediaBrowser.Common.Plugins
/// <value>The configuration date last modified.</value>
DateTime ConfigurationDateLastModified { get; }
/// <summary>
/// Gets the last date modified of the plugin
/// </summary>
/// <value>The assembly date last modified.</value>
DateTime AssemblyDateLastModified { get; }
/// <summary>
/// Gets the path to the assembly file
/// </summary>

@ -1,7 +0,0 @@
namespace MediaBrowser.Common.ScheduledTasks
{
public interface IHasKey
{
string Key { get; }
}
}

@ -1,194 +0,0 @@
using MediaBrowser.Model.Tasks;
using System;
using System.Linq;
namespace MediaBrowser.Common.ScheduledTasks
{
/// <summary>
/// Class ScheduledTaskHelpers
/// </summary>
public static class ScheduledTaskHelpers
{
/// <summary>
/// Gets the task info.
/// </summary>
/// <param name="task">The task.</param>
/// <returns>TaskInfo.</returns>
public static TaskInfo GetTaskInfo(IScheduledTaskWorker task)
{
var isHidden = false;
var configurableTask = task.ScheduledTask as IConfigurableScheduledTask;
if (configurableTask != null)
{
isHidden = configurableTask.IsHidden;
}
string key = null;
var hasKey = task.ScheduledTask as IHasKey;
if (hasKey != null)
{
key = hasKey.Key;
}
var triggers = task.Triggers
.Select(GetTriggerInfo)
.OrderBy(i => i.Type)
.ThenBy(i => i.DayOfWeek ?? DayOfWeek.Sunday)
.ThenBy(i => i.TimeOfDayTicks ?? 0)
.ToList();
return new TaskInfo
{
Name = task.Name,
CurrentProgressPercentage = task.CurrentProgress,
State = task.State,
Id = task.Id,
LastExecutionResult = task.LastExecutionResult,
Triggers = triggers,
Description = task.Description,
Category = task.Category,
IsHidden = isHidden,
Key = key
};
}
/// <summary>
/// Gets the trigger info.
/// </summary>
/// <param name="trigger">The trigger.</param>
/// <returns>TaskTriggerInfo.</returns>
public static TaskTriggerInfo GetTriggerInfo(ITaskTrigger trigger)
{
var info = new TaskTriggerInfo
{
Type = trigger.GetType().Name
};
var dailyTrigger = trigger as DailyTrigger;
if (dailyTrigger != null)
{
info.TimeOfDayTicks = dailyTrigger.TimeOfDay.Ticks;
}
var weeklyTaskTrigger = trigger as WeeklyTrigger;
if (weeklyTaskTrigger != null)
{
info.TimeOfDayTicks = weeklyTaskTrigger.TimeOfDay.Ticks;
info.DayOfWeek = weeklyTaskTrigger.DayOfWeek;
}
var intervalTaskTrigger = trigger as IntervalTrigger;
if (intervalTaskTrigger != null)
{
info.IntervalTicks = intervalTaskTrigger.Interval.Ticks;
}
var systemEventTrigger = trigger as SystemEventTrigger;
if (systemEventTrigger != null)
{
info.SystemEvent = systemEventTrigger.SystemEvent;
}
if (trigger.TaskOptions != null)
{
info.MaxRuntimeMs = trigger.TaskOptions.MaxRuntimeMs;
}
return info;
}
/// <summary>
/// Converts a TaskTriggerInfo into a concrete BaseTaskTrigger
/// </summary>
/// <param name="info">The info.</param>
/// <returns>BaseTaskTrigger.</returns>
/// <exception cref="System.ArgumentNullException"></exception>
/// <exception cref="System.ArgumentException">Invalid trigger type: + info.Type</exception>
public static ITaskTrigger GetTrigger(TaskTriggerInfo info)
{
var options = new TaskExecutionOptions
{
MaxRuntimeMs = info.MaxRuntimeMs
};
if (info.Type.Equals(typeof(DailyTrigger).Name, StringComparison.OrdinalIgnoreCase))
{
if (!info.TimeOfDayTicks.HasValue)
{
throw new ArgumentNullException();
}
return new DailyTrigger
{
TimeOfDay = TimeSpan.FromTicks(info.TimeOfDayTicks.Value),
TaskOptions = options
};
}
if (info.Type.Equals(typeof(WeeklyTrigger).Name, StringComparison.OrdinalIgnoreCase))
{
if (!info.TimeOfDayTicks.HasValue)
{
throw new ArgumentNullException();
}
if (!info.DayOfWeek.HasValue)
{
throw new ArgumentNullException();
}
return new WeeklyTrigger
{
TimeOfDay = TimeSpan.FromTicks(info.TimeOfDayTicks.Value),
DayOfWeek = info.DayOfWeek.Value,
TaskOptions = options
};
}
if (info.Type.Equals(typeof(IntervalTrigger).Name, StringComparison.OrdinalIgnoreCase))
{
if (!info.IntervalTicks.HasValue)
{
throw new ArgumentNullException();
}
return new IntervalTrigger
{
Interval = TimeSpan.FromTicks(info.IntervalTicks.Value),
TaskOptions = options
};
}
if (info.Type.Equals(typeof(SystemEventTrigger).Name, StringComparison.OrdinalIgnoreCase))
{
if (!info.SystemEvent.HasValue)
{
throw new ArgumentNullException();
}
return new SystemEventTrigger
{
SystemEvent = info.SystemEvent.Value,
TaskOptions = options
};
}
if (info.Type.Equals(typeof(StartupTrigger).Name, StringComparison.OrdinalIgnoreCase))
{
return new StartupTrigger();
}
throw new ArgumentException("Unrecognized trigger type: " + info.Type);
}
}
}

@ -10,6 +10,8 @@ using System.Runtime.Serialization;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Extensions;
using MediaBrowser.Model.Extensions;
namespace MediaBrowser.Controller.Entities.Audio
{

@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Extensions;
using MediaBrowser.Model.Extensions;
namespace MediaBrowser.Controller.Entities.Audio
{

@ -24,7 +24,9 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Controller.Extensions;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.LiveTv;
using MediaBrowser.Model.Providers;

@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Extensions;
using MediaBrowser.Model.Extensions;
namespace MediaBrowser.Controller.Entities
{

@ -4,6 +4,8 @@ using System;
using System.Collections.Generic;
using System.Linq;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Extensions;
using MediaBrowser.Model.Extensions;
namespace MediaBrowser.Controller.Entities
{

@ -4,7 +4,9 @@ using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Extensions;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Extensions;
namespace MediaBrowser.Controller.Entities
{

@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Extensions;
using MediaBrowser.Model.Extensions;
namespace MediaBrowser.Controller.Entities
{

@ -0,0 +1,22 @@
using System;
using System.Globalization;
using System.Linq;
using System.Text;
namespace MediaBrowser.Controller.Extensions
{
/// <summary>
/// Class BaseExtensions
/// </summary>
public static class StringExtensions
{
public static string RemoveDiacritics(this string text)
{
return String.Concat(
text.Normalize(NormalizationForm.FormD)
.Where(ch => CharUnicodeInfo.GetUnicodeCategory(ch) !=
UnicodeCategory.NonSpacingMark)
).Normalize(NormalizationForm.FormC);
}
}
}

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using MediaBrowser.Controller.Extensions;
using MediaBrowser.Model.Extensions;
namespace MediaBrowser.Controller.Library

@ -165,6 +165,7 @@
<Compile Include="Entities\TagExtensions.cs" />
<Compile Include="Entities\UserView.cs" />
<Compile Include="Entities\UserViewBuilder.cs" />
<Compile Include="Extensions\StringExtensions.cs" />
<Compile Include="FileOrganization\IFileOrganizationService.cs" />
<Compile Include="IO\ThrottledStream.cs" />
<Compile Include="Library\DeleteOptions.cs" />

@ -12,6 +12,7 @@ using CommonIO;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.MediaInfo;

@ -20,6 +20,7 @@ using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.IO;
using MediaBrowser.Model.IO;
using UniversalDetector;
namespace MediaBrowser.MediaEncoding.Subtitles

@ -0,0 +1,9 @@
using System;
namespace MediaBrowser.Model.Cryptography
{
public interface ICryptographyProvider
{
Guid GetMD5(string str);
}
}

@ -171,7 +171,7 @@ namespace MediaBrowser.Model.Dlna
}
bool expected;
if (BoolHelper.TryParseCultureInvariant(condition.Value, out expected))
if (bool.TryParse(condition.Value, out expected))
{
switch (condition.Condition)
{
@ -196,7 +196,7 @@ namespace MediaBrowser.Model.Dlna
}
float expected;
if (FloatHelper.TryParseCultureInvariant(condition.Value, out expected))
if (float.TryParse(condition.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out expected))
{
switch (condition.Condition)
{
@ -225,7 +225,7 @@ namespace MediaBrowser.Model.Dlna
}
double expected;
if (DoubleHelper.TryParseCultureInvariant(condition.Value, out expected))
if (double.TryParse(condition.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out expected))
{
switch (condition.Condition)
{

@ -1111,7 +1111,7 @@ namespace MediaBrowser.Model.Dlna
case ProfileConditionValue.VideoFramerate:
{
float num;
if (FloatHelper.TryParseCultureInvariant(value, out num))
if (float.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out num))
{
item.MaxFramerate = num;
}

@ -1,4 +1,4 @@
using MediaBrowser.Model.Extensions;
using System.Globalization;
namespace MediaBrowser.Model.Drawing
{
@ -71,12 +71,12 @@ namespace MediaBrowser.Model.Drawing
{
double val;
if (DoubleHelper.TryParseCultureInvariant(parts[0], out val))
if (double.TryParse(parts[0], NumberStyles.Any, CultureInfo.InvariantCulture, out val))
{
_width = val;
}
if (DoubleHelper.TryParseCultureInvariant(parts[1], out val))
if (double.TryParse(parts[1], NumberStyles.Any, CultureInfo.InvariantCulture, out val))
{
_height = val;
}

@ -118,7 +118,7 @@ namespace MediaBrowser.Model.Entities
private string AddLanguageIfNeeded(string title)
{
if (!string.IsNullOrEmpty(Language) && title.IndexOf(Language, StringComparison.OrdinalIgnoreCase) == -1)
if (!string.IsNullOrEmpty(Language) && !string.Equals(Language, "und", StringComparison.OrdinalIgnoreCase) && title.IndexOf(Language, StringComparison.OrdinalIgnoreCase) == -1)
{
title = StringHelper.FirstToUpper(Language) + " " + title;
}

@ -1,16 +0,0 @@
namespace MediaBrowser.Model.Extensions
{
public static class BoolHelper
{
/// <summary>
/// Tries the parse culture invariant.
/// </summary>
/// <param name="s">The s.</param>
/// <param name="result">The result.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
public static bool TryParseCultureInvariant(string s, out bool result)
{
return bool.TryParse(s, out result);
}
}
}

@ -1,21 +0,0 @@
using System.Globalization;
namespace MediaBrowser.Model.Extensions
{
/// <summary>
/// Isolating these helpers allow this entire project to be easily converted to Java
/// </summary>
public static class DoubleHelper
{
/// <summary>
/// Tries the parse culture invariant.
/// </summary>
/// <param name="s">The s.</param>
/// <param name="result">The result.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
public static bool TryParseCultureInvariant(string s, out double result)
{
return double.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out result);
}
}
}

@ -1,18 +0,0 @@
using System.Globalization;
namespace MediaBrowser.Model.Extensions
{
public static class FloatHelper
{
/// <summary>
/// Tries the parse culture invariant.
/// </summary>
/// <param name="s">The s.</param>
/// <param name="result">The result.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
public static bool TryParseCultureInvariant(string s, out float result)
{
return float.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out result);
}
}
}

@ -1,6 +1,6 @@
using System.IO;
namespace MediaBrowser.Common.IO
namespace MediaBrowser.Model.IO
{
public interface IMemoryStreamProvider
{

@ -1,5 +1,5 @@

namespace MediaBrowser.Common.IO
namespace MediaBrowser.Model.IO
{
/// <summary>
/// Class StreamDefaults

@ -2,7 +2,7 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}</ProjectGuid>
@ -13,8 +13,9 @@
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>Profile7</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -98,6 +99,7 @@
<Compile Include="Connect\PinExchangeResult.cs" />
<Compile Include="Connect\PinStatusResult.cs" />
<Compile Include="Connect\UserLinkType.cs" />
<Compile Include="Cryptography\ICryptographyProvider.cs" />
<Compile Include="Devices\DeviceOptions.cs" />
<Compile Include="Devices\DeviceQuery.cs" />
<Compile Include="Devices\LocalFileInfo.cs" />
@ -133,6 +135,8 @@
<Compile Include="Extensions\LinqExtensions.cs" />
<Compile Include="FileOrganization\SmartMatchInfo.cs" />
<Compile Include="Health\IHealthMonitor.cs" />
<Compile Include="IO\IMemoryStreamProvider.cs" />
<Compile Include="IO\StreamDefaults.cs" />
<Compile Include="MediaInfo\LiveStreamRequest.cs" />
<Compile Include="MediaInfo\LiveStreamResponse.cs" />
<Compile Include="MediaInfo\PlaybackInfoRequest.cs" />
@ -141,8 +145,6 @@
<Compile Include="Configuration\DynamicDayOfWeek.cs" />
<Compile Include="Entities\ExtraType.cs" />
<Compile Include="Entities\TrailerType.cs" />
<Compile Include="Extensions\BoolHelper.cs" />
<Compile Include="Extensions\FloatHelper.cs" />
<Compile Include="FileOrganization\AutoOrganizeOptions.cs" />
<Compile Include="FileOrganization\TvFileOrganizationOptions.cs" />
<Compile Include="Configuration\BaseApplicationConfiguration.cs" />
@ -215,7 +217,6 @@
<Compile Include="Entities\ScrollDirection.cs" />
<Compile Include="Entities\SortOrder.cs" />
<Compile Include="Events\GenericEventArgs.cs" />
<Compile Include="Extensions\DoubleHelper.cs" />
<Compile Include="Extensions\ListHelper.cs" />
<Compile Include="Extensions\StringHelper.cs" />
<Compile Include="FileOrganization\EpisodeFileOrganizationRequest.cs" />
@ -384,6 +385,14 @@
<Compile Include="System\Architecture.cs" />
<Compile Include="System\LogFile.cs" />
<Compile Include="System\PublicSystemInfo.cs" />
<Compile Include="Tasks\IConfigurableScheduledTask.cs" />
<Compile Include="Tasks\IScheduledTask.cs" />
<Compile Include="Tasks\IScheduledTaskWorker.cs" />
<Compile Include="Tasks\ITaskManager.cs" />
<Compile Include="Tasks\ITaskTrigger.cs" />
<Compile Include="Tasks\ScheduledTaskHelpers.cs" />
<Compile Include="Tasks\TaskCompletionEventArgs.cs" />
<Compile Include="Tasks\TaskExecutionOptions.cs" />
<Compile Include="Updates\CheckForUpdateResult.cs" />
<Compile Include="Updates\PackageTargetSystem.cs" />
<Compile Include="Updates\InstallationInfo.cs" />

@ -1,4 +1,4 @@
namespace MediaBrowser.Common.ScheduledTasks
namespace MediaBrowser.Model.Tasks
{
public interface IConfigurableScheduledTask
{
@ -12,10 +12,7 @@
/// </summary>
/// <value><c>true</c> if this instance is enabled; otherwise, <c>false</c>.</value>
bool IsEnabled { get; }
}
public interface IScheduledTaskActivityLog
{
bool IsActivityLogged { get; }
bool IsLogged { get; }
}
}

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Common.ScheduledTasks
namespace MediaBrowser.Model.Tasks
{
/// <summary>
/// Interface IScheduledTaskWorker
@ -16,6 +16,8 @@ namespace MediaBrowser.Common.ScheduledTasks
/// <value>The name.</value>
string Name { get; }
string Key { get; }
/// <summary>
/// Gets the description.
/// </summary>
@ -40,6 +42,6 @@ namespace MediaBrowser.Common.ScheduledTasks
/// Gets the default triggers.
/// </summary>
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
IEnumerable<ITaskTrigger> GetDefaultTriggers();
IEnumerable<TaskTriggerInfo> GetDefaultTriggers();
}
}

@ -1,9 +1,7 @@
using MediaBrowser.Model.Events;
using MediaBrowser.Model.Tasks;
using System;
using System.Collections.Generic;
using System;
using MediaBrowser.Model.Events;
namespace MediaBrowser.Common.ScheduledTasks
namespace MediaBrowser.Model.Tasks
{
/// <summary>
/// Interface IScheduledTaskWorker
@ -61,8 +59,8 @@ namespace MediaBrowser.Common.ScheduledTasks
/// Gets the triggers that define when the task will run
/// </summary>
/// <value>The triggers.</value>
/// <exception cref="System.ArgumentNullException">value</exception>
IEnumerable<ITaskTrigger> Triggers { get; set; }
/// <exception cref="ArgumentNullException">value</exception>
TaskTriggerInfo[] Triggers { get; set; }
/// <summary>
/// Gets the unique id.

@ -1,9 +1,9 @@
using MediaBrowser.Model.Events;
using System;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using MediaBrowser.Model.Events;
namespace MediaBrowser.Common.ScheduledTasks
namespace MediaBrowser.Model.Tasks
{
public interface ITaskManager : IDisposable
{

@ -1,9 +1,8 @@
using MediaBrowser.Model.Events;
using MediaBrowser.Model.Tasks;
using System;
using System;
using MediaBrowser.Model.Events;
using MediaBrowser.Model.Logging;
namespace MediaBrowser.Common.ScheduledTasks
namespace MediaBrowser.Model.Tasks
{
/// <summary>
/// Interface ITaskTrigger
@ -18,8 +17,6 @@ namespace MediaBrowser.Common.ScheduledTasks
/// <summary>
/// Stars waiting for the trigger action
/// </summary>
/// <param name="lastResult">The last result.</param>
/// <param name="isApplicationStartup">if set to <c>true</c> [is application startup].</param>
void Start(TaskResult lastResult, ILogger logger, string taskName, bool isApplicationStartup);
/// <summary>

@ -0,0 +1,52 @@
using System;
using System.Linq;
namespace MediaBrowser.Model.Tasks
{
/// <summary>
/// Class ScheduledTaskHelpers
/// </summary>
public static class ScheduledTaskHelpers
{
/// <summary>
/// Gets the task info.
/// </summary>
/// <param name="task">The task.</param>
/// <returns>TaskInfo.</returns>
public static TaskInfo GetTaskInfo(IScheduledTaskWorker task)
{
var isHidden = false;
var configurableTask = task.ScheduledTask as IConfigurableScheduledTask;
if (configurableTask != null)
{
isHidden = configurableTask.IsHidden;
}
string key = task.ScheduledTask.Key;
var triggers = task.Triggers
.OrderBy(i => i.Type)
.ThenBy(i => i.DayOfWeek ?? DayOfWeek.Sunday)
.ThenBy(i => i.TimeOfDayTicks ?? 0)
.ToList();
return new TaskInfo
{
Name = task.Name,
CurrentProgressPercentage = task.CurrentProgress,
State = task.State,
Id = task.Id,
LastExecutionResult = task.LastExecutionResult,
Triggers = triggers,
Description = task.Description,
Category = task.Category,
IsHidden = isHidden,
Key = key
};
}
}
}

@ -1,7 +1,6 @@
using MediaBrowser.Model.Tasks;
using System;
using System;
namespace MediaBrowser.Common.ScheduledTasks
namespace MediaBrowser.Model.Tasks
{
public class TaskCompletionEventArgs : EventArgs
{

@ -1,5 +1,5 @@

namespace MediaBrowser.Common.ScheduledTasks
namespace MediaBrowser.Model.Tasks
{
/// <summary>
/// A class that encomposases all common task run properties.

@ -42,5 +42,11 @@ namespace MediaBrowser.Model.Tasks
/// </summary>
/// <value>The maximum runtime ms.</value>
public int? MaxRuntimeMs { get; set; }
public const string TriggerDaily = "DailyTrigger";
public const string TriggerWeekly = "WeeklyTrigger";
public const string TriggerInterval = "IntervalTrigger";
public const string TriggerSystemEvent = "SystemEventTrigger";
public const string TriggerStartup = "StartupTrigger";
}
}

@ -1,7 +1,16 @@
{
"supports": {},
"dependencies": {},
{
"supports": {
"net46.app": {},
"uwp.10.0.app": {},
"dnxcore50.app": {}
},
"dependencies": {
"Microsoft.NETCore": "5.0.0",
"Microsoft.NETCore.Portable.Compatibility": "1.0.0"
},
"frameworks": {
".NETPortable,Version=v4.5,Profile=Profile7": {}
"dotnet": {
"imports": "portable-net452+win81"
}
}
}

File diff suppressed because it is too large Load Diff

@ -17,6 +17,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Model.IO;
namespace MediaBrowser.Providers.Manager
{

@ -21,6 +21,7 @@ using System.Threading;
using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Common.IO;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Serialization;
namespace MediaBrowser.Providers.Manager

@ -139,7 +139,7 @@ namespace MediaBrowser.Providers.MediaInfo
request.IndexNumberEnd = episode.IndexNumberEnd;
request.SeriesName = episode.SeriesName;
}
try
{
var searchResults = await _subtitleManager.SearchSubtitles(request, cancellationToken).ConfigureAwait(false);

@ -1,5 +1,4 @@
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
@ -16,6 +15,7 @@ using System.Threading;
using System.Threading.Tasks;
using System.IO;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Tasks;
namespace MediaBrowser.Providers.MediaInfo
{
@ -184,12 +184,18 @@ namespace MediaBrowser.Providers.MediaInfo
return false;
}
public IEnumerable<ITaskTrigger> GetDefaultTriggers()
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{
return new ITaskTrigger[]
{
new IntervalTrigger{ Interval = TimeSpan.FromHours(8)}
};
return new[] {
// Every so often
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks}
};
}
public string Key
{
get { return "DownloadSubtitles"; }
}
}
}

@ -11,9 +11,9 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Model.Tasks;
namespace MediaBrowser.Providers.TV
{

@ -5,10 +5,11 @@ using MediaBrowser.Model.Logging;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using MediaBrowser.Model.Tasks;
namespace MediaBrowser.Server.Implementations.Channels
{
class RefreshChannelsScheduledTask : IScheduledTask, IConfigurableScheduledTask
class RefreshChannelsScheduledTask : IScheduledTask
{
private readonly IChannelManager _channelManager;
private readonly IUserManager _userManager;
@ -48,14 +49,23 @@ namespace MediaBrowser.Server.Implementations.Channels
.ConfigureAwait(false);
}
public IEnumerable<ITaskTrigger> GetDefaultTriggers()
/// <summary>
/// Creates the triggers that define when the task will run
/// </summary>
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{
return new ITaskTrigger[]
{
new IntervalTrigger{ Interval = TimeSpan.FromHours(24)}
return new[] {
// Every so often
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks}
};
}
public string Key
{
get { return "RefreshInternetChannels"; }
}
public bool IsHidden
{
get { return false; }

@ -401,8 +401,8 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
{
var task = e.Argument;
var activityTask = task.ScheduledTask as IScheduledTaskActivityLog;
if (activityTask != null && !activityTask.IsActivityLogged)
var activityTask = task.ScheduledTask as IConfigurableScheduledTask;
if (activityTask != null && !activityTask.IsLogged)
{
return;
}
@ -419,8 +419,8 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
var result = e.Result;
var task = e.Task;
var activityTask = task.ScheduledTask as IScheduledTaskActivityLog;
if (activityTask != null && !activityTask.IsActivityLogged)
var activityTask = task.ScheduledTask as IConfigurableScheduledTask;
if (activityTask != null && !activityTask.IsLogged)
{
return;
}

@ -13,6 +13,7 @@ using MediaBrowser.Model.Sync;
using System;
using System.Collections.Generic;
using System.Threading;
using MediaBrowser.Model.Tasks;
namespace MediaBrowser.Server.Implementations.EntryPoints
{

@ -7,6 +7,7 @@ using MediaBrowser.Model.FileOrganization;
using MediaBrowser.Model.Logging;
using System;
using System.Threading;
using MediaBrowser.Model.Tasks;
namespace MediaBrowser.Server.Implementations.FileOrganization
{

@ -18,6 +18,7 @@ using CommonIO;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Events;
using MediaBrowser.Common.Events;
using MediaBrowser.Model.Tasks;
namespace MediaBrowser.Server.Implementations.FileOrganization
{

@ -10,10 +10,11 @@ using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Model.Tasks;
namespace MediaBrowser.Server.Implementations.FileOrganization
{
public class OrganizerScheduledTask : IScheduledTask, IConfigurableScheduledTask, IScheduledTaskActivityLog, IHasKey
public class OrganizerScheduledTask : IScheduledTask, IConfigurableScheduledTask
{
private readonly ILibraryMonitor _libraryMonitor;
private readonly ILibraryManager _libraryManager;
@ -63,12 +64,17 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
}
}
public IEnumerable<ITaskTrigger> GetDefaultTriggers()
/// <summary>
/// Creates the triggers that define when the task will run
/// </summary>
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{
return new ITaskTrigger[]
{
new IntervalTrigger{ Interval = TimeSpan.FromMinutes(5)}
};
return new[] {
// Every so often
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromMinutes(5).Ticks}
};
}
public bool IsHidden
@ -81,7 +87,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
get { return GetAutoOrganizeOptions().TvOptions.IsEnabled; }
}
public bool IsActivityLogged
public bool IsLogged
{
get { return false; }
}

@ -23,6 +23,7 @@ using MediaBrowser.Common.IO;
using MediaBrowser.Common.Net;
using MediaBrowser.Common.Security;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.IO;
namespace MediaBrowser.Server.Implementations.HttpServer
{

@ -3,6 +3,7 @@ using MediaBrowser.Common.IO;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging;
using ServiceStack.Logging;

@ -10,6 +10,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using MediaBrowser.Common.IO;
using MediaBrowser.Model.IO;
namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
{

@ -4,6 +4,7 @@ using System.IO;
using System.Text;
using Funq;
using MediaBrowser.Common.IO;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging;
using ServiceStack;
using ServiceStack.Host;

@ -12,6 +12,7 @@ using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Tasks;
using MediaBrowser.Server.Implementations.ScheduledTasks;
namespace MediaBrowser.Server.Implementations.IO

@ -14,6 +14,7 @@ using System.Linq;
using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Controller;
using MediaBrowser.Model.Tasks;
namespace MediaBrowser.Server.Implementations.IO
{
@ -174,6 +175,11 @@ namespace MediaBrowser.Server.Implementations.IO
private bool IsLibraryMonitorEnabaled(BaseItem item)
{
if (item is BasePluginFolder)
{
return false;
}
var options = LibraryManager.GetLibraryOptions(item);
if (options != null)

@ -43,6 +43,7 @@ using MediaBrowser.Server.Implementations.Library.Resolvers;
using SortOrder = MediaBrowser.Model.Entities.SortOrder;
using VideoResolver = MediaBrowser.Naming.Video.VideoResolver;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Model.Tasks;
namespace MediaBrowser.Server.Implementations.Library
{

@ -10,6 +10,8 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using MediaBrowser.Controller.Extensions;
using MediaBrowser.Model.Extensions;
namespace MediaBrowser.Server.Implementations.Library
{

@ -35,6 +35,7 @@ using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Model.Events;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.Tasks;
using MediaBrowser.Server.Implementations.LiveTv.Listings;
namespace MediaBrowser.Server.Implementations.LiveTv

@ -6,10 +6,11 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using MediaBrowser.Model.Tasks;
namespace MediaBrowser.Server.Implementations.LiveTv
{
public class RefreshChannelsScheduledTask : IScheduledTask, IConfigurableScheduledTask, IHasKey
public class RefreshChannelsScheduledTask : IScheduledTask, IConfigurableScheduledTask
{
private readonly ILiveTvManager _liveTvManager;
private readonly IConfigurationManager _config;
@ -42,11 +43,16 @@ namespace MediaBrowser.Server.Implementations.LiveTv
return manager.RefreshChannels(progress, cancellationToken);
}
public IEnumerable<ITaskTrigger> GetDefaultTriggers()
/// <summary>
/// Creates the triggers that define when the task will run
/// </summary>
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{
return new ITaskTrigger[]
{
new IntervalTrigger{ Interval = TimeSpan.FromHours(12)}
return new[] {
// Every so often
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(12).Ticks}
};
}
@ -65,6 +71,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv
get { return true; }
}
public bool IsLogged
{
get { return true; }
}
public string Key
{
get { return "RefreshGuide"; }

@ -47,7 +47,7 @@
<HintPath>..\packages\CommonIO.1.0.0.9\lib\net45\CommonIO.dll</HintPath>
</Reference>
<Reference Include="Emby.XmlTv, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Emby.XmlTv.1.0.0.56\lib\net45\Emby.XmlTv.dll</HintPath>
<HintPath>..\packages\Emby.XmlTv.1.0.0.57\lib\portable-net46+win10\Emby.XmlTv.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="INIFileParser, Version=2.3.0.0, Culture=neutral, PublicKeyToken=79af7b307b65cf3c, processorArchitecture=MSIL">

@ -18,6 +18,7 @@ using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.Localization;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Tasks;
using MediaBrowser.Server.Implementations.ScheduledTasks;
namespace MediaBrowser.Server.Implementations.Persistence
@ -337,12 +338,22 @@ namespace MediaBrowser.Server.Implementations.Persistence
}
}
public IEnumerable<ITaskTrigger> GetDefaultTriggers()
/// <summary>
/// Creates the triggers that define when the task will run
/// </summary>
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{
return new ITaskTrigger[]
{
new IntervalTrigger{ Interval = TimeSpan.FromHours(24)}
return new[] {
// Every so often
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks}
};
}
public string Key
{
get { return "CleanDatabase"; }
}
}
}

@ -5,6 +5,7 @@ using System;
using System.Data;
using System.IO;
using MediaBrowser.Common.IO;
using MediaBrowser.Model.IO;
namespace MediaBrowser.Server.Implementations.Persistence
{

@ -11,6 +11,7 @@ using System.IO;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.IO;
using MediaBrowser.Model.IO;
namespace MediaBrowser.Server.Implementations.Persistence
{

@ -23,8 +23,11 @@ using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Collections;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Extensions;
using MediaBrowser.Controller.Playlists;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.LiveTv;
using MediaBrowser.Server.Implementations.Devices;
using MediaBrowser.Server.Implementations.Playlists;

@ -10,6 +10,7 @@ using System.IO;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.IO;
using MediaBrowser.Model.IO;
namespace MediaBrowser.Server.Implementations.Persistence
{

@ -13,6 +13,7 @@ using System.Threading;
using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Tasks;
namespace MediaBrowser.Server.Implementations.ScheduledTasks
{
@ -62,20 +63,22 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
/// <summary>
/// Creates the triggers that define when the task will run
/// </summary>
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
public IEnumerable<ITaskTrigger> GetDefaultTriggers()
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{
return new ITaskTrigger[]
return new[] {
new TaskTriggerInfo
{
new DailyTrigger
{
TimeOfDay = TimeSpan.FromHours(1),
TaskOptions = new TaskExecutionOptions
{
MaxRuntimeMs = Convert.ToInt32(TimeSpan.FromHours(4).TotalMilliseconds)
}
}
};
Type = TaskTriggerInfo.TriggerDaily,
TimeOfDayTicks = TimeSpan.FromHours(1).Ticks,
MaxRuntimeMs = Convert.ToInt32(TimeSpan.FromHours(4).TotalMilliseconds)
}
};
}
public string Key
{
get { return "RefreshChapterImages"; }
}
/// <summary>

@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Controller;
using MediaBrowser.Model.Tasks;
namespace MediaBrowser.Server.Implementations.ScheduledTasks
{
@ -33,16 +34,21 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
/// <summary>
/// Creates the triggers that define when the task will run
/// </summary>
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
public IEnumerable<ITaskTrigger> GetDefaultTriggers()
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{
// Randomize the default start hour because this operation can really hammer internet metadata providers
var startHour = new Random(_appHost.SystemId.GetHashCode()).Next(0, 8);
return new ITaskTrigger[]
{
new DailyTrigger { TimeOfDay = TimeSpan.FromHours(startHour) },
};
return new[] {
// Every so often
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerDaily, TimeOfDayTicks = TimeSpan.FromHours(startHour).Ticks}
};
}
public string Key
{
get { return "RefreshPeople"; }
}
/// <summary>

@ -9,6 +9,7 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Tasks;
namespace MediaBrowser.Server.Implementations.ScheduledTasks
{
@ -37,18 +38,23 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
/// Creates the triggers that define when the task will run
/// </summary>
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
public IEnumerable<ITaskTrigger> GetDefaultTriggers()
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{
return new ITaskTrigger[] {
return new[] {
// At startup
new StartupTrigger(),
new TaskTriggerInfo {Type = TaskTriggerInfo.TriggerStartup},
// Every so often
new IntervalTrigger { Interval = TimeSpan.FromHours(24)}
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks}
};
}
public string Key
{
get { return "PluginUpdates"; }
}
/// <summary>
/// Update installed plugins
/// </summary>

@ -7,13 +7,14 @@ using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Tasks;
namespace MediaBrowser.Server.Implementations.ScheduledTasks
{
/// <summary>
/// Class RefreshMediaLibraryTask
/// </summary>
public class RefreshMediaLibraryTask : IScheduledTask, IHasKey
public class RefreshMediaLibraryTask : IScheduledTask
{
/// <summary>
/// The _library manager
@ -32,18 +33,16 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
}
/// <summary>
/// Gets the default triggers.
/// Creates the triggers that define when the task will run
/// </summary>
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
public IEnumerable<ITaskTrigger> GetDefaultTriggers()
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{
var list = new ITaskTrigger[] {
new IntervalTrigger{ Interval = TimeSpan.FromHours(12)}
}.ToList();
return list;
return new[] {
// Every so often
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(12).Ticks}
};
}
/// <summary>

@ -6,13 +6,14 @@ using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Tasks;
namespace MediaBrowser.Server.Implementations.ScheduledTasks
{
/// <summary>
/// Plugin Update Task
/// </summary>
public class SystemUpdateTask : IScheduledTask, IHasKey
public class SystemUpdateTask : IScheduledTask
{
/// <summary>
/// The _app host
@ -47,16 +48,15 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
/// Creates the triggers that define when the task will run
/// </summary>
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
public IEnumerable<ITaskTrigger> GetDefaultTriggers()
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{
// Until we can vary these default triggers per server and MBT, we need something that makes sense for both
return new ITaskTrigger[] {
return new[] {
// At startup
new StartupTrigger(),
new TaskTriggerInfo {Type = TaskTriggerInfo.TriggerStartup},
// Every so often
new IntervalTrigger { Interval = TimeSpan.FromHours(24)}
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks}
};
}

@ -14,6 +14,7 @@ using System.Net.Sockets;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.IO;
using MediaBrowser.Model.IO;
namespace MediaBrowser.Server.Implementations.ServerManager
{

@ -10,6 +10,7 @@ using System.IO;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.IO;
using MediaBrowser.Model.IO;
using UniversalDetector;
namespace MediaBrowser.Server.Implementations.ServerManager

@ -9,10 +9,11 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Model.Tasks;
namespace MediaBrowser.Server.Implementations.Sync
{
class ServerSyncScheduledTask : IScheduledTask, IConfigurableScheduledTask, IHasKey
class ServerSyncScheduledTask : IScheduledTask, IConfigurableScheduledTask
{
private readonly ISyncManager _syncManager;
private readonly ILogger _logger;
@ -58,14 +59,17 @@ namespace MediaBrowser.Server.Implementations.Sync
get { return ((SyncManager)_syncManager).ServerSyncProviders; }
}
public IEnumerable<ITaskTrigger> GetDefaultTriggers()
/// <summary>
/// Creates the triggers that define when the task will run
/// </summary>
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{
return new ITaskTrigger[]
{
new IntervalTrigger { Interval = TimeSpan.FromHours(3) }
};
return new[] {
// Every so often
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(3).Ticks}
};
}
public bool IsHidden
{
get { return !IsEnabled; }
@ -76,6 +80,11 @@ namespace MediaBrowser.Server.Implementations.Sync
get { return ServerSyncProviders.Any(); }
}
public bool IsLogged
{
get { return true; }
}
public string Key
{
get { return "ServerSync"; }

@ -10,10 +10,11 @@ using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Model.Tasks;
namespace MediaBrowser.Server.Implementations.Sync
{
public class SyncConvertScheduledTask : IScheduledTask, IConfigurableScheduledTask, IHasKey
public class SyncConvertScheduledTask : IScheduledTask
{
private readonly ILibraryManager _libraryManager;
private readonly ISyncRepository _syncRepo;
@ -66,22 +67,17 @@ namespace MediaBrowser.Server.Implementations.Sync
.Sync(progress, cancellationToken);
}
public IEnumerable<ITaskTrigger> GetDefaultTriggers()
/// <summary>
/// Creates the triggers that define when the task will run
/// </summary>
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{
return new ITaskTrigger[]
{
new IntervalTrigger { Interval = TimeSpan.FromHours(3) }
};
}
public bool IsHidden
{
get { return false; }
}
public bool IsEnabled
{
get { return true; }
return new[] {
// Every so often
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(3).Ticks}
};
}
public string Key

@ -25,6 +25,7 @@ using System.Threading;
using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.IO;
namespace MediaBrowser.Server.Implementations.Sync
{

@ -30,6 +30,8 @@ using System.Threading;
using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Common.IO;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Tasks;
namespace MediaBrowser.Server.Implementations.Sync
{

@ -13,6 +13,7 @@ using System.Threading.Tasks;
using CommonIO;
using Interfaces.IO;
using MediaBrowser.Common.IO;
using MediaBrowser.Model.IO;
namespace MediaBrowser.Server.Implementations.Sync
{

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommonIO" version="1.0.0.9" targetFramework="net45" />
<package id="Emby.XmlTv" version="1.0.0.56" targetFramework="net45" />
<package id="Emby.XmlTv" version="1.0.0.57" targetFramework="net46" />
<package id="ini-parser" version="2.3.0" targetFramework="net45" />
<package id="Interfaces.IO" version="1.0.0.5" targetFramework="net45" />
<package id="MediaBrowser.Naming" version="1.0.0.55" targetFramework="net45" />

@ -1,6 +1,7 @@
using System.Threading.Tasks;
using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Model.Tasks;
using MediaBrowser.Server.Implementations.Persistence;
namespace MediaBrowser.Server.Startup.Common.Migrations

@ -192,7 +192,7 @@ namespace MediaBrowser.ServerApplication
{
_logger.Info("Found a duplicate process. Giving it time to exit.");
if (!duplicate.WaitForExit(20000))
if (!duplicate.WaitForExit(30000))
{
_logger.Info("The duplicate process did not exit.");
return true;

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

Loading…
Cancel
Save