Added CommandId to commands

pull/4/head
Mark McDowall 11 years ago
parent e4d7ea9fd8
commit a3961ffb69

@ -76,17 +76,23 @@ namespace NzbDrone.Common.Test.EventingTests
public class CommandA : ICommand public class CommandA : ICommand
{ {
public String CommandId { get; set; }
// ReSharper disable UnusedParameter.Local // ReSharper disable UnusedParameter.Local
public CommandA(int id = 0) public CommandA(int id = 0)
// ReSharper restore UnusedParameter.Local // ReSharper restore UnusedParameter.Local
{ {
CommandId = HashUtil.GenerateCommandId();
} }
} }
public class CommandB : ICommand public class CommandB : ICommand
{ {
public String CommandId { get; set; }
public CommandB()
{
CommandId = HashUtil.GenerateCommandId();
}
} }
} }

@ -34,31 +34,9 @@ namespace NzbDrone.Common
return String.Format("{0:x8}", mCrc); return String.Format("{0:x8}", mCrc);
} }
public static string GenerateUserId() public static string GenerateCommandId()
{ {
return GenerateId("u"); return GenerateId("c");
}
public static string GenerateAppId()
{
return GenerateId("a");
}
public static string GenerateApiToken()
{
return Guid.NewGuid().ToString().Replace("-", "");
}
public static string GenerateSecurityToken(int length)
{
var byteSize = (length / 4) * 3;
var linkBytes = new byte[byteSize];
var rngCrypto = new RNGCryptoServiceProvider();
rngCrypto.GetBytes(linkBytes);
var base64String = Convert.ToBase64String(linkBytes);
return base64String;
} }
private static string GenerateId(string prefix) private static string GenerateId(string prefix)

@ -1,6 +1,9 @@
using System;
namespace NzbDrone.Common.Messaging namespace NzbDrone.Common.Messaging
{ {
public interface ICommand : IMessage public interface ICommand : IMessage
{ {
String CommandId { get; }
} }
} }

@ -1,13 +1,15 @@
namespace NzbDrone.Common.Messaging using System;
namespace NzbDrone.Common.Messaging
{ {
public class TestCommand : ICommand public class TestCommand : ICommand
{ {
public int Duration { get; set; }
public String CommandId { get; set; }
public TestCommand() public TestCommand()
{ {
Duration = 4000; Duration = 4000;
} }
public int Duration { get; set; }
} }
} }

@ -1,8 +1,16 @@
using System;
using NzbDrone.Common;
using NzbDrone.Common.Messaging; using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.DataAugmentation.Scene namespace NzbDrone.Core.DataAugmentation.Scene
{ {
public class UpdateSceneMappingCommand : ICommand public class UpdateSceneMappingCommand : ICommand
{ {
public String CommandId { get; set; }
public UpdateSceneMappingCommand()
{
CommandId = HashUtil.GenerateCommandId();
}
} }
} }

@ -1,9 +1,17 @@
using NzbDrone.Common.Messaging; using System;
using NzbDrone.Common;
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.IndexerSearch namespace NzbDrone.Core.IndexerSearch
{ {
public class EpisodeSearchCommand : ICommand public class EpisodeSearchCommand : ICommand
{ {
public String CommandId { get; set; }
public int EpisodeId { get; set; } public int EpisodeId { get; set; }
public EpisodeSearchCommand()
{
CommandId = HashUtil.GenerateCommandId();
}
} }
} }

@ -1,10 +1,18 @@
using NzbDrone.Common.Messaging; using System;
using NzbDrone.Common;
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.IndexerSearch namespace NzbDrone.Core.IndexerSearch
{ {
public class SeasonSearchCommand : ICommand public class SeasonSearchCommand : ICommand
{ {
public String CommandId { get; set; }
public int SeriesId { get; set; } public int SeriesId { get; set; }
public int SeasonNumber { get; set; } public int SeasonNumber { get; set; }
public SeasonSearchCommand()
{
CommandId = HashUtil.GenerateCommandId();
}
} }
} }

