Пример #1
0
        public bool ListExists(string maillistName)
        {
            Tree        config  = AMSHelper.GetMailListsConfig();
            AmsMailList amsList = new AmsMailList(maillistName);

            return(amsList.Load(config));
        }
Пример #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);
        }
Пример #3
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.");
            }
        }
Пример #4
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.");
            }
        }
Пример #5
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.");
            }
        }
Пример #6
0
        public static AmsMailList[] GetMailLists(Tree config, string domainName)
        {
            List <AmsMailList> list = new List <AmsMailList>();

            foreach (TreeNode node in config.ChildNodes)
            {
                string user   = node["user"];
                string domain = node["domain"];
                if (string.Compare(domain, domainName, true) == 0)
                {
                    AmsMailList ml = new AmsMailList(string.Concat(user, "@", domain));
                    ml.Load(node);
                    ml.LoadListConfig();

                    list.Add(ml);
                }
            }

            return(list.ToArray());
        }