Add project files.
This commit is contained in:
parent
dd96dcd05e
commit
160f5c7130
37
AacpsBusAlert.sln
Normal file
37
AacpsBusAlert.sln
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.0.31903.59
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BinaryDad.AacpsBusAlert.Worker", "BinaryDad.AacpsBusAlert.Worker\BinaryDad.AacpsBusAlert.Worker.csproj", "{A11DB85E-ECAC-4CE7-866F-245BB8A3F4D0}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BinaryDad.AacpsBusAlert", "BinaryDad.AacpsBusAlert\BinaryDad.AacpsBusAlert.csproj", "{A5478ED8-55A1-40BB-B1DC-24EDF36E5B1A}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BinaryDad.AacpsBusAlert.Services", "BinaryDad.AacpsBusAlert.Services\BinaryDad.AacpsBusAlert.Services.csproj", "{3707126F-FE2F-4733-9702-1822AC05AABD}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{A11DB85E-ECAC-4CE7-866F-245BB8A3F4D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{A11DB85E-ECAC-4CE7-866F-245BB8A3F4D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{A11DB85E-ECAC-4CE7-866F-245BB8A3F4D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{A11DB85E-ECAC-4CE7-866F-245BB8A3F4D0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{A5478ED8-55A1-40BB-B1DC-24EDF36E5B1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{A5478ED8-55A1-40BB-B1DC-24EDF36E5B1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{A5478ED8-55A1-40BB-B1DC-24EDF36E5B1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{A5478ED8-55A1-40BB-B1DC-24EDF36E5B1A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{3707126F-FE2F-4733-9702-1822AC05AABD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{3707126F-FE2F-4733-9702-1822AC05AABD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{3707126F-FE2F-4733-9702-1822AC05AABD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{3707126F-FE2F-4733-9702-1822AC05AABD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {933518CD-A34E-4096-AED4-BB5CD7D44F86}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
@ -0,0 +1,19 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="BinaryDad.Extensions" Version="21.4.20.3" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\BinaryDad.AacpsBusAlert\BinaryDad.AacpsBusAlert.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
45
BinaryDad.AacpsBusAlert.Services/BusRouteService.cs
Normal file
45
BinaryDad.AacpsBusAlert.Services/BusRouteService.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
using BinaryDad.Extensions;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace BinaryDad.AacpsBusAlert.Services
|
||||||
|
{
|
||||||
|
public class BusRouteService
|
||||||
|
{
|
||||||
|
private readonly HttpClient httpClient;
|
||||||
|
|
||||||
|
public BusRouteService(IHttpClientFactory httpClientFactory)
|
||||||
|
{
|
||||||
|
httpClient = httpClientFactory.CreateClient();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<ICollection<BusRoute>> GetBusRoutesAsync()
|
||||||
|
{
|
||||||
|
var url = "https://busstops.aacps.org/public/BusRouteIssues.aspx";
|
||||||
|
var content = await httpClient.GetStringAsync(url);
|
||||||
|
|
||||||
|
var dataArrayMatch = Regex.Match(content, "var dataArray \\= (.*)\\;");
|
||||||
|
|
||||||
|
if (dataArrayMatch.Success && dataArrayMatch.Groups.Count == 2)
|
||||||
|
{
|
||||||
|
var dataArray = dataArrayMatch.Groups[1].Value;
|
||||||
|
|
||||||
|
var parsedArray = JsonConvert.DeserializeObject<string[][]>(dataArray);
|
||||||
|
|
||||||
|
return parsedArray
|
||||||
|
.Select(r => new BusRoute
|
||||||
|
{
|
||||||
|
BusNumber = r[0].To<int>(),
|
||||||
|
SubBusNumber = r[1].To<int>(),
|
||||||
|
Schools = r[2],
|
||||||
|
Schedules = r[3],
|
||||||
|
Impact = r[4]
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ApplicationException("Unable to parse bus route page");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\BinaryDad.AacpsBusAlert.Services\BinaryDad.AacpsBusAlert.Services.csproj" />
|
||||||
|
<ProjectReference Include="..\BinaryDad.AacpsBusAlert\BinaryDad.AacpsBusAlert.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
17
BinaryDad.AacpsBusAlert.Worker/Program.cs
Normal file
17
BinaryDad.AacpsBusAlert.Worker/Program.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using BinaryDad.AacpsBusAlert.Services;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
|
var host = Host.CreateDefaultBuilder(args)
|
||||||
|
.ConfigureServices(services =>
|
||||||
|
{
|
||||||
|
services.AddTransient<BusRouteService>();
|
||||||
|
services.AddHttpClient();
|
||||||
|
})
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var busRouteService = host.Services.GetService<BusRouteService>();
|
||||||
|
|
||||||
|
var routes = await busRouteService.GetBusRoutesAsync();
|
||||||
|
|
||||||
|
Console.ReadLine();
|
9
BinaryDad.AacpsBusAlert/BinaryDad.AacpsBusAlert.csproj
Normal file
9
BinaryDad.AacpsBusAlert/BinaryDad.AacpsBusAlert.csproj
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
11
BinaryDad.AacpsBusAlert/BusRoute.cs
Normal file
11
BinaryDad.AacpsBusAlert/BusRoute.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
namespace BinaryDad.AacpsBusAlert
|
||||||
|
{
|
||||||
|
public class BusRoute
|
||||||
|
{
|
||||||
|
public int BusNumber { get; set; }
|
||||||
|
public int SubBusNumber { get; set; }
|
||||||
|
public string Schools { get; set; }
|
||||||
|
public string Schedules { get; set; }
|
||||||
|
public string Impact { get; set; }
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user