Beispiel #1
0
 /// <summary>
 /// Load local stored project tree
 /// </summary>
 private void LoadLocalProject()
 {
     try
     {
         ProjectComponent tree = ComponentTreeStream.LoadProjectComponent();
         model.SetTree(tree);
     }
     catch (Exception e)
     {
         Debug.Log("Not able to load Project from disk: " + e.Message);
         model.SetTree(null);
     }
 }
Beispiel #2
0
        /// <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;
                }
            }));
        }