Пример #1
0
        private static async Task <bool> CheckForDatabaseUpdatesAsync()
        {
            try
            {
                await using var ctx = new UchuContext();

                await ctx.EnsureUpdatedAsync();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Пример #2
0
        private static async Task Main(string[] args)
        {
            await OpenConfig();

            await using (var ctx = new UchuContext())
            {
                Logger.Information("Checking for database updates...");

                await ctx.EnsureUpdatedAsync();

                Logger.Information("Database up to date...");

                foreach (var specification in ctx.Specifications)
                {
                    ctx.Specifications.Remove(specification);
                }

                foreach (var request in ctx.WorldServerRequests)
                {
                    ctx.WorldServerRequests.Remove(request);
                }

                foreach (var session in ctx.SessionCaches)
                {
                    ctx.SessionCaches.Remove(session);
                }

                await ctx.SaveChangesAsync();
            }

            await StartAuthentication();
            await StartCharacter();

            Console.CancelKeyPress += ShutdownProcesses;

            AppDomain.CurrentDomain.ProcessExit += ShutdownProcesses;

            Running = true;

            await HandleRequests();
        }