Пример #1
0
        ActionResultBase BatchDomainTools.IWebPanelObjectActions.ISubDomainActions.ISubDomainGet.Get(WebPanelItemCollection saveCollection)
        {
            cPanel_ActionResult result     = new cPanel_ActionResult();
            DomainItem          mainDomain = GetMainDomain();

            //if(mainDomain==null)
            //  mainDomain = GetMainDomainAlternative();
            result.DataNodeProccessor = new cPanel_ActionResult.DataNodeHandler((nodeList) =>
            {
                if (nodeList != null)
                {
                    foreach (XmlNode node in nodeList)
                    {
                        cPanel_SubDomain subDomain = new cPanel_SubDomain(node);
                        if (mainDomain != null && !subDomain.RootDomain.Equals(mainDomain.Name, StringComparison.InvariantCultureIgnoreCase) ||
                            mainDomain == null)
                        {
                            saveCollection.Add(subDomain);
                        }
                    }
                    return(ActionResultCode.Success);
                }
                return(ActionResultCode.Error_InvalidServerAnswer);
            });
            result.ExecuteQuery(WebNetCommunication.BuildGetRequest(BuildCommandQuery("SubDomain", "listsubdomains"), this.Account.WebSession));
            return(result);
        }
        ActionResultBase IDomainAdd.Add(DomainItem Domain, IOptionData properties)
        {
            cPanel_ActionResult result = new cPanel_ActionResult();

            result.DataNodeProccessor = new cPanel_ActionResult.DataNodeHandler((nodeList) =>
            {
                if (nodeList != null)
                {
                    string status = nodeList[0]["reason"].InnerText;
                    if (status.Contains("already exists") || status.Contains("Deleted domain: "))
                    {
                        return(ActionResultCode.Error_ItemAlreadyExist);
                    }
                    //you are not allowed to add any more than
                    if (!status.Contains("was successfully parked"))
                    {
                        return(ActionResultCode.Error_UknowError);
                    }
                }
                return(ActionResultCode.Success);
            });

            CommandArgs[] commands = new CommandArgs[]
            {
                properties.ToCommandArgs(Domain.Name)[0],
                new CommandArgs("newdomain", Domain.Name),
                new CommandArgs("subdomain", Domain.Name.Replace(".", ""))
            };
            result.ExecuteQuery(WebNetCommunication.BuildGetRequest(BuildCommandQuery("AddonDomain", "addaddondomain", commands), this.Account.WebSession));
            return(result);
        }
