示例#1
0
        public MailGroup ToMailGroup()
        {
            MailGroup group = new MailGroup();

            group.Name    = mailboxName;
            group.Enabled = userConfig["enabled"] == "1" ? true : false;

            TreeNode redirection = deliveryConfig.ChildNodes["redirection"];

            if (redirection != null)
            {
                TreeNode redirections = redirection.ChildNodes["redirections"];

                if (redirections != null)
                {
                    List <string> list = new List <string>();

                    foreach (TreeNode node in redirections.ChildNodes)
                    {
                        list.Add(node.NodeValue);
                    }

                    group.Members = list.ToArray();
                }
            }

            return(group);
        }
示例#2
0
        public void Read(MailGroup group)
        {
            userConfig["domain"]  = GetDomainName(group.Name);
            userConfig["enabled"] = group.Enabled ? "1" : "0";
            userConfig["user"]    = GetAccountName(group.Name);

            AddForwardingInfo(group.Members, true);
        }
        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.");
            }
        }
        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.");
            }
        }
 public void BindItem(MailGroup item)
 {
     mailEditItems.Items = item.Members;
 }
示例#6
0
		public MailGroup GetGroup(string groupName)
		{
			try
			{
				svcAliasAdmin svcGroups = new svcAliasAdmin();
				PrepareProxy(svcGroups);

				AliasInfoResult result = svcGroups.GetAlias(AdminUsername, AdminPassword,
					GetDomainName(groupName), groupName);

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

				MailGroup group = new MailGroup();
				group.Name = groupName;
				group.Members = result.AliasInfo.Addresses;
				group.Enabled = true; // by default
				return group;
			}
			catch (Exception ex)
			{
				throw new Exception("Could not get mail domain group", ex);
			}
		}
示例#7
0
		private void UpdateDomainCatchAllGroup(string domainName, string mailboxName)
		{
			// check if system catch all group exists
			string groupName = SYSTEM_CATCH_ALL + "@" + domainName;
			if (GroupExists(groupName))
			{
				// delete group
				DeleteGroup(groupName);
			}

			if (!String.IsNullOrEmpty(mailboxName))
			{
				// create catch-all group
				MailGroup group = new MailGroup();
				group.Name = groupName;
				group.Enabled = true;
				group.Members = new string[] { mailboxName + "@" + domainName };

				// create
				CreateGroup(group);
			}
		}
示例#8
0
		public MailGroup ToMailGroup()
		{
			MailGroup group = new MailGroup();

			group.Name = mailboxName;
			group.Enabled = userConfig["enabled"] == "1" ? true : false;

			TreeNode redirection = deliveryConfig.ChildNodes["redirection"];

			if (redirection != null)
			{
				TreeNode redirections = redirection.ChildNodes["redirections"];

				if (redirections != null)
				{
					List<string> list = new List<string>();
					
					foreach (TreeNode node in redirections.ChildNodes)
						list.Add(node.NodeValue);

					group.Members = list.ToArray();
				}
			}

			return group;
		}
		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.");
			}
		}
        public static int UpdateMailGroup(MailGroup item)
        {
            // check account
            int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
            if (accountCheck < 0) return accountCheck;

            // load original meta item
            MailGroup origItem = (MailGroup)PackageController.GetPackageItem(item.Id);
            if (origItem == null)
                return BusinessErrorCodes.ERROR_MAIL_GROUPS_PACKAGE_ITEM_NOT_FOUND;


            // check package
            int packageCheck = SecurityContext.CheckPackage(origItem.PackageId, DemandPackage.IsActive);
            if (packageCheck < 0) return packageCheck;

            // check recipients number
            if (!CheckRecipientsAllowedNumber(origItem.PackageId, Quotas.MAIL_MAXGROUPMEMBERS, item.Members))
                return BusinessErrorCodes.ERROR_MAIL_GROUPS_RECIPIENTS_LIMIT;

            // place log record
            TaskManager.StartTask("MAIL_GROUP", "UPDATE", origItem.Name);
            TaskManager.ItemId = item.Id;

            try
            {
                // get service
                MailServer mail = new MailServer();
                ServiceProviderProxy.Init(mail, origItem.ServiceId);
                item.Name = origItem.Name;
                item.Enabled = true;
				item.Members = RemoveItemNameFromMembersList(
						  item.Name
						, item.Members.Clone() as string[]
					);

                // update service item
                mail.UpdateGroup(item);
                return 0;
            }
            catch (Exception ex)
            {
                throw TaskManager.WriteError(ex);
            }
            finally
            {
                TaskManager.CompleteTask();
            }
        }
