You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
911 B
C#

using DSWeb.Common.Model;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DSWeb.Common.Helper
{
public static class EventMessageHelper
{
/// <summary>
/// 发送事件消息
/// </summary>
public static void PostMessage(EventMessageType type, JObject para, string redisConfig = "RedisServerAddr")
{
var redis = ConnectionMultiplexer.Connect(ConfigurationManager.AppSettings[redisConfig]);
var paraObj = new
{
type = type.ToString(),
body = para
};
redis.GetSubscriber().PublishAsync("EventMessage", JsonConvert.SerializeObject(paraObj));
redis.Close();
}
}
}