コード例 #1
0
        public async Task <IHttpActionResult> GetState(string id)
        {
            // @TODO: Yeah, way too much going on in here. Farm all this off to another service or something.
            var states = new List <ElementState>();

            var dashboard = await _dashRepo.GetDashboardAsync(id);

            if (dashboard == null)
            {
                return(NotFound());
            }

            // Get all tests for dashboard
            if (dashboard.Tests != null)
            {
                states.AddRange(_testRunner.GetTestResults(dashboard.Tests.Select(t => t.Id)).Select(x => new ElementState(x.Id, x.Id)
                {
                    Output    = x.Output,
                    Status    = x.Status,
                    Timestamp = x.Timestamp
                }));
            }

            // Sort out the argos stuff
            if (dashboard.Argos != null)
            {
                foreach (var a in dashboard.Argos)
                {
                    var rs = await _argosRunner.GetState(a.Id);

                    if (rs != null)
                    {
                        states.AddRange(rs.Items);
                    }
                }
            }

            return(Ok(states));
        }