/// <summary>
        /// Send a tile notification to all WP7 devices subscribed to a given subscription.
        /// </summary>
        /// <param name="subId">Id of the subscription to send the message to.</param>
        /// <param name="message">The message text.</param>
        /// <param name="count">Count to show on the tile or the badge.</param>
        /// <param name="image">The image to show on the tile.</param>
        /// <returns>Returns "success" if successful otherwise an error.</returns>
        public string SendTileNotification(string subId, string message, string count, string image)
        {
            // Make sure user is authenticated.
            if (!AuthManager.AuthenticateUser())
            {
                AuthManager.ConstructAuthResponse();
                return null;
            }

            // Make sure subscription name is created.
            bool subExists = this.subscriptionInfoMgr.IsSubscriptionRegistered(subId);
            if (!subExists)
            {
                throw new WebFaultException<string>(Utils.GetErrorString(PushMessageError.ErrorSubscriptionNameNotFound), System.Net.HttpStatusCode.BadRequest);
            }

            // Make sure that the count is an int.
            int countVal;
            bool success = int.TryParse(count, out countVal);
            if (!success)
            {
                throw new WebFaultException<string>(Utils.GetErrorString(PushMessageError.ErrorIllegalCount), System.Net.HttpStatusCode.BadRequest);
            }

            try
            {
                TileMessage tileMsg = new TileMessage(subId, message, count, image);
                this.msgQueue.Enque(tileMsg);
            }
            catch (Exception e)
            {
                Trace.TraceError(string.Format(CultureInfo.InvariantCulture, "Internal Error: SendTile subscription: {0} title: {1}, Error: {2}", subId, message, e.Message));
                throw new WebFaultException<string>(e.Message, System.Net.HttpStatusCode.InternalServerError);
            }

            return "success";
        }
 /// <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;
         }
     }
 }