diff --git a/src/DotNetCore.CAP/Infrastructure/CapMessage.cs b/src/DotNetCore.CAP/Infrastructure/CapMessage.cs deleted file mode 100644 index 2059f45..0000000 --- a/src/DotNetCore.CAP/Infrastructure/CapMessage.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; - -namespace DotNetCore.CAP.Infrastructure -{ - /// - /// cap messages store model. - /// - public abstract class CapMessage : MessageBase - { - /// - /// Initializes a new instance of . - /// - /// - /// The Id property is initialized to from a new GUID string value. - /// - protected CapMessage() - { - Id = Guid.NewGuid().ToString(); - Added = DateTime.Now; - } - - protected CapMessage(MessageBase message) - { - KeyName = message.KeyName; - Content = message.Content; - } - - public string Id { get; set; } - - public DateTime Added { get; set; } - - public DateTime LastRun { get; set; } - - public int Retries { get; set; } - - public string StatusName { get; set; } - } - - /// - /// The message status name. - /// - public struct StatusName - { - public const string Enqueued = nameof(Enqueued); - public const string Processing = nameof(Processing); - public const string Succeeded = nameof(Succeeded); - public const string Failed = nameof(Failed); - } -} \ No newline at end of file diff --git a/src/DotNetCore.CAP/Infrastructure/CapReceivedMessage.cs b/src/DotNetCore.CAP/Infrastructure/CapReceivedMessage.cs index a3034af..7ca0525 100644 --- a/src/DotNetCore.CAP/Infrastructure/CapReceivedMessage.cs +++ b/src/DotNetCore.CAP/Infrastructure/CapReceivedMessage.cs @@ -1,14 +1,52 @@ -namespace DotNetCore.CAP.Infrastructure +using System; + +namespace DotNetCore.CAP.Infrastructure { - public class CapReceivedMessage : CapMessage + public class CapReceivedMessage { + /// + /// Initializes a new instance of . + /// + /// + /// The Id property is initialized to from a new GUID string value. + /// public CapReceivedMessage() { + Id = Guid.NewGuid().ToString(); + Added = DateTime.Now; + } + + public CapReceivedMessage(MessageContext message) : this() + { + Group = message.Group; + KeyName = message.KeyName; + Content = message.Content; } - public CapReceivedMessage(MessageBase baseMessage) - : base(baseMessage) + public string Id { get; set; } + + public string Group { get; set; } + + public string KeyName { get; set; } + + public string Content { get; set; } + + public DateTime Added { get; set; } + + public DateTime LastRun { get; set; } + + public int Retries { get; set; } + + public string StatusName { get; set; } + + public MessageContext ToMessageContext() { + return new MessageContext + { + Group = Group, + KeyName = KeyName, + Content = Content + }; } } } \ No newline at end of file diff --git a/src/DotNetCore.CAP/Infrastructure/CapSentMessage.cs b/src/DotNetCore.CAP/Infrastructure/CapSentMessage.cs index cc94c27..c250a48 100644 --- a/src/DotNetCore.CAP/Infrastructure/CapSentMessage.cs +++ b/src/DotNetCore.CAP/Infrastructure/CapSentMessage.cs @@ -1,6 +1,39 @@ -namespace DotNetCore.CAP.Infrastructure +using System; + +namespace DotNetCore.CAP.Infrastructure { - public class CapSentMessage : CapMessage + public class CapSentMessage { + /// + /// Initializes a new instance of . + /// + /// + /// The Id property is initialized to from a new GUID string value. + /// + public CapSentMessage() + { + Id = Guid.NewGuid().ToString(); + Added = DateTime.Now; + } + + public CapSentMessage(MessageContext message) + { + KeyName = message.KeyName; + Content = message.Content; + } + + public string Id { get; set; } + + public string KeyName { get; set; } + + public string Content { get; set; } + + public DateTime Added { get; set; } + + public DateTime LastRun { get; set; } + + public int Retries { get; set; } + + public string StatusName { get; set; } } } \ No newline at end of file diff --git a/src/DotNetCore.CAP/Infrastructure/StatusName.cs b/src/DotNetCore.CAP/Infrastructure/StatusName.cs new file mode 100644 index 0000000..459c17d --- /dev/null +++ b/src/DotNetCore.CAP/Infrastructure/StatusName.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace DotNetCore.CAP.Infrastructure +{ + /// + /// The message status name. + /// + public struct StatusName + { + public const string Enqueued = nameof(Enqueued); + public const string Processing = nameof(Processing); + public const string Succeeded = nameof(Succeeded); + public const string Failed = nameof(Failed); + } +}