enhance client with expicit classes for doc, patient and generate a global singleton service inintializer
This commit is contained in:
parent
87d07b3097
commit
ca15e9c341
|
@ -74,7 +74,6 @@
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
<Compile Include="Person.cs" />
|
|
||||||
<Page Include="MainWindow.xaml">
|
<Page Include="MainWindow.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
|
@ -88,12 +87,15 @@
|
||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
<DependentUpon>Reference.svcmap</DependentUpon>
|
<DependentUpon>Reference.svcmap</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Doctor.cs" />
|
||||||
|
<Compile Include="Global.cs" />
|
||||||
<Compile Include="MainWindow.xaml.cs">
|
<Compile Include="MainWindow.xaml.cs">
|
||||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Patient.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs">
|
<Compile Include="Properties\AssemblyInfo.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Client
|
||||||
|
{
|
||||||
|
public class Doctor
|
||||||
|
{
|
||||||
|
public string FirstName { get; set; }
|
||||||
|
public string LastName { get; set; }
|
||||||
|
public string Strasse { get; set; }
|
||||||
|
public int Plz { get; set; }
|
||||||
|
public string Ort { get; set; }
|
||||||
|
public string Region { get; set; }
|
||||||
|
public string DocType { get; set; }
|
||||||
|
|
||||||
|
public Doctor()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// this is my doctor construcor
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="firstName"> first name of the doctor</param>
|
||||||
|
/// <param name="lastName">last name of the doctor</param>
|
||||||
|
/// <param name="region">region where the doctor works</param>
|
||||||
|
/// <param name="doctype">Kantonal, Regional or Local Doctor</param>
|
||||||
|
public Doctor(string firstName,
|
||||||
|
string lastName,
|
||||||
|
string strasse,
|
||||||
|
string plz,
|
||||||
|
string ort,
|
||||||
|
string region,
|
||||||
|
string doctype )
|
||||||
|
{
|
||||||
|
FirstName = firstName;
|
||||||
|
LastName = lastName;
|
||||||
|
Strasse = strasse;
|
||||||
|
Plz = Convert.ToInt32(plz);
|
||||||
|
Ort = ort;
|
||||||
|
Region = region;
|
||||||
|
DocType = doctype;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This writes the doctor back to the service into the db
|
||||||
|
/// </summary>
|
||||||
|
public void CreateDoctor()
|
||||||
|
{
|
||||||
|
// write doctor to wcf interface
|
||||||
|
EHEC_Service.Doctor mydoctor = new EHEC_Service.Doctor
|
||||||
|
{
|
||||||
|
FirstName = FirstName,
|
||||||
|
LastName = LastName,
|
||||||
|
Region = Region,
|
||||||
|
DoctorOrigin = DocType
|
||||||
|
};
|
||||||
|
Global.GlobalInstance.Service.WriteDoctor(mydoctor);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Client.EHEC_Service;
|
||||||
|
|
||||||
|
namespace Client
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This is a Singleton implementation for the need of one single client connection
|
||||||
|
/// </summary>
|
||||||
|
|
||||||
|
public class Global
|
||||||
|
{
|
||||||
|
private Global()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
private static Global globalInstance = null;
|
||||||
|
private static ServiceClient service = null;
|
||||||
|
|
||||||
|
public static Global GlobalInstance {
|
||||||
|
get {
|
||||||
|
if (globalInstance == null)
|
||||||
|
{
|
||||||
|
globalInstance = new Global();
|
||||||
|
}
|
||||||
|
return globalInstance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServiceClient Service
|
||||||
|
{
|
||||||
|
get {
|
||||||
|
if (service == null)
|
||||||
|
{
|
||||||
|
service = new ServiceClient("BasicHttpBinding_IService");
|
||||||
|
}
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -45,7 +45,7 @@
|
||||||
<Button x:Name="ButtonAutogenerateMany" Content="Auto Many" Margin="1,1,10,1" Background="White" Grid.Column="6" Grid.Row="12" VerticalContentAlignment="Center" Click="ButtonAutogenerateMany_Click" Grid.ColumnSpan="2"/>
|
<Button x:Name="ButtonAutogenerateMany" Content="Auto Many" Margin="1,1,10,1" Background="White" Grid.Column="6" Grid.Row="12" VerticalContentAlignment="Center" Click="ButtonAutogenerateMany_Click" Grid.ColumnSpan="2"/>
|
||||||
<Button x:Name="ButtonSend" Content="Senden" Margin="1,0.5,10,1.5" Click="ButtonSend_Click" Background="White" Grid.Column="6" Grid.Row="14" VerticalContentAlignment="Center" Grid.ColumnSpan="2"/>
|
<Button x:Name="ButtonSend" Content="Senden" Margin="1,0.5,10,1.5" Click="ButtonSend_Click" Background="White" Grid.Column="6" Grid.Row="14" VerticalContentAlignment="Center" Grid.ColumnSpan="2"/>
|
||||||
<Label x:Name="LabelRueckmeldung" Content="Rückmeldung:" Margin="1" Grid.Column="3" Grid.Row="13" VerticalContentAlignment="Center"/>
|
<Label x:Name="LabelRueckmeldung" Content="Rückmeldung:" Margin="1" Grid.Column="3" Grid.Row="13" VerticalContentAlignment="Center"/>
|
||||||
<Label x:Name="LabelRueckmeldungsfeld" Content="" Margin="1" Grid.ColumnSpan="3" Grid.Column="4" Grid.Row="13" VerticalContentAlignment="Center"/>
|
<Label x:Name="LabelRueckmeldungsfeld" Content="" Margin="1,1,10,1.5" Grid.ColumnSpan="4" Grid.Column="4" Grid.Row="13" VerticalContentAlignment="Center"/>
|
||||||
<xctk:WatermarkTextBox x:Name="TextboxArztname" Margin="1" Padding="3,1" Grid.ColumnSpan="2" Grid.Column="1" Grid.Row="2" VerticalContentAlignment="Center">
|
<xctk:WatermarkTextBox x:Name="TextboxArztname" Margin="1" Padding="3,1" Grid.ColumnSpan="2" Grid.Column="1" Grid.Row="2" VerticalContentAlignment="Center">
|
||||||
<xctk:WatermarkTextBox.Watermark>
|
<xctk:WatermarkTextBox.Watermark>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
|
@ -221,5 +221,6 @@
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</xctk:WatermarkTextBox.Watermark>
|
</xctk:WatermarkTextBox.Watermark>
|
||||||
</xctk:WatermarkTextBox>
|
</xctk:WatermarkTextBox>
|
||||||
|
<ComboBox Grid.ColumnSpan="2" Grid.Column="4" HorizontalAlignment="Left" Grid.Row="12" VerticalAlignment="Top" Width="242"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|
|
@ -25,6 +25,9 @@ namespace Client
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
// loading of dropdowns
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonClose_Click(object sender, RoutedEventArgs e)
|
private void ButtonClose_Click(object sender, RoutedEventArgs e)
|
||||||
|
@ -33,22 +36,26 @@ namespace Client
|
||||||
}
|
}
|
||||||
private void ButtonSend_Click(object sender, RoutedEventArgs e)
|
private void ButtonSend_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
ServiceClient servize = new ServiceClient("BasicHttpBinding_IService");
|
Doctor newDoctor = new Doctor(TextboxArztVorname.Text,
|
||||||
|
TextboxArztname.Text,
|
||||||
|
TextboxArztStrasseNr.Text,
|
||||||
|
TextboxArztPlz.Text,
|
||||||
|
TextboxArztOrt.Text,
|
||||||
|
TextboxArztRegion.Text,
|
||||||
|
TextboxArztKantonsarzt.Text
|
||||||
|
);
|
||||||
|
Patient newPatient = new Patient(TextboxPatientVorname.Text,
|
||||||
|
TextboxPatientName.Text,
|
||||||
|
TextboxPatientStrasseNr.Text,
|
||||||
|
TextboxPatientPlz.Text,
|
||||||
|
TextboxPatientOrt.Text,
|
||||||
|
TextboxPatientRegion.Text,
|
||||||
|
TextboxPatientGeburtstag.Text
|
||||||
|
);
|
||||||
|
newDoctor.CreateDoctor();
|
||||||
|
newPatient.CreatePatient();
|
||||||
|
|
||||||
|
|
||||||
String arztName = TextboxArztname.Text;
|
|
||||||
String arztVorname = TextboxArztVorname.Text;
|
|
||||||
String arztStrasseNr = TextboxArztStrasseNr.Text;
|
|
||||||
String arztPlz = TextboxArztPlz.Text;
|
|
||||||
String arztOrt = TextboxArztOrt.Text;
|
|
||||||
String arztKantonsarzt = TextboxArztKantonsarzt.Text;
|
|
||||||
String arztRegion = TextboxArztRegion.Text;
|
|
||||||
String patientName = TextboxPatientName.Text;
|
|
||||||
String patientVorname = TextboxPatientVorname.Text;
|
|
||||||
String patientStrasseNr = TextboxPatientStrasseNr.Text;
|
|
||||||
String patientPlz = TextboxPatientPlz.Text;
|
|
||||||
String patientOrt = TextboxPatientOrt.Text;
|
|
||||||
String patientRegion = TextboxPatientRegion.Text;
|
|
||||||
DateTime patientGeburtstag = Convert.ToDateTime(TextboxPatientGeburtstag.Text);
|
|
||||||
String Bakterienstamm = TextboxBakterienstamm.Text;
|
String Bakterienstamm = TextboxBakterienstamm.Text;
|
||||||
String Nahrung1Restaurant = TextboxNahrung1Restaurant.Text;
|
String Nahrung1Restaurant = TextboxNahrung1Restaurant.Text;
|
||||||
String Nahrung2Restaurant = TextboxNahrung2Restaurant.Text;
|
String Nahrung2Restaurant = TextboxNahrung2Restaurant.Text;
|
||||||
|
@ -56,31 +63,21 @@ namespace Client
|
||||||
String Nahrung4Restaurant = TextboxNahrung4Restaurant.Text;
|
String Nahrung4Restaurant = TextboxNahrung4Restaurant.Text;
|
||||||
String Nahrung5Restaurant = TextboxNahrung5Restaurant.Text;
|
String Nahrung5Restaurant = TextboxNahrung5Restaurant.Text;
|
||||||
|
|
||||||
Patient p = new Patient
|
|
||||||
{
|
|
||||||
BirthDate = patientGeburtstag,
|
|
||||||
City = patientOrt,
|
|
||||||
FirstName = patientVorname,
|
|
||||||
LastName = patientName,
|
|
||||||
Street = patientStrasseNr,
|
|
||||||
Region = patientRegion
|
|
||||||
};
|
|
||||||
servize.WritePatient(p);
|
|
||||||
if (p.PatientId == 0)
|
|
||||||
{
|
|
||||||
//LabelRueckmeldungsfeld.Text = "some";
|
|
||||||
}
|
|
||||||
|
|
||||||
Doctor d = new Doctor
|
|
||||||
{
|
|
||||||
FirstName = arztVorname,
|
|
||||||
LastName = arztName,
|
|
||||||
Region = arztRegion,
|
|
||||||
DoctorOrigin = arztKantonsarzt,
|
|
||||||
|
|
||||||
};
|
//try {
|
||||||
servize.WriteDoctor(d);
|
// Global.GlobalInstance.Service.WritePatient(p);
|
||||||
//WatermarkTextBox TextboxArztname = null;
|
// //servize.WritePatient(p);
|
||||||
|
//} catch (Exception) {
|
||||||
|
// if (p.PatientId == 0) {
|
||||||
|
// LabelRueckmeldungsfeld.Content = "fehler id = 0, beim schreiben von Patient!";
|
||||||
|
// } else {
|
||||||
|
// LabelRueckmeldungsfeld.Content = "fehler id != 0, beim schreiben von Patient!";
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//LabelRueckmeldungsfeld.Content = "erfolgreich Patient gespeichert";
|
||||||
|
//TextboxPatientName.Clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonAutogenerateMany_Click(object sender, RoutedEventArgs e)
|
private void ButtonAutogenerateMany_Click(object sender, RoutedEventArgs e)
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Client
|
||||||
|
{
|
||||||
|
class Patient
|
||||||
|
{
|
||||||
|
public string FirstName { get; set; }
|
||||||
|
public string LastName { get; set; }
|
||||||
|
public string Street { get; set; }
|
||||||
|
public int Plz { get; set; }
|
||||||
|
public string City { get; set; }
|
||||||
|
public string Region { get; set; }
|
||||||
|
public string BirthDate { get; set; }
|
||||||
|
|
||||||
|
public Patient(string firstName,
|
||||||
|
string lastName,
|
||||||
|
string street,
|
||||||
|
string plz,
|
||||||
|
string city,
|
||||||
|
string region,
|
||||||
|
string birthDate
|
||||||
|
)
|
||||||
|
{
|
||||||
|
FirstName = firstName;
|
||||||
|
LastName = lastName;
|
||||||
|
Street = street;
|
||||||
|
Plz = Convert.ToInt32(plz);
|
||||||
|
City = city;
|
||||||
|
Region = region;
|
||||||
|
BirthDate = birthDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreatePatient()
|
||||||
|
{
|
||||||
|
EHEC_Service.Patient mypatient = new EHEC_Service.Patient
|
||||||
|
{
|
||||||
|
FirstName = FirstName,
|
||||||
|
LastName = LastName,
|
||||||
|
Street = Street,
|
||||||
|
City = City,
|
||||||
|
Region = Region,
|
||||||
|
BirthDate = Convert.ToDateTime(BirthDate)
|
||||||
|
};
|
||||||
|
Global.GlobalInstance.Service.WritePatient(mypatient);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue