Example #1
0
        public bool ListExists(string maillistName)
        {
            Tree        config  = AMSHelper.GetMailListsConfig();
            AmsMailList amsList = new AmsMailList(maillistName);

            return(amsList.Load(config));
        }
Example #2
0
        public MailList GetList(string maillistName)
        {
            Tree        config  = AMSHelper.GetMailListsConfig();
            AmsMailList amsList = new AmsMailList(maillistName);

            if (amsList.Load(config))
            {
                amsList.LoadListConfig();
                return(amsList.ToMailList());
            }

            return(null);
        }
Example #3
0
        public MailList[] GetLists(string domainName)
        {
            List <MailList> lists  = new List <MailList>();
            Tree            config = AMSHelper.GetMailListsConfig();

            AmsMailList[] amsLists = AmsMailList.GetMailLists(config, domainName);

            foreach (AmsMailList amsList in amsLists)
            {
                lists.Add(amsList.ToMailList());
            }

            return(lists.ToArray());
        }
Example #4
0
        public void DeleteList(string maillistName)
        {
            Tree        config  = AMSHelper.GetMailListsConfig();
            AmsMailList amsList = new AmsMailList(maillistName);

            if (amsList.Load(config))
            {
                if (!amsList.Delete(config))
                {
                    throw new Exception("Couldn't delete a mail list.");
                }
            }
            else
            {
                throw new Exception("Couldn't find specified mail list.");
            }
        }
Example #5
0
        public void CreateList(MailList maillist)
        {
            Tree        config  = AMSHelper.GetMailListsConfig();
            AmsMailList amsList = new AmsMailList(maillist.Name);

            if (amsList.Load(config))
            {
                throw new Exception("Mail list is already exists.");
            }

            amsList.Read(maillist);

            if (!amsList.Save(config))
            {
                throw new Exception("Couldn't create a mail list.");
            }
        }
Example #6
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));
        }
Example #7
0
        public void UpdateList(MailList maillist)
        {
            Tree        config  = AMSHelper.GetMailListsConfig();
            AmsMailList amsList = new AmsMailList(maillist.Name);

            if (amsList.Load(config))
            {
                amsList.LoadListConfig();
                amsList.Read(maillist);

                if (!amsList.Save(config))
                {
                    throw new Exception("Couldn't update specified mail list.");
                }
            }
            else
            {
                throw new Exception("Couldn't find specified mail list.");
            }
        }