Ejemplo n.º 1
0
        public override MailList[] GetLists(string domainName)
        {
            try
            {
                SM3.svcMailListAdmin svcLists = new SM3.svcMailListAdmin();
                PrepareProxy(svcLists);

                SM3.MailingListResult mResult = svcLists.GetMailingListsByDomain(
                    AdminUsername,
                    AdminPassword,
                    domainName
                    );

                if (!mResult.Result)
                {
                    throw new Exception(mResult.Message);
                }

                List <MailList> mailLists = new List <MailList>();
                foreach (string listName in mResult.listNames)
                {
                    SM3.SettingsRequestResult sResult = svcLists.GetRequestedListSettings(
                        AdminUsername,
                        AdminPassword,
                        domainName,
                        listName,
                        sm3Settings
                        );

                    if (!sResult.Result)
                    {
                        throw new Exception(sResult.Message);
                    }

                    SM3.SubscriberListResult rResult = svcLists.GetSubscriberList(
                        AdminUsername,
                        AdminPassword,
                        domainName,
                        listName
                        );

                    if (!rResult.Result)
                    {
                        throw new Exception(rResult.Message);
                    }

                    MailList list = new MailList();
                    list.Name = string.Concat(listName, "@", domainName);
                    SetMailListSettings(list, sResult.settingValues);
                    SetMailListMembers(list, rResult.Subscribers);
                    mailLists.Add(list);
                }

                return(mailLists.ToArray());
            }
            catch (Exception ex)
            {
                throw new Exception("Couldn't obtain domain mail lists.", ex);
            }
        }
