示例#1
0
        /// <summary>
        /// Fetch json array from the server.
        /// As JsonUtility can't directly read array json, this method wraps the array json to read correctly.
        /// </summary>
        /// <typeparam name="T">array element model type</typeparam>
        /// <param name="logTitle">title for logging</param>
        /// <param name="fetchCoroutine">coroutine to access api</param>
        /// <returns></returns>
        List <T> FetchArrayFromServer <T>(string logTitle, IEnumerator fetchCoroutine)
        {
            var api = new CloudBuildApi(settings);

            while (fetchCoroutine.MoveNext())
            {
                Debug.Log("FetchArrayFromServer: " + logTitle + " Current: " + fetchCoroutine.Current);
            }
            if ((string)fetchCoroutine.Current != "error")
            {
                var json = (string)fetchCoroutine.Current;
                Debug.Log("FetchArrayFromServer: " + logTitle + " json:" + json);
                var modifiedJson = "{ \"items\":" + json + "}";
                var result       = JsonUtility.FromJson <GenericArrayResponseModel <T> >(modifiedJson);
                if (result == null || result.items == null)
                {
                    Debug.LogError("FetchArrayFromServer: " + logTitle + ": result is null.");
                    return(null);
                }
                return(result.items);
            }
            else
            {
                throw new Exception("FetchArrayFromServer: " + logTitle + ": failed.");
            }
        }
示例#2
0
        List <BuildTargetModel> FetchBuildTargets()
        {
            var         api            = new CloudBuildApi(settings);
            IEnumerator fetchCoroutine = api.ListBuildTargets();
            var         targets        = FetchArrayFromServer <BuildTargetModel>("fetch build targets", fetchCoroutine);

            return(targets);
        }
示例#3
0
        private List <ProjectModel> FetchAllProjects()
        {
            var         api            = new CloudBuildApi(settings);
            IEnumerator fetchCoroutine = api.ListAllProjects();
            var         projects       = FetchArrayFromServer <ProjectModel>("fetch all projects", fetchCoroutine);

            return(projects);
        }
示例#4
0
        void AdjustAndLaunchConfig(string targetId)
        {
            var api = new CloudBuildApi(settings);

            if (changeBranch)
            {
                // Adjust Config
                Debug.Log("Adjust config for target: " + targetId + " branch: " + branchName);
                IEnumerator co = api.ChangeConfigBranch(targetId, branchName);
                while (co.MoveNext())
                {
                    Debug.Log("Current: " + co.Current);
                }
                if ((string)co.Current == "true")
                {
                    // success
                    status += "adjusting target:" + targetId + " succeeded.\n";
                }
                else
                {
                    // failure
                    var msg = "adjusting target:" + targetId + " failed.\n";
                    status += msg;
                    throw new Exception(msg);
                }
            }

            // Launch the build
            Debug.Log("Launching target: " + targetId);
            IEnumerator coLaunch = api.LaunchBuild(targetId);

            while (coLaunch.MoveNext())
            {
                Debug.Log("Current: " + coLaunch.Current);
            }
            if ((string)coLaunch.Current == "true")
            {
                // success
                status += "start building target:" + targetId + " succeeded.\n";
            }
            else
            {
                // failure
                var msg = "start building target:" + targetId + " failed.\n";
                status += msg;
                throw new Exception(msg);
            }
        }