public ActionResult SendMicrosoftTile(string userId, string message) { if (string.IsNullOrWhiteSpace(message)) { return(this.Json("The notification message cannot be null, empty nor white space.", JsonRequestBehavior.AllowGet)); } var resultList = new List <MessageSendResultLight>(); var pushUserEndpointList = this.pushUserEndpointsRepository.GetPushUsersByName(userId); foreach (var pushUserEndpoint in pushUserEndpointList) { var tile = new TilePushNotificationMessage { SendPriority = MessageSendPriority.High, Count = ++pushUserEndpoint.TileCount }; var messageResult = tile.SendAndHandleErrors(new Uri(pushUserEndpoint.ChannelUri)); resultList.Add(messageResult); if (messageResult.Status.Equals(MessageSendResultLight.Success)) { this.QueueMessage(pushUserEndpoint, message); this.pushUserEndpointsRepository.UpdatePushUserEndpoint(pushUserEndpoint); } } return(this.Json(resultList, JsonRequestBehavior.AllowGet)); }
private void ResetTileNotificationCount(string applicationId, string deviceId) { var pushUserEndpoint = this.pushUserEndpointsRepository.GetPushUserByApplicationAndDevice(applicationId, deviceId); pushUserEndpoint.TileCount = 0; var tile = new TilePushNotificationMessage { SendPriority = MessageSendPriority.High, Count = pushUserEndpoint.TileCount }; // Send a new tile notification message to reset the count in the phone application. tile.SendAndHandleErrors(new Uri(pushUserEndpoint.ChannelUri)); // Save the updated count. this.pushUserEndpointsRepository.UpdatePushUserEndpoint(pushUserEndpoint); }
public ActionResult SendMicrosoftTile(string userId, string message) { if (string.IsNullOrWhiteSpace(message)) { return this.Json("The notification message cannot be null, empty nor white space.", JsonRequestBehavior.AllowGet); } var resultList = new List<MessageSendResultLight>(); var pushUserEndpointList = this.pushUserEndpointsRepository.GetPushUsersByName(userId); foreach (var pushUserEndpoint in pushUserEndpointList) { var tile = new TilePushNotificationMessage { SendPriority = MessageSendPriority.High, Count = ++pushUserEndpoint.TileCount }; var messageResult = tile.SendAndHandleErrors(new Uri(pushUserEndpoint.ChannelUri)); resultList.Add(messageResult); if (messageResult.Status.Equals(MessageSendResultLight.Success)) { this.QueueMessage(pushUserEndpoint, message); this.pushUserEndpointsRepository.UpdatePushUserEndpoint(pushUserEndpoint); } } return this.Json(resultList, JsonRequestBehavior.AllowGet); }
private void ResetTileNotificationCount(Uri channelUri) { var pushUserEndpointList = this.pushUserEndpointsRepository.GetPushUsersByNameAndEndpoint(this.UserId, channelUri); foreach (var pushUserEndpoint in pushUserEndpointList) { pushUserEndpoint.TileCount = 0; var tile = new TilePushNotificationMessage { SendPriority = MessageSendPriority.High, Count = pushUserEndpoint.TileCount }; // Send a new tile notification message to reset the count in the phone application. tile.SendAndHandleErrors(new Uri(pushUserEndpoint.ChannelUri)); // Save the updated count. this.pushUserEndpointsRepository.UpdatePushUserEndpoint(pushUserEndpoint); } }