@ -1,9 +1,17 @@
using NzbDrone.Common.Messaging; using System;
using NzbDrone.Common;
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.IndexerSearch namespace NzbDrone.Core.IndexerSearch
{ {
public class SeriesSearchCommand : ICommand public class SeriesSearchCommand : ICommand
{ {
public String CommandId { get; set; }
public int SeriesId { get; set; } public int SeriesId { get; set; }
public SeriesSearchCommand()
{
CommandId = HashUtil.GenerateCommandId();
}
} }
} }

@ -1,9 +1,16 @@
using NzbDrone.Common.Messaging; using System;
using NzbDrone.Common;
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.Indexers namespace NzbDrone.Core.Indexers
{ {
public class RssSyncCommand : ICommand public class RssSyncCommand : ICommand
{ {
public String CommandId { get; set; }
public RssSyncCommand()
{
CommandId = HashUtil.GenerateCommandId();
}
} }
} }

@ -1,8 +1,16 @@
using NzbDrone.Common.Messaging; using System;
using NzbDrone.Common;
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.Instrumentation.Commands namespace NzbDrone.Core.Instrumentation.Commands
{ {
public class ClearLogCommand : ICommand public class ClearLogCommand : ICommand
{ {
public String CommandId { get; set; }
public ClearLogCommand()
{
CommandId = HashUtil.GenerateCommandId();
}
} }
} }

@ -1,8 +1,16 @@
using NzbDrone.Common.Messaging; using System;
using NzbDrone.Common;
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.Instrumentation.Commands namespace NzbDrone.Core.Instrumentation.Commands
{ {
public class DeleteLogFilesCommand : ICommand public class DeleteLogFilesCommand : ICommand
{ {
public String CommandId { get; set; }
public DeleteLogFilesCommand()
{
CommandId = HashUtil.GenerateCommandId();
}
} }
} }

@ -1,8 +1,16 @@
using NzbDrone.Common.Messaging; using System;
using NzbDrone.Common;
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.Instrumentation.Commands namespace NzbDrone.Core.Instrumentation.Commands
{ {
public class TrimLogCommand : ICommand public class TrimLogCommand : ICommand
{ {
public String CommandId { get; set; }
public TrimLogCommand()
{
CommandId = HashUtil.GenerateCommandId();
}
} }
} }

