2017-04-17 12:55:20 +02:00
|
|
|
|
using System;
|
2017-04-18 14:08:56 +02:00
|
|
|
|
using System.Collections.Generic;
|
2017-04-17 12:55:20 +02:00
|
|
|
|
using System.IO;
|
2017-04-18 14:08:56 +02:00
|
|
|
|
using System.Runtime.Serialization.Json;
|
2017-04-17 12:55:20 +02:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Geekbot.net.Modules;
|
2017-04-18 14:08:56 +02:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
2017-04-17 12:55:20 +02:00
|
|
|
|
|
|
|
|
|
namespace Geekbot.net.Lib
|
|
|
|
|
{
|
|
|
|
|
public class BootTasks
|
|
|
|
|
{
|
|
|
|
|
public static async Task CheckSettingsFile()
|
|
|
|
|
{
|
|
|
|
|
// ToDO: Check settings file, if invalid, reconfig it
|
|
|
|
|
// Console.WriteLine(Path.GetFullPath("./settings.json"));
|
|
|
|
|
}
|
2017-04-18 14:08:56 +02:00
|
|
|
|
|
|
|
|
|
public static void ParseOldDatabase(string path)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Starting Database Conversion...");
|
|
|
|
|
path = Path.GetFullPath(path);
|
|
|
|
|
Console.WriteLine($"Old db location: {path}");
|
|
|
|
|
var redis = new RedisClient().Client;
|
|
|
|
|
Console.WriteLine("Connected to Redis...");
|
|
|
|
|
var allfiles = Directory.GetFiles(path, "*.json", SearchOption.AllDirectories);
|
|
|
|
|
foreach ( var file in allfiles)
|
|
|
|
|
{
|
|
|
|
|
var info = new FileInfo(file);
|
|
|
|
|
if (info.Name.StartsWith("-")) continue;
|
|
|
|
|
Console.WriteLine(info.FullName);
|
|
|
|
|
dynamic json = JObject.Parse(File.ReadAllText(file));
|
|
|
|
|
var key = info.Name.Substring(0, info.Name.Length - 5) + "-messages";
|
|
|
|
|
Console.WriteLine($"{key} - {json.messages}");
|
|
|
|
|
redis.StringSet(key, json.messages.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-04-17 12:55:20 +02:00
|
|
|
|
}
|
|
|
|
|
}
|