public OctoRepository(ServerInstanceElement instance) { ApiUri = instance.ApiUri.TrimEnd('/'); var endpoint = new OctopusServerEndpoint(ApiUri, instance.ApiKey); var client = new OctopusClient(endpoint); _repository = new OctopusRepository(client); SystemInfoResource systemInfo; try { ServerStatusResource serverStatus = _repository.ServerStatus.GetServerStatus(); systemInfo = _repository.ServerStatus.GetSystemInfo(serverStatus); } catch (OctopusException ex) { throw; } Version = new SemanticVersion(systemInfo.Version); using (var databaseModel = new DatabaseModel()) { OctopusServer octopusServer = databaseModel.OctopusServers.SingleOrDefault(octo => octo.ApiUri == ApiUri); if (octopusServer == null) { octopusServer = new OctopusServer(); octopusServer.ApiUri = ApiUri; octopusServer.DisplayName = ApiUri; databaseModel.OctopusServers.Add(octopusServer); databaseModel.SaveChanges(); } OctopusServerId = octopusServer.Id; } }
public SqlRepository() { _model = new DatabaseModel(); }