Ejemplo n.º 2
0
        public override void DeleteList(string listName)
        {
            try
            {
                SM3.svcMailListAdmin svcLists = new SM3.svcMailListAdmin();
                PrepareProxy(svcLists);

                string account = GetAccountName(listName);
                string domain  = GetDomainName(listName);

                SM3.GenericResult gResult = svcLists.DeleteList(
                    AdminUsername,
                    AdminPassword,
                    domain,
                    listName
                    );

                if (!gResult.Result)
                {
                    throw new Exception(gResult.Message);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Couldn't delete a mail list.", ex);
            }
        }
Ejemplo n.º 3
0
        public override bool ListExists(string listName)
        {
            bool exists = false;

            try
            {
                string domain  = GetDomainName(listName);
                string account = GetAccountName(listName);

                SM3.svcMailListAdmin lists = new SM3.svcMailListAdmin();
                PrepareProxy(lists);

                SM3.MailingListResult result = lists.GetMailingListsByDomain(AdminUsername, AdminPassword, domain);

                if (result.Result)
                {
                    foreach (string member in result.listNames)
                    {
                        if (string.Compare(member, listName, true) == 0)
                        {
                            exists = true;
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Couldn't obtain mail list.", ex);
            }

            return(exists);
        }
Ejemplo n.º 4
0
        public override MailList GetList(string listName)
        {
            try
            {
                string domain  = GetDomainName(listName);
                string account = GetAccountName(listName);

                SM3.svcMailListAdmin svcLists = new SM3.svcMailListAdmin();
                PrepareProxy(svcLists);

                SM3.SettingsRequestResult sResult = svcLists.GetRequestedListSettings(
                    AdminUsername,
                    AdminPassword,
                    domain,
                    account,
                    sm3Settings
                    );

                if (!sResult.Result)
                {
                    throw new Exception(sResult.Message);
                }

                SM3.SubscriberListResult mResult = svcLists.GetSubscriberList(
                    AdminUsername,
                    AdminPassword,
                    domain,
                    account
                    );

                if (!mResult.Result)
                {
                    throw new Exception(mResult.Message);
                }

                MailList list = new MailList();
                list.Name = listName;

                SetMailListSettings(list, sResult.settingValues);
                SetMailListMembers(list, mResult.Subscribers);

                return(list);
            }
            catch (Exception ex)
            {
                throw new Exception("Couldn't obtain mail list.", ex);
            }
        }
Ejemplo n.º 5
0
        public override void UpdateList(MailList list)
        {
            try
            {
                string domain  = GetDomainName(list.Name);
                string account = GetAccountName(list.Name);

                SM3.svcMailListAdmin lists = new SM3.svcMailListAdmin();
                PrepareProxy(lists);

                List <string> settings = new List <string>();
                settings.Add(string.Concat("description=", list.Description));
                settings.Add(string.Concat("disabled=", !list.Enabled));
                settings.Add(string.Concat("moderator=", list.ModeratorAddress));
                settings.Add(string.Concat("password="******"requirepassword="******"whocanpost=anyone");
                    break;

                case PostingMode.MembersCanPost:
                    settings.Add("whocanpost=subscribersonly");
                    break;

                case PostingMode.ModeratorCanPost:
                    settings.Add("whocanpost=moderator");
                    break;
                }

                settings.Add(string.Concat("prependsubject=", list.EnableSubjectPrefix));
                settings.Add(string.Concat("maxmessagesize=", list.MaxMessageSize));
                settings.Add(string.Concat("maxrecipients=", list.MaxRecipientsPerMessage));

                switch (list.ReplyToMode)
                {
                case ReplyTo.RepliesToList:
                    settings.Add("replytolist=true");
                    break;

                case ReplyTo.RepliesToSender:
                    settings.Add("replytolist=false");
                    break;
                }

                SM3.GenericResult result = lists.SetRequestedListSettings(AdminUsername, AdminPassword,
                                                                          domain,
                                                                          account,
                                                                          settings.ToArray()
                                                                          );

                if (!result.Result)
                {
                    throw new Exception(result.Message);
                }

                if (list.Members.Length > 0)
                {
                    result = lists.SetSubscriberList(AdminUsername, AdminPassword,
                                                     domain,
                                                     account,
                                                     list.Members
                                                     );

                    if (!result.Result)
                    {
                        throw new Exception(result.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Couldn't update mail list.", ex);
            }
        }
Ejemplo n.º 6
0
		public override void UpdateList(MailList list)
		{
			try
			{
				string domain = GetDomainName(list.Name);
				string account = GetAccountName(list.Name);

				SM3.svcMailListAdmin lists = new SM3.svcMailListAdmin();
				PrepareProxy(lists);

				List<string> settings = new List<string>();
                settings.Add(string.Concat("description=", list.Description));
				settings.Add(string.Concat("disabled=", !list.Enabled));
				settings.Add(string.Concat("moderator=", list.ModeratorAddress));
				settings.Add(string.Concat("password="******"requirepassword="******"whocanpost=anyone");
						break;
					case PostingMode.MembersCanPost:
						settings.Add("whocanpost=subscribersonly");
						break;
					case PostingMode.ModeratorCanPost:
						settings.Add("whocanpost=moderator");
						break;
				}

				settings.Add(string.Concat("prependsubject=", list.EnableSubjectPrefix));
				settings.Add(string.Concat("maxmessagesize=", list.MaxMessageSize));
				settings.Add(string.Concat("maxrecipients=", list.MaxRecipientsPerMessage));

				switch (list.ReplyToMode)
				{
					case ReplyTo.RepliesToList:
						settings.Add("replytolist=true");
						break;
                    case ReplyTo.RepliesToSender:
                        settings.Add("replytolist=false");
                        break;
				}

				SM3.GenericResult result = lists.SetRequestedListSettings(AdminUsername, AdminPassword,
					domain,
					account,
					settings.ToArray()
				);

				if (!result.Result)
					throw new Exception(result.Message);

				if (list.Members.Length > 0)
				{
					result = lists.SetSubscriberList(AdminUsername, AdminPassword,
						domain,
						account,
						list.Members
					);

					if (!result.Result)
						throw new Exception(result.Message);
				}
			}
			catch (Exception ex)
			{
				throw new Exception("Couldn't update mail list.", ex);
			}
		}
Ejemplo n.º 7
0
		public override void DeleteList(string listName)
		{
			try
			{
				SM3.svcMailListAdmin svcLists = new SM3.svcMailListAdmin();
				PrepareProxy(svcLists);

				string account = GetAccountName(listName);
				string domain = GetDomainName(listName);

				SM3.GenericResult gResult = svcLists.DeleteList(
					AdminUsername,
					AdminPassword,
					domain,
					listName
				);

				if (!gResult.Result)
					throw new Exception(gResult.Message);
			}
			catch (Exception ex)
			{
				throw new Exception("Couldn't delete a mail list.", ex);
			}
		}
Ejemplo n.º 8
0
		public override MailList[] GetLists(string domainName)
		{
			try
			{
				SM3.svcMailListAdmin svcLists = new SM3.svcMailListAdmin();
				PrepareProxy(svcLists);

				SM3.MailingListResult mResult = svcLists.GetMailingListsByDomain(
					AdminUsername,
					AdminPassword,
					domainName
				);

				if (!mResult.Result)
					throw new Exception(mResult.Message);

				List<MailList> mailLists = new List<MailList>();
				foreach (string listName in mResult.listNames)
				{
					SM3.SettingsRequestResult sResult = svcLists.GetRequestedListSettings(
						AdminUsername,
						AdminPassword,
						domainName,
						listName,
						sm3Settings
					);

					if (!sResult.Result)
						throw new Exception(sResult.Message);

					SM3.SubscriberListResult rResult = svcLists.GetSubscriberList(
						AdminUsername,
						AdminPassword,
						domainName,
						listName
					);

					if (!rResult.Result)
						throw new Exception(rResult.Message);

					MailList list = new MailList();
					list.Name = string.Concat(listName, "@", domainName);
					SetMailListSettings(list, sResult.settingValues);
					SetMailListMembers(list, rResult.Subscribers);
					mailLists.Add(list);
				}

				return mailLists.ToArray();
			}
			catch(Exception ex)
			{
				throw new Exception("Couldn't obtain domain mail lists.", ex);
			}
		}
Ejemplo n.º 9
0
		public override MailList GetList(string listName)
		{
			try
			{
				string domain = GetDomainName(listName);
				string account = GetAccountName(listName);

				SM3.svcMailListAdmin svcLists = new SM3.svcMailListAdmin();
				PrepareProxy(svcLists);

				SM3.SettingsRequestResult sResult = svcLists.GetRequestedListSettings(
					AdminUsername,
					AdminPassword,
					domain,
					account,
					sm3Settings
				);

				if (!sResult.Result)
					throw new Exception(sResult.Message);

				SM3.SubscriberListResult mResult = svcLists.GetSubscriberList(
					AdminUsername,
					AdminPassword,
					domain,
					account
				);

				if (!mResult.Result)
					throw new Exception(mResult.Message);

				MailList list = new MailList();
				list.Name = listName;

				SetMailListSettings(list, sResult.settingValues);
				SetMailListMembers(list, mResult.Subscribers);

				return list;
			}
			catch (Exception ex)
			{
				throw new Exception("Couldn't obtain mail list.", ex);
			}
		}
Ejemplo n.º 10
0
		public override bool ListExists(string listName)
		{
			bool exists = false;

			try
			{
				string domain = GetDomainName(listName);
				string account = GetAccountName(listName);

				SM3.svcMailListAdmin lists = new SM3.svcMailListAdmin();
				PrepareProxy(lists);

				SM3.MailingListResult result = lists.GetMailingListsByDomain(AdminUsername, AdminPassword, domain);

				if (result.Result)
				{
					foreach (string member in result.listNames)
					{
						if (string.Compare(member, listName, true) == 0)
						{
							exists = true;
							break;
						}
					}
				}
			}
			catch (Exception ex)
			{
				throw new Exception("Couldn't obtain mail list.", ex);
			}

			return exists;
		}