public bool AccountExists(string mailboxName)
		{
			Tree users = AMSHelper.GetUsersConfig();
			AmsMailbox accnt = new AmsMailbox(mailboxName);

			return accnt.Load(users);
		}
        public bool AccountExists(string mailboxName)
        {
            Tree       users = AMSHelper.GetUsersConfig();
            AmsMailbox accnt = new AmsMailbox(mailboxName);

            return(accnt.Load(users));
        }
Esempio n. 3
0
        public void Read(MailList maillist)
        {
            nodeConfig["domain"]                   = AmsMailbox.GetDomainName(maillist.Name);
            nodeConfig["enabled"]                  = maillist.Enabled ? "1" : "0";
            nodeConfig["user"]                     = AmsMailbox.GetAccountName(maillist.Name);
            nodeConfig["triggertext"]              = "TRIGGER";
            nodeConfig["usetriggeredreplyto"]      = "0";
            nodeConfig["triggeredreplyto"]         = string.Empty;
            nodeConfig["usetriggeredfrom"]         = string.Empty;
            nodeConfig["triggeredfrom"]            = string.Empty;
            nodeConfig["maxtriggersperday"]        = "100";
            nodeConfig["useonlymemberscantrigger"] = "0";
            nodeConfig["maxaddresses"]             = "5000";

            // copy mail list members
            TreeNode addresses = listConfig.ChildNodes["addresses"];

            if (addresses == null)
            {
                addresses          = new TreeNode();
                addresses.NodeName = "addresses";
                listConfig.ChildNodes.Add(addresses);
            }
            addresses.ChildNodes.Clear();

            foreach (string member in maillist.Members)
            {
                TreeNode node = new TreeNode(addresses);
                node.NodeValue = member;
                addresses.ChildNodes.Add(node);
            }
        }
Esempio n. 4
0
        public static bool SetAccountDelivery(Tree config, string mailboxName)
        {
            string account        = AmsMailbox.GetAccountName(mailboxName);
            string domain         = AmsMailbox.GetDomainName(mailboxName);
            string deliveryConfig = string.Format(AccountDeliveryFile, domain, account);

            return(SaveAmsConfigurationFile(config, deliveryConfig));
        }
Esempio n. 5
0
        public static Tree GetAccountDelivery(string mailboxName)
        {
            string account        = AmsMailbox.GetAccountName(mailboxName);
            string domain         = AmsMailbox.GetDomainName(mailboxName);
            string deliveryConfig = string.Format(AccountDeliveryFile, domain, account);

            return(ReadAmsConfigurationFile(deliveryConfig));
        }
Esempio n. 6
0
        public static bool SetMailingListConfig(Tree config, string maillistName)
        {
            string domain     = AmsMailbox.GetDomainName(maillistName);
            string account    = AmsMailbox.GetAccountName(maillistName);
            string listConfig = Path.Combine(AMSLocation, string.Format(MailListConfigFile, domain, account));

            return(SaveAmsConfigurationFile(config, listConfig));
        }
Esempio n. 7
0
        public bool Save(Tree config)
        {
            if (!config.ChildNodes.Contains(nodeConfig))
            {
                nodeConfig["file"] = string.Format(AMSHelper.MailListConfigFile, AmsMailbox.GetDomainName(maillistName), AmsMailbox.GetAccountName(maillistName));
                config.ChildNodes.Add(nodeConfig);
            }

            return(AMSHelper.SetMailListsConfig(config) &&
                   AMSHelper.SetMailingListConfig(listConfig, maillistName));
        }
        public MailAccount[] GetAccounts(string domainName)
        {
            Tree config = AMSHelper.GetUsersConfig();
            List <MailAccount> accounts = new List <MailAccount>();

            AmsMailbox[] mbList = AmsMailbox.GetMailboxes(config, domainName);
            foreach (AmsMailbox mb in mbList)
            {
                accounts.Add(mb.ToMailAccount());
            }

            return(accounts.ToArray());
        }
        public MailGroup GetGroup(string groupName)
        {
            Tree       config   = AMSHelper.GetUsersConfig();
            AmsMailbox amsGroup = new AmsMailbox(groupName);

            if (amsGroup.Load(config))
            {
                amsGroup.LoadAccountConfig();
                return(amsGroup.ToMailGroup());
            }

            return(null);
        }
Esempio n. 10
0
        public MailAccount GetAccount(string mailboxName)
        {
            Tree       config     = AMSHelper.GetUsersConfig();
            AmsMailbox amsMailbox = new AmsMailbox(mailboxName);

            if (amsMailbox.Load(config))
            {
                amsMailbox.LoadAccountConfig();
                return(amsMailbox.ToMailAccount());
            }

            return(null);
        }
Esempio n. 11
0
		public void CreateAccount(MailAccount mailbox)
		{
			Tree users = AMSHelper.GetUsersConfig();
			AmsMailbox accnt = new AmsMailbox(mailbox.Name);

			if (accnt.Load(users))
				throw new Exception("Mailbox is already registered.");

			accnt.Read(mailbox);

			if (!accnt.Save(users))
				throw new Exception("Couldn't create a mailbox.");
		}
Esempio n. 12
0
        public MailGroup[] GetGroups(string domainName)
        {
            List <MailGroup> groups = new List <MailGroup>();
            Tree             config = AMSHelper.GetUsersConfig();

            AmsMailbox[] amsGroups = AmsMailbox.GetMailGroups(config, domainName);

            foreach (AmsMailbox amsGroup in amsGroups)
            {
                groups.Add(amsGroup.ToMailGroup());
            }

            return(groups.ToArray());
        }
Esempio n. 13
0
        public bool GroupExists(string groupName)
        {
            Tree       config   = AMSHelper.GetUsersConfig();
            AmsMailbox amsGroup = new AmsMailbox(groupName);

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

                return(amsGroup.IsMailGroup());
            }

            return(false);
        }
Esempio n. 14
0
        public void CreateAccount(MailAccount mailbox)
        {
            Tree       users = AMSHelper.GetUsersConfig();
            AmsMailbox accnt = new AmsMailbox(mailbox.Name);

            if (accnt.Load(users))
            {
                throw new Exception("Mailbox is already registered.");
            }

            accnt.Read(mailbox);

            if (!accnt.Save(users))
            {
                throw new Exception("Couldn't create a mailbox.");
            }
        }
Esempio n. 15
0
        public void DeleteGroup(string groupName)
        {
            Tree       config   = AMSHelper.GetUsersConfig();
            AmsMailbox amsGroup = new AmsMailbox(groupName);

            if (amsGroup.Load(config))
            {
                if (!amsGroup.Delete(config))
                {
                    throw new Exception("Couldn't delete specified mail group.");
                }
            }
            else
            {
                throw new Exception("Couldn't find specified mail group.");
            }
        }
Esempio n. 16
0
        public bool Load(TreeNode configNode)
        {
            string account = AmsMailbox.GetAccountName(maillistName);
            string domain  = AmsMailbox.GetDomainName(maillistName);

            string amsUser   = configNode["user"];
            string amsDomain = configNode["domain"];

            if (string.Compare(amsUser, account, true) == 0 &&
                string.Compare(amsDomain, domain, true) == 0)
            {
                nodeConfig = configNode;
                return(true);
            }

            return(false);
        }
Esempio n. 17
0
        public void DeleteAccount(string mailboxName)
        {
            Tree       config     = AMSHelper.GetUsersConfig();
            AmsMailbox amsMailbox = new AmsMailbox(mailboxName);

            if (amsMailbox.Load(config))
            {
                if (!amsMailbox.Delete(config))
                {
                    throw new Exception("Couldn't delete a specified account.");
                }
            }
            else
            {
                throw new Exception("Couldn't load account settings.");
            }
        }
Esempio n. 18
0
        public void CreateGroup(MailGroup group)
        {
            Tree       users    = AMSHelper.GetUsersConfig();
            AmsMailbox amsGroup = new AmsMailbox(group.Name);

            if (amsGroup.Load(users))
            {
                throw new Exception("Mail group is already exists.");
            }

            amsGroup.Read(group);

            if (!amsGroup.Save(users))
            {
                throw new Exception("Couldn't create a mail group.");
            }
        }
