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 { /// /// 发送事件消息 /// 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(); } } }