Пример #3
0
        ActionResultBase ISubDomainAdd.Add(SubDomainItem SubDomain2Add, BatchDomainTools.WebPanelOptionData.IOptionData properties)
        {
            cPanel_ActionResult result = new cPanel_ActionResult();

            result.DataNodeProccessor = new cPanel_ActionResult.DataNodeHandler((nodeList) =>
            {
                if (nodeList != null)
                {
                    string status = nodeList[0]["result"].InnerText;
                    if (status.Contains("already exists") || status.Contains("Deleted domain: "))
                    {
                        return(ActionResultCode.Error_ItemAlreadyExist);
                    }
                    if (status != "1")
                    {
                        return(ActionResultCode.Error_UknowError);
                    }
                }
                return(ActionResultCode.Success);
            });

            CommandArgs[] commands = new CommandArgs[]
            {
                properties.ToCommandArgs(SubDomain2Add.SubDomainName)[0],
                new CommandArgs("domain", SubDomain2Add.SubDomainName),
                new CommandArgs("rootdomain", SubDomain2Add.RootDomain)
            };
            result.ExecuteQuery(WebNetCommunication.BuildGetRequest(BuildCommandQuery("SubDomain", "addsubdomain", commands), this.Account.WebSession));
            return(result);
        }
        ActionResultBase IDomainRemove.RemoveOject(DomainItem DomainToRemove)
        {
            cPanel_Domain cpDomain = DomainToRemove as cPanel_Domain;

            if (cpDomain == null)
            {
                throw new ArgumentException("Wrong type of argument, the expected cPanel_Domain type.", "Domain");
            }
            cPanel_ActionResult result = new cPanel_ActionResult();

            result.DataNodeProccessor = new cPanel_ActionResult.DataNodeHandler((nodeList) =>
            {
                if (nodeList != null)
                {
                    string status = nodeList[0]["reason"].InnerText;
                    if (status.Contains("Deleted domain:") || status.Contains("Bind reloading"))
                    {
                        return(ActionResultCode.Success);
                    }
                }
                return(ActionResultCode.Error_UknowError);
            });
            CommandArgs[] commands = new CommandArgs[]
            {
                new CommandArgs("domain", cpDomain.Name),
                new CommandArgs("subdomain", cpDomain.ExtViewData["domainkey"]),
                new CommandArgs("user", cpDomain.ExtViewData["subdomain"])
            };
            result.ExecuteQuery(WebNetCommunication.BuildGetRequest(BuildCommandQuery("AddonDomain", "deladdondomain", commands), this.Account.WebSession));
            return(result);
        }
        ActionResultBase IDomainEdit.Edit(DomainItem DomainToEdit, IOptionData properties)
        {
            cPanel_Domain cpDomain = DomainToEdit as cPanel_Domain;

            if (cpDomain == null)
            {
                throw new ArgumentException("Wrong type of argument, the expected cPanel_Domain type.", "Domain");
            }
            cPanel_ActionResult result = new cPanel_ActionResult();

            result.DataNodeProccessor = new cPanel_ActionResult.DataNodeHandler((nodeList) =>
            {
                if (nodeList != null)
                {
                    return(ActionResultCode.Success);
                }
                return(ActionResultCode.Error_UknowError);
            });
            CommandArgs[] commands = new CommandArgs[]
            {
                new CommandArgs("rootdomain", cpDomain.ExtViewData["rootdomain"]),
                new CommandArgs("subdomain", cpDomain.ExtViewData["subdomain"]),
                properties.ToCommandArgs(cpDomain.Name)[0]
            };
            result.ExecuteQuery(WebNetCommunication.BuildGetRequest(BuildCommandQuery("SubDomain", "changedocroot", commands), this.Account.WebSession));
            return(result);
        }
Пример #6
0
        ActionResultBase IDomainEdit.Edit(DomainItem Domain2Edit, IOptionData properties)
        {
            ISPmanager_ActionResult result   = new ISPmanager_ActionResult();
            List <CommandArgs>      commands = new List <CommandArgs>(properties.ToCommandArgs(Domain2Edit.Name));

            commands.Add(new CommandArgs("elid", Domain2Edit.Name));
            commands.Add(new CommandArgs("admin", "admin@" + Domain2Edit.Name));
            result.ExecuteQuery(WebNetCommunication.BuildGetRequest(BuildCommandQuery("wwwdomain.edit", commands.ToArray()), this.Account.WebSession));
            return(result);
        }
        ActionResultBase ISubDomainAdd.Add(SubDomainItem SubDomain2Add, IOptionData properties)
        {
            DirectAdmin_ActionResult result = new DirectAdmin_ActionResult();

            CommandArgs[] commands = new CommandArgs[]
            {
                new CommandArgs("domain", SubDomain2Add.RootDomain),
                new CommandArgs("subdomain", SubDomain2Add.SubDomainName),
            };
            result.ExecuteQuery(WebNetCommunication.BuildGetRequest(BuildCommandQuery("CMD_API_SUBDOMAINS", "create", commands), this.Account.WebSession));
            return(result);
        }