示例#11
0
 /// <remarks/>
 public void AddMailGroupAsync(MailGroup item)
 {
     this.AddMailGroupAsync(item, null);
 }
示例#12
0
 /// <remarks/>
 public System.IAsyncResult BeginAddMailGroup(MailGroup item, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("AddMailGroup", new object[] {
                 item}, callback, asyncState);
 }
 public int UpdateMailGroup(MailGroup item)
 {
     return MailServerController.UpdateMailGroup(item);
 }
 public int AddMailGroup(MailGroup item)
 {
     return MailServerController.AddMailGroup(item);
 }
示例#15
0
 public void UpdateGroup(MailGroup group)
 {
     try
     {
         Log.WriteStart("'{0}' UpdateGroup", ProviderSettings.ProviderName);
         MailProvider.UpdateGroup(group);
         Log.WriteEnd("'{0}' UpdateGroup", ProviderSettings.ProviderName);
     }
     catch (Exception ex)
     {
         Log.WriteError(String.Format("'{0}' UpdateGroup", ProviderSettings.ProviderName), ex);
         throw;
     }
 }
        private void BindItem()
        {
            try
            {
                if (!IsPostBack)
                {
                    // load item if required
                    if (PanelRequest.ItemID > 0)
                    {
                        // existing item
                        try
                        {
                            item = ES.Services.MailServers.GetMailGroup(PanelRequest.ItemID);
                        }
                        catch (Exception ex)
                        {
                            ShowErrorMessage("MAIL_GET_GROUP", ex);
                            return;
                        }

                        if (item != null)
                        {
                            // save package info
                            ViewState["PackageId"] = item.PackageId;
                            emailAddress.PackageId = item.PackageId;
                        }
                        else
                            RedirectToBrowsePage();
                    }
                    else
                    {
                        // new item
                        ViewState["PackageId"] = PanelSecurity.PackageId;
                        emailAddress.PackageId = PanelSecurity.PackageId;
                    }
                }

                // load provider control
                LoadProviderControl((int)ViewState["PackageId"], "Mail", providerControl, "EditGroup.ascx");

                if (!IsPostBack)
                {
                    // bind item to controls
                    if (item != null)
                    {
                        // bind item to controls
                        emailAddress.Email = item.Name;
                        emailAddress.EditMode = true;

                        // other controls
                        IMailEditGroupControl ctrl = (IMailEditGroupControl)providerControl.Controls[0];
                        ctrl.BindItem(item);
                    }
                }
            }
            catch
            {
                ShowWarningMessage("INIT_SERVICE_ITEM_FORM");
                DisableFormControls(this, btnCancel);
                return;
            }
        }
        public static int AddMailGroup(MailGroup item)
        {
            // check account
            int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
            if (accountCheck < 0) return accountCheck;

            // check package
            int packageCheck = SecurityContext.CheckPackage(item.PackageId, DemandPackage.IsActive);
            if (packageCheck < 0) return packageCheck;

            // check quota
            QuotaValueInfo quota = PackageController.GetPackageQuota(item.PackageId, Quotas.MAIL_GROUPS);
            if (quota.QuotaExhausted)
                return BusinessErrorCodes.ERROR_MAIL_GROUPS_RESOURCE_QUOTA_LIMIT;

            // check recipients number
            if(!CheckRecipientsAllowedNumber(item.PackageId, Quotas.MAIL_MAXGROUPMEMBERS, item.Members))
                return BusinessErrorCodes.ERROR_MAIL_GROUPS_RECIPIENTS_LIMIT;

            // check if mail resource is available
            int serviceId = PackageController.GetPackageServiceId(item.PackageId, ResourceGroups.Mail);
            if (serviceId == 0)
                return BusinessErrorCodes.ERROR_MAIL_RESOURCE_UNAVAILABLE;

            // check package items
            if (PackageController.GetPackageItemByName(item.PackageId, item.Name, typeof(MailGroup)) != null)
                return BusinessErrorCodes.ERROR_MAIL_GROUPS_PACKAGE_ITEM_EXISTS;

            // place log record
            TaskManager.StartTask("MAIL_GROUP", "ADD", item.Name);

            try
            {
                // check service items
                MailServer mail = new MailServer();
                ServiceProviderProxy.Init(mail, serviceId);
                if (mail.GroupExists(item.Name))
                    return BusinessErrorCodes.ERROR_MAIL_GROUPS_SERVICE_ITEM_EXISTS;

                // add domain if not exists
                string domainName = item.Name.Substring(item.Name.IndexOf("@") + 1);
                int domainResult = AddMailDomain(item.PackageId, serviceId, domainName);
                if (domainResult < 0)
                    return domainResult;

                // create service item
                item.Enabled = true;
				item.Members = RemoveItemNameFromMembersList(
						  item.Name
						, item.Members.Clone() as string[]
					);

                // add service item
                mail.CreateGroup(item);

                // save item
                item.ServiceId = serviceId;
                int itemId = PackageController.AddPackageItem(item);

                TaskManager.ItemId = itemId;

                return itemId;
            }
            catch (Exception ex)
            {
                throw TaskManager.WriteError(ex);
            }
            finally
            {
                TaskManager.CompleteTask();
            }
        }
