public static string RunUpdates(DynamixSettings settings, string IPAddress) { string returnStatus = ""; foreach (string host in settings.Hosts) { SubdomainDomain info = DomainHelper.getSubdomainDomainFromString(host); if (info != null && !string.IsNullOrEmpty(info.domain)) { string url = endPointURL + "?key=" + settings.Password + "&action=ddns&subaction=update"; url += (!string.IsNullOrEmpty(info.subdomain) ? "&subdomain=" + info.subdomain : ""); url += "&domain=" + info.domain + "&ip=" + IPAddress; string response = GenericHelper.MakeHTTPGETRequest(url); if (response == "1") { returnStatus += serviceName + " host " + host + " was successfully updated to your current IP address." + Environment.NewLine; } else if (response == "0") { returnStatus += serviceName + " host " + host + " failed to update to your current IP address." + Environment.NewLine; } else if (response.StartsWith("Exception")) { returnStatus += serviceName + " host " + host + " failed to update due to a system exception. " + response.Replace(Environment.NewLine, " ") + Environment.NewLine; } else if (response.StartsWith("error=")) { returnStatus += serviceName + " host " + host + " failed to update. " + response.Replace("error=", ""); } } } return(returnStatus); }
public static SubdomainDomain getSubdomainDomainFromString(string str) { SubdomainDomain subDom = new SubdomainDomain(); string[] parts = str.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 3) { subDom.subdomain = parts[0]; subDom.domain = parts[1] + "." + parts[2]; } else if (parts.Length == 2) { subDom.subdomain = string.Empty; subDom.domain = parts[0] + "." + parts[1]; } else { return(null); } return(subDom); }