示例#1
0
        public void UpdateAccount(MailAccount mailbox)
        {
            Tree       config     = AMSHelper.GetUsersConfig();
            AmsMailbox amsMailbox = new AmsMailbox(mailbox.Name);

            if (amsMailbox.Load(config))
            {
                amsMailbox.LoadAccountConfig();
                amsMailbox.Read(mailbox);

                if (!amsMailbox.Save(config))
                {
                    throw new Exception("Couldn't update specified mailbox.");
                }
            }
            else
            {
                throw new Exception("Couldn't find specified mailbox.");
            }
        }
示例#2
0
        public void UpdateGroup(MailGroup group)
        {
            Tree       config   = AMSHelper.GetUsersConfig();
            AmsMailbox amsGroup = new AmsMailbox(group.Name);

            if (amsGroup.Load(config))
            {
                amsGroup.LoadAccountConfig();
                amsGroup.Read(group);

                if (!amsGroup.Save(config))
                {
                    throw new Exception("Couldn't update specified mail group.");
                }
            }
            else
            {
                throw new Exception("Couldn't find specified mail group.");
            }
        }
示例#3
0
        public static AmsMailbox[] GetMailGroups(Tree config, string domainName)
        {
            List <AmsMailbox> groups = new List <AmsMailbox>();

            foreach (TreeNode node in config.ChildNodes)
            {
                string account   = node["user"];
                string amsDomain = node["domain"];

                if (string.Compare(amsDomain, domainName, true) == 0)
                {
                    AmsMailbox mb = new AmsMailbox(string.Concat(account, "@", amsDomain));
                    mb.Load(node);
                    mb.LoadAccountConfig();

                    if (mb.IsMailGroup())
                    {
                        groups.Add(mb);
                    }
                }
            }

            return(groups.ToArray());
        }