Esempio n. 1
0
        static void AddDomainRecord()
        {
            //Init Api
            AliyunDnsApi request = new AliyunDnsApi();

            //Init DescribeDomainRecords object
            IAddDomainRecord describeDomainRecords = new IAddDomainRecord()
            {
                DomainName = "quarkbook.com",
                RR         = "yr",
                Type       = ResolveLogFormat.A,
                Value      = "1.1.1.1"
            };

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

            if (domain != null)
            {
                Console.WriteLine("添加成功!");
            }
            else
            {
                Console.WriteLine("添加失败!");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 添加新纪录
        /// </summary>
        /// <param name="domain"></param>
        /// <param name="ip"></param>
        /// <returns></returns>
        private RecordType AddDomainRecords(string domain, string ip)
        {
            string     rr = domain.Split('.')[0], domainBody = GetDomainByUrl(domain);
            RecordType recordType = null;

            try
            {
                IAddDomainRecord addDomain = new IAddDomainRecord()
                {
                    DomainName = domainBody,
                    RR         = rr,
                    Type       = AliyunDnsSDK.Model.EnumType.ResolveLogFormat.A,
                    Value      = ip
                };
                AddDomainRecordResult result = api.Request <AddDomainRecordResult>(addDomain);
                if (result != null)
                {
                    recordType = new RecordType()
                    {
                        RecordId = result.RecordId
                    };
                    return(recordType);
                }
                else
                {
                    return(null);
                }
            }
            catch
            {
                return(null);
            }
        }