|
- using DataVAPI.ModelDataBus;
- using DataVAPI.Tool.IOT;
- using System.Collections.Generic;
- using Tea;
- using static AlibabaCloud.SDK.Iot20180120.Models.QueryDeviceFileResponseBody;
-
- namespace DataVAPI.UpAndDown
- {
- public class Sample
- {
-
- /**
- * 使用AK&SK初始化账号Client
- * @param accessKeyId
- * @param accessKeySecret
- * @return Client
- * @throws Exception
- */
- public static AlibabaCloud.SDK.Iot20180120.Client CreateClient(string accessKeyId, string accessKeySecret)
- {
- AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
- {
- // 您的AccessKey ID
- AccessKeyId = accessKeyId,
- // 您的AccessKey Secret
- AccessKeySecret = accessKeySecret,
- };
- // 访问的域名
- config.Endpoint = "iot.cn-shanghai.aliyuncs.com";
- return new AlibabaCloud.SDK.Iot20180120.Client(config);
- }
-
- public static List<QueryDeviceFileResponseBodyData> FileQueryALL(string DeviceName)
- {
- List<QueryDeviceFileResponseBodyData> retdata=new List<QueryDeviceFileResponseBodyData>();
- AlibabaCloud.SDK.Iot20180120.Client client = CreateClient("LTAI5tDbUDuCvqU5hP8ZpHHV", "SvNIRQuz3BQFEaC3PFSJdgpeOKWFRi");
- AlibabaCloud.SDK.Iot20180120.Models.QueryDeviceFileListRequest queryDeviceFileListRequest = new AlibabaCloud.SDK.Iot20180120.Models.QueryDeviceFileListRequest
- {
- IotInstanceId = "iot-06z00g9pf3kwtxp",
- ProductKey = DataBus.ProductKey,
- DeviceName = DeviceName,
- };
- AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
- AlibabaCloud.SDK.Iot20180120.Models.QueryDeviceFileListResponse resp = client.QueryDeviceFileListWithOptions(queryDeviceFileListRequest, runtime);
- //AlibabaCloud.TeaConsole.Client.Log();
- //;
- AlibabaCloudRes cloudRes= Tools.JsonToObjectTools<AlibabaCloudRes>(AlibabaCloud.TeaUtil.Common.ToJSONString(resp.ToMap()));
- cloudRes?.body?.Data?.FileSummary?.ForEach(fileSummary =>
- {
- QueryDeviceFileResponseBodyData _data= FileQuery(DeviceName,fileSummary.FileId);
- if (_data != null)
- {
- retdata.Add(_data);
- }
- });
- return retdata;
- }
-
- public static QueryDeviceFileResponseBodyData FileQuery(string DeviceName,string FileId)
- {
- AlibabaCloud.SDK.Iot20180120.Client client = CreateClient("LTAI5tDbUDuCvqU5hP8ZpHHV", "SvNIRQuz3BQFEaC3PFSJdgpeOKWFRi");
- AlibabaCloud.SDK.Iot20180120.Models.QueryDeviceFileRequest queryDeviceFileRequest = new AlibabaCloud.SDK.Iot20180120.Models.QueryDeviceFileRequest
- {
- IotInstanceId = "iot-06z00g9pf3kwtxp",
- DeviceName = DeviceName,
- ProductKey = DataBus.ProductKey,
- FileId = FileId,
- };
- AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
- // 复制代码运行请自行打印 API 的返回值
- QueryDeviceFileResponseBodyData queryDeviceFile= client.QueryDeviceFileWithOptions(queryDeviceFileRequest, runtime).Body.Data;
- return queryDeviceFile;
- }
-
- }
-
- public class AlibabaCloudRes
- {
- public object headers { get; set; }
- public StrRes body { get; set; }
- }
- public class StrRes
- {
- public string code { get; set; }
- public string CurrentPage { get; set; }
- public ResData Data { get; set; }
- public string ErrorMessage { get; set; }
- public int PageCount { get; set; }
- public int PageSize { get; set; }
- public string RequestId { get; set; }
- public bool Success { get; set; }
- public int Total { get; set; }
- }
- public class ResData
- {
- public List<summary> FileSummary { get; set; }
- }
- public class summary
- {
- public string UtcCreatedOn { get; set; }
- public string Size { get; set; }
- public string FileId { get; set; }
- public string Name { get; set; }
- }
- }
|