コード例 #1
0
ファイル: Client.cs プロジェクト: aliyun/dingtalk-sdk
        public async Task <BatchRegisterDeviceResponse> BatchRegisterDeviceAsync(BatchRegisterDeviceRequest request)
        {
            AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
            BatchRegisterDeviceHeaders headers = new BatchRegisterDeviceHeaders();

            return(await BatchRegisterDeviceWithOptionsAsync(request, headers, runtime));
        }
コード例 #2
0
ファイル: Client.cs プロジェクト: aliyun/dingtalk-sdk
        public BatchRegisterDeviceResponse BatchRegisterDeviceWithOptions(BatchRegisterDeviceRequest request, BatchRegisterDeviceHeaders headers, AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime)
        {
            AlibabaCloud.TeaUtil.Common.ValidateModel(request);
            Dictionary <string, object> body = new Dictionary <string, object>()
            {
            };

            if (!AlibabaCloud.TeaUtil.Common.IsUnset(request.CorpId))
            {
                body["corpId"] = request.CorpId;
            }
            if (!AlibabaCloud.TeaUtil.Common.IsUnset(request.Devices))
            {
                body["devices"] = request.Devices;
            }
            Dictionary <string, string> realHeaders = new Dictionary <string, string>()
            {
            };

            if (!AlibabaCloud.TeaUtil.Common.IsUnset(headers.CommonHeaders))
            {
                realHeaders = headers.CommonHeaders;
            }
            if (!AlibabaCloud.TeaUtil.Common.IsUnset(headers.XAcsDingtalkAccessToken))
            {
                realHeaders["x-acs-dingtalk-access-token"] = AlibabaCloud.TeaUtil.Common.ToJSONString(headers.XAcsDingtalkAccessToken);
            }
            AlibabaCloud.OpenApiClient.Models.OpenApiRequest req = new AlibabaCloud.OpenApiClient.Models.OpenApiRequest
            {
                Headers = realHeaders,
                Body    = AlibabaCloud.OpenApiUtil.Client.ParseToMap(body),
            };
            return(TeaModel.ToObject <BatchRegisterDeviceResponse>(DoROARequest("BatchRegisterDevice", "diot_1.0", "HTTP", "POST", "AK", "/v1.0/diot/devices/registrations/batch", "json", req, runtime)));
        }
コード例 #3
0
ファイル: Client.cs プロジェクト: aliyun/dingtalk-sdk
        public BatchRegisterDeviceResponse BatchRegisterDevice(BatchRegisterDeviceRequest request)
        {
            AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
            BatchRegisterDeviceHeaders headers = new BatchRegisterDeviceHeaders();

            return(BatchRegisterDeviceWithOptions(request, headers, runtime));
        }
コード例 #4
0
        //批量注册设备,最多一次创建1000台设备,设备名称随机生成
        public void TestBatchRegisterDevice()
        {
            DefaultAcsClient acsClient = Demo.IotClient.GetClient();

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

            request1.ProductKey = productKey;
            request1.Count      = 10;

            //Step1 创建申请单,返回applyId
            BatchRegisterDeviceResponse response1 = acsClient.GetAcsResponse(request1);

            Console.WriteLine("Batch Register: " + response1.Success);
            if (!(bool)response1.Success)
            {
                Console.WriteLine(response1.Code + ", " + response1.ErrorMessage);
            }
            long applyId = (long)response1.Data.ApplyId;

            Console.WriteLine("ApplyId: " + applyId);

            String Status = "CHECK_FAILED";

            while (true)
            {
                //轮询申请单的检查进度,如果检查正常通过,则可以量产设备
                QueryBatchRegisterDeviceStatusRequest request2 = new QueryBatchRegisterDeviceStatusRequest();
                request2.ApplyId    = applyId;
                request2.ProductKey = productKey;

                QueryBatchRegisterDeviceStatusResponse response2 = acsClient.GetAcsResponse(request2);

                if (!(bool)response2.Success)
                {
                    Console.WriteLine(response2.Code + ", " + response2.ErrorMessage);
                    break;
                }
                QueryBatchRegisterDeviceStatusResponse.QueryBatchRegisterDeviceStatus_Data data = response2.Data;
                Status = data.Status;
                Console.WriteLine("Query Status: " + response2.Success + ", " + Status);
                if ("CREATE_SUCCESS".Equals(Status))
                {
                    break;
                }
                else
                {
                    Thread.Sleep(1000);
                }
            }

            if ("CREATE_SUCCESS".Equals(Status))
            {
                QueryPageByApplyIdRequest request3 = new QueryPageByApplyIdRequest();
                request3.ApplyId     = applyId;
                request3.CurrentPage = 1;
                request3.PageSize    = 10;

                QueryPageByApplyIdResponse response3 = acsClient.GetAcsResponse(request3);
                Console.WriteLine("Query With ApplyId: " + response3.Success);
                if (!(bool)response3.Success)
                {
                    Console.WriteLine(response3.Code + ", " + response3.ErrorMessage);
                }
                Console.WriteLine("Page: " + response3.Page);
                Console.WriteLine("PageSize: " + response3.PageSize);
                Console.WriteLine("PageCount: " + response3.PageCount);
                Console.WriteLine("Total: " + response3.Total);
            }
        }