MessageStatus.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Net;
  6. using WindowsPhone.Recipes.Push.Messasges;
  7. using WindowsPhone.Recipes.Push.Server.Models;
  8. namespace WindowsPhone.Recipes.Push.Server.Models
  9. {
  10. /// <summary>
  11. /// Represents a push notification message send response status.
  12. /// </summary>
  13. public class MessageStatus
  14. {
  15. private static readonly Dictionary<Type, string> MessageTypes = new Dictionary<Type, string>
  16. {
  17. {typeof(TilePushNotificationMessage), "Tile"},
  18. {typeof(ToastPushNotificationMessage), "Toast"},
  19. {typeof(RawPushNotificationMessage), "Raw"}
  20. };
  21. /// <summary>
  22. /// Gets the push notification pattern type.
  23. /// </summary>
  24. public string Pattern { get; private set; }
  25. /// <summary>
  26. /// Gets the response time stamp.
  27. /// </summary>
  28. public DateTimeOffset Timestamp { get; private set; }
  29. /// <summary>
  30. /// Gets the message type.
  31. /// </summary>
  32. public string MessageType { get; private set; }
  33. /// <summary>
  34. /// Gets the message ID.
  35. /// </summary>
  36. public Guid MessageId { get; private set; }
  37. /// <summary>
  38. /// Gets the notification channel URI.
  39. /// </summary>
  40. public Uri ChannelUri { get; private set; }
  41. /// <summary>
  42. /// Gets the response status code.
  43. /// </summary>
  44. public HttpStatusCode StatusCode { get; private set; }
  45. /// <summary>
  46. /// Gets the notification status.
  47. /// </summary>
  48. public NotificationStatus NotificationStatus { get; private set; }
  49. /// <summary>
  50. /// Gets the device connection status.
  51. /// </summary>
  52. public DeviceConnectionStatus DeviceConnectionStatus { get; private set; }
  53. /// <summary>
  54. /// Gets the subscription status.
  55. /// </summary>
  56. public SubscriptionStatus SubscriptionStatus { get; private set; }
  57. /// <summary>
  58. /// Initialize a new instance of this type.
  59. /// </summary>
  60. public MessageStatus(string pattern, MessageSendResult result)
  61. {
  62. Pattern = pattern;
  63. Timestamp = result.Timestamp;
  64. MessageType = MessageTypes[result.AssociatedMessage.GetType()];
  65. MessageId = result.AssociatedMessage.Id;
  66. ChannelUri = result.ChannelUri;
  67. StatusCode = result.StatusCode;
  68. NotificationStatus = result.NotificationStatus;
  69. DeviceConnectionStatus = result.DeviceConnectionStatus;
  70. SubscriptionStatus = result.SubscriptionStatus;
  71. }
  72. /// <summary>
  73. /// Initialize a new instance of this type.
  74. /// </summary>
  75. public MessageStatus(PushPatternType pattern, MessageSendException exception)
  76. {
  77. }
  78. }
  79. }