Exemple #1
0
        public async Task <IHttpActionResult> PostLastBuilds(GetLastBuildsRequest request)
        {
            var result = new List <BuildModel>();

            if (request == null || request.BuildTypeIds == null)
            {
                return(Ok(result));
            }

            foreach (var buildTypeId in request.BuildTypeIds)
            {
                var model = new BuildModel();
                try
                {
                    var buildDto = await _apiClient.GetLastBuildsForBuildTypeAsync(buildTypeId);

                    if (buildDto == null)
                    {
                        continue;
                    }
                    var build = buildDto.Build.FirstOrDefault();

                    if (build == null)
                    {
                        continue;
                    }

                    model.Id          = build.Id;
                    model.Number      = build.Number;
                    model.BuildTypeId = build.BuildTypeId;
                    model.Status      = build.Status;
                    model.StatusText  = build.StatusText;
                    model.WebUrl      = build.WebUrl;
                    model.FinishDate  = build.FinishDate;
                    model.StartDate   = build.StartDate;

                    result.Add(model);
                }
                catch
                {
                    result.Add(new BuildModel {
                        BuildTypeId = buildTypeId, Status = "Failed to update"
                    });
                }
            }
            return(Ok(result));
        }
Exemple #2
0
        public IHttpActionResult GetBuild(string id)
        {
            try
            {
                var build = _apiClient.GetBuild(id);
                var model = new BuildModel();
                if (build == null)
                {
                    return(Ok(model));
                }
                model.Id          = build.Id;
                model.Number      = build.Number;
                model.BuildTypeId = build.BuildType.Id;

                if (build.RunningInfo != null)
                {
                    model.RunningInfo = new RunningInfoModel
                    {
                        PercentageComplete = build.RunningInfo.PercentageComplete,
                        CurrentStageText   = build.RunningInfo.CurrentStageText
                    };
                }

                model.Status     = build.Status;
                model.StatusText = build.StatusText;
                model.WebUrl     = build.WebUrl;
                model.StartDate  = build.StartDate;
                model.FinishDate = build.FinishDate;

                return(Ok(model));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Exemple #3
0
 public BuildTypeModel()
 {
     LastBuild = new BuildModel();
 }