public void Process(PushModel model) { if (model == null) { throw new ArgumentNullException("PushModel"); } this.sourceType = model.SourceType; this.userId = model.PositionModel?.UserId ?? 0; this.messageType = model.PushMessageType; this.messageModel = model.MessageModel; this.positionModel = model.PositionModel; if (this.userId <= 0) { throw new ArgumentNullException("UserId"); } if (this.positionModel == null) { throw new ArgumentNullException("PushPositionModel"); } this.CheckMessageModel(); this.AddNearCircle(); }
private NotificationData CreateMessage(JObject eventoObject, PushMessageType messageType) { return(new NotificationData( eventoObject.Value <Guid>("EventId"), eventoObject.Value <string>("EventName"), eventoObject.Value <Guid>("InitiatorId"), eventoObject.Value <string>("InitiatorName"), messageType)); }
/// <summary> /// 设置发送的json /// </summary> /// <param name="openid"></param> /// <param name="type"></param> /// <param name="dic"></param> /// <returns></returns> private static string SetPushMessageJosn(string openid, PushMessageType type, Dictionary <string, string> dic) { string json = "{{" + "\"touser\":\"" + openid + "\"," + "\"msgtype\":\"" + type.ToString() + "\"," + "\"" + type.ToString() + "\":" + "{{{0}}}" + "}}"; int len = dic.Count; StringBuilder pars = new StringBuilder(); foreach (KeyValuePair <string, string> a in dic) { pars.AppendFormat("\"{0}\":\"{1}\",", a.Key, a.Value); } pars.Remove(pars.Length - 1, 1); switch (type) { case PushMessageType.news: { json = string.Format(json, "\"articles\": [{" + pars + "}]"); } break; default: json = string.Format(json, pars); break; } return(json); }
public NotificationData(Guid eventId, string eventName, Guid initiatorId, string initiatorName, PushMessageType messageType) { this.EventId = eventId; this.EventName = eventName; this.InitiatorId = initiatorId; this.InitiatorName = initiatorName; this.MessageType = messageType; }
public void PushOrdersInfo(object objectToSend, PushMessageType messageType) { using (var ms = new MemoryStream()) { var messageToSend = new NetMQMessage(2); messageToSend.Append(BitConverter.GetBytes((byte)messageType)); messageToSend.Append(MyUtils.ProtoBufSerialize(objectToSend, ms)); pushSocket.SendMultipartMessage(messageToSend); } }
/// <summary> /// Initializes a new instance of the NotificationFormatException class. /// </summary> /// This is needed for ISerializable interface /// <param name="serializationInfo">SerializationInfo provides the class where the class is serialized.</param> /// <param name="streamingContext">Additional StreamingContext class.</param> protected NotificationFormatException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { if (serializationInfo != null) { PushMessageType messageType = (PushMessageType)serializationInfo.GetInt16("MessageType"); string subscriptionName = serializationInfo.GetString("SubscriptionName"); if ((PushMessageType)this.NotificationMessage.MessageType == PushMessageType.Raw) { string rawMessageText = serializationInfo.GetString("rawMessageText"); RawMessage rawMessage = new RawMessage(subscriptionName, rawMessageText); this.NotificationMessage = rawMessage; } else if ((PushMessageType)this.NotificationMessage.MessageType == PushMessageType.Toast) { string tileMessageText = serializationInfo.GetString("toastMessageText"); ToastMessage toastMessage = new ToastMessage(subscriptionName, tileMessageText); this.NotificationMessage = toastMessage; } else if ((PushMessageType)this.NotificationMessage.MessageType == PushMessageType.Tile) { string tileMessageTitle = serializationInfo.GetString("tileMessageTitle"); string tileMessageCount = serializationInfo.GetString("tileMessageCount"); string tileMessageUrl = serializationInfo.GetString("tileMessageUrl"); TileMessage tileMessage = new TileMessage(subscriptionName, tileMessageTitle, tileMessageCount, tileMessageUrl); this.NotificationMessage = tileMessage; } else if ((PushMessageType)this.NotificationMessage.MessageType == PushMessageType.Iphone) { string messageAlert = serializationInfo.GetString("iPhoneMessageAlert"); string messageBadge = serializationInfo.GetString("iPhoneMessageBadge"); string messageSound = serializationInfo.GetString("iPhoneMessageSound"); iPhoneMessage iphoneMessage = new iPhoneMessage(subscriptionName, messageAlert, messageBadge, messageSound); this.NotificationMessage = iphoneMessage; } else if ((PushMessageType)this.NotificationMessage.MessageType == PushMessageType.Common) { string messageTitle = serializationInfo.GetString("commmonMessageTitle"); int messageCount = serializationInfo.GetInt32("commonMessageCount"); string messageImage = serializationInfo.GetString("commonMessageImage"); string messageSound = serializationInfo.GetString("commonMessageSound"); CommonMessage commonMessage = new CommonMessage(subscriptionName, messageTitle, messageCount, messageImage, messageSound); this.NotificationMessage = commonMessage; } } }
public void Process(PushModel model) { if (model == null) { throw new ArgumentNullException("PushModel"); } this.sourceType = model.SourceType; this.userId = model.PositionModel?.UserId ?? 0; this.messageType = model.PushMessageType; this.messageModel = model.MessageModel; if (this.userId <= 0) { throw new ArgumentNullException("UserId"); } this.CheckMessageModel(); //save to db for current user id }
/// <summary> /// Provides the messages this connection handles. /// </summary> /// <param name="messageType">The message type to be evaluated.</param> /// <returns>Returns true if the MpnsConnection handles the specific message type, false otherwise.</returns> public override bool HandlesMessageType(PushMessageType messageType) { switch (messageType) { case PushMessageType.Iphone: return(false); case PushMessageType.Common: return(true); case PushMessageType.Raw: return(true); case PushMessageType.Tile: return(true); case PushMessageType.Toast: return(true); default: return(false); } }
/// <summary> /// Provides the messages this connection handles. /// </summary> /// <param name="messageType">The message type to be evaluated.</param> /// <returns>Returns true if the MpnsConnection handles the specific message type, false otherwise.</returns> public override bool HandlesMessageType(PushMessageType messageType) { switch (messageType) { case PushMessageType.Iphone: return true; case PushMessageType.Common: return true; case PushMessageType.Raw: return true; case PushMessageType.Tile: return false; case PushMessageType.Toast: return true; default: return false; } }
/// <summary> /// 初始化 <see cref="PushMessage"/> 类的新实例。 /// </summary> /// <param name="type">消息类型。</param> protected PushMessage(PushMessageType type) { // 设置消息类型。 this._type = type; }
public PushQueue(string connectionString, PushMessageType pushMessageType) { _connectionString = connectionString; _pushMessageType = pushMessageType; }
/// <summary> /// This method returns if the connection class supports the message type. /// </summary> /// <param name="messageType">Check if the specific message type is supported.</param> /// <returns>Returns true of this message type is supported. False otherwise.</returns> public abstract bool HandlesMessageType(PushMessageType messageType);
public PushQueueReciever(string connectionString, int instanceKey, IConnectionManager connectionManager, PushMessageType pushMessageType, ILogger logger) { _pushMessageType = pushMessageType; _connectionManager = connectionManager; _queue = RabbitQueue.CreateReciever(connectionString, "pushqueue", $"{instanceKey}", OnRecieve); }
public static void Initialize(SqlServerDBContext context) { // Look for any students. if (context.PushTopics.Any()) { //If database is over return no data. return; // DB has been seeded } var _pushTopics = new PushTopics[] { new PushTopics { TopicFilters = "Lead", Actived = true, TimeAfterToSend = new TimeSpan(00, 00, 30) }, new PushTopics { TopicFilters = "Activity", Actived = true, TimeAfterToSend = new TimeSpan(00, 00, 30) }, new PushTopics { TopicFilters = "ActionCRM", Actived = true, TimeAfterToSend = new TimeSpan(00, 00, 30) }, new PushTopics { TopicFilters = "Other", Actived = true, TimeAfterToSend = new TimeSpan(00, 00, 30) }, }; foreach (PushTopics e in _pushTopics) { context.PushTopics.Add(e); } context.SaveChanges(); var _pushMessageTypes = new PushMessageType[] { new PushMessageType { Name = "Tile", Description = "Tile Message" }, new PushMessageType { Name = "Toast", Description = "Toast Message" }, new PushMessageType { Name = "Push", Description = "Push Message" }, new PushMessageType { Name = "Normal", Description = "Normal Message" }, new PushMessageType { Name = "Lead", Description = "Lead Message" } }; foreach (PushMessageType e in _pushMessageTypes) { context.PushMessageType.Add(e); } context.SaveChanges(); var _pushMessageUrgencys = new PushMessageUrgency[] { new PushMessageUrgency { Name = "Very Low", Description = "Battery full max power" }, new PushMessageUrgency { Name = "Low", Description = "Battery semi full" }, new PushMessageUrgency { Name = "Normal", Description = "Battery normal" }, new PushMessageUrgency { Name = "Medium", Description = "Battery medium no power full" }, new PushMessageUrgency { Name = "High", Description = "Battery low no power" } }; foreach (PushMessageUrgency e in _pushMessageUrgencys) { context.PushMessageUrgency.Add(e); } context.SaveChanges(); var _pushSubscriptionUsers = new PushSubscriptionUser[] { new PushSubscriptionUser { UserId = "Max", Endpoint = "http://fcm.google.com/sjfasfjfjaf", P256DH = "alfalsfasfklsflafll", Auth = "falflafafaklflasfafla", CreatedTime = DateTime.UtcNow }, new PushSubscriptionUser { UserId = "4022", Endpoint = "http://fcm.google.com/sjfasfjfjaf", P256DH = "alfalsfasfklsflafll", Auth = "falflafafaklflasfafla", CreatedTime = DateTime.UtcNow }, new PushSubscriptionUser { UserId = "4023", Endpoint = "http://fcm.google.com/sjfasfjfjaf", P256DH = "alfalsfasfklsflafll", Auth = "falflafafaklflasfafla", CreatedTime = DateTime.UtcNow }, new PushSubscriptionUser { UserId = "4024", Endpoint = "http://fcm.google.com/sjfasfjfjaf", P256DH = "alfalsfasfklsflafll", Auth = "falflafafaklflasfafla", CreatedTime = DateTime.UtcNow } }; foreach (PushSubscriptionUser c in _pushSubscriptionUsers) { context.PushSubscriptionUser.Add(c); } context.SaveChanges(); var _pushSubscriptionTopics = new PushSubscriptionTopic[] { new PushSubscriptionTopic { Topic = _pushTopics[0], Subscription = _pushSubscriptionUsers[0] }, new PushSubscriptionTopic { Topic = _pushTopics[0], Subscription = _pushSubscriptionUsers[1] }, new PushSubscriptionTopic { Topic = _pushTopics[1], Subscription = _pushSubscriptionUsers[1] }, new PushSubscriptionTopic { Topic = _pushTopics[2], Subscription = _pushSubscriptionUsers[0] } }; foreach (PushSubscriptionTopic s in _pushSubscriptionTopics) { context.PushSubscriptionTopic.Add(s); } context.SaveChanges(); var _pushUsers = new PushNotificationUser[] { new PushNotificationUser { UserId = "4022", SubscriptionId = 2, NotificationMessage = "{message: ''}", CreatedTime = DateTime.Now }, new PushNotificationUser { UserId = "4022", SubscriptionId = 2, NotificationMessage = "{message: ''}", CreatedTime = DateTime.Now }, new PushNotificationUser { UserId = "Max", SubscriptionId = 1, NotificationMessage = "{message: ''}", CreatedTime = DateTime.Now }, new PushNotificationUser { UserId = "Max", SubscriptionId = 1, NotificationMessage = "{message: ''}", CreatedTime = DateTime.Now }, new PushNotificationUser { UserId = "4023", SubscriptionId = 3, NotificationMessage = "{message: ''}", CreatedTime = DateTime.Now }, new PushNotificationUser { UserId = "4024", SubscriptionId = 4, NotificationMessage = "{message: ''}", CreatedTime = DateTime.Now }, }; foreach (PushNotificationUser e in _pushUsers) { context.PushNotificationUser.Add(e); } context.SaveChanges(); }
public PushSentMessage(string message, PushMessageType pushMessageType) { Message = message; Messagetype = pushMessageType.ToString(); }