Finalize the Client with real Random Value Generator throug Bogus dependency and Dropdown Bacterialist

This commit is contained in:
Ivan Hörler 2018-07-14 15:43:59 +02:00
parent a9defbad51
commit 7f82d99616
7 changed files with 168 additions and 66 deletions

View File

@ -37,6 +37,9 @@
<Reference Include="AutoMapper, Version=7.0.1.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL"> <Reference Include="AutoMapper, Version=7.0.1.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
<HintPath>..\packages\AutoMapper.7.0.1\lib\net45\AutoMapper.dll</HintPath> <HintPath>..\packages\AutoMapper.7.0.1\lib\net45\AutoMapper.dll</HintPath>
</Reference> </Reference>
<Reference Include="Bogus, Version=22.3.1.0, Culture=neutral, PublicKeyToken=fa1bb3f3f218129a, processorArchitecture=MSIL">
<HintPath>..\packages\Bogus.22.3.1\lib\net40\Bogus.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Runtime.Serialization" /> <Reference Include="System.Runtime.Serialization" />
@ -80,6 +83,7 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</ApplicationDefinition> </ApplicationDefinition>
<Compile Include="Models\Testdata.cs" />
<Compile Include="Models\AutomapperProfile.cs" /> <Compile Include="Models\AutomapperProfile.cs" />
<Compile Include="Models\Exam.cs" /> <Compile Include="Models\Exam.cs" />
<Compile Include="Models\Origin.cs" /> <Compile Include="Models\Origin.cs" />

View File

