diff --git a/src/DotNetCore.CAP/IStorage.cs b/src/DotNetCore.CAP/IStorage.cs index ea5726d..4e6dfb4 100644 --- a/src/DotNetCore.CAP/IStorage.cs +++ b/src/DotNetCore.CAP/IStorage.cs @@ -1,5 +1,6 @@ using System.Threading; using System.Threading.Tasks; +using DotNetCore.CAP.Dashboard; namespace DotNetCore.CAP { @@ -12,5 +13,9 @@ namespace DotNetCore.CAP /// Initializes the storage. For example, making sure a database is created and migrations are applied. /// Task InitializeAsync(CancellationToken cancellationToken); + + IMonitoringApi GetMonitoringApi(); + + IStorageConnection GetConnection(); } } \ No newline at end of file diff --git a/src/DotNetCore.CAP/IStorageConnection.cs b/src/DotNetCore.CAP/IStorageConnection.cs index 33b022b..f89b265 100644 --- a/src/DotNetCore.CAP/IStorageConnection.cs +++ b/src/DotNetCore.CAP/IStorageConnection.cs @@ -63,5 +63,15 @@ namespace DotNetCore.CAP /// Creates and returns an . /// IStorageTransaction CreateTransaction(); + + + //------------------------------------------- + long GetSetCount(string key); + + List GetRangeFromSet(string key, int startingFrom, int endingAt); + + MessageData GetJobData( string jobId); + + StateData GetStateData(string jobId); } } \ No newline at end of file diff --git a/src/DotNetCore.CAP/Infrastructure/Helper.cs b/src/DotNetCore.CAP/Infrastructure/Helper.cs index 1f349d5..bbf804d 100644 --- a/src/DotNetCore.CAP/Infrastructure/Helper.cs +++ b/src/DotNetCore.CAP/Infrastructure/Helper.cs @@ -1,5 +1,6 @@ using System; using System.ComponentModel; +using System.Globalization; using System.Reflection; using Newtonsoft.Json; @@ -49,6 +50,22 @@ namespace DotNetCore.CAP.Infrastructure return Epoch.AddSeconds(value); } + public static string SerializeDateTime(DateTime value) + { + return value.ToString("o", CultureInfo.InvariantCulture); + } + + public static DateTime DeserializeDateTime(string value) + { + long timestamp; + if (long.TryParse(value, out timestamp)) + { + return FromTimestamp(timestamp); + } + + return DateTime.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind); + } + public static bool IsController(TypeInfo typeInfo) { if (!typeInfo.IsClass)