示例#18
0
 /// <remarks/>
 public void AddMailGroupAsync(MailGroup item, object userState)
 {
     if ((this.AddMailGroupOperationCompleted == null))
     {
         this.AddMailGroupOperationCompleted = new System.Threading.SendOrPostCallback(this.OnAddMailGroupOperationCompleted);
     }
     this.InvokeAsync("AddMailGroup", new object[] {
                 item}, this.AddMailGroupOperationCompleted, userState);
 }
		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.");
		}
示例#20
0
 public int UpdateMailGroup(MailGroup item)
 {
     object[] results = this.Invoke("UpdateMailGroup", new object[] {
                 item});
     return ((int)(results[0]));
 }
示例#21
0
 /// <remarks/>
 public void UpdateMailGroupAsync(MailGroup item)
 {
     this.UpdateMailGroupAsync(item, null);
 }
示例#22
0
 /// <remarks/>
 public void CreateGroupAsync(MailGroup group)
 {
     this.CreateGroupAsync(group, null);
 }
示例#23
0
        public virtual MailGroup[] GetGroups(string domainName)
        {
            try
            {
                svcAliasAdmin svcGroups = new svcAliasAdmin();
                PrepareProxy(svcGroups);

                AliasInfoListResult result = svcGroups.GetAliases(AdminUsername, AdminPassword, domainName);

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

                MailGroup[] groups = new MailGroup[result.AliasInfos.Length];
                for (int i = 0; i < groups.Length; i++)
                {
                    groups[i] = new MailGroup();
                    groups[i].Name = result.AliasInfos[i].Name + "@" + domainName;
                    groups[i].Members = result.AliasInfos[i].Addresses;
                    groups[i].Enabled = true; // by default
                }

                return groups;
            }
            catch (Exception ex)
            {
                throw new Exception("Could not get the list of mail domain groups", ex);
            }
        }
示例#24
0
 public void UpdateGroup(MailGroup group)
 {
     this.Invoke("UpdateGroup", new object[] {
                 group});
 }
示例#25
0
		public void Read(MailGroup group)
		{
			userConfig["domain"] = GetDomainName(group.Name);
			userConfig["enabled"] = group.Enabled ? "1" : "0";
			userConfig["user"] = GetAccountName(group.Name);

			AddForwardingInfo(group.Members, true);
		}
示例#26
0
 /// <remarks/>
 public System.IAsyncResult BeginUpdateGroup(MailGroup group, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("UpdateGroup", new object[] {
                 group}, callback, asyncState);
 }