@ -46,10 +46,9 @@
<Button x:Name="ButtonAutogenerateOne" Content="Auto One" Margin="1.4,1,1.2,1" Background="White" Grid.Column="5" Grid.Row="14" VerticalContentAlignment="Center" RenderTransformOrigin="0.501,0.5" Click="ButtonAutogenerateOne_Click"/> <Button x:Name="ButtonAutogenerateOne" Content="Auto One" Margin="1.4,1,1.2,1" Background="White" Grid.Column="5" Grid.Row="14" VerticalContentAlignment="Center" RenderTransformOrigin="0.501,0.5" Click="ButtonAutogenerateOne_Click"/>
<Button x:Name="ButtonAutogenerateMany" Content="Many" Margin="0.8,1,1.2,1" Background="White" Grid.Column="6" Grid.Row="14" VerticalContentAlignment="Center" Click="ButtonAutogenerateMany_Click"/> <Button x:Name="ButtonAutogenerateMany" Content="Many" Margin="0.8,1,1.2,1" Background="White" Grid.Column="6" Grid.Row="14" VerticalContentAlignment="Center" Click="ButtonAutogenerateMany_Click"/>
<Button x:Name="ButtonSend" Content="Senden" Margin="1.2,1,0.8,1" Click="ButtonSend_Click" Background="White" Grid.Column="8" Grid.Row="14" VerticalContentAlignment="Center"/> <Button x:Name="ButtonSend" Content="Senden" Margin="1.2,1,0.8,1" Click="ButtonSend_Click" Background="White" Grid.Column="8" Grid.Row="14" VerticalContentAlignment="Center"/>
<Button x:Name="ButtonOnline" Content="" Margin="1,1,1,1" Click="ButtonOnline_Click" Background="{x:Null}" Grid.Column="8" Grid.Row="0" VerticalContentAlignment="Center" BorderBrush="{x:Null}"/>
<Label x:Name="LabelRueckmeldung" Content="Rückmeldung:" Margin="1,1.2,0.6,2" Grid.Column="4" Grid.Row="13" VerticalContentAlignment="Center"/> <Label x:Name="LabelRueckmeldung" Content="Rückmeldung:" Margin="1,1.2,0.6,2" Grid.Column="4" Grid.Row="13" VerticalContentAlignment="Center"/>
<Label x:Name="LabelRueckmeldungsfeld" Content="" Margin="1.4,1.2,9.6,2" Grid.ColumnSpan="5" Grid.Column="5" Grid.Row="13" VerticalContentAlignment="Center"/> <Label x:Name="LabelRueckmeldungsfeld" Content="" Margin="1.4,1.2,9.6,2" Grid.ColumnSpan="5" Grid.Column="5" Grid.Row="13" VerticalContentAlignment="Center"/>
<Label x:Name="LabelRueckmeldungsOnline" Content="" Margin="1.2,1,0.8,0.8" Grid.ColumnSpan="1" Grid.Column="8" Grid.Row="0" VerticalContentAlignment="Center"/>
<ComboBox Grid.Column="5" HorizontalAlignment="Left" Grid.Row="12" VerticalAlignment="Top" Width="148" Height="22" Margin="0.4,0.2,0,0" Grid.ColumnSpan="2"/>
<Label x:Name="LabelPatientId" Content="" Margin="1" Grid.Row="8" VerticalContentAlignment="Center" Grid.Column="1" FontSize="6" Foreground="Gray"/> <Label x:Name="LabelPatientId" Content="" Margin="1" Grid.Row="8" VerticalContentAlignment="Center" Grid.Column="1" FontSize="6" Foreground="Gray"/>
<Label x:Name="LabelArztId" Content="" Margin="1" Grid.Row="2" VerticalContentAlignment="Center" Grid.Column="1" FontSize="6" Foreground="Gray"/> <Label x:Name="LabelArztId" Content="" Margin="1" Grid.Row="2" VerticalContentAlignment="Center" Grid.Column="1" FontSize="6" Foreground="Gray"/>
<Label x:Name="LabelBakterienstamm" Content="" Margin="0.8,0.6,58.8,1.4" Grid.Row="2" VerticalContentAlignment="Center" Grid.Column="7" FontSize="6" Foreground="Gray"/> <Label x:Name="LabelBakterienstamm" Content="" Margin="0.8,0.6,58.8,1.4" Grid.Row="2" VerticalContentAlignment="Center" Grid.Column="7" FontSize="6" Foreground="Gray"/>
@ -155,13 +154,13 @@
</StackPanel> </StackPanel>
</xctk:WatermarkTextBox.Watermark> </xctk:WatermarkTextBox.Watermark>
</xctk:WatermarkTextBox> </xctk:WatermarkTextBox>
<xctk:WatermarkTextBox x:Name="TextboxBakterienstamm" Margin="1.4,0.6,0.2,1.4" Padding="3,1" Grid.Column="5" Grid.Row="2" VerticalContentAlignment="Center" Grid.ColumnSpan="2"> <xctk:WatermarkComboBox IsEditable="True" IsTextSearchEnabled="True" x:Name="ComboBoxBakterienstamm" Margin="1,1,1,1" Padding="3,1" Grid.Column="5" Grid.Row="2" VerticalContentAlignment="Center" Grid.ColumnSpan="2">
<xctk:WatermarkTextBox.Watermark> <xctk:WatermarkComboBox.Watermark>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Text="Bakterienstamm" Margin="2,0,0,0" /> <TextBlock Text="Bakterienstamm" Margin="2,0,0,0" />
</StackPanel> </StackPanel>
</xctk:WatermarkTextBox.Watermark> </xctk:WatermarkComboBox.Watermark>
</xctk:WatermarkTextBox> </xctk:WatermarkComboBox>
<xctk:WatermarkTextBox x:Name="TextboxNahrung1Restaurant" Margin="1.4,0.6,0.2,1.4" Padding="3,1" Grid.Column="5" Grid.Row="3" VerticalContentAlignment="Center" Grid.ColumnSpan="2"> <xctk:WatermarkTextBox x:Name="TextboxNahrung1Restaurant" Margin="1.4,0.6,0.2,1.4" Padding="3,1" Grid.Column="5" Grid.Row="3" VerticalContentAlignment="Center" Grid.ColumnSpan="2">
<xctk:WatermarkTextBox.Watermark> <xctk:WatermarkTextBox.Watermark>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
@ -302,5 +301,6 @@
</StackPanel> </StackPanel>
</xctk:WatermarkTextBox.Watermark> </xctk:WatermarkTextBox.Watermark>
</xctk:WatermarkTextBox> </xctk:WatermarkTextBox>
</Grid> </Grid>
</Window> </Window>

View File

@ -24,22 +24,17 @@ namespace Client
/// </summary> /// </summary>
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
// Start Automapper // Start Automapper
Mapper.Initialize(cfg => cfg.AddProfile<AutomapperProfile>()); Mapper.Initialize(cfg => cfg.AddProfile<AutomapperProfile>());
// loading of dropdowns // loading of dropdowns
try ComboBoxBakterienstamm.ItemsSource = Global.GlobalInstance.Service.GetResults();
{ ComboBoxBakterienstamm.DisplayMemberPath = "Name";
string con = Global.GlobalInstance.Service.Ping(); // check if Server(ping) answers throug a invoke of ButtonOnline_Click
if (con == "pong") { LabelRueckmeldungsOnline.Content = "online"; } ButtonOnline.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
}
catch (Exception)
{
LabelRueckmeldungsOnline.Content = "offline";
LabelRueckmeldungsOnline.Foreground = Brushes.Red;
}
} }
@ -73,7 +68,7 @@ namespace Client
); );
Result newResult = new Result(TextboxBakterienstamm.Text); Result newResult = new Result(ComboBoxBakterienstamm.Text);
LabelRueckmeldungsfeld.Content += "erstelle Doktor, "; LabelRueckmeldungsfeld.Content += "erstelle Doktor, ";
newDoctor.CreateDoctor(); newDoctor.CreateDoctor();
@ -171,7 +166,7 @@ namespace Client
TextboxPatientOrt.Clear(); TextboxPatientOrt.Clear();
TextboxPatientRegion.Clear(); TextboxPatientRegion.Clear();
TextboxPatientGeburtstag.Clear(); TextboxPatientGeburtstag.Clear();
TextboxBakterienstamm.Clear(); ComboBoxBakterienstamm.Items.Clear();
TextboxNahrung1Restaurant.Clear(); TextboxNahrung1Restaurant.Clear();
TextboxNahrung1Essen.Clear(); TextboxNahrung1Essen.Clear();
TextboxNahrung1Strasse.Clear(); TextboxNahrung1Strasse.Clear();
@ -195,49 +190,77 @@ namespace Client
} }
private void ButtonAutogenerateOne_Click(object sender, RoutedEventArgs e) private void ButtonAutogenerateOne_Click(object sender, RoutedEventArgs e)
{ {
TextboxArztName.Text = new Bogus.DataSets.Name("de_CH").LastName();
TextboxArztName.Text = "doctorLastname"; TextboxArztVorname.Text = new Bogus.DataSets.Name("de_CH").FirstName();
TextboxArztVorname.Text = "doctorFirstname"; TextboxArztStrasseNr.Text = new Bogus.DataSets.Address("de_CH").StreetName();
TextboxArztStrasseNr.Text = "doctorStreet"; TextboxArztPlz.Text = new Bogus.DataSets.Address("de_CH").ZipCode();
TextboxArztPlz.Text = "1000"; TextboxArztOrt.Text = new Bogus.DataSets.Address("de_CH").City();
TextboxArztOrt.Text = "doctorCity"; TextboxArztKantonsarzt.Text = Testdata.RandomEnumValue<Testdata.Doctortyp>().ToString();
TextboxArztKantonsarzt.Text = "doctorOrigin"; TextboxArztRegion.Text = new Bogus.DataSets.Address("de_CH").State();
TextboxArztRegion.Text = "ArztRegion"; TextboxPatientName.Text = new Bogus.DataSets.Name("de_CH").LastName();
TextboxPatientName.Text = "patientLastname"; TextboxPatientVorname.Text = new Bogus.DataSets.Name("de_CH").FirstName();
TextboxPatientVorname.Text = "patientFirstname"; TextboxPatientStrasseNr.Text = new Bogus.DataSets.Address("de_CH").StreetName();
TextboxPatientStrasseNr.Text = "patientStreet"; TextboxPatientPlz.Text = new Bogus.DataSets.Address("de_CH").ZipCode();
TextboxPatientPlz.Text = "2000"; TextboxPatientOrt.Text = new Bogus.DataSets.Address("de_CH").City();
TextboxPatientOrt.Text = "patientCity"; TextboxPatientRegion.Text = new Bogus.DataSets.Address("de_CH").State();
TextboxPatientRegion.Text = "patientRegion"; TextboxPatientGeburtstag.Text = new Bogus.DataSets.Date().Past().ToString();
TextboxPatientGeburtstag.Text = "1.1.2001"; ComboBoxBakterienstamm.Text = "bacteriaName";
TextboxBakterienstamm.Text = "bacteriaName"; TextboxNahrung1Restaurant.Text = Testdata.RandomEnumValue<Testdata.RestaurantPre>().ToString() +
TextboxNahrung1Restaurant.Text = "firstRestaurantName"; " " + Testdata.RandomEnumValue<Testdata.RestaurantName>().ToString();
TextboxNahrung1Essen.Text = "firstRestaurantFood"; TextboxNahrung1Essen.Text = Testdata.RandomEnumValue<Testdata.Vegie>().ToString() +
TextboxNahrung1Strasse.Text = "firstRestaurantStreet"; " " + Testdata.RandomEnumValue<Testdata.Vegie>().ToString();
TextboxNahrung1Plz.Text = "1111"; TextboxNahrung1Strasse.Text = new Bogus.DataSets.Address("de_CH").StreetName();
TextboxNahrung1Ort.Text = "firstRestaurantCity"; TextboxNahrung1Plz.Text = new Bogus.DataSets.Address("de_CH").ZipCode();
TextboxNahrung2Restaurant.Text = "secondRestaurantName"; TextboxNahrung1Ort.Text = new Bogus.DataSets.Address("de_CH").City();
TextboxNahrung2Essen.Text = "secondRestaurantFood"; TextboxNahrung2Restaurant.Text = Testdata.RandomEnumValue<Testdata.RestaurantPre>().ToString() +
TextboxNahrung2Strasse.Text = "secondRestaurantStreet"; " " + Testdata.RandomEnumValue<Testdata.RestaurantName>().ToString();
TextboxNahrung2Plz.Text = "2222"; TextboxNahrung2Essen.Text = Testdata.RandomEnumValue<Testdata.Vegie>().ToString() +
TextboxNahrung2Ort.Text = "secondRestaurantCity"; " " + Testdata.RandomEnumValue<Testdata.Vegie>().ToString();
TextboxNahrung3Restaurant.Text = "thirdRestaurantName"; TextboxNahrung1Strasse.Text = new Bogus.DataSets.Address("de_CH").StreetName();
TextboxNahrung3Essen.Text = "thirdRestaurantFood"; TextboxNahrung2Plz.Text = new Bogus.DataSets.Address("de_CH").ZipCode();
TextboxNahrung3Strasse.Text = "thirdRestaurantStreet"; TextboxNahrung2Ort.Text = new Bogus.DataSets.Address("de_CH").City();
TextboxNahrung3Plz.Text = "3333"; TextboxNahrung3Restaurant.Text = Testdata.RandomEnumValue<Testdata.RestaurantPre>().ToString() +
TextboxNahrung3Ort.Text = "thirdRestaurantCity"; " " + Testdata.RandomEnumValue<Testdata.RestaurantName>().ToString();
TextboxNahrung4Restaurant.Text = "fourthRestaurantName"; TextboxNahrung3Essen.Text = Testdata.RandomEnumValue<Testdata.Vegie>().ToString() +
TextboxNahrung4Essen.Text = "fourthRestaurantFood"; " " + Testdata.RandomEnumValue<Testdata.Vegie>().ToString();
TextboxNahrung4Strasse.Text = "fourthRestaurantStreet"; TextboxNahrung3Strasse.Text = new Bogus.DataSets.Address("de_CH").StreetName();
TextboxNahrung4Plz.Text = "4444"; TextboxNahrung3Plz.Text = new Bogus.DataSets.Address("de_CH").ZipCode();
TextboxNahrung4Ort.Text = "fourthRestaurantCity"; TextboxNahrung3Ort.Text = new Bogus.DataSets.Address("de_CH").City();
TextboxNahrung4Restaurant.Text = Testdata.RandomEnumValue<Testdata.RestaurantPre>().ToString() +
" " + Testdata.RandomEnumValue<Testdata.RestaurantName>().ToString();
TextboxNahrung4Essen.Text = Testdata.RandomEnumValue<Testdata.Vegie>().ToString() +
" " + Testdata.RandomEnumValue<Testdata.Vegie>().ToString();
TextboxNahrung4Strasse.Text = new Bogus.DataSets.Address("de_CH").StreetName();
TextboxNahrung4Plz.Text = new Bogus.DataSets.Address("de_CH").ZipCode();
TextboxNahrung4Ort.Text = new Bogus.DataSets.Address("de_CH").City();
} }
private void ButtonAutogenerateMany_Click(object sender, RoutedEventArgs e) private void ButtonAutogenerateMany_Click(object sender, RoutedEventArgs e)
{ {
} }
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
private void ButtonOnline_Click(object sender, RoutedEventArgs e)
{
try
{
string con = Global.GlobalInstance.Service.Ping();
if (con == "pong")
{
ButtonOnline.Content = "online";
ButtonOnline.Foreground = Brushes.Green;
}
}
catch (Exception)
{
ButtonOnline.Content = "offline";
ButtonOnline.Foreground = Brushes.Red;
}
}
} }

