Example #1
0
        public static BatchUpdateDeviceNicknameResponse Unmarshall(UnmarshallerContext context)
        {
            BatchUpdateDeviceNicknameResponse batchUpdateDeviceNicknameResponse = new BatchUpdateDeviceNicknameResponse();

            batchUpdateDeviceNicknameResponse.HttpResponse = context.HttpResponse;
            batchUpdateDeviceNicknameResponse.RequestId    = context.StringValue("BatchUpdateDeviceNickname.RequestId");
            batchUpdateDeviceNicknameResponse.Success      = context.BooleanValue("BatchUpdateDeviceNickname.Success");
            batchUpdateDeviceNicknameResponse.Code         = context.StringValue("BatchUpdateDeviceNickname.Code");
            batchUpdateDeviceNicknameResponse.ErrorMessage = context.StringValue("BatchUpdateDeviceNickname.ErrorMessage");

            return(batchUpdateDeviceNicknameResponse);
        }
        //批量更新多个设备的nickname
        public void TestBatchUpdateDeviceNickname()
        {
            DefaultAcsClient acsClient = Demo.IotClient.GetClient();

            String productKey = "<productKey>";
            BatchUpdateDeviceNicknameRequest request1 = new BatchUpdateDeviceNicknameRequest();

            List <BatchUpdateDeviceNicknameRequest.DeviceNicknameInfo> DeviceNicknameInfos = new List <BatchUpdateDeviceNicknameRequest.DeviceNicknameInfo>();

            BatchUpdateDeviceNicknameRequest.DeviceNicknameInfo deviceNickname1 = new BatchUpdateDeviceNicknameRequest.DeviceNicknameInfo();
            deviceNickname1.ProductKey = productKey;
            deviceNickname1.DeviceName = "device_0821_147";
            deviceNickname1.Nickname   = "nick147";
            DeviceNicknameInfos.Add(deviceNickname1);


            BatchUpdateDeviceNicknameRequest.DeviceNicknameInfo deviceNickname2 = new BatchUpdateDeviceNicknameRequest.DeviceNicknameInfo();
            deviceNickname2.ProductKey = productKey;
            deviceNickname2.DeviceName = "device_0821_148";
            deviceNickname2.Nickname   = "nick148";
            DeviceNicknameInfos.Add(deviceNickname2);
            request1.DeviceNicknameInfos = DeviceNicknameInfos;


            BatchUpdateDeviceNicknameResponse response1 = acsClient.GetAcsResponse(request1);

            Console.WriteLine("Update DeviceNickname: " + response1.Success);
            if (!(bool)response1.Success)
            {
                Console.WriteLine(response1.Code + ", " + response1.ErrorMessage);
            }

            QueryDeviceDetailRequest request2 = new QueryDeviceDetailRequest();

            request2.ProductKey = productKey;
            request2.DeviceName = deviceNickname1.DeviceName;

            QueryDeviceDetailResponse response2 = acsClient.GetAcsResponse(request2);

            Console.WriteLine(response2.Success);
            Console.WriteLine(response2.ErrorMessage);

            QueryDeviceDetailResponse.QueryDeviceDetail_Data DeviceInfo = response2.Data;
            Console.WriteLine("productKey: " + DeviceInfo.ProductKey);
            Console.WriteLine("deviceName: " + DeviceInfo.DeviceName);
            Console.WriteLine("iotId: " + DeviceInfo.IotId);
            Console.WriteLine("Nickname: " + DeviceInfo.Nickname);
        }