Revize c9eed50c
Přidáno uživatelem Alex Konig před více než 3 roky(ů)
Server/ServerApp/App.config | ||
---|---|---|
7 | 7 |
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
8 | 8 |
<dependentAssembly> |
9 | 9 |
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> |
10 |
<bindingRedirect oldVersion="0.0.0.0-4.0.4.1" newVersion="4.0.4.1" />
|
|
10 |
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
|
|
11 | 11 |
</dependentAssembly> |
12 | 12 |
<dependentAssembly> |
13 | 13 |
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> |
Server/ServerApp/Parser/Parsers/JsonParser.cs | ||
---|---|---|
1 |
using ServerApp.DataDownload; |
|
2 |
using System; |
|
3 |
using System.Collections.Generic; |
|
4 |
using System.IO; |
|
5 |
using System.Linq; |
|
6 |
using System.Net; |
|
7 |
using System.Text; |
|
8 |
using System.Text.Json; |
|
9 |
using System.Threading.Tasks; |
|
10 |
|
|
11 |
|
|
12 |
namespace ServerApp.Parser.Parsers |
|
13 |
{ |
|
14 |
class JsonParser |
|
15 |
{ |
|
16 |
DataDownloader loader; |
|
17 |
|
|
18 |
public JsonParser(DataDownloader loader) |
|
19 |
{ |
|
20 |
this.loader = loader; |
|
21 |
} |
|
22 |
|
|
23 |
|
|
24 |
public void ParsePrediction() |
|
25 |
{ |
|
26 |
// TODO ask DataDownloader for download said file and return path to it |
|
27 |
// get file |
|
28 |
string file = DownloadWeatherPrediction(); |
|
29 |
DateTime now = DateTime.Now; |
|
30 |
Console.WriteLine(File.Exists(file)); |
|
31 |
|
|
32 |
// parse file |
|
33 |
string data = File.ReadAllText(file); |
|
34 |
|
|
35 |
JsonDocument doc = JsonDocument.Parse(data); |
|
36 |
JsonElement root = doc.RootElement; |
|
37 |
|
|
38 |
var users = root.EnumerateObject(); |
|
39 |
while (users.MoveNext()) |
|
40 |
{ |
|
41 |
var user = users.Current; |
|
42 |
Console.WriteLine(user.Name); |
|
43 |
|
|
44 |
/* |
|
45 |
var props = user.EnumerateObject(); |
|
46 |
|
|
47 |
while (props.MoveNext()) |
|
48 |
{ |
|
49 |
var prop = props.Current; |
|
50 |
Console.WriteLine($"{prop.Name}: {prop.Value}"); |
|
51 |
} |
|
52 |
*/ |
|
53 |
} |
|
54 |
|
|
55 |
} |
|
56 |
|
|
57 |
private string DownloadWeatherPrediction() |
|
58 |
{ |
|
59 |
DateTime now = DateTime.Now; |
|
60 |
WebClient webClient = new WebClient(); |
|
61 |
webClient.DownloadFile("http://wttr.in/Plzen,czechia?format=j1", $"data/weather/{now.Year}{now.Month}{now.Day}.json"); |
|
62 |
|
|
63 |
return $"data/weather/{now.Year}{now.Month}{now.Day}.json"; |
|
64 |
} |
|
65 |
} |
|
66 |
} |
Server/ServerApp/Program.cs | ||
---|---|---|
30 | 30 |
static void Main(string[] args) |
31 | 31 |
{ |
32 | 32 |
|
33 |
JsonParser p = new JsonParser(null); |
|
34 |
p.ParsePrediction(); |
|
35 |
|
|
36 |
/* |
|
37 |
|
|
33 | 38 |
Config config = FillConfigInfo(args); |
34 | 39 |
if (config == null) |
35 | 40 |
{ |
... | ... | |
75 | 80 |
{ |
76 | 81 |
Console.WriteLine(s); |
77 | 82 |
} |
83 |
*/ |
|
78 | 84 |
|
79 | 85 |
// test - connection: |
80 | 86 |
//ConnectionListener cl = new ConnectionListener(int.Parse(args[0])/*8000*//*int.Parse(config.Port)*/); |
Server/ServerApp/ServerApp.csproj | ||
---|---|---|
57 | 57 |
<Prefer32Bit>true</Prefer32Bit> |
58 | 58 |
</PropertyGroup> |
59 | 59 |
<ItemGroup> |
60 |
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> |
|
61 |
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath> |
|
62 |
</Reference> |
|
60 | 63 |
<Reference Include="Microsoft.ML, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> |
61 | 64 |
<HintPath>..\packages\Microsoft.ML.1.5.5\lib\netstandard2.0\Microsoft.ML.dll</HintPath> |
62 | 65 |
</Reference> |
... | ... | |
88 | 91 |
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> |
89 | 92 |
</Reference> |
90 | 93 |
<Reference Include="System" /> |
91 |
<Reference Include="System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
|
92 |
<HintPath>..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll</HintPath>
|
|
94 |
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
|
95 |
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
|
93 | 96 |
</Reference> |
94 | 97 |
<Reference Include="System.CodeDom, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> |
95 | 98 |
<HintPath>..\packages\System.CodeDom.4.4.0\lib\net461\System.CodeDom.dll</HintPath> |
... | ... | |
106 | 109 |
<Private>True</Private> |
107 | 110 |
</Reference> |
108 | 111 |
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> |
109 |
<HintPath>..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll</HintPath>
|
|
112 |
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
|
|
110 | 113 |
</Reference> |
111 | 114 |
<Reference Include="System.Numerics" /> |
112 |
<Reference Include="System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> |
|
113 |
<HintPath>..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll</HintPath> |
|
115 |
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> |
|
116 |
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath> |
|
117 |
</Reference> |
|
118 |
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> |
|
119 |
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll</HintPath> |
|
114 | 120 |
</Reference> |
115 |
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> |
|
116 |
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath> |
|
121 |
<Reference Include="System.Text.Encodings.Web, Version=5.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> |
|
122 |
<HintPath>..\packages\System.Text.Encodings.Web.5.0.1\lib\net461\System.Text.Encodings.Web.dll</HintPath> |
|
123 |
</Reference> |
|
124 |
<Reference Include="System.Text.Json, Version=5.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> |
|
125 |
<HintPath>..\packages\System.Text.Json.5.0.2\lib\net461\System.Text.Json.dll</HintPath> |
|
117 | 126 |
</Reference> |
118 | 127 |
<Reference Include="System.Threading.Channels, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> |
119 | 128 |
<HintPath>..\packages\System.Threading.Channels.4.7.1\lib\net461\System.Threading.Channels.dll</HintPath> |
... | ... | |
121 | 130 |
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> |
122 | 131 |
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath> |
123 | 132 |
</Reference> |
133 |
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> |
|
134 |
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath> |
|
135 |
</Reference> |
|
124 | 136 |
<Reference Include="System.Web" /> |
125 | 137 |
<Reference Include="System.Xml.Linq" /> |
126 | 138 |
<Reference Include="System.Data.DataSetExtensions" /> |
... | ... | |
149 | 161 |
<Compile Include="Parser\OutputInfo\WindInfo.cs" /> |
150 | 162 |
<Compile Include="Parser\Parsers\DataParser.cs" /> |
151 | 163 |
<Compile Include="Parser\Parsers\JisParser.cs" /> |
164 |
<Compile Include="Parser\Parsers\JsonParser.cs" /> |
|
152 | 165 |
<Compile Include="Parser\Parsers\LogInParser.cs" /> |
153 | 166 |
<Compile Include="Parser\Parsers\TagInfo.cs" /> |
154 | 167 |
<Compile Include="Parser\Parsers\WeatherParser.cs" /> |
Server/ServerApp/packages.config | ||
---|---|---|
1 | 1 |
<?xml version="1.0" encoding="utf-8"?> |
2 | 2 |
<packages> |
3 |
<package id="Microsoft.Bcl.AsyncInterfaces" version="5.0.0" targetFramework="net472" /> |
|
3 | 4 |
<package id="Microsoft.ML" version="1.5.5" targetFramework="net472" /> |
4 | 5 |
<package id="Microsoft.ML.CpuMath" version="1.5.5" targetFramework="net472" /> |
5 | 6 |
<package id="Microsoft.ML.DataView" version="1.5.5" targetFramework="net472" /> |
6 | 7 |
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net472" /> |
7 |
<package id="System.Buffers" version="4.4.0" targetFramework="net472" />
|
|
8 |
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
|
|
8 | 9 |
<package id="System.CodeDom" version="4.4.0" targetFramework="net472" /> |
9 | 10 |
<package id="System.Collections.Immutable" version="1.5.0" targetFramework="net472" /> |
10 | 11 |
<package id="System.IO.Compression.ZipFile" version="4.3.0" targetFramework="net472" /> |
11 |
<package id="System.Memory" version="4.5.3" targetFramework="net472" />
|
|
12 |
<package id="System.Numerics.Vectors" version="4.4.0" targetFramework="net472" />
|
|
12 |
<package id="System.Memory" version="4.5.4" targetFramework="net472" />
|
|
13 |
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
|
|
13 | 14 |
<package id="System.Reflection.Emit.Lightweight" version="4.3.0" targetFramework="net472" /> |
14 |
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net472" /> |
|
15 |
<package id="System.Runtime.CompilerServices.Unsafe" version="5.0.0" targetFramework="net472" /> |
|
16 |
<package id="System.Text.Encodings.Web" version="5.0.1" targetFramework="net472" /> |
|
17 |
<package id="System.Text.Json" version="5.0.2" targetFramework="net472" /> |
|
15 | 18 |
<package id="System.Threading.Channels" version="4.7.1" targetFramework="net472" /> |
16 | 19 |
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" /> |
20 |
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" /> |
|
17 | 21 |
</packages> |
Také k dispozici: Unified diff
re #8840 First test