2011-03-28 21:22:11 +03:00
parent a4c09735f0
commit 00f97e41d6
130 changed files with 13440 additions and 0 deletions
@@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using WindowsPhone.Recipes.Push.Messasges;
using WindowsPhone.Recipes.Push.Server.Models;
namespace WindowsPhone.Recipes.Push.Server.Models
{
/// <summary>
/// Represents a push notification message send response status.
/// </summary>
public class MessageStatus
{
private static readonly Dictionary<Type, string> MessageTypes = new Dictionary<Type, string>
{
{typeof(TilePushNotificationMessage), "Tile"},
{typeof(ToastPushNotificationMessage), "Toast"},
{typeof(RawPushNotificationMessage), "Raw"}
};
/// <summary>
/// Gets the push notification pattern type.
/// </summary>
public string Pattern { get; private set; }
/// <summary>
/// Gets the response time stamp.
/// </summary>
public DateTimeOffset Timestamp { get; private set; }
/// <summary>
/// Gets the message type.
/// </summary>
public string MessageType { get; private set; }
/// <summary>
/// Gets the message ID.
/// </summary>
public Guid MessageId { get; private set; }
/// <summary>
/// Gets the notification channel URI.
/// </summary>
public Uri ChannelUri { get; private set; }
/// <summary>
/// Gets the response status code.
/// </summary>
public HttpStatusCode StatusCode { get; private set; }
/// <summary>
/// Gets the notification status.
/// </summary>
public NotificationStatus NotificationStatus { get; private set; }
/// <summary>
/// Gets the device connection status.
/// </summary>
public DeviceConnectionStatus DeviceConnectionStatus { get; private set; }
/// <summary>
/// Gets the subscription status.
/// </summary>
public SubscriptionStatus SubscriptionStatus { get; private set; }
/// <summary>
/// Initialize a new instance of this type.
/// </summary>
public MessageStatus(string pattern, MessageSendResult result)
{
Pattern = pattern;
Timestamp = result.Timestamp;
MessageType = MessageTypes[result.AssociatedMessage.GetType()];
MessageId = result.AssociatedMessage.Id;
ChannelUri = result.ChannelUri;
StatusCode = result.StatusCode;
NotificationStatus = result.NotificationStatus;
DeviceConnectionStatus = result.DeviceConnectionStatus;
SubscriptionStatus = result.SubscriptionStatus;
}
/// <summary>
/// Initialize a new instance of this type.
/// </summary>
public MessageStatus(PushPatternType pattern, MessageSendException exception)
{
}
}
}
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
namespace WindowsPhone.Recipes.Push.Server.Models
{
/// <summary>
/// Types of server push patterns.
/// </summary>
public enum PushPatternType
{
/// <value>One time server push pattern.</value>
OneTime,
/// <value>Login counter server push pattern.</value>
LoginCounter,
/// <value>Ask to pin server push pattern.</value>
AskToPin,
/// <value>Custom tile image server push pattern.</value>
CustomTileImage,
/// <value>Tile shedule server push pattern.</value>
TileSchedule,
}
}
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
namespace WindowsPhone.Recipes.Push.Server.Models
{
/// <summary>
/// Server status data contract.
/// </summary>
[DataContract]
public class ServerInfo
{
/// <summary>
/// Current push pattern.
/// </summary>
[DataMember]
public string PushPattern { get; set; }
/// <summary>
/// Current tile counter value.
/// </summary>
[DataMember]
public int Counter { get; set; }
}
}
@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security;
namespace WindowsPhone.Recipes.Push.Server.Models
{
/// <summary>
/// Represents user subscription.
/// </summary>
public class Subscription
{
/// <summary>
/// Gets the user name.
/// </summary>
public string UserName { get; private set; }
/// <summary>
/// Gets the notification channel uri.
/// </summary>
public Uri ChannelUri { get; private set; }
/// <summary>
/// Initialize a new instance of this type.
/// </summary>
public Subscription(string userName, Uri channelUri)
{
UserName = userName;
ChannelUri = channelUri;
}
/// <summary>
/// Initialize a new instance of this type.
/// </summary>
public Subscription(string userName, string channelUri)
: this (userName, new Uri(channelUri, UriKind.Absolute))
{
}
}
}