finsh testdatageneration

This commit is contained in:
Strati 2018-08-30 21:07:44 +02:00
parent e92f45f51c
commit 074eda6186
2 changed files with 50 additions and 5 deletions

View File

@ -10,6 +10,7 @@ namespace WpfWebClient.Helper
public static class GenerateTestData
{
private static List<FoodPlace> Foodplaces = new List<FoodPlace>();
private static List<PatientAtFoodPlace> PatientsAtFoodPlaces = new List<PatientAtFoodPlace>();
private static List<Exam> Exams = new List<Exam>();
private static Random random = new Random();
@ -53,10 +54,10 @@ namespace WpfWebClient.Helper
int Description = random.Next(FoodPlaceDescription.Count);
string FoodPlaceDescr = FoodPlaceDescription[Description];
int StreetName = random.Next(FoodPlaceStreetName.Count);
string FoodPlacesm = FoodPlaceStreetName[StreetName];
string FoodPlacesn = FoodPlaceStreetName[StreetName];
string FoodPlaceName = FoodPlaceNameFirstPart[FirstPart] + FoodPlaceNameSecondPart[SecondPart];
string streetname = FoodPlacesm;
string streetname = FoodPlacesn;
string fpdescr = FoodPlaceDescr;
int StreetNumber = random.Next(1, 100);
int CityID = random.Next(1, cities.Count());
@ -78,17 +79,34 @@ namespace WpfWebClient.Helper
return Foodplaces;
}
public static List<PatientAtFoodPlace> CreatePatientAtFoodPlaces()
{
WpfWebClient.ServiceReferenceEHEC.ServiceClient client = new WpfWebClient.ServiceReferenceEHEC.ServiceClient();
List<WpfWebClient.ServiceReferenceEHEC.FoodPlace> foodPlaces = new List<ServiceReferenceEHEC.FoodPlace>(client.GetFoodPlaces());
List<WpfWebClient.ServiceReferenceEHEC.Person> patients = new List<ServiceReferenceEHEC.Person>(client.GetPersons());
foodPlaces.OrderBy(x => random.Next()).Take(50);
}
PatientAtFoodPlace patf = new PatientAtFoodPlace();
return x
int i = 300;
do
{
patf.FoodPlace = (FoodPlace)foodPlaces.OrderBy(x => random.Next()).Take(1);
patf.Patient = (Person)patients.OrderBy(x => random.Next()).Take(1);
patf.PatientID = i;
patf.VistingDate = new DateTime(2005, 12, 20);
PatientsAtFoodPlaces.Add(patf);
i++;
} while (i < 375);
return PatientsAtFoodPlaces;
}
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WpfWebClient.Helper
{
class RandomDateTime
{
DateTime start;
Random gen;
int range;
public RandomDateTime()
{
start = new DateTime(1995, 1, 1);
gen = new Random();
range = (DateTime.Today - start).Days;
}
public DateTime Next()
{
return start.AddDays(gen.Next(range)).AddHours(gen.Next(0, 24)).AddMinutes(gen.Next(0, 60)).AddSeconds(gen.Next(0, 60));
}
}
}