void ParseStatus(HttpWebResponse resp, BISNotification notification, ref BISMessageStatus status, ref string desc) { status = new BISMessageStatus { Notification = notification, HttpStatus = HttpStatusCode.ServiceUnavailable }; var bbNotStatus = string.Empty; if (resp != null) { status.HttpStatus = resp.StatusCode; using (var responseStream = resp.GetResponseStream()) { var doc = XDocument.Load(responseStream); var result = doc.Descendants("response-result").SingleOrDefault(); if (result != null) { bbNotStatus = result.Attribute("code").Value; desc = result.Attribute("desc").Value; } else { result = doc.Descendants("badmessage-response").SingleOrDefault(); if (result != null) { bbNotStatus = result.Attribute("code").Value; desc = result.Attribute("desc").Value; } } } } BISNotificationStatus notStatus; Enum.TryParse(bbNotStatus, true, out notStatus); status.NotificationStatus = notStatus; }
void HandleStatus(SendNotificationCallbackDelegate callback, BISMessageStatus status, string desc, BISNotification notification = null) { if (status.NotificationStatus == BISNotificationStatus.NoAppReceivePush) { if (callback != null) { callback(this, new SendNotificationResult(notification, false, new Exception("Device Subscription Expired")) { IsSubscriptionExpired = true }); } return; } if (status.HttpStatus == HttpStatusCode.OK && status.NotificationStatus == BISNotificationStatus.RequestAcceptedForProcessing) { if (callback != null) { callback(this, new SendNotificationResult(notification)); } return; } if (callback != null) { callback(this, new SendNotificationResult(status.Notification, false, new BISNotificationSendFailureException(status, desc))); } }