Exemple #1
0
        public bool Save(Tree config)
        {
            if (!config.ChildNodes.Contains(domainConfig))
            {
                domainConfig["dir"] = Path.Combine(AMSHelper.AMSLocation, domainName);
                config.ChildNodes.Add(domainConfig);
            }

            return(AMSHelper.SetDomainsConfig(config));
        }
Exemple #2
0
        public bool Delete(Tree config)
        {
            if (config.ChildNodes.Contains(domainConfig))
            {
                config.ChildNodes.Remove(domainConfig);
            }

            Tree            usersConfig   = AMSHelper.GetUsersConfig();
            List <TreeNode> nodesToDelete = new List <TreeNode>();

            foreach (TreeNode node in usersConfig.ChildNodes)
            {
                if (string.Compare(node["domain"], domainName, true) == 0)
                {
                    nodesToDelete.Add(node);
                }
            }

            while (nodesToDelete.Count > 0)
            {
                usersConfig.ChildNodes.Remove(nodesToDelete[0]);
                nodesToDelete.RemoveAt(0);
            }

            Tree listsConfig = AMSHelper.GetMailListsConfig();

            foreach (TreeNode node in listsConfig.ChildNodes)
            {
                if (string.Compare(node["domain"], domainName, true) == 0)
                {
                    nodesToDelete.Add(node);
                }
            }

            while (nodesToDelete.Count > 0)
            {
                listsConfig.ChildNodes.Remove(nodesToDelete[0]);
                nodesToDelete.RemoveAt(0);
            }

            return(AMSHelper.RemoveDomain(domainName) &&
                   AMSHelper.SetUsersConfig(usersConfig) &&
                   AMSHelper.SetMailListsConfig(listsConfig) &&
                   AMSHelper.SetDomainsConfig(config));
        }