/// <summary> /// Removes the rendered city /// </summary> public void DestroyEnviroment() { Destroy(GameObject.FindGameObjectWithTag("Enviroment")); enviromentExist = false; toLoadProjectKey = ""; cityLoadingState = CityLoadingState.NotReady; LoadLocalProject(); }
/// <summary> /// Select the local project as to render /// </summary> /// <param name="projectKey">SonarQube Project Key</param> /// <exception cref="ArgumentException">If the key does't match the local project</exception> public void SelectLocalProject(string projectKey) { ProjectComponent p = model.GetTree(); if (p == null || p.Key != projectKey) { throw new ArgumentException("The requested project is not locally available"); } cityLoadingState = CityLoadingState.Ready; toLoadProjectKey = projectKey; }
/// <summary> /// If the second metric is selected this method should be called. This starts the request for the city to load. /// </summary> public void SecondMetricSelected() { // The CityLoadingState is Ready if the local project is requested // If the baseUrl is set the credentials are valid if (cityLoadingState != CityLoadingState.Ready && model.GetBaseUrl() != null) { model.DeleteTree(); LoadOnlineProject(toLoadProjectKey, 1); cityLoadingState = CityLoadingState.Ready; } }
/// <summary> /// Requests all project components and their metrics from the sonarqube api /// </summary> /// <param name="projectKey">SonarQube Project Key</param> /// <param name="page">The page of the request, should be 1. /// The other calls are recursive in the method.</param> private void LoadOnlineProject(string projectKey, int page) { SqComponentTreeUriBuilder uriBuilder = new SqComponentTreeUriBuilder(model.GetBaseUrl(), projectKey, model.GetAvailableMetricsAsString()); if (model.GetUsername() != "" && model.GetPassword() != "") { uriBuilder.UserCredentials(model.GetUsername(), model.GetPassword()); } StartCoroutine(WebInterface.WebRequest <ComponentTree>( uriBuilder.Page(page).GetSqUri(), (res, err) => { switch (err) { case 200: model.BuildProjectTree(res.baseComponent, res.components); int TotalNumOfPages = res.paging.total / res.paging.pageSize + 1; if (page < TotalNumOfPages) { LoadOnlineProject(projectKey, page + 1); } else { if (cityLoadingState != CityLoadingState.LodingError) { cityLoadingState = CityLoadingState.Ready; } ComponentTreeStream.SaveProjectComponent(model.GetTree()); } break; default: Debug.Log("Addyi ResponseCode: " + err); cityLoadingState = CityLoadingState.LodingError; break; } })); }