Commit 6541e1aa authored by yangxiaodong's avatar yangxiaodong

add helper methods.

parent 6a1b5441
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using DotNetCore.CAP.Dashboard;
namespace DotNetCore.CAP namespace DotNetCore.CAP
{ {
...@@ -12,5 +13,9 @@ 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. /// Initializes the storage. For example, making sure a database is created and migrations are applied.
/// </summary> /// </summary>
Task InitializeAsync(CancellationToken cancellationToken); Task InitializeAsync(CancellationToken cancellationToken);
IMonitoringApi GetMonitoringApi();
IStorageConnection GetConnection();
} }
} }
\ No newline at end of file
...@@ -63,5 +63,15 @@ namespace DotNetCore.CAP ...@@ -63,5 +63,15 @@ namespace DotNetCore.CAP
/// Creates and returns an <see cref="IStorageTransaction"/>. /// Creates and returns an <see cref="IStorageTransaction"/>.
/// </summary> /// </summary>
IStorageTransaction CreateTransaction(); IStorageTransaction CreateTransaction();
//-------------------------------------------
long GetSetCount(string key);
List<string> GetRangeFromSet(string key, int startingFrom, int endingAt);
MessageData GetJobData( string jobId);
StateData GetStateData(string jobId);
} }
} }
\ No newline at end of file
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Globalization;
using System.Reflection; using System.Reflection;
using Newtonsoft.Json; using Newtonsoft.Json;
...@@ -49,6 +50,22 @@ namespace DotNetCore.CAP.Infrastructure ...@@ -49,6 +50,22 @@ namespace DotNetCore.CAP.Infrastructure
return Epoch.AddSeconds(value); 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) public static bool IsController(TypeInfo typeInfo)
{ {
if (!typeInfo.IsClass) if (!typeInfo.IsClass)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment