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">
<HintPath>..\packages\AutoMapper.7.0.1\lib\net45\AutoMapper.dll</HintPath>
</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.Data" />
<Reference Include="System.Runtime.Serialization" />
@ -80,6 +83,7 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Models\Testdata.cs" />
<Compile Include="Models\AutomapperProfile.cs" />
<Compile Include="Models\Exam.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="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="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="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="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"/>
@ -155,13 +154,13 @@
</StackPanel>
</xctk:WatermarkTextBox.Watermark>
</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:WatermarkTextBox.Watermark>
<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:WatermarkComboBox.Watermark>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Bakterienstamm" Margin="2,0,0,0" />
</StackPanel>
</xctk:WatermarkTextBox.Watermark>
</xctk:WatermarkTextBox>
</xctk:WatermarkComboBox.Watermark>
</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.Watermark>
<StackPanel Orientation="Horizontal">
@ -302,5 +301,6 @@
</StackPanel>
</xctk:WatermarkTextBox.Watermark>
</xctk:WatermarkTextBox>
</Grid>
</Window>

View File

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

View File

@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27428.2027
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}"
EndProject
Global
@ -15,14 +13,6 @@ Global
Release|x86 = Release|x86
EndGlobalSection
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.Build.0 = Debug|Any CPU
{611B075A-0526-4661-BD58-B141BD42E6D7}.Debug|x86.ActiveCfg = Debug|x86