コード例 #1
0
        private static void Init()
        {
            RestartFlag    = false;
            ShutdownSignal = new AutoResetEvent(false);

            Log.Logger = new LoggerConfiguration()
                         .WriteTo.Console(outputTemplate: "{Timestamp:dd.MM HH:mm:ss} [{Level}] {Message}{NewLine}{Exception}")
                         .WriteTo.File(path: Path.Combine("Logs", "log.txt"), outputTemplate: "{Timestamp:dd.MM.yyyy HH:mm:ss.fff} [{Level}] {Message}{NewLine}{Exception}", fileSizeLimitBytes: 20 * 1024 * 1024, rollOnFileSizeLimit: true, retainedFileCountLimit: null)
                         .CreateLogger();

            PluginManager.BeginInit(true);

            if (Environment.OSVersion.Platform == PlatformID.Unix)
            {
                SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_sqlite3());
                SQLitePCL.raw.FreezeProvider();
            }

            using (var context = new BotContext())
            {
                context.Database.Migrate();
                int count = context.Users.Count();
                Log.Information("{UserCount} Benutzer geladen!", count);
            }

            if (ServerManager.ConnectionCount == 0)
            {
                Console.WriteLine("Keine Verbindungen bekannt, starte Verbindungsassistent");
                AskConnection();
            }
            ServerManager.ConnectAll();

            Toolbox.SafeThreadStart("ConsolenThread", true, HandleConsoleInput);
        }