Ejemplo n.º 1
0
        static void ShowDescribeDomainRecordsList()
        {
            //Init Api
            AliyunDnsApi request = new AliyunDnsApi();

            //Init DescribeDomainRecords object
            IDescribeDomainRecords describeDomainRecords = new IDescribeDomainRecords()
            {
                DomainName = "quarkbook.com",
            };

            //Get and out result
            DomainRecords domain = new DomainRecords();

            domain = request.Request <DescribeDomainRecordsResult>(describeDomainRecords).DomainRecords; //泛型参数为Result实体模型

            if (domain != null && domain.Record.Count > 0)
            {
                foreach (var item in domain.Record)
                {
                    Console.WriteLine(item.RecordId + "\t" + item.DomainName + "\t" + item.Status + "\t" + item.RR + "\t" + item.Value);
                }
            }
            else
            {
                Console.WriteLine("请求失败!");
            }
            Console.WriteLine();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 查找相关的记录
        /// </summary>
        /// <param name="domain"></param>
        /// <returns></returns>
        private RecordType GetDomainRecords(string domain)
        {
            int               pageSize = 500, pageNumber = 1;
            string            rr = domain.Split('.')[0], domainBody = GetDomainByUrl(domain);
            bool              isNeedBreak = false;
            List <RecordType> recordType  = null;

            try
            {
                do
                {
                    IDescribeDomainRecords request = new IDescribeDomainRecords()
                    {
                        DomainName = domainBody,
                        PageSize   = pageSize,
                        PageNumber = pageNumber,
                    };
                    DescribeDomainRecordsResult result = api.Request <DescribeDomainRecordsResult>(request);
                    if ((recordType = result.DomainRecords.Record.FindAll(p => p.RR == rr)) == null)
                    {
                        if (result.TotalCount <= request.PageSize)
                        {
                            isNeedBreak = true;
                        }
                        else if (result.TotalCount > request.PageSize)
                        {
                            pageNumber++;
                            continue;
                        }
                    }
                    else
                    {
                        isNeedBreak = true;
                    }
                } while (!isNeedBreak);

                return(recordType[0]);
            }
            catch
            {
                return(null);
            }
        }