public async Task ImportCkAsync(string tenantId, string key, ScopeIdsDto scopeId, IJobCancellationToken cancellationToken) { try { if (scopeId == ScopeIdsDto.System) { throw new InvalidOperationException("Scope SYSTEM cannot be imported, because this scope is handled by system."); } Logger.Info($"Reading input file from cache for CK import to '{tenantId}'"); var tempFile = await GetTempFile(key); Logger.Info($"Starting import of file '{tempFile}'"); using var systemSession = await _systemContext.StartSystemSessionAsync(); systemSession.StartTransaction(); await _systemContext.ImportCkModelAsync(systemSession, tenantId, (ScopeIds)scopeId, tempFile, cancellationToken.ShutdownToken); await systemSession.CommitTransactionAsync(); await ClearCache(key); Logger.Info($"Import of file '{tempFile}' completed."); } catch (Exception e) { Logger.Error(e, "Import failed with error."); throw; } }