Пример #8
0
        ActionResultBase IDomainRemove.RemoveOject(DomainItem DomainToRemove)
        {
            ISPmanager_ActionResult result = new ISPmanager_ActionResult();

            CommandArgs[] commands = new CommandArgs[]
            {
                new CommandArgs("elid", DomainToRemove.Name),
                //new CommandArgs("admin", "admin@" + Domain2Check.Name)
            };
            result.ExecuteQuery(WebNetCommunication.BuildGetRequest(BuildCommandQuery("wwwdomain.delete", commands), this.Account.WebSession));
            return(result);
        }
        ActionResultBase IDomainRemove.RemoveOject(DomainItem DomainToRemove)
        {
            DirectAdmin_ActionResult result = new DirectAdmin_ActionResult();

            CommandArgs[] commands = new CommandArgs[]
            {
                new CommandArgs("confirmed", "anything"),
                new CommandArgs("delete", "anything"),
                new CommandArgs("select0", DomainToRemove.Name),
            };
            result.ExecuteQuery(WebNetCommunication.BuildGetRequest(BuildCommandQuery("CMD_API_DOMAIN", "", commands.ToArray()), this.Account.WebSession));
            return(result);
        }
        ActionResultBase IDomainEdit.Edit(DomainItem Domain2Edit, BatchDomainTools.WebPanelOptionData.IOptionData properties)
        {
            DirectAdmin_ActionResult result   = new DirectAdmin_ActionResult();
            List <CommandArgs>       commands = new List <CommandArgs>(properties.ToCommandArgs())
            {
                new CommandArgs("domain", Domain2Edit.Name),
                new CommandArgs("ubandwidth", "unlimited"),
                new CommandArgs("uquota", "unlimited"),
            };

            result.ExecuteQuery(WebNetCommunication.BuildGetRequest(BuildCommandQuery("CMD_API_DOMAIN", "modify", commands.ToArray()), this.Account.WebSession));
            return(result);
        }
        ActionResultBase ISubDomainRemove.RemoveOject(SubDomainItem SubDomain2Remove)
        {
            DirectAdmin_ActionResult result = new DirectAdmin_ActionResult();

            CommandArgs[] commands = new CommandArgs[]
            {
                new CommandArgs("domain", SubDomain2Remove.RootDomain),
                new CommandArgs("select0", SubDomain2Remove.SubDomainName),
                new CommandArgs("contents", "yes")
            };
            result.ExecuteQuery(WebNetCommunication.BuildGetRequest(BuildCommandQuery("CMD_API_SUBDOMAINS", "delete", commands), this.Account.WebSession));
            return(result);
        }
        ActionResultBase IDomainGet.Get(WebPanelItemCollection saveCollection)
        {
            DirectAdmin_ActionResult result = new DirectAdmin_ActionResult();

            result.DataTextProccessor = new DirectAdmin_ActionResult.DataTextHandler((InputText) =>
            {
                foreach (KeyValuePair <string, string> domainNow  in StrHelpClass.ToKeyValueURLString(InputText, true))
                {
                    saveCollection.Add(new DirectAdmin_Domain(domainNow.Key, StrHelpClass.ToNameValueURLString(domainNow.Value)));
                }
                return(ActionResultCode.Success);
            });
            result.ExecuteQuery(WebNetCommunication.BuildGetRequest(BuildCommandQuery("CMD_API_ADDITIONAL_DOMAINS", ""), this.Account.WebSession));
            return(result);
        }
        /// <summary>
        /// Метод получает все поддомены для указанного поддомена
        /// </summary>
        ActionResultBase GetAllAdditionalDomains(DomainItem domain, WebPanelItemCollection SubDomainList)
        {
            DirectAdmin_ActionResult result = new DirectAdmin_ActionResult();

            result.DataTextProccessor = new DirectAdmin_ActionResult.DataTextHandler((InputText) =>
            {
                foreach (KeyValuePair <string, string> domainNow in StrHelpClass.ToKeyValueURLString(InputText, true))
                {
                    SubDomainList.Add(new SubDomainItem(domain.Name, domainNow.Value));
                }
                return(ActionResultCode.Success);
            });
            CommandArgs arg = new CommandArgs("domain", domain.Name);

            result.ExecuteQuery(WebNetCommunication.BuildGetRequest(BuildCommandQuery("CMD_API_SUBDOMAINS", "", arg), this.Account.WebSession));
            return(result);
        }
        ActionResultBase IDomainGet.Get(WebPanelItemCollection saveCollection)
        {
            cPanel_ActionResult result = new cPanel_ActionResult();

            result.DataNodeProccessor = new cPanel_ActionResult.DataNodeHandler((nodeList) =>
            {
                if (nodeList != null)
                {
                    foreach (XmlNode node in nodeList)
                    {
                        saveCollection.Add(new cPanel_Domain(node));
                    }
                }
                return(ActionResultCode.Success);
            });
            result.ExecuteQuery(WebNetCommunication.BuildGetRequest(BuildCommandQuery("AddonDomain", "listaddondomains"), this.Account.WebSession));
            return(result);
        }
        ActionResultBase IDomainGet.Exist(DomainItem Domain2Check)
        {
            DirectAdmin_ActionResult result = new DirectAdmin_ActionResult();

            result.DataTextProccessor = new DirectAdmin_ActionResult.DataTextHandler((InputText) =>
            {
                foreach (KeyValuePair <string, string> domainNow in StrHelpClass.ToKeyValueURLString(InputText, true))
                {
                    if (domainNow.Key.Equals(Domain2Check.Name))
                    {
                        return(ActionResultCode.Success);
                    }
                }
                return(ActionResultCode.Error_ItemNotFound);
            });
            result.ExecuteQuery(WebNetCommunication.BuildGetRequest(BuildCommandQuery("CMD_API_ADDITIONAL_DOMAINS", ""), this.Account.WebSession));
            return(result);
        }
