示例#1
0
        public async Task <List <ThingStatus> > updateCurrentStatus(int thingId, ThingStatus newStatus, bool recurrent = false)
        {
            var thingUpdateList = new List <int>();

            thingUpdateList.Add(thingId);
            if (recurrent)
            {
                for (int i = 0; i < thingUpdateList.Count; i++)
                {
                    var(childrenThings, status) = await _thingService.getChildrenThingList(thingUpdateList[i]);

                    if (status == HttpStatusCode.OK && childrenThings.Count != 0)
                    {
                        thingUpdateList.AddRange(childrenThings.Select(x => x.thingId));
                    }
                }
            }
            var returnstatusList = new List <ThingStatus>();

            foreach (var item in thingUpdateList)
            {
                var status = await updateThingCurrentStatus(item, JsonConvert.SerializeObject(newStatus));

                returnstatusList.Add(status);
            }
            return(returnstatusList);
        }