Add source code
This commit is contained in:
25
ServiceBus98.sln
Normal file
25
ServiceBus98.sln
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.13.35825.156 d17.13
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceBus98", "ServiceBus98\ServiceBus98.csproj", "{70EC8B33-8F08-4B6D-B386-2C2747AF61F0}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{70EC8B33-8F08-4B6D-B386-2C2747AF61F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{70EC8B33-8F08-4B6D-B386-2C2747AF61F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{70EC8B33-8F08-4B6D-B386-2C2747AF61F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{70EC8B33-8F08-4B6D-B386-2C2747AF61F0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {0D27DA3B-F216-4E9A-AD54-A25935289BA6}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
67
ServiceBus98/App.xaml
Normal file
67
ServiceBus98/App.xaml
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<Application x:Class="ServiceBus98.App"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:ServiceBus98"
|
||||||
|
StartupUri="MainWindow.xaml">
|
||||||
|
<Application.Resources>
|
||||||
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
|
||||||
|
<Style x:Key="FormField" TargetType="{x:Type StackPanel}">
|
||||||
|
<Setter Property="Margin" Value="5" />
|
||||||
|
<Setter Property="Orientation" Value="Horizontal" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style x:Key="Header" TargetType="{x:Type TextBlock}">
|
||||||
|
<Setter Property="Foreground" Value="#008080" />
|
||||||
|
<Setter Property="FontSize" Value="36" />
|
||||||
|
<Setter Property="FontWeight" Value="Bold" />
|
||||||
|
<Setter Property="FontStyle" Value="Italic" />
|
||||||
|
<Setter Property="FontFamily" Value="Comic Sans MS" />
|
||||||
|
<Setter Property="Margin" Value="10" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style TargetType="{x:Type TextBox}">
|
||||||
|
<Setter Property="FontFamily" Value="Tahoma" />
|
||||||
|
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||||
|
<Setter Property="BorderThickness" Value="0" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style TargetType="{x:Type Label}">
|
||||||
|
<Setter Property="Width" Value="120" />
|
||||||
|
<Setter Property="FontFamily" Value="Tahoma" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style TargetType="{x:Type StatusBar}">
|
||||||
|
<Setter Property="Width" Value="640" />
|
||||||
|
<Setter Property="Height" Value="24" />
|
||||||
|
<Setter Property="Background" Value="#C3C3C3" />
|
||||||
|
<Setter Property="FontFamily" Value="Tahoma" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style TargetType="{x:Type Button}">
|
||||||
|
<Setter Property="Background" Value="#008080"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="{x:Type Button}">
|
||||||
|
<Border Background="{TemplateBinding Background}" BorderBrush="Black" BorderThickness="2">
|
||||||
|
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
|
</Border>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter Property="Background" Value="#010081"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsMouseCaptured" Value="True">
|
||||||
|
<Setter Property="Background" Value="#FF0081"/>
|
||||||
|
</Trigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
|
||||||
|
</ResourceDictionary>
|
||||||
|
|
||||||
|
</Application.Resources>
|
||||||
|
</Application>
|
||||||
13
ServiceBus98/App.xaml.cs
Normal file
13
ServiceBus98/App.xaml.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using System.Configuration;
|
||||||
|
using System.Data;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace ServiceBus98;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for App.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class App : Application
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
10
ServiceBus98/AssemblyInfo.cs
Normal file
10
ServiceBus98/AssemblyInfo.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
[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)
|
||||||
|
)]
|
||||||
60
ServiceBus98/MainWindow.xaml
Normal file
60
ServiceBus98/MainWindow.xaml
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<Window x:Class="ServiceBus98.MainWindow"
|
||||||
|
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"
|
||||||
|
xmlns:local="clr-namespace:ServiceBus98"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="Service Bus 98" Height="480" Width="640"
|
||||||
|
Background="#C3C3C3"
|
||||||
|
WindowStartupLocation="CenterScreen"
|
||||||
|
ResizeMode="NoResize"
|
||||||
|
>
|
||||||
|
|
||||||
|
<StackPanel>
|
||||||
|
|
||||||
|
<TextBlock Text="Service Bus 98" Style="{StaticResource Header}">
|
||||||
|
<TextBlock.Effect>
|
||||||
|
<DropShadowEffect ShadowDepth="2" Direction="315" Color="Black" Opacity="1" BlurRadius="0"/>
|
||||||
|
</TextBlock.Effect>
|
||||||
|
</TextBlock>
|
||||||
|
|
||||||
|
<StackPanel Style="{StaticResource FormField}">
|
||||||
|
<Label>Connection String:</Label>
|
||||||
|
<local:TextBox9x Width="490" x:Name="ConnectionString"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<StackPanel Style="{StaticResource FormField}">
|
||||||
|
<Label>Queue Name:</Label>
|
||||||
|
<local:TextBox9x Width="490" x:Name="QueueName"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<StackPanel Style="{StaticResource FormField}">
|
||||||
|
<Label>Content Type:</Label>
|
||||||
|
<local:TextBox9x Width="490" x:Name="ContentType" Text="text/plain"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<StackPanel Style="{StaticResource FormField}">
|
||||||
|
<Label>Message:</Label>
|
||||||
|
<local:MultilineTextBox9x x:Name="Message" Width="490" Height="170" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<Button Margin="124,10,10,10" Foreground="White" BorderThickness="2" BorderBrush="Black" FontFamily="Comic Sans MS" FontSize="16" Width="490" Height="30" x:Name="Send" Click="Send_Click">Send</Button>
|
||||||
|
|
||||||
|
|
||||||
|
<StatusBar Height="40">
|
||||||
|
<DockPanel LastChildFill="True" Width="618" Height="24">
|
||||||
|
<Border DockPanel.Dock="Left" Background="#818181" Width="1" />
|
||||||
|
<Border DockPanel.Dock="Left" Background="#000000" Width="1" />
|
||||||
|
<Border DockPanel.Dock="Top" Background="#818181" Height="1" />
|
||||||
|
<Border DockPanel.Dock="Top" Background="#000000" Height="1" />
|
||||||
|
<Border DockPanel.Dock="Right" Background="#FFFFFF" Width="1" />
|
||||||
|
<Border DockPanel.Dock="Right" Background="#C3C3C3" Width="1" />
|
||||||
|
<Border DockPanel.Dock="Bottom" Background="#FFFFFF" Height="1" />
|
||||||
|
<Border DockPanel.Dock="Bottom" Background="#C3C3C3" Height="1" />
|
||||||
|
<TextBlock Padding="3" x:Name="StatusText">Status: Idle</TextBlock>
|
||||||
|
</DockPanel>
|
||||||
|
|
||||||
|
</StatusBar>
|
||||||
|
</StackPanel>
|
||||||
|
</Window>
|
||||||
75
ServiceBus98/MainWindow.xaml.cs
Normal file
75
ServiceBus98/MainWindow.xaml.cs
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
using System.Windows;
|
||||||
|
using Azure.Messaging.ServiceBus;
|
||||||
|
|
||||||
|
namespace ServiceBus98;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for MainWindow.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class MainWindow : Window
|
||||||
|
{
|
||||||
|
public MainWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void Send_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(ConnectionString.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Enter a connection string.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(QueueName.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Enter a queue name.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(Message.Text))
|
||||||
|
{
|
||||||
|
MessageBoxResult result = MessageBox.Show("You did not enter a message. Do you want to send an empty message?", "Empty Message", MessageBoxButton.YesNo, MessageBoxImage.Question);
|
||||||
|
if (result == MessageBoxResult.Cancel)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
StatusText.Text = "Status: Sending";
|
||||||
|
|
||||||
|
await using ServiceBusClient serviceBusClient = new ServiceBusClient(ConnectionString.Text);
|
||||||
|
await using ServiceBusSender serviceBusSender = serviceBusClient.CreateSender(QueueName.Text);
|
||||||
|
using ServiceBusMessageBatch messageBatch = await serviceBusSender.CreateMessageBatchAsync();
|
||||||
|
|
||||||
|
ServiceBusMessage serviceBusMessage = new ServiceBusMessage(Message.Text ?? string.Empty)
|
||||||
|
{
|
||||||
|
ContentType = ContentType.Text ?? "text/plain"
|
||||||
|
};
|
||||||
|
|
||||||
|
messageBatch.TryAddMessage(serviceBusMessage);
|
||||||
|
|
||||||
|
await serviceBusSender.SendMessagesAsync(messageBatch);
|
||||||
|
|
||||||
|
MessageBox.Show("Message sent successfully.", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
string errorMessage = ex.Message;
|
||||||
|
if (ex is ServiceBusException)
|
||||||
|
{
|
||||||
|
errorMessage = $"Service Bus returned an error. Ensure that the connection string is valid and the queue exists.\n\nAdditional Details:\n{errorMessage}";
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageBox.Show(errorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
StatusText.Text = "Status: Idle";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
19
ServiceBus98/MultilineTextBox9x.xaml
Normal file
19
ServiceBus98/MultilineTextBox9x.xaml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<UserControl x:Class="ServiceBus98.MultilineTextBox9x"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:local="clr-namespace:ServiceBus98"
|
||||||
|
mc:Ignorable="d">
|
||||||
|
<DockPanel LastChildFill="True">
|
||||||
|
<Border DockPanel.Dock="Left" Background="#818181" Width="1" />
|
||||||
|
<Border DockPanel.Dock="Left" Background="#000000" Width="1" />
|
||||||
|
<Border DockPanel.Dock="Top" Background="#818181" Height="1" />
|
||||||
|
<Border DockPanel.Dock="Top" Background="#000000" Height="1" />
|
||||||
|
<Border DockPanel.Dock="Right" Background="#FFFFFF" Width="1" />
|
||||||
|
<Border DockPanel.Dock="Right" Background="#C3C3C3" Width="1" />
|
||||||
|
<Border DockPanel.Dock="Bottom" Background="#FFFFFF" Height="1" />
|
||||||
|
<Border DockPanel.Dock="Bottom" Background="#C3C3C3" Height="1" />
|
||||||
|
<TextBox x:Name="InnerTextBox" VerticalContentAlignment="Top" AcceptsTab="True" AcceptsReturn="True" Padding="0,5,0,0" FontFamily="Lucida Console" />
|
||||||
|
</DockPanel>
|
||||||
|
</UserControl>
|
||||||
34
ServiceBus98/MultilineTextBox9x.xaml.cs
Normal file
34
ServiceBus98/MultilineTextBox9x.xaml.cs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
namespace ServiceBus98
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for MultilineTextBox9x.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class MultilineTextBox9x : UserControl
|
||||||
|
{
|
||||||
|
public MultilineTextBox9x()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Text
|
||||||
|
{
|
||||||
|
get => InnerTextBox.Text;
|
||||||
|
set => InnerTextBox.Text = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
15
ServiceBus98/ServiceBus98.csproj
Normal file
15
ServiceBus98/ServiceBus98.csproj
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<UseWPF>true</UseWPF>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Azure.Messaging.ServiceBus" Version="7.18.4" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
20
ServiceBus98/TextBox9x.xaml
Normal file
20
ServiceBus98/TextBox9x.xaml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<UserControl x:Class="ServiceBus98.TextBox9x"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:local="clr-namespace:ServiceBus98"
|
||||||
|
mc:Ignorable="d">
|
||||||
|
|
||||||
|
<DockPanel LastChildFill="True">
|
||||||
|
<Border DockPanel.Dock="Left" Background="#818181" Width="1" />
|
||||||
|
<Border DockPanel.Dock="Left" Background="#000000" Width="1" />
|
||||||
|
<Border DockPanel.Dock="Top" Background="#818181" Height="1" />
|
||||||
|
<Border DockPanel.Dock="Top" Background="#000000" Height="1" />
|
||||||
|
<Border DockPanel.Dock="Right" Background="#FFFFFF" Width="1" />
|
||||||
|
<Border DockPanel.Dock="Right" Background="#C3C3C3" Width="1" />
|
||||||
|
<Border DockPanel.Dock="Bottom" Background="#FFFFFF" Height="1" />
|
||||||
|
<Border DockPanel.Dock="Bottom" Background="#C3C3C3" Height="1" />
|
||||||
|
<TextBox x:Name="InnerTextBox"/>
|
||||||
|
</DockPanel>
|
||||||
|
</UserControl>
|
||||||
34
ServiceBus98/TextBox9x.xaml.cs
Normal file
34
ServiceBus98/TextBox9x.xaml.cs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
namespace ServiceBus98
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for TextBox9x.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class TextBox9x : UserControl
|
||||||
|
{
|
||||||
|
public TextBox9x()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Text
|
||||||
|
{
|
||||||
|
get => InnerTextBox.Text;
|
||||||
|
set => InnerTextBox.Text = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user