View File

@ -13,7 +13,7 @@ namespace Client
public string FirstName { get; set; } public string FirstName { get; set; }
public string LastName { get; set; } public string LastName { get; set; }
public string Strasse { get; set; } public string Strasse { get; set; }
public int Plz { get; set; } public string Plz { get; set; }
public string Ort { get; set; } public string Ort { get; set; }
public string Region { get; set; } public string Region { get; set; }
public string DoctorOrigin { get; set; } public string DoctorOrigin { get; set; }
@ -37,7 +37,7 @@ namespace Client
FirstName = firstName; FirstName = firstName;
LastName = lastName; LastName = lastName;
Strasse = strasse; Strasse = strasse;
Plz = Convert.ToInt32(plz); Plz = plz;
Ort = ort; Ort = ort;
Region = region; Region = region;
DoctorOrigin = doctype; DoctorOrigin = doctype;

View File

@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Bogus;
namespace Client
{
class Testdata
{
public static T RandomEnumValue<T>()
{
var v = Enum.GetValues(typeof(T));
return (T)v.GetValue(new Random(DateTime.Now.Millisecond).Next(v.Length));
}
public enum Doctortyp
{
Kantonsarzt,
Regionalarzt,
BAGArzt
}
public enum RestaurantPre
{
None,
Zum,
Auf,
Im,
Goldenen,
Silbrigen,
Panorama,
Warmen,
Schönen,
}
public enum RestaurantName
{
Schützen,
Hirschen,
Ochsen,
Frohsinn,
Hüftgold,
Seerose,
Rosengarten,
Schäferstube,
Tramdepot,
Braui,
Taverne,
Schiff,
Bellavista,
Quellenhof,
Volkshaus,
Panorama
}
public enum Vegie
{
Gurken,
Salat,
Rüben,
Karrotten,
Spinat,
Okra,
Bohnen,
Sprossen,
Tomaten,
Chabis,
Kartoffeln,
Spargeln,
Pilze,
Radieschen,
Mais
}
//var doctor = new Faker<Doctor>()
// .RuleFor(d => d.FirstName, f => f.Name.FirstName())
// .RuleFor(d => d.LastName, f => f.Name.LastName())
// .RuleFor(d => d.Strasse, f => f.Address.StreetName())
// .RuleFor(d => d.Plz, f => f.Address.ZipCode())
// .RuleFor(d => d.Ort, f => f.Address.City())
// .RuleFor(d => d.Region, f => f.Address.State())
// .RuleFor(d => d.DoctorOrigin, f => f.PickRandom<Doctortyp>())
// ;
//.RuleFor(d => d.
}
}

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="AutoMapper" version="7.0.1" targetFramework="net461" /> <package id="AutoMapper" version="7.0.1" targetFramework="net461" />
<package id="Bogus" version="22.3.1" targetFramework="net461" />
<package id="Extended.Wpf.Toolkit" version="3.3.0" targetFramework="net461" /> <package id="Extended.Wpf.Toolkit" version="3.3.0" targetFramework="net461" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net461" /> <package id="System.ValueTuple" version="4.5.0" targetFramework="net461" />
</packages> </packages>

