コード例 #1
0
        public async Task <IActionResult> ProcessEndDateTime()
        {
            // find userLabs that have an EndDateTime paste the current UtcDateTime.
            var userLabs = await DatabaseContext.UserLabs
                           .IncludeRelations()
                           .IncludeHypervisor()
                           .Include(l => l.UserLabVms)
                           .Include(l => l.BridgeInstances)
                           .Where(l => l.Status == EUserLabStatus.Started)
                           .Where(l => l.EndDateTime < DateTime.UtcNow)
                           .ToListAsync();


            // with the found items, destroy all vms and delete the UserLabVm rows.
            foreach (var userLab in userLabs)
            {
                await _instantiationService.Deconstruct(userLab, ProxmoxManager);
            }
            return(Ok());
        }