@ -1,13 +1,22 @@
using System;
using NzbDrone.Common;
using NzbDrone.Common.Messaging; using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.MediaFiles.Commands namespace NzbDrone.Core.MediaFiles.Commands
{ {
public class CleanMediaFileDb : ICommand public class CleanMediaFileDb : ICommand
{ {
public String CommandId { get; set; }
public int SeriesId { get; private set; } public int SeriesId { get; private set; }
public CleanMediaFileDb()
{
CommandId = HashUtil.GenerateCommandId();
}
public CleanMediaFileDb(int seriesId) public CleanMediaFileDb(int seriesId)
{ {
CommandId = HashUtil.GenerateCommandId();
SeriesId = seriesId; SeriesId = seriesId;
} }
} }

@ -1,8 +1,16 @@
using System;
using NzbDrone.Common;
using NzbDrone.Common.Messaging; using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.MediaFiles.Commands namespace NzbDrone.Core.MediaFiles.Commands
{ {
public class CleanUpRecycleBinCommand : ICommand public class CleanUpRecycleBinCommand : ICommand
{ {
public String CommandId { get; set; }
public CleanUpRecycleBinCommand()
{
CommandId = HashUtil.GenerateCommandId();
}
} }
} }

@ -1,11 +1,16 @@
using System;
using NzbDrone.Common;
using NzbDrone.Common.Messaging; using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.MediaFiles.Commands namespace NzbDrone.Core.MediaFiles.Commands
{ {
public class DownloadedEpisodesScanCommand : ICommand public class DownloadedEpisodesScanCommand : ICommand
{ {
public String CommandId { get; set; }
public DownloadedEpisodesScanCommand() public DownloadedEpisodesScanCommand()
{ {
CommandId = HashUtil.GenerateCommandId();
} }
} }
} }

@ -1,3 +1,5 @@
using System;
using NzbDrone.Common;
using NzbDrone.Common.Messaging; using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.MediaFiles.Commands namespace NzbDrone.Core.MediaFiles.Commands
@ -7,8 +9,16 @@ namespace NzbDrone.Core.MediaFiles.Commands
public int SeriesId { get; private set; } public int SeriesId { get; private set; }
public int SeasonNumber { get; private set; } public int SeasonNumber { get; private set; }
public String CommandId { get; set; }
public RenameSeasonCommand()
{
CommandId = HashUtil.GenerateCommandId();
}
public RenameSeasonCommand(int seriesId, int seasonNumber) public RenameSeasonCommand(int seriesId, int seasonNumber)
{ {
CommandId = HashUtil.GenerateCommandId();
SeriesId = seriesId; SeriesId = seriesId;
SeasonNumber = seasonNumber; SeasonNumber = seasonNumber;
} }

@ -1,13 +1,22 @@
using System;
using NzbDrone.Common;
using NzbDrone.Common.Messaging; using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.MediaFiles.Commands namespace NzbDrone.Core.MediaFiles.Commands
{ {
public class RenameSeriesCommand : ICommand public class RenameSeriesCommand : ICommand
{ {
public String CommandId { get; set; }
public int SeriesId { get; private set; } public int SeriesId { get; private set; }
public RenameSeriesCommand()
{
CommandId = HashUtil.GenerateCommandId();
}
public RenameSeriesCommand(int seriesId) public RenameSeriesCommand(int seriesId)
{ {
CommandId = HashUtil.GenerateCommandId();
SeriesId = seriesId; SeriesId = seriesId;
} }
} }

@ -1,9 +1,12 @@
using NzbDrone.Common.Messaging; using System;
using NzbDrone.Common;
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.Notifications.Email namespace NzbDrone.Core.Notifications.Email
{ {
public class TestEmailCommand : ICommand public class TestEmailCommand : ICommand
{ {
public String CommandId { get; set; }
public string Server { get; set; } public string Server { get; set; }
public int Port { get; set; } public int Port { get; set; }
public bool Ssl { get; set; } public bool Ssl { get; set; }
@ -11,5 +14,10 @@ namespace NzbDrone.Core.Notifications.Email
public string Password { get; set; } public string Password { get; set; }
public string From { get; set; } public string From { get; set; }
public string To { get; set; } public string To { get; set; }
public TestEmailCommand()
{
CommandId = HashUtil.GenerateCommandId();
}
} }
} }

@ -1,11 +1,19 @@
using NzbDrone.Common.Messaging; using System;
using NzbDrone.Common;
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.Notifications.Growl namespace NzbDrone.Core.Notifications.Growl
{ {
public class TestGrowlCommand : ICommand public class TestGrowlCommand : ICommand
{ {
public String CommandId { get; set; }
public string Host { get; set; } public string Host { get; set; }
public int Port { get; set; } public int Port { get; set; }
public string Password { get; set; } public string Password { get; set; }
public TestGrowlCommand()
{
CommandId = HashUtil.GenerateCommandId();
}
} }
} }

@ -1,12 +1,20 @@
using NzbDrone.Common.Messaging; using System;
using NzbDrone.Common;
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.Notifications.Plex namespace NzbDrone.Core.Notifications.Plex
{ {
public class TestPlexClientCommand : ICommand public class TestPlexClientCommand : ICommand
{ {
public String CommandId { get; set; }
public string Host { get; set; } public string Host { get; set; }
public int Port { get; set; } public int Port { get; set; }
public string Username { get; set; } public string Username { get; set; }
public string Password { get; set; } public string Password { get; set; }
public TestPlexClientCommand()
{
CommandId = HashUtil.GenerateCommandId();
}
} }
} }

@ -1,10 +1,18 @@
using NzbDrone.Common.Messaging; using System;
using NzbDrone.Common;
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.Notifications.Plex namespace NzbDrone.Core.Notifications.Plex
{ {
public class TestPlexServerCommand : ICommand public class TestPlexServerCommand : ICommand
{ {
public String CommandId { get; set; }
public string Host { get; set; } public string Host { get; set; }
public int Port { get; set; } public int Port { get; set; }
public TestPlexServerCommand()
{
CommandId = HashUtil.GenerateCommandId();
}
} }
} }

@ -1,10 +1,18 @@
using NzbDrone.Common.Messaging; using System;
using NzbDrone.Common;
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.Notifications.Prowl namespace NzbDrone.Core.Notifications.Prowl
{ {
public class TestProwlCommand : ICommand public class TestProwlCommand : ICommand
{ {
public String CommandId { get; set; }
public string ApiKey { get; set; } public string ApiKey { get; set; }
public int Priority { get; set; } public int Priority { get; set; }
public TestProwlCommand()
{
CommandId = HashUtil.GenerateCommandId();
}
} }
} }

@ -1,10 +1,18 @@
using NzbDrone.Common.Messaging; using System;
using NzbDrone.Common;
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.Notifications.Pushover namespace NzbDrone.Core.Notifications.Pushover
{ {
public class TestPushoverCommand : ICommand public class TestPushoverCommand : ICommand
{ {
public String CommandId { get; set; }
public string UserKey { get; set; } public string UserKey { get; set; }
public int Priority { get; set; } public int Priority { get; set; }
public TestPushoverCommand()
{
CommandId = HashUtil.GenerateCommandId();
}
} }
} }

@ -1,13 +1,21 @@
using NzbDrone.Common.Messaging; using System;
using NzbDrone.Common;
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.Notifications.Xbmc namespace NzbDrone.Core.Notifications.Xbmc
{ {
public class TestXbmcCommand : ICommand public class TestXbmcCommand : ICommand
{ {
public String CommandId { get; set; }
public string Host { get; set; } public string Host { get; set; }
public int Port { get; set; } public int Port { get; set; }
public string Username { get; set; } public string Username { get; set; }
public string Password { get; set; } public string Password { get; set; }
public int DisplayTime { get; set; } public int DisplayTime { get; set; }
public TestXbmcCommand()
{
CommandId = HashUtil.GenerateCommandId();
}
} }
} }

@ -1,13 +1,18 @@
using NzbDrone.Common.Messaging; using System;
using NzbDrone.Common;
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.Providers namespace NzbDrone.Core.Providers
{ {
public class UpdateXemMappingsCommand : ICommand public class UpdateXemMappingsCommand : ICommand
{ {
public String CommandId { get; set; }
public int? SeriesId { get; private set; } public int? SeriesId { get; private set; }
public UpdateXemMappingsCommand(int? seriesId) public UpdateXemMappingsCommand(int? seriesId)
{ {
CommandId = HashUtil.GenerateCommandId();
SeriesId = seriesId; SeriesId = seriesId;
} }
} }

@ -1,13 +1,23 @@
using NzbDrone.Common.Messaging; using System;
using NzbDrone.Common;
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.Tv.Commands namespace NzbDrone.Core.Tv.Commands
{ {
public class RefreshSeriesCommand : ICommand public class RefreshSeriesCommand : ICommand
{ {
public String CommandId { get; set; }
public int? SeriesId { get; private set; } public int? SeriesId { get; private set; }
public RefreshSeriesCommand()
{
CommandId = HashUtil.GenerateCommandId();
}
public RefreshSeriesCommand(int? seriesId) public RefreshSeriesCommand(int? seriesId)
{ {
CommandId = HashUtil.GenerateCommandId();
SeriesId = seriesId; SeriesId = seriesId;
} }
} }

@ -1,8 +1,16 @@
using NzbDrone.Common.Messaging; using System;
using NzbDrone.Common;
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.Update.Commands namespace NzbDrone.Core.Update.Commands
{ {
public class ApplicationUpdateCommand : ICommand public class ApplicationUpdateCommand : ICommand
{ {
public String CommandId { get; set; }
public ApplicationUpdateCommand()
{
CommandId = HashUtil.GenerateCommandId();
}
} }
} }
Loading…
Cancel
Save