Пример #1
0
        public async Task SeedDatabase(CancellationToken cancellationToken)
        {
            try
            {
                List <Task> TaskList = new List <Task>();

                Task worldsTask = _worldService.RefreshStore(true, true);
                TaskList.Add(worldsTask);

                Task factionsTask = _factionService.RefreshStore(true, true);
                TaskList.Add(factionsTask);

                Task itemsTask = _itemService.RefreshStore(true, true);
                TaskList.Add(itemsTask);

                Task itemCategoriesTask = _itemCategoryService.RefreshStore(true, true);
                TaskList.Add(itemCategoriesTask);

                Task zoneTask = _zoneService.RefreshStore(true, true);
                TaskList.Add(zoneTask);

                Task profileTask = _profileService.RefreshStore(true, true);
                TaskList.Add(profileTask);

                Task loadoutsTask = _loadoutService.RefreshStore(true, true);
                TaskList.Add(loadoutsTask);

                Task scrimActionTask = _rulesetManager.SeedScrimActionModels();
                TaskList.Add(scrimActionTask);

                Task facilitiesTask = _facilityService.RefreshStore(true, true);
                TaskList.Add(facilitiesTask);

                Task facilityTypesTask = _facilityTypeService.RefreshStore(true, true);
                TaskList.Add(facilityTypesTask);

                Task vehicleTask = _vehicleService.RefreshStore(true, false);
                TaskList.Add(vehicleTask);

                Task vehicleTypeTask = _vehicleTypeService.SeedVehicleClasses();
                TaskList.Add(vehicleTypeTask);

                Task deathTypeTask = _deathTypeService.SeedDeathTypes();
                TaskList.Add(deathTypeTask);

                await Task.WhenAll(TaskList);

                _sqlScriptRunner.RunSqlDirectoryScripts("Views");

                _logger.LogInformation($"Compiled all SQL Views");

                cancellationToken.ThrowIfCancellationRequested();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Failed to seed database: {ex}");
            }
        }
Пример #2
0
        public async Task OnApplicationStartup(CancellationToken cancellationToken)
        {
            List <Task> TaskList = new List <Task>();

            Task worldsTask = _worldService.RefreshStore(true, true);

            TaskList.Add(worldsTask);

            Task factionsTask = _factionService.RefreshStore(true, true);

            TaskList.Add(factionsTask);

            Task itemsTask = _itemService.RefreshStore(true, true);

            TaskList.Add(itemsTask);

            Task itemCategoriesTask = _itemCategoryService.RefreshStore(true, true);

            TaskList.Add(itemCategoriesTask);

            Task zoneTask = _zoneService.RefreshStore(true, true);

            TaskList.Add(zoneTask);

            Task profileTask = _profileService.RefreshStore(true, true);

            TaskList.Add(profileTask);

            Task loadoutsTask = _loadoutService.RefreshStore(true, true);

            TaskList.Add(loadoutsTask);

            Task scrimActionTask = _rulesetManager.SeedScrimActionModels();

            TaskList.Add(scrimActionTask);

            Task facilitiesTask = _facilityService.RefreshStore(true, true);

            TaskList.Add(facilitiesTask);

            Task facilityTypesTask = _facilityTypeService.RefreshStore(true, true);

            TaskList.Add(facilityTypesTask);

            Task vehicleTask = _vehicleService.RefreshStore(true, false);

            TaskList.Add(vehicleTask);

            Task vehicleTypeTask = _vehicleTypeService.SeedVehicleClasses();

            TaskList.Add(vehicleTypeTask);

            Task deathTypeTask = _deathTypeService.SeedDeathTypes();

            TaskList.Add(deathTypeTask);

            await Task.WhenAll(TaskList);

            await _rulesetManager.SeedDefaultRuleset();

            _sqlScriptRunner.RunSqlDirectoryScripts("Views");
        }