1 |
6b4c34a2
|
Eliška Mourycová
|
using System;
|
2 |
|
|
using System.Xml.Serialization;
|
3 |
|
|
|
4 |
|
|
namespace ServerApp.Connection.XMLProtocolHandler
|
5 |
|
|
{
|
6 |
|
|
[XmlRoot("Request")]
|
7 |
|
|
public class Request
|
8 |
|
|
{
|
9 |
|
|
[XmlElement]
|
10 |
|
|
public bool useWeather;
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
[XmlElement]
|
14 |
|
|
public double temperature;
|
15 |
|
|
|
16 |
|
|
[XmlElement]
|
17 |
|
|
public double wind;
|
18 |
|
|
|
19 |
|
|
[XmlElement]
|
20 |
|
|
public double rain;
|
21 |
|
|
|
22 |
|
|
[XmlElement]
|
23 |
|
|
public WeatherCondition weather;
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
[XmlElement]
|
27 |
|
|
public bool useEndDate;
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
[XmlElement]
|
31 |
|
|
public Date start;
|
32 |
|
|
|
33 |
|
|
[XmlElement]
|
34 |
|
|
public Date end;
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
public static Request Randomize()
|
38 |
|
|
{
|
39 |
|
|
Request r = new Request();
|
40 |
|
|
Random rand = new Random();
|
41 |
|
|
|
42 |
|
|
r.useWeather = (rand.Next(0, 100)) < 50 ? true : false;
|
43 |
|
|
|
44 |
|
|
if (r.useWeather)
|
45 |
|
|
{
|
46 |
|
|
r.temperature = rand.Next(0, 40);
|
47 |
|
|
r.wind = rand.Next(0, 100);
|
48 |
|
|
r.rain = rand.Next(0, 100);
|
49 |
|
|
r.weather = (WeatherCondition)rand.Next(0, 3);
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
r.start = Date.Randomize();
|
53 |
|
|
|
54 |
|
|
r.useEndDate = (rand.Next(0, 100) < 50) ? true : false;
|
55 |
|
|
|
56 |
|
|
if (r.useEndDate)
|
57 |
|
|
{
|
58 |
|
|
r.end = Date.Randomize();
|
59 |
|
|
if (r.start.CompareTo(r.end) < 0)
|
60 |
|
|
{
|
61 |
|
|
Date tmp = r.start;
|
62 |
|
|
r.start = r.end;
|
63 |
|
|
r.end = tmp;
|
64 |
|
|
}
|
65 |
|
|
else if (r.start.CompareTo(r.end) == 0)
|
66 |
|
|
{
|
67 |
|
|
r.useEndDate = false;
|
68 |
|
|
}
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
return r;
|
72 |
|
|
}
|
73 |
|
|
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
}
|