示例#27
0
		public MailGroup[] GetGroups(string domainName)
		{
			try
			{
				svcAliasAdmin svcGroups = new svcAliasAdmin();
				PrepareProxy(svcGroups);

				AliasInfoListResult result = svcGroups.GetAliases(AdminUsername, AdminPassword, domainName);

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


				List<MailGroup> groups = new List<MailGroup>();

				foreach (AliasInfo alias in result.AliasInfos)
				{
					//group - alias with more than one forwarding address
					if (alias.Addresses.Length > 1)
					{
						MailGroup mailGroup = new MailGroup();
						mailGroup.Name = alias.Name + "@" + domainName;
						mailGroup.Members = alias.Addresses;
						groups.Add(mailGroup);
					}
				}

				return groups.ToArray();
			}
			catch (Exception ex)
			{
				throw new Exception("Could not get the list of mail domain groups", ex);
			}
		}
示例#28
0
 /// <remarks/>
 public void UpdateGroupAsync(MailGroup group)
 {
     this.UpdateGroupAsync(group, null);
 }
示例#29
0
		public void UpdateGroup(MailGroup group)
		{
			try
			{
				svcAliasAdmin svcGroups = new svcAliasAdmin();
				PrepareProxy(svcGroups);

				GenericResult result = svcGroups.UpdateAlias(AdminUsername, AdminPassword,
					GetDomainName(group.Name), group.Name, group.Members);

				if (!result.Result)
					throw new Exception(result.Message);
			}
			catch (Exception ex)
			{
				throw new Exception("Could not update mail domain group", ex);
			}
		}
示例#30
0
 /// <remarks/>
 public void UpdateGroupAsync(MailGroup group, object userState)
 {
     if ((this.UpdateGroupOperationCompleted == null))
     {
         this.UpdateGroupOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUpdateGroupOperationCompleted);
     }
     this.InvokeAsync("UpdateGroup", new object[] {
                 group}, this.UpdateGroupOperationCompleted, userState);
 }
 public void SaveItem(MailGroup item)
 {
     item.Members = mailEditItems.Items;
 }
        private void SaveItem()
        {
            if (!Page.IsValid)
                return;

            // get form data
            MailGroup item = new MailGroup();
            item.Id = PanelRequest.ItemID;
            item.PackageId = PanelSecurity.PackageId;
            item.Name = emailAddress.Email;

            //checking if group name is different from existing e-mail accounts
            MailAccount[] accounts = ES.Services.MailServers.GetMailAccounts(PanelSecurity.PackageId, true);
            foreach (MailAccount account in accounts)
            {
                if (item.Name == account.Name)
                {
                    ShowWarningMessage("MAIL_GROUP_NAME");
                    return;
                }
            }
            //checking if group name is different from existing mail lists
            MailList[] lists = ES.Services.MailServers.GetMailLists(PanelSecurity.PackageId, true);
            foreach (MailList list in lists)
            {
                if (item.Name == list.Name)
                {
                    ShowWarningMessage("MAIL_GROUP_NAME");
                    return;
                }
            }

            //checking if group name is different from existing forwardings
            MailAlias[] forwardings = ES.Services.MailServers.GetMailForwardings(PanelSecurity.PackageId, true);
            foreach (MailAlias forwarding in forwardings)
            {
                if (item.Name == forwarding.Name)
                {
                    ShowWarningMessage("MAIL_GROUP_NAME");
                    return;
                }
            }

            // get other props
            IMailEditGroupControl ctrl = (IMailEditGroupControl)providerControl.Controls[0];
            ctrl.SaveItem(item);

            if (PanelRequest.ItemID == 0)
            {
                // new item
                try
                {
                    int result = ES.Services.MailServers.AddMailGroup(item);
                    if (result < 0)
                    {
                        ShowResultMessage(result);
                        return;
                    }

                }
                catch (Exception ex)
                {
                    ShowErrorMessage("MAIL_ADD_GROUP", ex);
                    return;
                }
            }
            else
            {
                // existing item
                try
                {
                    int result = ES.Services.MailServers.UpdateMailGroup(item);
                    if (result < 0)
                    {
                        ShowResultMessage(result);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    ShowErrorMessage("MAIL_UPDATE_GROUP", ex);
                    return;
                }
            }

            // return
            RedirectSpaceHomePage();
        }