Пример #16
0
        public ActionResultBase Exist(SubDomainItem SubDomain2Check)
        {
            cPanel_ActionResult result     = new cPanel_ActionResult();
            DomainItem          mainDomain = GetMainDomain();

            result.DataNodeProccessor = new cPanel_ActionResult.DataNodeHandler((nodeList) =>
            {
                if (nodeList != null)
                {
                    return(ActionResultCode.Success);
                }
                return(ActionResultCode.Error_EmptyServerAnswer);
            });
            CommandArgs[] commands = new CommandArgs[]
            {
                new CommandArgs("regex", SubDomain2Check.Name)
            };
            result.ExecuteQuery(WebNetCommunication.BuildGetRequest(BuildCommandQuery("SubDomain", "listsubdomains", commands), this.Account.WebSession));
            return(result);
        }
        ActionResultBase ISubDomainGet.Exist(SubDomainItem SubDomain2Check)
        {
            DirectAdmin_ActionResult result = new DirectAdmin_ActionResult();

            result.DataTextProccessor = new DirectAdmin_ActionResult.DataTextHandler((InputText) =>
            {
                foreach (KeyValuePair <string, string> domainNow in StrHelpClass.ToKeyValueURLString(InputText, true))
                {
                    if (SubDomain2Check.SubDomainName.Equals(domainNow.Value))
                    {
                        return(ActionResultCode.Success);
                    }
                }
                return(ActionResultCode.Error_ItemNotFound);
            });
            CommandArgs arg = new CommandArgs("domain", SubDomain2Check.RootDomain);

            result.ExecuteQuery(WebNetCommunication.BuildGetRequest(BuildCommandQuery("CMD_API_SUBDOMAINS", "", arg), this.Account.WebSession));
            return(result);
        }
        ActionResultBase IDomainGet.Exist(DomainItem Domain2Check)
        {
            cPanel_ActionResult result = new cPanel_ActionResult();

            result.DataNodeProccessor = new cPanel_ActionResult.DataNodeHandler((nodeList) =>
            {
                if (nodeList != null)
                {
                    foreach (XmlNode dNode in nodeList)
                    {
                        string domain = dNode["domain"].InnerText;
                        if (domain.Equals(Domain2Check.Name, StringComparison.InvariantCultureIgnoreCase))
                        {
                            return(ActionResultCode.Success);
                        }
                    }
                }
                return(ActionResultCode.Error_EmptyServerAnswer);
            });
            result.ExecuteQuery(WebNetCommunication.BuildGetRequest(BuildCommandQuery("DomainLookup", "getbasedomains"), this.Account.WebSession));
            return(result);
        }
Пример #19
0
        ActionResultBase ISubDomainRemove.RemoveOject(SubDomainItem SubDomain2Remove)
        {
            cPanel_ActionResult result = new cPanel_ActionResult();

            result.DataNodeProccessor = new cPanel_ActionResult.DataNodeHandler((nodeList) =>
            {
                if (nodeList != null)
                {
                    string status = nodeList[0]["reason"].InnerText;
                    if (status.Contains("Deleted domain:") || status.Contains("Bind reloading"))
                    {
                        return(ActionResultCode.Success);
                    }
                }
                return(ActionResultCode.Error_UknowError);
            });
            CommandArgs[] commands = new CommandArgs[]
            {
                new CommandArgs("domain", SubDomain2Remove.Name)
            };
            result.ExecuteQuery(WebNetCommunication.BuildGetRequest(BuildCommandQuery("SubDomain", "delsubdomain", commands), this.Account.WebSession));
            return(result);
        }