public static DescribeSubDomainRecordsResponse Unmarshall(UnmarshallerContext context)
        {
            DescribeSubDomainRecordsResponse describeSubDomainRecordsResponse = new DescribeSubDomainRecordsResponse();

            describeSubDomainRecordsResponse.HttpResponse = context.HttpResponse;
            describeSubDomainRecordsResponse.RequestId    = context.StringValue("DescribeSubDomainRecords.RequestId");
            describeSubDomainRecordsResponse.TotalCount   = context.LongValue("DescribeSubDomainRecords.TotalCount");
            describeSubDomainRecordsResponse.PageNumber   = context.LongValue("DescribeSubDomainRecords.PageNumber");
            describeSubDomainRecordsResponse.PageSize     = context.LongValue("DescribeSubDomainRecords.PageSize");

            List <DescribeSubDomainRecordsResponse.DescribeSubDomainRecords_Record> describeSubDomainRecordsResponse_domainRecords = new List <DescribeSubDomainRecordsResponse.DescribeSubDomainRecords_Record>();

            for (int i = 0; i < context.Length("DescribeSubDomainRecords.DomainRecords.Length"); i++)
            {
                DescribeSubDomainRecordsResponse.DescribeSubDomainRecords_Record record = new DescribeSubDomainRecordsResponse.DescribeSubDomainRecords_Record();
                record.DomainName = context.StringValue("DescribeSubDomainRecords.DomainRecords[" + i + "].DomainName");
                record.RecordId   = context.StringValue("DescribeSubDomainRecords.DomainRecords[" + i + "].RecordId");
                record.RR         = context.StringValue("DescribeSubDomainRecords.DomainRecords[" + i + "].RR");
                record.Type       = context.StringValue("DescribeSubDomainRecords.DomainRecords[" + i + "].Type");
                record._Value     = context.StringValue("DescribeSubDomainRecords.DomainRecords[" + i + "].Value");
                record.TTL        = context.LongValue("DescribeSubDomainRecords.DomainRecords[" + i + "].TTL");
                record.Priority   = context.LongValue("DescribeSubDomainRecords.DomainRecords[" + i + "].Priority");
                record.Line       = context.StringValue("DescribeSubDomainRecords.DomainRecords[" + i + "].Line");
                record.Status     = context.StringValue("DescribeSubDomainRecords.DomainRecords[" + i + "].Status");
                record.Locked     = context.BooleanValue("DescribeSubDomainRecords.DomainRecords[" + i + "].Locked");
                record.Weight     = context.IntegerValue("DescribeSubDomainRecords.DomainRecords[" + i + "].Weight");

                describeSubDomainRecordsResponse_domainRecords.Add(record);
            }
            describeSubDomainRecordsResponse.DomainRecords = describeSubDomainRecordsResponse_domainRecords;

            return(describeSubDomainRecordsResponse);
        }
Esempio n. 2
0
        /// <summary>
        /// 从阿里云获取域名记录recordId
        /// </summary>
        /// <returns></returns>
        private bool getRecordId()
        {
            if (textBox_accessKeyId.Text.ToString() == null || textBox_accessKeySecret.Text.ToString() == null || fullDomainName.Text.ToString() == null || textBox_TTL.Text.ToString() == null || textBox_newSeconds.Text.ToString() == null)
            {
                textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "请检查设置,不能为空!" + "\r\n");
                return(false);
            }
            clientProfile = DefaultProfile.GetProfile("cn-hangzhou", textBox_accessKeyId.Text.ToString(), textBox_accessKeySecret.Text.ToString());
            client        = new DefaultAcsClient(clientProfile);
            DescribeSubDomainRecordsRequest request = new DescribeSubDomainRecordsRequest();

            request.SubDomain = fullDomainName.Text;
            try
            {
                DescribeSubDomainRecordsResponse response = client.GetAcsResponse(request);
                List <Record> list = response.DomainRecords;

                if (list.Count == 0) //当不存在域名记录时,添加一个
                {
                    textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "阿里云DNS服务访问成功,但没有找到对应域名记录,请添加域名后重试!" + "\r\n");
                    return(false);
                }
                else
                {
                    int i = 0;
                    foreach (Record record in list) //当存在域名记录时,返回域名记录信息
                    {
                        i++;
                        textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "阿里云DNS服务返回RecordId:" + i.ToString() + " RecordId:" + record.RecordId + "\r\n");
                        textBox_recordId.Text = record.RecordId;
                        cfg.SaveAppSetting("RecordID", record.RecordId.ToString());
                        globalRR.Text                  = record.RR;
                        globalDomainType.Text          = record.Type;
                        globalValue.Text               = domainIP.Text = record.Value;
                        label_TTL.Text                 = Convert.ToString(record.TTL);
                        label_DomainIpStatus.Text      = "已绑定";
                        label_DomainIpStatus.ForeColor = System.Drawing.Color.FromArgb(0, 0, 0, 255);
                    }
                    return(true);
                }
            }
            catch (ServerException e)
            {
                textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "Server Exception:  " + e.ErrorCode + e.ErrorMessage + "\r\n");
                return(false);
            }
            catch (ClientException e)
            {
                textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "Client Exception:  " + e.ErrorCode + e.ErrorMessage + "\r\n");
                return(false);
            }
            //处理错误

            /*
             * catch (Exception error)
             * {
             *  textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "updateDomainRecord() Exception:  " + error + "\r\n");
             *  return false;
             * }*/
        }