Esempio n. 19
0
        public static AmsMailbox[] GetMailboxes(Tree config, string domainName)
        {
            List <AmsMailbox> list = 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();
                    list.Add(mb);
                }
            }

            return(list.ToArray());
        }
Esempio n. 20
0
        public static bool RemoveAccount(string mailboxName)
        {
            bool   succeed    = false;
            string account    = AmsMailbox.GetAccountName(mailboxName);
            string domain     = AmsMailbox.GetDomainName(mailboxName);
            string accountDir = Path.Combine(AMSLocation, string.Format(AccountFolder, domain, account));

            try
            {
                Directory.Delete(accountDir, true);
                succeed = true;
            }
            catch (Exception ex)
            {
                Log.WriteError(ex);
            }

            return(succeed);
        }
Esempio n. 21
0
        public static bool RemoveMailList(string maillistName)
        {
            bool   succeed        = false;
            string account        = AmsMailbox.GetAccountName(maillistName);
            string domain         = AmsMailbox.GetDomainName(maillistName);
            string maillistConfig = Path.Combine(AMSLocation, string.Format(MailListConfigFile, domain, account));

            try
            {
                File.Delete(maillistConfig);
                succeed = true;
            }
            catch (Exception ex)
            {
                Log.WriteError(ex.Message, ex);
            }

            return(succeed);
        }
Esempio n. 22
0
        public bool Load(Tree config)
        {
            string account = AmsMailbox.GetAccountName(maillistName);
            string domain  = AmsMailbox.GetDomainName(maillistName);

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

                if (string.Compare(amsUser, account, true) == 0 &&
                    string.Compare(amsDomain, domain, true) == 0)
                {
                    nodeConfig = node;
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 23
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.");
            }
        }
Esempio n. 24
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.");
            }
        }
Esempio n. 25
0
		public bool GroupExists(string groupName)
		{
			Tree config = AMSHelper.GetUsersConfig();
			AmsMailbox amsGroup = new AmsMailbox(groupName);

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

				return amsGroup.IsMailGroup();
			}

			return false;
		}
Esempio n. 26
0
		public void CreateGroup(MailGroup group)
		{
			Tree users = AMSHelper.GetUsersConfig();
			AmsMailbox amsGroup = new AmsMailbox(group.Name);

			if (amsGroup.Load(users))
				throw new Exception("Mail group is already exists.");

			amsGroup.Read(group);

			if (!amsGroup.Save(users))
				throw new Exception("Couldn't create a mail group.");
		}
Esempio n. 27
0
		public void DeleteAccount(string mailboxName)
		{
			Tree config = AMSHelper.GetUsersConfig();
			AmsMailbox amsMailbox = new AmsMailbox(mailboxName);

			if (amsMailbox.Load(config))
			{
				if (!amsMailbox.Delete(config))
					throw new Exception("Couldn't delete a specified account.");
			}
			else
				throw new Exception("Couldn't load account settings.");
		}
Esempio n. 28
0
		public void DeleteGroup(string groupName)
		{
			Tree config = AMSHelper.GetUsersConfig();
			AmsMailbox amsGroup = new AmsMailbox(groupName);

			if (amsGroup.Load(config))
			{
				if (!amsGroup.Delete(config))
					throw new Exception("Couldn't delete specified mail group.");
			}
			else
			{
				throw new Exception("Couldn't find specified mail group.");
			}
		}
Esempio n. 29
0
		public MailAccount GetAccount(string mailboxName)
		{
			Tree config = AMSHelper.GetUsersConfig();
			AmsMailbox amsMailbox = new AmsMailbox(mailboxName);
			
			if (amsMailbox.Load(config))
			{
				amsMailbox.LoadAccountConfig();
				return amsMailbox.ToMailAccount();
			}

			return null;
		}
Esempio n. 30
0
		public MailGroup GetGroup(string groupName)
		{
			Tree config = AMSHelper.GetUsersConfig();
			AmsMailbox amsGroup = new AmsMailbox(groupName);

			if (amsGroup.Load(config))
			{
				amsGroup.LoadAccountConfig();
				return amsGroup.ToMailGroup();
			}

			return null;
		}
Esempio n. 31
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.");
			}
		}
Esempio n. 32
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();
		}
Esempio n. 33
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.");
			}
		}