Ejemplo n.º 1
0
        //获取网关设备的拓扑结构(子设备列表)
        public void TestGetThingTopo()
        {
            DefaultAcsClient acsClient = Demo.IotClient.GetClient();

            //网关设备
            String gwProductKey         = "<productKey>";
            String gwDevicename         = "device_0821_148";
            GetThingTopoRequest request = new GetThingTopoRequest();

            request.ProductKey = gwProductKey;
            request.DeviceName = gwDevicename;
            request.PageNo     = 1;
            request.PageSize   = 10;

            GetThingTopoResponse response = acsClient.GetAcsResponse(request);

            Console.WriteLine("Get ThingTopo: " + response.Success);
            if (!(bool)response.Success)
            {
                Console.WriteLine(response.Code + ", " + response.ErrorMessage);
            }

            GetThingTopoResponse.GetThingTopo_Data Data = response.Data;
            Console.WriteLine("Page: " + Data.CurrentPage);
            Console.WriteLine("PageSize: " + Data.PageSize);
            Console.WriteLine("PageCount: " + Data.PageCount);
            Console.WriteLine("Total: " + Data.Total);
        }
        public static GetThingTopoResponse Unmarshall(UnmarshallerContext context)
        {
            GetThingTopoResponse getThingTopoResponse = new GetThingTopoResponse();

            getThingTopoResponse.HttpResponse = context.HttpResponse;
            getThingTopoResponse.RequestId    = context.StringValue("GetThingTopo.RequestId");
            getThingTopoResponse.Success      = context.BooleanValue("GetThingTopo.Success");
            getThingTopoResponse.Code         = context.StringValue("GetThingTopo.Code");
            getThingTopoResponse.ErrorMessage = context.StringValue("GetThingTopo.ErrorMessage");

            GetThingTopoResponse.GetThingTopo_Data data = new GetThingTopoResponse.GetThingTopo_Data();
            data.Total       = context.LongValue("GetThingTopo.Data.Total");
            data.CurrentPage = context.IntegerValue("GetThingTopo.Data.CurrentPage");
            data.PageSize    = context.IntegerValue("GetThingTopo.Data.PageSize");
            data.PageCount   = context.LongValue("GetThingTopo.Data.PageCount");

            List <GetThingTopoResponse.GetThingTopo_Data.GetThingTopo_DeviceInfo> data_list = new List <GetThingTopoResponse.GetThingTopo_Data.GetThingTopo_DeviceInfo>();

            for (int i = 0; i < context.Length("GetThingTopo.Data.List.Length"); i++)
            {
                GetThingTopoResponse.GetThingTopo_Data.GetThingTopo_DeviceInfo deviceInfo = new GetThingTopoResponse.GetThingTopo_Data.GetThingTopo_DeviceInfo();
                deviceInfo.IotId      = context.StringValue("GetThingTopo.Data.List[" + i + "].IotId");
                deviceInfo.ProductKey = context.StringValue("GetThingTopo.Data.List[" + i + "].ProductKey");
                deviceInfo.DeviceName = context.StringValue("GetThingTopo.Data.List[" + i + "].DeviceName");

                data_list.Add(deviceInfo);
            }
            data.List = data_list;
            getThingTopoResponse.Data = data;

            return(getThingTopoResponse);
        }