Mercurial > silverbladetech
changeset 89:3c67e54e3a17
Working version
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Workflow/Client/App.xaml Mon Apr 30 10:45:32 2012 +0100 @@ -0,0 +1,14 @@ +<Application x:Class="Client.App" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + StartupUri="MainWindow.xaml"> + <Application.Resources> + <ResourceDictionary> + <ResourceDictionary.MergedDictionaries> + <ResourceDictionary Source="/Elysium.Theme;component/Themes/Generic.xaml" /> + </ResourceDictionary.MergedDictionaries> + <!-- Bug in .Net 4: http://connect.microsoft.com/VisualStudio/feedback/details/555322/global-wpf-styles-are-not-shown-when-using-2-levels-of-references --> + <Style TargetType="{x:Type Window}" /> + </ResourceDictionary> + </Application.Resources> +</Application>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Workflow/Client/App.xaml.cs Mon Apr 30 10:45:32 2012 +0100 @@ -0,0 +1,11 @@ +using System.Windows; + +namespace Client +{ + /// <summary> + /// Interaction logic for App.xaml + /// </summary> + public partial class App : Application + { + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Workflow/Client/Client.csproj Mon Apr 30 10:45:32 2012 +0100 @@ -0,0 +1,150 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">x86</Platform> + <ProductVersion>8.0.30703</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{52DBB55B-5483-4E56-93D3-0D6DEC3FF603}</ProjectGuid> + <OutputType>WinExe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Client</RootNamespace> + <AssemblyName>Client</AssemblyName> + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> + <TargetFrameworkProfile> + </TargetFrameworkProfile> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> + <PlatformTarget>x86</PlatformTarget> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> + <PlatformTarget>x86</PlatformTarget> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="Burrow"> + <HintPath>..\packages\Burrow.NET.1.0.4\lib\net40\Burrow.dll</HintPath> + </Reference> + <Reference Include="Burrow.Extras"> + <HintPath>..\packages\Burrow.Extras.1.0.4\lib\net40\Burrow.Extras.dll</HintPath> + </Reference> + <Reference Include="Elysium.Theme, Version=1.2.257.1, Culture=neutral, PublicKeyToken=774478744bbf1dcc, processorArchitecture=MSIL"> + <HintPath>..\packages\Elysium.Theme.1.3\lib\net40\Elysium.Theme.dll</HintPath> + </Reference> + <Reference Include="Newtonsoft.Json"> + <HintPath>..\packages\Newtonsoft.Json.4.5.4\lib\net40\Newtonsoft.Json.dll</HintPath> + </Reference> + <Reference Include="RabbitMQ.Client, Version=2.8.1.0, Culture=neutral, PublicKeyToken=89e7d7c5feba84ce, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\packages\RabbitMQ.Client.2.8.1\lib\net30\RabbitMQ.Client.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Web.Extensions" /> + <Reference Include="System.Xaml"> + <RequiredTargetFramework>4.0</RequiredTargetFramework> + </Reference> + <Reference Include="WindowsBase" /> + <Reference Include="PresentationCore" /> + <Reference Include="PresentationFramework" /> + </ItemGroup> + <ItemGroup> + <ApplicationDefinition Include="App.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </ApplicationDefinition> + <Compile Include="App.xaml.cs"> + <DependentUpon>App.xaml</DependentUpon> + <SubType>Code</SubType> + </Compile> + </ItemGroup> + <ItemGroup> + <Compile Include="Controls\UIMessage.xaml.cs"> + <DependentUpon>UIMessage.xaml</DependentUpon> + </Compile> + <Compile Include="MainWindow.xaml.cs"> + <DependentUpon>MainWindow.xaml</DependentUpon> + </Compile> + <Compile Include="Messages\DeliveryMessage.cs" /> + <Compile Include="Messages\OrderMessage.cs" /> + <Compile Include="Messages\PaymentMessage.cs" /> + <Compile Include="Properties\AssemblyInfo.cs"> + <SubType>Code</SubType> + </Compile> + <Compile Include="Properties\Resources.Designer.cs"> + <AutoGen>True</AutoGen> + <DesignTime>True</DesignTime> + <DependentUpon>Resources.resx</DependentUpon> + </Compile> + <Compile Include="Properties\Settings.Designer.cs"> + <AutoGen>True</AutoGen> + <DependentUpon>Settings.settings</DependentUpon> + <DesignTimeSharedInput>True</DesignTimeSharedInput> + </Compile> + <EmbeddedResource Include="Properties\Resources.resx"> + <Generator>ResXFileCodeGenerator</Generator> + <LastGenOutput>Resources.Designer.cs</LastGenOutput> + </EmbeddedResource> + <None Include="app.config" /> + <None Include="packages.config" /> + <None Include="Properties\Settings.settings"> + <Generator>SettingsSingleFileGenerator</Generator> + <LastGenOutput>Settings.Designer.cs</LastGenOutput> + </None> + <AppDesigner Include="Properties\" /> + </ItemGroup> + <ItemGroup> + <Page Include="Controls\UIMessage.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> + <Page Include="MainWindow.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\client.ico" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\gift.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\order.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\delivery.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\payment.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\error.png" /> + <Resource Include="Images\info.png" /> + <Resource Include="Images\question.png" /> + <Resource Include="Images\success.png" /> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Workflow/Client/Controls/UIMessage.xaml Mon Apr 30 10:45:32 2012 +0100 @@ -0,0 +1,65 @@ +<UserControl x:Class="Client.Controls.UIMessage" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + x:Name="UIMessageControl" + mc:Ignorable="d"> + <UserControl.Resources> + <SolidColorBrush x:Key="ErrorBrush" Color="#D5BD3630" /> + <SolidColorBrush x:Key="InfoBrush" Color="#D759ABC3" /> + <SolidColorBrush x:Key="SuccessBrush" Color="#E151A351" /> + <SolidColorBrush x:Key="QuestionBrush" Color="#DCF9A938" /> + <BitmapImage x:Key="ErrorImage" UriSource="../Images/error.png" /> + <BitmapImage x:Key="InfoImage" UriSource="../Images/info.png" /> + <BitmapImage x:Key="SuccessImage" UriSource="../Images/success.png" /> + <BitmapImage x:Key="QuestionImage" UriSource="../Images/question.png" /> + <Storyboard x:Key="FadeIn"> + <DoubleAnimation BeginTime="0" + Duration="00:00:02" + From="0" + Storyboard.TargetName="Display" + Storyboard.TargetProperty="Opacity" + To="1" /> + </Storyboard> + <Storyboard x:Key="FadeOut"> + <DoubleAnimation BeginTime="00:00:01" + Duration="00:00:02" + From="1" + Storyboard.TargetName="Display" + Storyboard.TargetProperty="Opacity" + To="0" /> + </Storyboard> + </UserControl.Resources> + <Grid x:Name="LayoutRoot" Background="White"> + + <Border x:Name="Display" + Width="200" + Height="70" + Background="Pink" + CornerRadius="5" + Opacity="0"> + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="60" /> + <ColumnDefinition Width="*" /> + </Grid.ColumnDefinitions> + + <Image x:Name="Icon" + Grid.Row="0" + Grid.Column="0" + Width="30" + Height="30" + HorizontalAlignment="Center" + VerticalAlignment="Center" + Stretch="Uniform" /> + <TextBlock Grid.Column="1" + VerticalAlignment="Center" + Foreground="White" + Text="{Binding Path=Text, + ElementName=UIMessageControl, + UpdateSourceTrigger=PropertyChanged}" /> + </Grid> + </Border> + </Grid> +</UserControl>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Workflow/Client/Controls/UIMessage.xaml.cs Mon Apr 30 10:45:32 2012 +0100 @@ -0,0 +1,161 @@ +using System; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; +using System.Windows.Media.Animation; +using System.Windows.Media.Imaging; + +namespace Client.Controls +{ + public enum MessageType + { + NotSet = 0, + Error, + Info, + Success, + Question + } + + public partial class UIMessage : UserControl + { + #region Fields + + private SolidColorBrush _errorBrush; + private SolidColorBrush _infoBrush; + private SolidColorBrush _successBrush; + private SolidColorBrush _questionBrush; + + private BitmapImage _errorImage; + private BitmapImage _infoImage; + private BitmapImage _successImage; + private BitmapImage _questionImage; + + private Storyboard _fadeInStoryboard; + private Storyboard _fadeOutStoryboard; + + #endregion + + #region Constructor + + public UIMessage() + { + InitializeComponent(); + CheckResourcesAreAvailable(); + + _fadeInStoryboard.Completed += (sender, args) => _fadeOutStoryboard.Begin(); + } + + #endregion + + #region Dependency Properties: MessageType, Text + + public static readonly DependencyProperty TypeProperty = + DependencyProperty.Register("MessageType", + typeof(MessageType), + typeof(UIMessage), + new PropertyMetadata(MessageType.NotSet, TypePropertyChanged)); + + private static void TypePropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) + { + var uiMessage = (UIMessage)dependencyObject; + uiMessage.Display.SetValue(Border.BackgroundProperty, uiMessage.GetBrush(uiMessage.MessageType)); + uiMessage.Icon.SetValue(Image.SourceProperty, uiMessage.GetImage(uiMessage.MessageType)); + } + + public MessageType MessageType + { + get { return (MessageType)GetValue(TypeProperty); } + set { SetValue(TypeProperty, value); } + } + + public static readonly DependencyProperty TextProperty = + DependencyProperty.Register("Text", + typeof(string), + typeof(UIMessage), + new PropertyMetadata(default(string))); + + public string Text + { + get { return (string)GetValue(TextProperty); } + set { SetValue(TextProperty, value); } + } + + #endregion + + #region Methods + + private void CheckResourcesAreAvailable() + { + _errorBrush = (SolidColorBrush)this.Resources["ErrorBrush"]; + _infoBrush = (SolidColorBrush)this.Resources["InfoBrush"]; + _successBrush = (SolidColorBrush)this.Resources["SuccessBrush"]; + _questionBrush = (SolidColorBrush)this.Resources["QuestionBrush"]; + _errorImage = (BitmapImage)this.Resources["ErrorImage"]; + _infoImage = (BitmapImage)this.Resources["InfoImage"]; + _successImage = (BitmapImage)this.Resources["SuccessImage"]; + _questionImage = (BitmapImage)this.Resources["QuestionImage"]; + _fadeInStoryboard = (Storyboard)this.Resources["FadeIn"]; + _fadeOutStoryboard = (Storyboard)this.Resources["FadeOut"]; + + if (_errorBrush == null) throw new Exception("Missing ErrorBrush resource"); + if (_infoBrush == null) throw new Exception("Missing InfoBrush resource"); + if (_successBrush == null) throw new Exception("Missing SuccessBrush resource"); + if (_questionBrush == null) throw new Exception("Missing QuestionBrush resource"); + if (_errorImage == null) throw new Exception("Missing BitmapImage ErrorImage resource"); + if (_infoImage == null) throw new Exception("Missing BitmapImage InfoImage resource"); + if (_successImage == null) throw new Exception("Missing BitmapImage SuccessImage resource"); + if (_questionImage == null) throw new Exception("Missing BitmapImage QuestionImage resource"); + if (_fadeInStoryboard == null) throw new Exception("Missing Storyboard FadeIn resource"); + if (_fadeOutStoryboard == null) throw new Exception("Missing Storyboard FadeOut resource"); + } + + private SolidColorBrush GetBrush(MessageType type) + { + SolidColorBrush brush = null; + switch (type) + { + case MessageType.Info: + brush = _infoBrush; + break; + case MessageType.Error: + brush = _errorBrush; + break; + case MessageType.Success: + brush = _successBrush; + break; + case MessageType.Question: + brush = _questionBrush; + break; + } + return brush; + } + + private BitmapImage GetImage(MessageType type) + { + BitmapImage image = null; + switch (type) + { + case MessageType.Info: + image = _infoImage; + break; + case MessageType.Error: + image = _errorImage; + break; + case MessageType.Success: + image = _successImage; + break; + case MessageType.Question: + image = _questionImage; + break; + } + return image; + } + + public void Show() + { + _fadeInStoryboard.Begin(); + } + + #endregion + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Workflow/Client/MainWindow.xaml Mon Apr 30 10:45:32 2012 +0100 @@ -0,0 +1,111 @@ +<metro:Window x:Class="Client.MainWindow" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:Controls="clr-namespace:Client.Controls" + xmlns:metro="http://schemas.codeplex.com/elysium/theme" + Title="Messaging Client" + Width="550" + Height="625" + MinWidth="450" + MinHeight="625" + Closed="Window_Closed" + Icon="Images\client.ico"> + + <Window.Resources> + <Storyboard x:Key="OrderStoryboard" Completed="OnOrderStoryboardCompleted"> + <DoubleAnimation x:Name="moveOrder" + Duration="00:00:05" + From="0" + Storyboard.TargetName="imageOrder" + Storyboard.TargetProperty="(Canvas.Left)" + To="440" /> + </Storyboard> + <Storyboard x:Key="PaymentStoryboard" Completed="OnPaymentStoryboardCompleted"> + <DoubleAnimation x:Name="movePayment" + Duration="00:00:05" + From="0" + Storyboard.TargetName="imagePayment" + Storyboard.TargetProperty="(Canvas.Left)" + To="440" /> + </Storyboard> + <Storyboard x:Key="DeliveryStoryboard" Completed="OnDeliveryStoryboardCompleted"> + <DoubleAnimation x:Name="moveDelivery" + Duration="00:00:05" + From="0" + Storyboard.TargetName="imageDelivery" + Storyboard.TargetProperty="(Canvas.Left)" + To="440" /> + </Storyboard> + <Storyboard x:Key="FadeInGiftStoryboard"> + <DoubleAnimation Duration="00:00:02" + From="0" + Storyboard.TargetName="imageGift" + Storyboard.TargetProperty="Opacity" + To="1" /> + </Storyboard> + </Window.Resources> + + <TabControl> + <TabItem Header="place order"> + <Grid HorizontalAlignment="Center"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="200" /> + <ColumnDefinition Width="100" /> + <ColumnDefinition Width="200" /> + </Grid.ColumnDefinitions> + <Grid.RowDefinitions> + <RowDefinition Height="300" /> + <RowDefinition Height="150" /> + <RowDefinition Height="75" /> + </Grid.RowDefinitions> + + <Canvas Grid.Row="0" + Grid.Column="0" + Grid.ColumnSpan="3"> + + <Image x:Name="imageOrder" + Canvas.Left="0" + Canvas.Top="20" + Height="60" + HorizontalAlignment="Left" + Source="Images\order.png" /> + + <Image x:Name="imagePayment" + Canvas.Left="0" + Canvas.Top="120" + Height="60" + HorizontalAlignment="Left" + Source="Images\payment.png" /> + + <Image x:Name="imageDelivery" + Canvas.Left="0" + Canvas.Top="220" + Height="60" + HorizontalAlignment="Left" + Source="Images\delivery.png" /> + </Canvas> + + <Image x:Name="imageGift" + Grid.Row="1" + Grid.Column="1" + Opacity="0" + Source="Images\gift.png" /> + + <Controls:UIMessage x:Name="NotificationLeft" + Grid.Row="2" + Grid.Column="0" /> + + <Button Name="btnSubmit" + Grid.Row="2" + Grid.Column="1" + Margin="10" + Click="btnSubmit_Click" + Content="Submit" /> + + <Controls:UIMessage x:Name="NotificationRight" + Grid.Row="2" + Grid.Column="2" /> + </Grid> + </TabItem> + </TabControl> +</metro:Window>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Workflow/Client/MainWindow.xaml.cs Mon Apr 30 10:45:32 2012 +0100 @@ -0,0 +1,209 @@ +using System; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Media.Animation; +using System.Windows.Threading; +using Burrow; +using Burrow.Extras; +using Client.Controls; +using Client.Messages; + +namespace Client +{ + public partial class MainWindow + { + private const string QUEUE_CONNECTION_STRING = "host=localhost;username=guest;password=guest"; + private readonly ITunnel tunnel; + private readonly Subscription subscriptionOrder; + private readonly Subscription subscriptionPayment; + private readonly Subscription subscriptionDelivery; + private readonly Subscription subscriptionError; + private readonly Guid orderId; + private const string ORDER_ROUTING_KEY = "Order"; + private const string PAYMENT_ROUTING_KEY = "Payment"; + private const string DELIVERY_ROUTING_KEY = "Delivery"; + private const string ORDER_STORYBOARD_KEY = "OrderStoryboard"; + private const string PAYMENT_STORYBOARD_KEY = "PaymentStoryboard"; + private const string DELIVERY_STORYBOARD_KEY = "DeliveryStoryboard"; + private const string FADEINGIFT_STORYBOARD_KEY = "FadeInGiftStoryboard"; + private readonly Storyboard orderStoryboard; + private readonly Storyboard paymentStoryboard; + private readonly Storyboard deliveryStoryboard; + private readonly Storyboard fadeInGiftStoryboard; + + public MainWindow() + { + InitializeComponent(); + + // set up rabbitmq tunnel + tunnel = RabbitTunnel.Factory.Create(QUEUE_CONNECTION_STRING); + tunnel.SetSerializer(new JsonSerializer()); + + // set up a subscription to each message type + subscriptionOrder = tunnel.SubscribeAsync<OrderMessage>("Workflow", + (message, args) => Dispatcher.BeginInvoke(new Action(() => OnOrderReceived(message, args)))); + + subscriptionPayment = tunnel.SubscribeAsync<PaymentMessage>("Workflow", + (message, args) => Dispatcher.BeginInvoke(new Action(() => OnPaymentReceived(message, args)))); + + subscriptionDelivery = tunnel.SubscribeAsync<DeliveryMessage>("Workflow", + (message, args) => Dispatcher.BeginInvoke(new Action(() => OnDeliveryReceived(message, args)))); + + //subscriptionError = tunnel.SubscribeAsync<?????>("Workflow", + // (message, args) => Dispatcher.BeginInvoke(new Action(() => OnErrorReceived(message, args)))); + + // make sure all storyboards are available + orderStoryboard = (Storyboard)this.TryFindResource(ORDER_STORYBOARD_KEY); + paymentStoryboard = (Storyboard)this.TryFindResource(PAYMENT_STORYBOARD_KEY); + deliveryStoryboard = (Storyboard)this.TryFindResource(DELIVERY_STORYBOARD_KEY); + fadeInGiftStoryboard = (Storyboard)this.TryFindResource(FADEINGIFT_STORYBOARD_KEY); + if (orderStoryboard == null) throw new ResourceReferenceKeyNotFoundException("Cannot find OrderStoryboard resource", ORDER_STORYBOARD_KEY); + if (paymentStoryboard == null) throw new ResourceReferenceKeyNotFoundException("Cannot find PaymentStoryboard resource", PAYMENT_STORYBOARD_KEY); + if (deliveryStoryboard == null) throw new ResourceReferenceKeyNotFoundException("Cannot find DeliveryStoryboard resource", DELIVERY_STORYBOARD_KEY); + if (fadeInGiftStoryboard == null) throw new ResourceReferenceKeyNotFoundException("Cannot find FadeInGiftStoryboard resource", FADEINGIFT_STORYBOARD_KEY); + + // create an orderid for the workflow + orderId = Guid.NewGuid(); + } + + private void NotifyUI(UIMessage ctrl, MessageType messageType, string text) + { + Dispatcher.BeginInvoke(new Action(() => + { + ctrl.MessageType = messageType; + ctrl.Text = text; + ctrl.Show(); + })); + } + + #region EventHandlers + + private void btnSubmit_Click(object sender, RoutedEventArgs e) + { + try + { + orderStoryboard.Begin(); + NotifyUI(NotificationRight, MessageType.Success, "Order submitted"); + } + catch (Exception ex) + { + NotifyUI(NotificationRight, MessageType.Error, ex.Message); + } + } + + private void OnOrderStoryboardCompleted(object sender, EventArgs e) + { + try + { + tunnel.Publish(new OrderMessage + { + OrderId = orderId, + OrderDate = DateTime.Now, + ProductCode = "ABCDE", + Quantity = 10, + UnitPrice = 9.99m + }, ORDER_ROUTING_KEY); + + NotifyUI(NotificationLeft, MessageType.Success, "Order published"); + } + catch (Exception ex) + { + NotifyUI(NotificationRight, MessageType.Error, ex.Message); + } + } + + private void OnOrderReceived(OrderMessage order, MessageDeliverEventArgs args) + { + try + { + NotifyUI(NotificationRight, MessageType.Success, "Order received"); + paymentStoryboard.Begin(); + } + catch (Exception ex) + { + NotifyUI(NotificationRight, MessageType.Error, ex.Message); + } + finally + { + if (subscriptionOrder != null) subscriptionOrder.Ack(args.DeliveryTag); + } + } + + private void OnPaymentStoryboardCompleted(object sender, EventArgs e) + { + try + { + tunnel.Publish(new PaymentMessage() + { + OrderId = orderId, + IsConfirmed = true + }, PAYMENT_ROUTING_KEY); + + NotifyUI(NotificationLeft, MessageType.Success, "Payment published"); + } + catch (Exception ex) + { + NotifyUI(NotificationRight, MessageType.Error, ex.Message); + } + } + + private void OnPaymentReceived(PaymentMessage payment, MessageDeliverEventArgs args) + { + try + { + NotifyUI(NotificationRight, MessageType.Success, "Payment received"); + deliveryStoryboard.Begin(); + } + catch (Exception ex) + { + NotifyUI(NotificationRight, MessageType.Error, ex.Message); + } + finally + { + if (subscriptionPayment != null) subscriptionPayment.Ack(args.DeliveryTag); + } + } + + private void OnDeliveryStoryboardCompleted(object sender, EventArgs e) + { + try + { + tunnel.Publish(new DeliveryMessage() + { + OrderId = orderId, + Address = "123 Some Street, Somewhere" + }, DELIVERY_ROUTING_KEY); + + NotifyUI(NotificationLeft, MessageType.Success, "Delivery published"); + } + catch (Exception ex) + { + NotifyUI(NotificationRight, MessageType.Error, ex.Message); + } + } + + private void OnDeliveryReceived(DeliveryMessage delivery, MessageDeliverEventArgs args) + { + try + { + NotifyUI(NotificationRight, MessageType.Success, "Delivery received"); + fadeInGiftStoryboard.Begin(); + } + catch (Exception ex) + { + NotifyUI(NotificationRight, MessageType.Error, ex.Message); + } + finally + { + if (subscriptionDelivery != null) subscriptionDelivery.Ack(args.DeliveryTag); + } + } + + #endregion + + private void Window_Closed(object sender, EventArgs e) + { + Application.Current.Shutdown(); + } + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Workflow/Client/Messages/DeliveryMessage.cs Mon Apr 30 10:45:32 2012 +0100 @@ -0,0 +1,11 @@ +using System; + +namespace Client.Messages +{ + [Serializable] + public class DeliveryMessage + { + public Guid OrderId { get; set; } + public string Address { get; set; } + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Workflow/Client/Messages/OrderMessage.cs Mon Apr 30 10:45:32 2012 +0100 @@ -0,0 +1,14 @@ +using System; + +namespace Client.Messages +{ + [Serializable] + public class OrderMessage + { + public Guid OrderId { get; set; } + public DateTime OrderDate { get; set; } + public int Quantity { get; set; } + public string ProductCode { get; set; } + public decimal UnitPrice { get; set; } + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Workflow/Client/Messages/PaymentMessage.cs Mon Apr 30 10:45:32 2012 +0100 @@ -0,0 +1,11 @@ +using System; + +namespace Client.Messages +{ + [Serializable] + public class PaymentMessage + { + public Guid OrderId { get; set; } + public bool IsConfirmed { get; set; } + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Workflow/Client/Properties/AssemblyInfo.cs Mon Apr 30 10:45:32 2012 +0100 @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Client")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Client")] +[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file +//inside a <PropertyGroup>. For example, if you are using US english +//in your source files, set the <UICulture> to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")]
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Workflow/Client/Properties/Resources.Designer.cs Mon Apr 30 10:45:32 2012 +0100 @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:4.0.30319.17379 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace Client.Properties { + using System; + + + /// <summary> + /// A strongly-typed resource class, for looking up localized strings, etc. + /// </summary> + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// <summary> + /// Returns the cached ResourceManager instance used by this class. + /// </summary> + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Client.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// <summary> + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// </summary> + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Workflow/Client/Properties/Resources.resx Mon Apr 30 10:45:32 2012 +0100 @@ -0,0 +1,117 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Workflow/Client/Properties/Settings.Designer.cs Mon Apr 30 10:45:32 2012 +0100 @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:4.0.30319.17379 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace Client.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Workflow/Client/Properties/Settings.settings Mon Apr 30 10:45:32 2012 +0100 @@ -0,0 +1,7 @@ +<?xml version='1.0' encoding='utf-8'?> +<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)"> + <Profiles> + <Profile Name="(Default)" /> + </Profiles> + <Settings /> +</SettingsFile> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Workflow/Client/app.config Mon Apr 30 10:45:32 2012 +0100 @@ -0,0 +1,11 @@ +<?xml version="1.0"?> +<configuration> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="RabbitMQ.Client" publicKeyToken="89e7d7c5feba84ce" culture="neutral"/> + <bindingRedirect oldVersion="0.0.0.0-2.8.1.0" newVersion="2.8.1.0"/> + </dependentAssembly> + </assemblyBinding> + </runtime> +<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Workflow/Client/packages.config Mon Apr 30 10:45:32 2012 +0100 @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="Burrow.Extras" version="1.0.4" /> + <package id="Burrow.NET" version="1.0.4" /> + <package id="Elysium.Theme" version="1.3" /> + <package id="Newtonsoft.Json" version="4.5.4" /> + <package id="RabbitMQ.Client" version="2.8.1" /> +</packages> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Workflow/Workflow.sln Mon Apr 30 10:45:32 2012 +0100 @@ -0,0 +1,30 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "Client\Client.csproj", "{52DBB55B-5483-4E56-93D3-0D6DEC3FF603}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {52DBB55B-5483-4E56-93D3-0D6DEC3FF603}.Debug|Any CPU.ActiveCfg = Debug|x86 + {52DBB55B-5483-4E56-93D3-0D6DEC3FF603}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {52DBB55B-5483-4E56-93D3-0D6DEC3FF603}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {52DBB55B-5483-4E56-93D3-0D6DEC3FF603}.Debug|x86.ActiveCfg = Debug|x86 + {52DBB55B-5483-4E56-93D3-0D6DEC3FF603}.Debug|x86.Build.0 = Debug|x86 + {52DBB55B-5483-4E56-93D3-0D6DEC3FF603}.Release|Any CPU.ActiveCfg = Release|x86 + {52DBB55B-5483-4E56-93D3-0D6DEC3FF603}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {52DBB55B-5483-4E56-93D3-0D6DEC3FF603}.Release|Mixed Platforms.Build.0 = Release|x86 + {52DBB55B-5483-4E56-93D3-0D6DEC3FF603}.Release|x86.ActiveCfg = Release|x86 + {52DBB55B-5483-4E56-93D3-0D6DEC3FF603}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal