v3-to-v4 migrator
This commit is contained in:
parent
79bcc27257
commit
340b027939
47
c3stream.cs
47
c3stream.cs
|
@ -1,25 +1,40 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using c3stream.Pages;
|
using c3stream.Pages;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace c3stream {
|
namespace c3stream {
|
||||||
public static class c3stream {
|
public static class c3stream {
|
||||||
public const string DataPath = "data";
|
public const string DataPath = "data";
|
||||||
public const string DbFile = "_c3stream.json";
|
public const string DbFile = "_c3stream.json";
|
||||||
public const string CachePath = "/mnt/storage/archive/Video/congress/";
|
public const string CachePath = "/mnt/storage/archive/Video/congress/";
|
||||||
public const string CacheUrl = "https://mirror.c3stream.de/";
|
public const string CacheUrl = "https://mirror.c3stream.de/";
|
||||||
public static object Lock = new object();
|
public static object Lock = new object();
|
||||||
public static string DbPath = Path.Combine(DataPath, DbFile);
|
public static string DbPath = Path.Combine(DataPath, DbFile);
|
||||||
|
public static List<UserStatus> UserData = new List<UserStatus>();
|
||||||
|
|
||||||
public static void Main(string[] args) {
|
public static void Main(string[] args) {
|
||||||
if (!Directory.Exists(DataPath))
|
if (!Directory.Exists(DataPath))
|
||||||
Directory.CreateDirectory(DataPath);
|
Directory.CreateDirectory(DataPath);
|
||||||
if (!File.Exists(DbPath))
|
if (!File.Exists(DbPath))
|
||||||
ConferenceModel.WriteEventMetadata();
|
ConferenceModel.WriteEventMetadata();
|
||||||
CreateHostBuilder(args).Build().Run();
|
ConferenceModel.ReadEventMetadata();
|
||||||
|
|
||||||
|
foreach (var e in ConferenceModel.EventMetadata.FindAll(p => p.State != null)) {
|
||||||
|
foreach (var state in e.State) {
|
||||||
|
lock (Lock) {
|
||||||
|
UserData.Add(new UserStatus(state.Guid, e.Guid, state.State));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WriteUserData();
|
||||||
|
|
||||||
|
//CreateHostBuilder(args).Build().Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UpdateCookie(HttpRequest resquest, HttpResponse response, string redirectUri) {
|
public static void UpdateCookie(HttpRequest resquest, HttpResponse response, string redirectUri) {
|
||||||
|
@ -40,6 +55,24 @@ namespace c3stream {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void WriteUserData() {
|
||||||
|
lock (Lock) {
|
||||||
|
File.WriteAllText(Path.Combine(DataPath, "c3stream.user.json"), JsonConvert.SerializeObject(UserData));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UserStatus {
|
||||||
|
public readonly string TalkId;
|
||||||
|
public readonly string UserId;
|
||||||
|
public string State;
|
||||||
|
|
||||||
|
public UserStatus(string userId, string talkId, string state = "unwatched") {
|
||||||
|
UserId = userId;
|
||||||
|
State = state;
|
||||||
|
TalkId = talkId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||||
Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
|
Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue