static void Main(string[] args) { SendNotificationsRequest request = CreateSendNotificationsRequest(); // TrackService service = new TrackService(); if (usePropertyFile()) { service.Url = getProperty("endpoint"); } try { // Call the Track web service passing in a TrackNotificationRequest and returning a TrackNotificationReply SendNotificationsReply reply = service.sendNotifications(request); if (reply.HighestSeverity == NotificationSeverityType.SUCCESS || reply.HighestSeverity == NotificationSeverityType.NOTE || reply.HighestSeverity == NotificationSeverityType.WARNING) { ShowSendNotificationsReply(reply); } ShowNotifications(reply); } catch (SoapException e) { Console.WriteLine(e.Detail.InnerText); } catch (Exception e) { Console.WriteLine(e.Message); } Console.WriteLine("Press any key to quit!"); Console.ReadKey(); }
private static void ShowNotifications(SendNotificationsReply reply) { Console.WriteLine("Notifications"); for (int i = 0; i < reply.Notifications.Length; i++) { Notification notification = reply.Notifications[i]; Console.WriteLine("Notification no. {0}", i); Console.WriteLine(" Severity: {0}", notification.Severity); Console.WriteLine(" Code: {0}", notification.Code); Console.WriteLine(" Message: {0}", notification.Message); Console.WriteLine(" Source: {0}", notification.Source); } }
private static void ShowSendNotificationsReply(SendNotificationsReply reply) { Console.WriteLine("SendNotificationsReply details:"); Console.WriteLine(); foreach (TrackNotificationPackage package in reply.Packages) { Console.WriteLine("Tracking Number: {0} ", package.TrackingNumber); Console.WriteLine("Carrier Code: {0} ", package.CarrierCode); if (null != package.ShipDate) { Console.WriteLine("ShipDate: {0}", package.ShipDate.ToShortDateString()); } Console.WriteLine("Destination Address: {0}, {1}", package.Destination.City, package.Destination.StateOrProvinceCode); // if (package.RecipientDetails != null) { foreach (NotificationEventType notificationEventType in package.RecipientDetails) { Console.WriteLine("Recipient Email Notification Event type: {0}", notificationEventType); } } Console.WriteLine("************************************************"); } }