本文整理汇总了C#中WebsitePanel.Providers.DNS.DnsRecord类的典型用法代码示例。如果您正苦于以下问题:C# DnsRecord类的具体用法?C# DnsRecord怎么用?C# DnsRecord使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DnsRecord类属于WebsitePanel.Providers.DNS命名空间,在下文中一共展示了DnsRecord类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertToDomainRecord
private static DomainRecord ConvertToDomainRecord(DnsRecord dnsRecord, string zoneName)
{
DomainRecord domainRecord = new DomainRecord();
domainRecord.Data = dnsRecord.RecordData;
domainRecord.DomainName = zoneName;
domainRecord.Priority = dnsRecord.MxPriority;
domainRecord.RecordType = dnsRecord.RecordType.ToString();
domainRecord.HostName = dnsRecord.RecordName;
return domainRecord;
}
示例2: AddZoneRecord
public void AddZoneRecord(string zoneName, DnsRecord record)
{
try
{
Log.WriteStart("'{0}' AddZoneRecord", ProviderSettings.ProviderName);
DnsProvider.AddZoneRecord(zoneName, record);
Log.WriteEnd("'{0}' AddZoneRecord", ProviderSettings.ProviderName);
}
catch (Exception ex)
{
Log.WriteError(String.Format("'{0}' AddZoneRecord", ProviderSettings.ProviderName), ex);
throw;
}
}
示例3: DeleteZoneRecordsAsync
/// <remarks/>
public void DeleteZoneRecordsAsync(string zoneName, DnsRecord[] records) {
this.DeleteZoneRecordsAsync(zoneName, records, null);
}
示例4: DeleteZoneRecords
public void DeleteZoneRecords(string zoneName, DnsRecord[] records) {
this.Invoke("DeleteZoneRecords", new object[] {
zoneName,
records});
}
示例5: DeleteZoneRecordAsync
/// <remarks/>
public void DeleteZoneRecordAsync(string zoneName, DnsRecord record) {
this.DeleteZoneRecordAsync(zoneName, record, null);
}
示例6: AddZoneRecordAsync
/// <remarks/>
public void AddZoneRecordAsync(string zoneName, DnsRecord record, object userState) {
if ((this.AddZoneRecordOperationCompleted == null)) {
this.AddZoneRecordOperationCompleted = new System.Threading.SendOrPostCallback(this.OnAddZoneRecordOperationCompleted);
}
this.InvokeAsync("AddZoneRecord", new object[] {
zoneName,
record}, this.AddZoneRecordOperationCompleted, userState);
}
示例7: BeginAddZoneRecord
/// <remarks/>
public System.IAsyncResult BeginAddZoneRecord(string zoneName, DnsRecord record, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("AddZoneRecord", new object[] {
zoneName,
record}, callback, asyncState);
}
示例8: PDNSAddZoneRecord
protected void PDNSAddZoneRecord(string zoneName, DnsRecord record, bool isNeedToUpdateSOA)
{
string domainId = GetDomainId(zoneName);
if (domainId == string.Empty)
throw new ArgumentOutOfRangeException("DomainId not found. Zone does not exist.");
string recordType = ConvertDnsRecordTypeToString(record.RecordType);
string ttl = GetDefaultRecordTTL(record.RecordType);
//NS record
if (record.RecordType == DnsRecordType.NS)
{
if (string.IsNullOrEmpty(record.RecordName))
record.RecordName = zoneName;
}
//widen record name for Power DNS
if (!string.IsNullOrEmpty(record.RecordName))
{
if (!record.RecordName.Contains(zoneName))
{
record.RecordName = string.Format("{0}.{1}", record.RecordName, zoneName);
}
}
else
{
record.RecordName = zoneName;
}
AddRecord(
domainId
, record.RecordName
, record.RecordData
, recordType
, ttl
, record.MxPriority.ToString()
);
if (isNeedToUpdateSOA)
{
PDNSUpdateSoaRecord(zoneName);
}
}
示例9: DeleteZoneRecords
public override void DeleteZoneRecords(string zoneName, DnsRecord[] records)
{
// load zone
Connection cn = SetupProviderConnection();
DNSZone dnsZone = cn.GetZone(zoneName);
foreach (DnsRecord record in records)
{
if (ZoneExists(zoneName))
{
string m_strRecordName = ConvertRecordNameToSDNSFormat(record.RecordName, zoneName);
//
List<string> m_strRecordData = new List<string>();
String m_strRecordType = String.Empty;
// build record data
SupportedDnsRecords[record.RecordType](zoneName, ref m_strRecordType, record, m_strRecordData);
//
dnsZone.Records.Remove(m_strRecordName, m_strRecordType, m_strRecordData.ToArray());
}
}
// update zone
cn.UpdateZone(dnsZone, false);
// update SOA
UpdateSoaRecord(zoneName);
}
示例10: AddZoneRecord
public override void AddZoneRecord(string zoneName, DnsRecord record)
{
if (ZoneExists(zoneName))
{
//
if (SupportedDnsRecords.ContainsKey(record.RecordType))
{
string m_strRecordName = ConvertRecordNameToSDNSFormat(record.RecordName, zoneName);
//
Connection cn = SetupProviderConnection();
DNSZone dnsZone = cn.GetZone(zoneName);
//
List<string> m_strRecordData = new List<string>();
String m_strRecordType = String.Empty;
// build record data
SupportedDnsRecords[record.RecordType](zoneName, ref m_strRecordType, record, m_strRecordData);
// skip if already added
if (dnsZone.Records.Contains(m_strRecordName, m_strRecordType, m_strRecordData.ToArray()))
return;
//
dnsZone.Records.Add(m_strRecordName, m_strRecordType, m_strRecordData.ToArray());
//
cn.UpdateZone(dnsZone, false);
//
UpdateSoaRecord(zoneName);
}
}
}
示例11: AddZoneRecords
public override void AddZoneRecords(string zoneName, DnsRecord[] records)
{
// load zone
Connection cn = SetupProviderConnection();
DNSZone dnsZone = cn.GetZone(zoneName);
// add zone records
foreach (DnsRecord record in records)
{
if (!SupportedDnsRecords.ContainsKey(record.RecordType))
continue;
string m_strRecordName = ConvertRecordNameToSDNSFormat(record.RecordName, zoneName);
//
List<string> m_strRecordData = new List<string>();
String m_strRecordType = String.Empty;
// build record data
SupportedDnsRecords[record.RecordType](zoneName, ref m_strRecordType, record, m_strRecordData);
// skip if already added
if (dnsZone.Records.Contains(m_strRecordName, m_strRecordType, m_strRecordData.ToArray()))
continue;
// add records
dnsZone.Records.Add(m_strRecordName, m_strRecordType, m_strRecordData.ToArray());
}
// update zone
cn.UpdateZone(dnsZone, false);
// update SOA
UpdateSoaRecord(zoneName);
}
示例12: ConvertToNative
protected DnsRecord ConvertToNative(DNSRecord record, string zoneName)
{
string recordName = ConvertRecordNameToInternalFormat(record.Name, zoneName);
//
DnsRecord dnsRecord = null;
switch (record.Type)
{
case "A":
dnsRecord = new DnsRecord
{
RecordName = recordName,
RecordType = DnsRecordType.A,
RecordData = record.DataFields[0]
};
break;
case "AAAA":
dnsRecord = new DnsRecord
{
RecordName = recordName,
RecordType = DnsRecordType.AAAA,
RecordData = record.DataFields[0]
};
break;
case "NS":
dnsRecord = new DnsRecord
{
RecordName = recordName,
RecordType = DnsRecordType.NS,
RecordData = record.DataFields[0]
};
break;
case "CNAME":
dnsRecord = new DnsRecord
{
RecordName = recordName,
RecordType = DnsRecordType.CNAME,
RecordData = record.DataFields[0]
};
break;
case "MX":
dnsRecord = new DnsRecord
{
RecordName = recordName,
RecordType = DnsRecordType.MX,
MxPriority = Convert.ToInt32(record.DataFields[MX_RECORD_PRIORITY]),
RecordData = record.DataFields[MX_RECORD_NAMESERVER]
};
break;
case "TXT":
dnsRecord = new DnsRecord
{
RecordName = recordName,
RecordType = DnsRecordType.TXT,
RecordData = record.DataFields[0]
};
break;
case "SRV":
dnsRecord = new DnsRecord
{
RecordName = recordName,
RecordType = DnsRecordType.SRV,
RecordData = record.DataFields[3],
SrvPriority = Convert.ToInt32(record.DataFields[0]),
SrvWeight = Convert.ToInt32(record.DataFields[1]),
SrvPort = Convert.ToInt32(record.DataFields[2])
};
break;
}
//
return dnsRecord;
}
示例13: BuildDnsResourceRecords
public static List<DnsRecord> BuildDnsResourceRecords(List<GlobalDnsRecord> records,
string domainName, string serviceIP)
{
List<DnsRecord> zoneRecords = new List<DnsRecord>();
foreach (GlobalDnsRecord record in records)
{
DnsRecord rr = new DnsRecord();
rr.RecordType = (DnsRecordType)Enum.Parse(typeof(DnsRecordType), record.RecordType, true);
rr.RecordName = record.RecordName;
if (record.RecordType == "A")
{
rr.RecordData = String.IsNullOrEmpty(record.RecordData) ? record.ExternalIP : record.RecordData;
rr.RecordData = Utils.ReplaceStringVariable(rr.RecordData, "ip", record.ExternalIP);
if (String.IsNullOrEmpty(rr.RecordData) && !String.IsNullOrEmpty(serviceIP))
rr.RecordData = serviceIP;
}
else
{
rr.RecordData = record.RecordData;
}
// substitute variables
rr.RecordData = Utils.ReplaceStringVariable(rr.RecordData, "domain_name", domainName);
// add MX priority
if (record.RecordType == "MX")
rr.MxPriority = record.MxPriority;
if (!String.IsNullOrEmpty(rr.RecordData))
zoneRecords.Add(rr);
}
return zoneRecords;
}
示例14: AddDnsZoneRecord
public static int AddDnsZoneRecord(int domainId, string recordName, DnsRecordType recordType,
string recordData, int mxPriority)
{
// check account
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
if (accountCheck < 0) return accountCheck;
// load domain info
DomainInfo domain = GetDomain(domainId);
// check package
int packageCheck = SecurityContext.CheckPackage(domain.PackageId, DemandPackage.IsActive);
if (packageCheck < 0) return packageCheck;
// get DNS service
DnsZone zoneItem = (DnsZone)PackageController.GetPackageItem(domain.ZoneItemId);
if(zoneItem == null)
return 0;
// place log record
TaskManager.StartTask("DNS_ZONE", "ADD_RECORD", domain.DomainName);
TaskManager.ItemId = domain.ZoneItemId;
try
{
// check if record already exists
if (GetDnsZoneRecord(domainId, recordName, recordType, recordData) != null)
return 0;
DNSServer dns = new DNSServer();
ServiceProviderProxy.Init(dns, zoneItem.ServiceId);
DnsRecord record = new DnsRecord();
record.RecordType = recordType;
record.RecordName = recordName;
record.RecordData = recordData;
record.MxPriority = mxPriority;
dns.AddZoneRecord(zoneItem.Name, record);
return 0;
}
catch (Exception ex)
{
throw TaskManager.WriteError(ex);
}
finally
{
TaskManager.CompleteTask();
}
}
示例15: DeleteZoneRecords
public void DeleteZoneRecords(string zoneName, DnsRecord[] records)
{
try
{
Log.WriteStart("'{0}' DeleteZoneRecords", ProviderSettings.ProviderName);
DnsProvider.DeleteZoneRecords(zoneName, records);
Log.WriteEnd("'{0}' DeleteZoneRecords", ProviderSettings.ProviderName);
}
catch (Exception ex)
{
Log.WriteError(String.Format("'{0}' DeleteZoneRecords", ProviderSettings.ProviderName), ex);
throw;
}
}