Ejemplo n.º 1
0
        //根据产品PK和设备名称获取设备详细信息
        private static void TestQueryDeviceByName()
        {
            IClientProfile clientProfile = DefaultProfile.GetProfile("<your-region-id>", "<your-access-key-id>", "<your-access-key-secret>");

            DefaultAcsClient client = new DefaultAcsClient(clientProfile);

            QueryDeviceByNameRequest request = new QueryDeviceByNameRequest();

            request.ProductKey = "<productKey>";
            request.DeviceName = "<deviceName>";

            try
            {
                QueryDeviceByNameResponse response = client.GetAcsResponse(request);
                Console.WriteLine(response.Success);
                Console.WriteLine(response.ErrorMessage);
                QueryDeviceByNameResponse.QueryDeviceByName_DeviceInfo DeviceInfo = response.DeviceInfo;
                Console.WriteLine("productKey: " + DeviceInfo.ProductKey);
                Console.WriteLine("deviceName: " + DeviceInfo.DeviceName);
            }
            catch (ServerException e)
            {
                Console.WriteLine(e.ErrorCode);
                Console.WriteLine(e.ErrorMessage);
            }
            catch (ClientException e)
            {
                Console.WriteLine(e.ErrorCode);
                Console.WriteLine(e.ErrorMessage);
            }
            Console.ReadKey();
        }
Ejemplo n.º 2
0
        public static QueryDeviceByNameResponse Unmarshall(UnmarshallerContext context)
        {
            QueryDeviceByNameResponse queryDeviceByNameResponse = new QueryDeviceByNameResponse();

            queryDeviceByNameResponse.HttpResponse = context.HttpResponse;
            queryDeviceByNameResponse.RequestId    = context.StringValue("QueryDeviceByName.RequestId");
            queryDeviceByNameResponse.Success      = context.BooleanValue("QueryDeviceByName.Success");
            queryDeviceByNameResponse.ErrorMessage = context.StringValue("QueryDeviceByName.ErrorMessage");

            QueryDeviceByNameResponse.DeviceInfo_ deviceInfo = new QueryDeviceByNameResponse.DeviceInfo_();
            deviceInfo.DeviceId     = context.StringValue("QueryDeviceByName.DeviceInfo.DeviceId");
            deviceInfo.DeviceSecret = context.StringValue("QueryDeviceByName.DeviceInfo.DeviceSecret");
            deviceInfo.ProductKey   = context.StringValue("QueryDeviceByName.DeviceInfo.ProductKey");
            deviceInfo.DeviceStatus = context.StringValue("QueryDeviceByName.DeviceInfo.DeviceStatus");
            deviceInfo.DeviceName   = context.StringValue("QueryDeviceByName.DeviceInfo.DeviceName");
            deviceInfo.GmtCreate    = context.StringValue("QueryDeviceByName.DeviceInfo.GmtCreate");
            deviceInfo.GmtModified  = context.StringValue("QueryDeviceByName.DeviceInfo.GmtModified");
            queryDeviceByNameResponse.DeviceInfo = deviceInfo;

            return(queryDeviceByNameResponse);
        }