Esempio n. 3
0
        private bool setRecordId()
        {
            DescribeSubDomainRecordsRequest request = new DescribeSubDomainRecordsRequest();

            request.SubDomain = fullDomainName.Text;
            try
            {
                DescribeSubDomainRecordsResponse response = client.GetAcsResponse(request);
                List <Record> list = response.DomainRecords;

                if (list.Count == 0)
                {
                    addDomainRecord();
                    return(false);
                }

                int i = 0;

                foreach (Record record in list)
                {
                    i++;
                    MessageBox.Show("Record" + i.ToString());
                    recordId.Text         = record.RecordId;
                    globalRR.Text         = record.RR;
                    globalDomainType.Text = record.Type;
                    globalValue.Text      = record.Value;
                }
                return(true);
            }
            //处理错误
            catch (ServerException e)
            {
                MessageBox.Show(e.ErrorCode + e.ErrorMessage);

                return(false);
            }
            catch (ClientException e)
            {
                MessageBox.Show(e.ErrorCode + e.ErrorMessage);

                return(false);
            }
        }
        public static DescribeSubDomainRecordsResponse Unmarshall(UnmarshallerContext context)
        {
            DescribeSubDomainRecordsResponse describeSubDomainRecordsResponse = new DescribeSubDomainRecordsResponse
            {
                HttpResponse = context.HttpResponse,
                RequestId    = context.StringValue("DescribeSubDomainRecords.RequestId"),
                TotalCount   = context.LongValue("DescribeSubDomainRecords.TotalCount"),
                PageNumber   = context.LongValue("DescribeSubDomainRecords.PageNumber"),
                PageSize     = context.LongValue("DescribeSubDomainRecords.PageSize")
            };


            List <DescribeSubDomainRecordsResponse.Record> domainRecords = new List <DescribeSubDomainRecordsResponse.Record>();

            for (int i = 0; i < context.Length("DescribeSubDomainRecords.DomainRecords.Length"); i++)
            {
                DescribeSubDomainRecordsResponse.Record record = new DescribeSubDomainRecordsResponse.Record
                {
                    DomainName = context.StringValue($"DescribeSubDomainRecords.DomainRecords[{i}].DomainName"),
                    RecordId   = context.StringValue($"DescribeSubDomainRecords.DomainRecords[{i}].RecordId"),
                    RR         = context.StringValue($"DescribeSubDomainRecords.DomainRecords[{i}].RR"),
                    Type       = context.StringValue($"DescribeSubDomainRecords.DomainRecords[{i}].Type"),
                    Value      = context.StringValue($"DescribeSubDomainRecords.DomainRecords[{i}].Value"),
                    TTL        = context.LongValue($"DescribeSubDomainRecords.DomainRecords[{i}].TTL"),
                    Priority   = context.LongValue($"DescribeSubDomainRecords.DomainRecords[{i}].Priority"),
                    Line       = context.StringValue($"DescribeSubDomainRecords.DomainRecords[{i}].Line"),
                    Status     = context.StringValue($"DescribeSubDomainRecords.DomainRecords[{i}].Status"),
                    Locked     = context.BooleanValue($"DescribeSubDomainRecords.DomainRecords[{i}].Locked"),
                    Weight     = context.IntegerValue($"DescribeSubDomainRecords.DomainRecords[{i}].Weight")
                };

                domainRecords.Add(record);
            }
            describeSubDomainRecordsResponse.DomainRecords = domainRecords;

            return(describeSubDomainRecordsResponse);
        }