View File

@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15 # Visual Studio 15
VisualStudioVersion = 15.0.27428.2027 VisualStudioVersion = 15.0.27428.2027
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "..\Client\Client\Client.csproj", "{7467FD6B-4743-4436-A87B-095EA46C476F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EHEC_Server", "EHEC_Server\EHEC_Server.csproj", "{611B075A-0526-4661-BD58-B141BD42E6D7}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EHEC_Server", "EHEC_Server\EHEC_Server.csproj", "{611B075A-0526-4661-BD58-B141BD42E6D7}"
EndProject EndProject
Global Global
@ -15,14 +13,6 @@ Global
Release|x86 = Release|x86 Release|x86 = Release|x86
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7467FD6B-4743-4436-A87B-095EA46C476F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7467FD6B-4743-4436-A87B-095EA46C476F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7467FD6B-4743-4436-A87B-095EA46C476F}.Debug|x86.ActiveCfg = Debug|Any CPU
{7467FD6B-4743-4436-A87B-095EA46C476F}.Debug|x86.Build.0 = Debug|Any CPU
{7467FD6B-4743-4436-A87B-095EA46C476F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7467FD6B-4743-4436-A87B-095EA46C476F}.Release|Any CPU.Build.0 = Release|Any CPU
{7467FD6B-4743-4436-A87B-095EA46C476F}.Release|x86.ActiveCfg = Release|Any CPU
{7467FD6B-4743-4436-A87B-095EA46C476F}.Release|x86.Build.0 = Release|Any CPU
{611B075A-0526-4661-BD58-B141BD42E6D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {611B075A-0526-4661-BD58-B141BD42E6D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{611B075A-0526-4661-BD58-B141BD42E6D7}.Debug|Any CPU.Build.0 = Debug|Any CPU {611B075A-0526-4661-BD58-B141BD42E6D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{611B075A-0526-4661-BD58-B141BD42E6D7}.Debug|x86.ActiveCfg = Debug|x86 {611B075A-0526-4661-BD58-B141BD42E6D7}.Debug|x86.ActiveCfg = Debug|x86