annotate Workflow/Client/MainWindow.xaml.cs @ 98:d0c2cac12376

Latest version
author stevenhollidge <stevenhollidge@hotmail.com>
date Sat, 05 May 2012 22:53:40 +0100
parents 3c67e54e3a17
children
rev   line source
89
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1 using System;
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
2 using System.Threading.Tasks;
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
3 using System.Windows;
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
4 using System.Windows.Media.Animation;
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
5 using System.Windows.Threading;
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
6 using Burrow;
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
7 using Burrow.Extras;
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
8 using Client.Controls;
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
9 using Client.Messages;
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
10
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
11 namespace Client
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
12 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
13 public partial class MainWindow
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
14 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
15 private const string QUEUE_CONNECTION_STRING = "host=localhost;username=guest;password=guest";
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
16 private readonly ITunnel tunnel;
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
17 private readonly Subscription subscriptionOrder;
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
18 private readonly Subscription subscriptionPayment;
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
19 private readonly Subscription subscriptionDelivery;
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
20 private readonly Subscription subscriptionError;
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
21 private readonly Guid orderId;
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
22 private const string ORDER_ROUTING_KEY = "Order";
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
23 private const string PAYMENT_ROUTING_KEY = "Payment";
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
24 private const string DELIVERY_ROUTING_KEY = "Delivery";
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
25 private const string ORDER_STORYBOARD_KEY = "OrderStoryboard";
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
26 private const string PAYMENT_STORYBOARD_KEY = "PaymentStoryboard";
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
27 private const string DELIVERY_STORYBOARD_KEY = "DeliveryStoryboard";
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
28 private const string FADEINGIFT_STORYBOARD_KEY = "FadeInGiftStoryboard";
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
29 private readonly Storyboard orderStoryboard;
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
30 private readonly Storyboard paymentStoryboard;
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
31 private readonly Storyboard deliveryStoryboard;
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
32 private readonly Storyboard fadeInGiftStoryboard;
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
33
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
34 public MainWindow()
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
35 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
36 InitializeComponent();
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
37
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
38 // set up rabbitmq tunnel
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
39 tunnel = RabbitTunnel.Factory.Create(QUEUE_CONNECTION_STRING);
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
40 tunnel.SetSerializer(new JsonSerializer());
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
41
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
42 // set up a subscription to each message type
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
43 subscriptionOrder = tunnel.SubscribeAsync<OrderMessage>("Workflow",
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
44 (message, args) => Dispatcher.BeginInvoke(new Action(() => OnOrderReceived(message, args))));
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
45
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
46 subscriptionPayment = tunnel.SubscribeAsync<PaymentMessage>("Workflow",
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
47 (message, args) => Dispatcher.BeginInvoke(new Action(() => OnPaymentReceived(message, args))));
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
48
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
49 subscriptionDelivery = tunnel.SubscribeAsync<DeliveryMessage>("Workflow",
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
50 (message, args) => Dispatcher.BeginInvoke(new Action(() => OnDeliveryReceived(message, args))));
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
51
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
52 //subscriptionError = tunnel.SubscribeAsync<?????>("Workflow",
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
53 // (message, args) => Dispatcher.BeginInvoke(new Action(() => OnErrorReceived(message, args))));
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
54
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
55 // make sure all storyboards are available
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
56 orderStoryboard = (Storyboard)this.TryFindResource(ORDER_STORYBOARD_KEY);
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
57 paymentStoryboard = (Storyboard)this.TryFindResource(PAYMENT_STORYBOARD_KEY);
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
58 deliveryStoryboard = (Storyboard)this.TryFindResource(DELIVERY_STORYBOARD_KEY);
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
59 fadeInGiftStoryboard = (Storyboard)this.TryFindResource(FADEINGIFT_STORYBOARD_KEY);
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
60 if (orderStoryboard == null) throw new ResourceReferenceKeyNotFoundException("Cannot find OrderStoryboard resource", ORDER_STORYBOARD_KEY);
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
61 if (paymentStoryboard == null) throw new ResourceReferenceKeyNotFoundException("Cannot find PaymentStoryboard resource", PAYMENT_STORYBOARD_KEY);
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
62 if (deliveryStoryboard == null) throw new ResourceReferenceKeyNotFoundException("Cannot find DeliveryStoryboard resource", DELIVERY_STORYBOARD_KEY);
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
63 if (fadeInGiftStoryboard == null) throw new ResourceReferenceKeyNotFoundException("Cannot find FadeInGiftStoryboard resource", FADEINGIFT_STORYBOARD_KEY);
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
64
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
65 // create an orderid for the workflow
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
66 orderId = Guid.NewGuid();
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
67 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
68
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
69 private void NotifyUI(UIMessage ctrl, MessageType messageType, string text)
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
70 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
71 Dispatcher.BeginInvoke(new Action(() =>
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
72 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
73 ctrl.MessageType = messageType;
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
74 ctrl.Text = text;
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
75 ctrl.Show();
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
76 }));
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
77 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
78
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
79 #region EventHandlers
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
80
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
81 private void btnSubmit_Click(object sender, RoutedEventArgs e)
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
82 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
83 try
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
84 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
85 orderStoryboard.Begin();
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
86 NotifyUI(NotificationRight, MessageType.Success, "Order submitted");
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
87 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
88 catch (Exception ex)
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
89 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
90 NotifyUI(NotificationRight, MessageType.Error, ex.Message);
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
91 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
92 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
93
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
94 private void OnOrderStoryboardCompleted(object sender, EventArgs e)
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
95 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
96 try
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
97 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
98 tunnel.Publish(new OrderMessage
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
99 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
100 OrderId = orderId,
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
101 OrderDate = DateTime.Now,
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
102 ProductCode = "ABCDE",
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
103 Quantity = 10,
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
104 UnitPrice = 9.99m
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
105 }, ORDER_ROUTING_KEY);
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
106
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
107 NotifyUI(NotificationLeft, MessageType.Success, "Order published");
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
108 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
109 catch (Exception ex)
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
110 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
111 NotifyUI(NotificationRight, MessageType.Error, ex.Message);
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
112 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
113 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
114
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
115 private void OnOrderReceived(OrderMessage order, MessageDeliverEventArgs args)
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
116 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
117 try
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
118 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
119 NotifyUI(NotificationRight, MessageType.Success, "Order received");
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
120 paymentStoryboard.Begin();
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
121 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
122 catch (Exception ex)
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
123 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
124 NotifyUI(NotificationRight, MessageType.Error, ex.Message);
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
125 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
126 finally
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
127 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
128 if (subscriptionOrder != null) subscriptionOrder.Ack(args.DeliveryTag);
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
129 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
130 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
131
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
132 private void OnPaymentStoryboardCompleted(object sender, EventArgs e)
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
133 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
134 try
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
135 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
136 tunnel.Publish(new PaymentMessage()
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
137 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
138 OrderId = orderId,
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
139 IsConfirmed = true
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
140 }, PAYMENT_ROUTING_KEY);
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
141
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
142 NotifyUI(NotificationLeft, MessageType.Success, "Payment published");
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
143 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
144 catch (Exception ex)
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
145 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
146 NotifyUI(NotificationRight, MessageType.Error, ex.Message);
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
147 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
148 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
149
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
150 private void OnPaymentReceived(PaymentMessage payment, MessageDeliverEventArgs args)
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
151 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
152 try
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
153 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
154 NotifyUI(NotificationRight, MessageType.Success, "Payment received");
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
155 deliveryStoryboard.Begin();
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
156 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
157 catch (Exception ex)
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
158 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
159 NotifyUI(NotificationRight, MessageType.Error, ex.Message);
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
160 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
161 finally
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
162 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
163 if (subscriptionPayment != null) subscriptionPayment.Ack(args.DeliveryTag);
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
164 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
165 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
166
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
167 private void OnDeliveryStoryboardCompleted(object sender, EventArgs e)
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
168 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
169 try
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
170 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
171 tunnel.Publish(new DeliveryMessage()
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
172 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
173 OrderId = orderId,
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
174 Address = "123 Some Street, Somewhere"
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
175 }, DELIVERY_ROUTING_KEY);
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
176
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
177 NotifyUI(NotificationLeft, MessageType.Success, "Delivery published");
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
178 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
179 catch (Exception ex)
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
180 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
181 NotifyUI(NotificationRight, MessageType.Error, ex.Message);
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
182 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
183 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
184
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
185 private void OnDeliveryReceived(DeliveryMessage delivery, MessageDeliverEventArgs args)
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
186 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
187 try
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
188 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
189 NotifyUI(NotificationRight, MessageType.Success, "Delivery received");
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
190 fadeInGiftStoryboard.Begin();
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
191 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
192 catch (Exception ex)
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
193 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
194 NotifyUI(NotificationRight, MessageType.Error, ex.Message);
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
195 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
196 finally
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
197 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
198 if (subscriptionDelivery != null) subscriptionDelivery.Ack(args.DeliveryTag);
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
199 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
200 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
201
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
202 #endregion
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
203
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
204 private void Window_Closed(object sender, EventArgs e)
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
205 {
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
206 Application.Current.Shutdown();
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
207 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
208 }
3c67e54e3a17 Working version
stevenhollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
209 }