/// <summary> /// Parses the responce. /// </summary> /// <param name="response">The response.</param> /// <returns></returns> private WpPushResult ParseResponce(HttpResponseMessage response) { var wpStatus = ""; var wpChannelStatus = ""; var wpDeviceConnectionStatus = ""; var messageId = ""; StringBuilder builder = new StringBuilder(); builder.AppendFormat("Responce: {1}, {2}\nFrom: {0}\n", response.RequestMessage.RequestUri, response.StatusCode, response.ReasonPhrase); foreach (var key in response.Headers) { builder.AppendFormat(" {0}: {1}", key.Key, string.Join(";", key.Value)); builder.AppendLine(); switch (key.Key) { case "X-NotificationStatus": wpStatus = key.Value.FirstOrDefault(); break; case "X-SubscriptionStatus": wpChannelStatus = key.Value.FirstOrDefault(); break; case "X-DeviceConnectionStatus": wpDeviceConnectionStatus = key.Value.FirstOrDefault(); break; case "X-MessageID": messageId = key.Value.FirstOrDefault(); break; } } Info(builder.ToString()); var res = new WpPushResult(); WpNotificationStatus notStatus; Enum.TryParse(wpStatus, true, out notStatus); res.NotificationStatus = notStatus; if (!string.IsNullOrEmpty(messageId)) { res.MessageId = Guid.Parse(messageId); } return(res); }
/// <summary> /// Parses the responce. /// </summary> /// <param name="response">The response.</param> /// <returns></returns> private WpPushResult ParseResponce(HttpResponseMessage response) { var wpStatus = ""; var wpChannelStatus = ""; var wpDeviceConnectionStatus = ""; var messageId = ""; StringBuilder builder = new StringBuilder(); builder.AppendFormat("Responce: {1}, {2}\nFrom: {0}\n", response.RequestMessage.RequestUri, response.StatusCode, response.ReasonPhrase); foreach (var key in response.Headers) { builder.AppendFormat(" {0}: {1}", key.Key, string.Join(";", key.Value)); builder.AppendLine(); switch (key.Key) { case "X-NotificationStatus": wpStatus = key.Value.FirstOrDefault(); break; case "X-SubscriptionStatus": wpChannelStatus = key.Value.FirstOrDefault(); break; case "X-DeviceConnectionStatus": wpDeviceConnectionStatus = key.Value.FirstOrDefault(); break; case "X-MessageID": messageId = key.Value.FirstOrDefault(); break; } } Info(builder.ToString()); var res = new WpPushResult(); WpNotificationStatus notStatus; Enum.TryParse(wpStatus, true, out notStatus); res.NotificationStatus = notStatus; if (!string.IsNullOrEmpty(messageId)) res.MessageId = Guid.Parse(messageId); return res; }