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

            return(amsList.Load(config));
        }
Esempio n. 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);
        }
Esempio n. 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());
        }
Esempio n. 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.");
            }
        }
Esempio n. 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.");
            }
        }
Esempio n. 6
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.");
            }
        }
Esempio n. 7
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());
        }