\ No newline at end of file
diff --git a/c3stream.cs b/c3stream.cs
index 55a35ba..a1c005b 100644
--- a/c3stream.cs
+++ b/c3stream.cs
@@ -2,10 +2,8 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using System.Net;
+using System.Net.Http;
using c3stream.DataModels;
-using c3stream.Pages;
-using LinqToDB.Common;
using LinqToDB.Data;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
@@ -39,8 +37,8 @@ namespace c3stream {
Directory.CreateDirectory(DataPath);
if (!File.Exists(DbPath))
File.Copy(Path.Combine(DataPath, "database.init.sqlite"), DbPath);
-
- DataConnection.DefaultSettings = new Database.Settings();
+
+ DataConnection.DefaultSettings = new Database.Settings();
foreach (var conference in Conferences)
UpdateConference(conference);
@@ -63,16 +61,16 @@ namespace c3stream {
//TODO: move this to the database as well
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 json = "";
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);
}
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 {
json = File.ReadAllText(jsonpath);
@@ -91,13 +89,13 @@ namespace c3stream {
var cookie = "";
//if new bookmark is in uri
if (request.Query.ContainsKey("bookmark") && Guid.TryParseExact(request.Query["bookmark"], "D", out _)) {
- response.Cookies.Append("bookmark", request.Query["bookmark"], new CookieOptions {Expires = DateTimeOffset.MaxValue});
+ response.Cookies.Append("bookmark", request.Query["bookmark"], new CookieOptions { Expires = DateTimeOffset.MaxValue });
cookie = request.Query["bookmark"];
}
//if no cookie exists or cookie is invalid
else if (!request.Cookies.ContainsKey("bookmark") || !Guid.TryParseExact(request.Cookies["bookmark"], "D", out _)) {
var guid = Guid.NewGuid().ToString();
- response.Cookies.Append("bookmark", guid, new CookieOptions {Expires = DateTimeOffset.MaxValue});
+ response.Cookies.Append("bookmark", guid, new CookieOptions { Expires = DateTimeOffset.MaxValue });
cookie = guid;
}
else {
@@ -134,4 +132,4 @@ namespace c3stream {
}
}
}
-}
+}
\ No newline at end of file