Replace WebClient usage with HttpClient
This commit is contained in:
parent
b79bb982f6
commit
686cab15bf
|
@ -11,12 +11,10 @@
|
||||||
|
|
||||||
var cookie = c3stream.UpdateCookie(Request, Response, $"/Conference?c={Request.Query["c"]}");
|
var cookie = c3stream.UpdateCookie(Request, Response, $"/Conference?c={Request.Query["c"]}");
|
||||||
ViewData["Title"] = Request.Query["c"];
|
ViewData["Title"] = Request.Query["c"];
|
||||||
var wc = new WebClient();
|
|
||||||
var conference = c3stream.Conferences.First(c => c.Acronym == Request.Query["c"]);
|
var conference = c3stream.Conferences.First(c => c.Acronym == Request.Query["c"]);
|
||||||
if (conference.Ongoing) {
|
if (conference.Ongoing) {
|
||||||
c3stream.UpdateConference(conference);
|
c3stream.UpdateConference(conference);
|
||||||
}
|
}
|
||||||
wc.Dispose();
|
|
||||||
await using var db = new Database.DbConn();
|
await using var db = new Database.DbConn();
|
||||||
var states = db.States.ToList();
|
var states = db.States.ToList();
|
||||||
}
|
}
|
||||||
|
@ -26,7 +24,8 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">Event</th>
|
<th scope="col">Event</th>
|
||||||
<th scope="col">
|
<th scope="col">
|
||||||
@Html.Raw(Request.Query["orderby"] == "published" ? $"<a href=\"/Conference?c={Request.Query["c"]}\">Published" : $"<a href=\"/Conference?c={Request.Query["c"]}&orderby=published\">Date")</th>
|
@Html.Raw(Request.Query["orderby"] == "published" ? $"<a href=\"/Conference?c={Request.Query["c"]}\">Published" : $"<a href=\"/Conference?c={Request.Query["c"]}&orderby=published\">Date")
|
||||||
|
</th>
|
||||||
<th scope="col">Category</th>
|
<th scope="col">Category</th>
|
||||||
<th scope="col">Title</th>
|
<th scope="col">Title</th>
|
||||||
<th scope="col">Speaker(s)</th>
|
<th scope="col">Speaker(s)</th>
|
||||||
|
|
10
c3stream.cs
10
c3stream.cs
|
@ -2,10 +2,8 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net.Http;
|
||||||
using c3stream.DataModels;
|
using c3stream.DataModels;
|
||||||
using c3stream.Pages;
|
|
||||||
using LinqToDB.Common;
|
|
||||||
using LinqToDB.Data;
|
using LinqToDB.Data;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
@ -63,16 +61,16 @@ namespace c3stream {
|
||||||
|
|
||||||
//TODO: move this to the database as well
|
//TODO: move this to the database as well
|
||||||
public static void UpdateConference(ConferenceObject conference) {
|
public static void UpdateConference(ConferenceObject conference) {
|
||||||
using var wc = new WebClient();
|
using var httpc = new HttpClient();
|
||||||
|
|
||||||
var jsonpath = Path.Combine(DataPath, conference.Acronym + "_index.json");
|
var jsonpath = Path.Combine(DataPath, conference.Acronym + "_index.json");
|
||||||
var json = "";
|
var json = "";
|
||||||
if (!File.Exists(jsonpath)) {
|
if (!File.Exists(jsonpath)) {
|
||||||
json = wc.DownloadString($"https://api.media.ccc.de/public/conferences/{conference.Acronym}");
|
json = httpc.GetStringAsync($"https://api.media.ccc.de/public/conferences/{conference.Acronym}").Result;
|
||||||
File.WriteAllText(jsonpath, json);
|
File.WriteAllText(jsonpath, json);
|
||||||
}
|
}
|
||||||
else if (conference.Ongoing) {
|
else if (conference.Ongoing) {
|
||||||
json = wc.DownloadString($"https://api.media.ccc.de/public/conferences/{conference.Acronym}");
|
json = httpc.GetStringAsync($"https://api.media.ccc.de/public/conferences/{conference.Acronym}").Result;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
json = File.ReadAllText(jsonpath);
|
json = File.ReadAllText(jsonpath);
|
||||||
|
|
Loading…
Reference in a new issue