Ejemplo n.º 1
0
        public void Can_Get_All_Active_Instances()
        {
            int[] ids = { 1051, 1052, 1063 };

            foreach (int id in ids)
            {
                Scaffold.Instances(1, nodeId: id);
            }

            Dictionary <int, bool> results = _service.IsActive(ids);

            Assert.True(results[ids[0]]);
            Assert.True(results[ids[1]]);
            Assert.True(results[ids[2]]);

            // try again, but with two ids with no attached instance
            int[] moreIds = { 1051, 3333, 4444 };
            results = _service.IsActive(moreIds);

            Assert.True(results[moreIds[0]]);
            Assert.False(results[moreIds[1]]);
            Assert.False(results[moreIds[2]]);
        }
Ejemplo n.º 2
0
        public IHttpActionResult GetStatus(string ids)
        {
            try
            {
                string[]          stringArray = ids.Split(',');
                IEnumerable <int> intArray    = stringArray
                                                .Select(s => int.TryParse(s, out int x) ? x : 0)
                                                .Where(x => x > 0);

                Dictionary <int, bool> nodes = _instancesService.IsActive(intArray);

                return(Json(new
                {
                    nodes
                }, ViewHelpers.CamelCase));
            }
            catch (Exception ex)
            {
                string msg = $"Error getting status for node id: {string.Join(",", ids)}";
                Log.Error(msg, ex);
                return(Content(HttpStatusCode.InternalServerError, ViewHelpers.ApiException(ex, msg)));
            }
        }