Click here to Skip to main content
Click here to Skip to main content

LumiSoft MailServer

By , 17 Nov 2006
 
mailserver_0_92.zip [file error]
mailserver_part_i.zip
Net
docs
dns
dns_records.jpg
dns_records.vsd
Net
_junk
_Obsolete
_Stuff
AUTH
bin
Debug
LumiSoft.Net.dll
LumiSoft.Net.pdb
vs2E3.tmp
Release
LumiSoft.Net.dll
Data
Dns
Client
FTP
Client
Server
HTTP
Server
ICMP
IMAP
Client
Server
IO
Log
LumiSoft.Net
Mime
vCard
Net.csproj.user
Net.suo
NNTP
Client
obj
Debug
TempPE
POP3
Client
Server
SDP
ServersCore
SIP
Client
Message
Proxy
Stack
SMTP
Client
Server
STUN
Client
Message
RFC
AUTH
DNSx
FTPx
HTTP
ICMP
IMAPx
MIME
NNTPx
POP3x
SASL
SIP
SMTPx
STUN
mailserver_part_ii.zip
MailServer
Application
Debug
BackUp
Filters
lsDNSBL_Filter.exe
lsInvalidMessageScanner.exe
lsSpamFilter.exe
lsVirusFilter.exe
LumiSoft.UI.dll
Help
ICSharpCode.SharpZipLib.dll
InstallUtil.InstallLog
lsMailServer.exe
lsMailServer.pdb
lsMailServer.vshost.exe
LumiSoft.MailServerAPI.dll
LumiSoft.MailServerAPI.pdb
LumiSoft.Net.dll
LumiSoft.Net.pdb
Mail Server Configuration.exe
Mail Server Configuration.pdb
Mail Server Configuration.vshost.exe
MailServerManager.exe
MailServerManager.pdb
MailServerManager.vshost.exe
MailServerService.exe
MailServerService.InstallLog
MailServerService.pdb
MailServerService.vshost.exe
Mono.Security.dll
mssql_API.dll
mssql_API.pdb
Npgsql.dll
pgsql_API.dll
pgsql_API.pdb
Settings
local_xml
UserAPI.dll
UserAPI.pdb
xml_API.dll
xml_API.pdb
Release
BackUp
Filters
lsDNSBL_Filter.exe
lsInvalidMessageScanner.exe
lsSpamFilter.exe
lsVirusFilter.exe
LumiSoft.UI.dll
Help
ICSharpCode.SharpZipLib.dll
lsMailServer.exe
lsMailServer.vshost.exe
LumiSoft.MailServerAPI.dll
LumiSoft.Net.dll
Mail Server Configuration.exe
MailServerManager.exe
MailServerManager.vshost.exe
MailServerService.exe
Mono.Security.dll
mssql_API.dll
Npgsql.dll
pgsql_API.dll
Settings
local_xml
MailStore
UserAPI.dll
xml_API.dll
docs
address_mapping.jpg
address_mapping.vsd
incoming_message_processing.jpg
incoming_message_processing.vsd
Filters
lsDNSBL
App.ico
lsDNSBL_Filter.csproj.user
lsDNSBL_Filter.suo
lsInvalidMessageScanner
App.ico
bin
Debug
Release
lsInvalidMessageScanner.vshost.exe
lsInvalidMessageScanner.csproj.user
lsInvalidMessageScanner.suo
lsSenderFilter
App.ico
bin
Db
lsSenderFilter.csproj.user
lsSenderFilter.suo
lsSpamFilter
bin
Db
lsSpamFilter.csproj.user
lsSpamFilter.suo
lsVirusFilter
App.ico
bin
lsVirusFilter.csproj.user
lsVirusFilter.suo
Resources
eicar_message.eml.base64
Help
NewHelp
User
ENG
_Images
alias.jpg
aliases.jpg
domain.jpg
domains.jpg
filter.jpg
filters.jpg
logo.jpg
main.jpg
route.jpg
routing.jpg
securit1.jpg
securit2.jpg
security.jpg
server.jpg
sys_delivery.jpg
sys_general.jpg
sys_imap.jpg
sys_pop3.jpg
sys_smtp.jpg
user1.jpg
user2.jpg
users.jpg
Admin
Install
Intro
mailserver.hhp
MailServer_ENG.chm
Problems
Started
Table of Contents.hhc
Windows
UserApi
UserApi.shfb
Install
lsMailserver_Install
bin
Debug
lsMailserver_Install.exe
lsMailserver_Install.pdb
lsMailserver_Install.vshost.exe
Release
lsMailserver_Install.exe
lsMailserver_Install.pdb
Files
Backup
default_data.bcp
Filters
lsDNSBL_Filter.exe
lsInvalidMessageScanner.exe
lsSpamFilter.exe
lsVirusFilter.exe
lumisoft.ui.dll
Help
MailServer_ENG.chm
lsMailServer.exe
LumiSoft.MailServerAPI.dll
LumiSoft.Net.dll
LumiSoft.UI.dll
mssql_API.dll
Settings
WebServices_API.dll
xml_API.dll
lsMailserver_Install.suo
Properties
Settings.settings
MailServer
_Junk
Fetch
GlobalMessageRules
licenses.licx
lsMailServer.csproj.user
lsMailServer.suo
ManagementServer
Relay
Resources
exit.ico
trayicon.ico
UI
MailServerConfiguration
Mail Server Configuration.suo
MailServerConfiguration.suo
Properties
Settings.settings
MailServerManager
_Junk
App.ico
Controls
Forms
MailServerManager.csproj.user
MailServerManager.suo
res
aliases.ico
authentication.ico
doc_delete.ico
doc_edit.ico
doc_new.ico
domains.ico
logging.ico
routing.ico
save.ico
security.ico
server.ico
servers.ico
services.ico
system.ico
users.ico
Resources
about.ico
acl.ico
add.ico
addressing.ico
authentication.ico
backup.ico
bold.ico
checksyntax.ico
connect.ico
connect32.ico
delete.ico
domain.ico
domain32.ico
down.ico
edit.ico
error.ico
error.jpg
exit.ico
filter.ico
filter_disabled.ico
filter32.ico
folder.ico
folder32.ico
folders.ico
fontbackcolor.ico
fontcolor.ico
forum.ico
group.ico
group_disabled.ico
help.ico
italic.ico
logging.ico
mailinglist.ico
mailinglist_disabled.ico
message.ico
message16.ico
messagerule.ico
messagerule_disabled.ico
properties.ico
queue.ico
recyclebin.ico
recyclebin16.ico
refresh.ico
remoteserver32.ico
restore.ico
rootfolder.ico
rootfolder_disabled.ico
rule.ico
ruleaction.ico
save.ico
security.ico
security_disabled.ico
security32.ico
server.ico
server_running.ico
server_stopped.ico
servers.ico
services.ico
share32.ico
system.ico
underline.ico
up.ico
user.ico
user_disabled.ico
userinfo.ico
viewmessages.ico
write.ico
Tmp
MailServerService
MailServerService.suo
Properties
Settings.settings
ServerAPI
API
Filters
ServerAPI.suo
UI
API_mssql
mssql_API.csproj.user
mssql_API.suo
Resources
API_pgsql
dep
Mono.Security.dll
Npgsql.dll
pgsql_API.csproj.user
pgsql_API.suo
Resources
API_xml
Junk
xml_API.csproj.user
xml_API.suo
TestUserAPI
TestUserAPI.suo
TestUserAPI
bin
Debug
LumiSoft.Net.dll
LumiSoft.Net.pdb
TestUserAPI.exe
TestUserAPI.pdb
TestUserAPI.vshost.exe
UserAPI.dll
UserAPI.pdb
Properties
Settings.settings
UserAPI
UserAPI.suo
UserAPI
bin
Debug
Properties
ve-60.tmp
SQL_Database
MSSQL
Upgrade
PGSQL
Stuff
Upgrade
WebAdmin
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Data;

using LumiSoft.Net;

namespace LumiSoft.MailServer.API.UserAPI
{
    /// <summary>
    /// The GlobalMessageRuleActionCollection object represents global message rule actions in global message rule.
    /// </summary>
    public class GlobalMessageRuleActionCollection : IEnumerable
    {
        private GlobalMessageRule                 m_pRule    = null;
        private List<GlobalMessageRuleActionBase> m_pActions = null;

        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="rule">Owner global message rule.</param>
        internal GlobalMessageRuleActionCollection(GlobalMessageRule rule)
        {
            m_pRule = rule;
            m_pActions = new List<GlobalMessageRuleActionBase>();

            Bind();
        }

        #region method Add

        #region method Add_AddHeaderField

        /// <summary>
        /// Creates and adds new 'Add Header Field' action to GlobalMessageRuleActionCollection collection.
        /// </summary>
        /// <param name="description">Action description text.</param>
        /// <param name="headerFieldName">Header field name.</param>
        /// <param name="headerFieldValue">Header field value.</param>
        /// <returns></returns>
        public GlobalMessageRuleAction_AddHeaderField Add_AddHeaderField(string description,string headerFieldName,string headerFieldValue)
        {
            GlobalMessageRuleAction_AddHeaderField action = new GlobalMessageRuleAction_AddHeaderField(
                m_pRule,
                this,
                Guid.NewGuid().ToString(),
                description,
                headerFieldName,
                headerFieldValue
            );

            // Add action to rule
            Add(action);

            m_pActions.Add(action);

            return action;
        }

        #endregion

        #region method Add_AutoResponse

        /// <summary>
        /// Creates and adds new 'Auto Response' action to GlobalMessageRuleActionCollection collection.
        /// </summary>
        /// <param name="description">Action description text.</param>
        /// <param name="from">MAIL FROM: what is reported to destination SMTP server when auto response is sent.</param>
        /// <param name="message">Full auto response message. This must be rfc 2822 defined message.
        /// You can use LumiSoft.Net.Mime class to parse and to construct valid message.</param>
        /// <returns></returns>
        public GlobalMessageRuleAction_AutoResponse Add_AutoResponse(string description,string from,byte[] message)
        {
            GlobalMessageRuleAction_AutoResponse action = new GlobalMessageRuleAction_AutoResponse(
                m_pRule,
                this,
                Guid.NewGuid().ToString(),
                description,
                from,
                message
            );

            // Add action to rule
            Add(action);

            m_pActions.Add(action);

            return action;
        }

        #endregion

        #region method Add_DeleteMessage

        /// <summary>
        /// Creates and adds new 'Delete Message' action to GlobalMessageRuleActionCollection collection.
        /// </summary>
        /// <param name="description">Action description text.</param>
        public GlobalMessageRuleAction_DeleteMessage Add_DeleteMessage(string description)
        {
            GlobalMessageRuleAction_DeleteMessage action = new GlobalMessageRuleAction_DeleteMessage(
                m_pRule,
                this,
                Guid.NewGuid().ToString(),
                description
            );

            // Add action to rule
            Add(action);

            m_pActions.Add(action);

            return action;
        }

        #endregion

        #region method Add_ExecuteProgram

        /// <summary>
        /// Creates and adds new 'Execute Program' action to GlobalMessageRuleActionCollection collection.
        /// </summary>
        /// <param name="description">Action description text.</param>
        /// <param name="program">Program to execute.</param>
        /// <param name="programArguments">Executable program arguments</param>
        public GlobalMessageRuleAction_ExecuteProgram Add_ExecuteProgram(string description,string program,string programArguments)
        {
            GlobalMessageRuleAction_ExecuteProgram action = new GlobalMessageRuleAction_ExecuteProgram(
                m_pRule,
                this,
                Guid.NewGuid().ToString(),
                description,
                program,
                programArguments
            );

            // Add action to rule
            Add(action);

            m_pActions.Add(action);

            return action;
        }

        #endregion

        #region method Add_ForwardToEmail

        /// <summary>
        /// Creates and adds new 'Forward To Email' action to GlobalMessageRuleActionCollection collection.
        /// </summary>
        /// <param name="description">Action description text.</param>
        /// <param name="email">Email address where to forward message.</param>
        public GlobalMessageRuleAction_ForwardToEmail Add_ForwardToEmail(string description,string email)
        {
            GlobalMessageRuleAction_ForwardToEmail action = new GlobalMessageRuleAction_ForwardToEmail(
                m_pRule,
                this,
                Guid.NewGuid().ToString(),
                description,
                email
            );

            // Add action to rule
            Add(action);

            m_pActions.Add(action);

            return action;
        }

        #endregion

        #region method Add_ForwardToHost

        /// <summary>
        /// Creates and adds new 'Forward To Host' action to GlobalMessageRuleActionCollection collection.
        /// </summary>
        /// <param name="description">Action description text.</param>
        /// <param name="host">Host name or IP where to forward message.</param>
        /// <param name="port">Destination host port.</param>
        public GlobalMessageRuleAction_ForwardToHost Add_ForwardToHost(string description,string host,int port)
        {
            GlobalMessageRuleAction_ForwardToHost action = new GlobalMessageRuleAction_ForwardToHost(
                m_pRule,
                this,
                Guid.NewGuid().ToString(),
                description,
                host,
                port
            );

            
            // Add action to rule
            Add(action);

            m_pActions.Add(action);

            return action;
        }

        #endregion

        #region method Add_MoveToImapFolder

        /// <summary>
        /// Creates and adds new 'Move To IMAP Folder' action to GlobalMessageRuleActionCollection collection.
        /// </summary>
        /// <param name="description">Action description text.</param>
        /// <param name="folder">IMAP folder where to move message. If specified folder doesn't exist, message is store users Inbox.</param>
        public GlobalMessageRuleAction_MoveToImapFolder Add_MoveToImapFolder(string description,string folder)
        {
            GlobalMessageRuleAction_MoveToImapFolder action = new GlobalMessageRuleAction_MoveToImapFolder(
                m_pRule,
                this,
                Guid.NewGuid().ToString(),
                description,
                folder
            );

            // Add action to rule
            Add(action);

            m_pActions.Add(action);

            return action;
        }

        #endregion

        #region method Add_PostToHttp

        /// <summary>
        /// Creates and adds new 'Post To HTTP' action to GlobalMessageRuleActionCollection collection.
        /// </summary>
        /// <param name="description">Action description text.</param>
        /// <param name="url">HTTP URL where to post message.</param>
        public GlobalMessageRuleAction_PostToHttp Add_PostToHttp(string description,string url)
        {
            GlobalMessageRuleAction_PostToHttp action = new GlobalMessageRuleAction_PostToHttp(
                m_pRule,
                this,
                Guid.NewGuid().ToString(),
                description,
                url
            );

            // Add action to rule
            Add(action);

            m_pActions.Add(action);

            return action;
        }

        #endregion

        #region method Add_PostToNntp

        /// <summary>
        /// Creates and adds new 'Post To NNTP Newsgroup' action to GlobalMessageRuleActionCollection collection.
        /// </summary>
        /// <param name="description">Action description text.</param>
        /// <param name="host">NTTP server where to post message.</param>
        /// <param name="port">NNTP server port.</param>
        /// <param name="newsgroup">NTTP newsgroup where to post message.</param>
        public GlobalMessageRuleAction_PostToNntpNewsgroup Add_PostToNntp(string description,string host,int port,string newsgroup)
        {
            GlobalMessageRuleAction_PostToNntpNewsgroup action = new GlobalMessageRuleAction_PostToNntpNewsgroup(
                m_pRule,
                this,
                Guid.NewGuid().ToString(),
                description,
                host,
                port,
                newsgroup
            );

            // Add action to rule
            Add(action);

            m_pActions.Add(action);

            return action;
        }

        #endregion

        #region method Add_RemoveHeaderField

        /// <summary>
        /// Creates and adds new 'Remove Header Field' action to GlobalMessageRuleActionCollection collection.
        /// </summary>
        /// <param name="description">Action description text.</param>
        /// <param name="headerField">Header field name what to remove.</param>
        public GlobalMessageRuleAction_RemoveHeaderField Add_RemoveHeaderField(string description,string headerField)
        {
            GlobalMessageRuleAction_RemoveHeaderField action = new GlobalMessageRuleAction_RemoveHeaderField(
                m_pRule,
                this,
                Guid.NewGuid().ToString(),
                description,
                headerField
            );

            // Add action to rule
            Add(action);

            m_pActions.Add(action);

            return action;
        }

        #endregion

        #region method Add_SendError

        /// <summary>
        /// Creates and adds new 'Send Error To Client' action to GlobalMessageRuleActionCollection collection.
        /// </summary>
        /// <param name="description">Action description text.</param>
        /// <param name="errorText">Error text..</param>
        public GlobalMessageRuleAction_SendError Add_SendError(string description,string errorText)
        {
            GlobalMessageRuleAction_SendError action = new GlobalMessageRuleAction_SendError(
                m_pRule,
                this,
                Guid.NewGuid().ToString(),
                description,
                errorText
            );

            // Add action to rule
            Add(action);

            m_pActions.Add(action);

            return action;
        }

        #endregion

        #region method Add_StoreToDisk

        /// <summary>
        /// Creates and adds new 'Store To Disk Folder' action to GlobalMessageRuleActionCollection collection.
        /// </summary>
        /// <param name="description">Action description text.</param>
        /// <param name="folder">Disk folder where to store message.</param>
        public GlobalMessageRuleAction_StoreToDiskFolder Add_StoreToDisk(string description,string folder)
        {
            GlobalMessageRuleAction_StoreToDiskFolder action = new GlobalMessageRuleAction_StoreToDiskFolder(
                m_pRule,
                this,
                Guid.NewGuid().ToString(),
                description,
                folder
            );

            // Add action to rule
            Add(action);

            m_pActions.Add(action);

            return action;
        }

        #endregion

        #region method Add_StoreToFtp

        /// <summary>
        /// Creates and adds new 'Store To FTP Folder' action to GlobalMessageRuleActionCollection collection.
        /// </summary>
        /// <param name="description">Action description text.</param>
        /// <param name="host">FTP server where to store message.</param>
        /// <param name="port">FTP server port.</param>
        /// <param name="userName">FTP server user name.</param>
        /// <param name="password">FTP server user password.</param>
        /// <param name="folder">FTP folder where to store message.</param>
        public GlobalMessageRuleAction_StoreToFtp Add_StoreToFtp(string description,string host,int port,string userName,string password,string folder)
        {
            GlobalMessageRuleAction_StoreToFtp action = new GlobalMessageRuleAction_StoreToFtp(
                m_pRule,
                this,
                Guid.NewGuid().ToString(),
                description,
                host,
                port,
                userName,
                password,
                folder
            );

            // Add action to rule
            Add(action);

            m_pActions.Add(action);

            return action;
        }

        #endregion


        #region method Add

        /// <summary>
        /// Adds specified action to global message rule.
        /// </summary>
        /// <param name="action">Action to add.</param>
        private void Add(GlobalMessageRuleActionBase action)
        {
            Add(action.ID,action.Description,action.ActionType,action.Serialize(),false);
        }

        /// <summary>
        /// Adds specified action to connected server.
        /// </summary>
        /// <param name="actionID">Action ID.</param>
        /// <param name="description">Action description.</param>
        /// <param name="type">Action type.</param>
        /// <param name="actionData">Action data.</param>
        /// <param name="addToCollection">Specifies if added action must be created locally and added to local collection.</param>
        internal void Add(string actionID,string description,GlobalMessageRuleAction_enum type,byte[] actionData,bool addToCollection)
        {
            /* AddGlobalMessageRuleAction <virtualServerID> "<messageRuleID>" "<actionID>" "<description>" <actionType> "<actionData>:base64"
                  Responses:
                    +OK <sizeOfData>
                    <data>
                    
                    -ERR <errorText>
            */

            string id = Guid.NewGuid().ToString();

            // Call TCP AddGlobalMessageRuleAction
            m_pRule.VirtualServer.Server.Socket.WriteLine("AddGlobalMessageRuleAction " +
                m_pRule.VirtualServer.VirtualServerID + " " +
                TextUtils.QuoteString(m_pRule.ID) + " " +
                TextUtils.QuoteString(actionID) + " " +
                TextUtils.QuoteString(description) + " " +
                ((int)type).ToString() + " " + 
                Convert.ToBase64String(actionData)
            );
                        
            string response = m_pRule.VirtualServer.Server.Socket.ReadLine();
            if(!response.ToUpper().StartsWith("+OK")){
                throw new Exception(response);
            }

            if(addToCollection){
                m_pActions.Add(GetAction(actionID,description,type,actionData));
            }
        }

        #endregion

        #endregion

        #region method Remove

        /// <summary>
        /// Deletes specified action from global message rule.
        /// </summary>
        /// <param name="action">Action to remove.</param>
        public void Remove(GlobalMessageRuleActionBase action)
        {
            /* DeleteGlobalMessageRuleAction <virtualServerID> "<ruleID>" "<actionID>"
                  Responses:
                    +OK                     
                    -ERR <errorText>
            */

            string id = Guid.NewGuid().ToString();

            // Call TCP DeleteGlobalMessageRuleAction
            m_pRule.VirtualServer.Server.Socket.WriteLine("DeleteGlobalMessageRuleAction " + 
                m_pRule.VirtualServer.VirtualServerID + " " + 
                TextUtils.QuoteString(m_pRule.ID) + " " + 
                TextUtils.QuoteString(action.ID)
            );
                        
            string response = m_pRule.VirtualServer.Server.Socket.ReadLine();
            if(!response.ToUpper().StartsWith("+OK")){
                throw new Exception(response);
            }

            m_pActions.Remove(action);
        }

        #endregion


        #region method Bind

        /// <summary>
        /// Gets server global message rule actions and binds them to this, if not binded already.
        /// </summary>
        private void Bind()
        {
            /* GetGlobalMessageRuleActions <virtualServerID> "<messageRuleID>"
                  Responses:
                    +OK <sizeOfData>
                    <data>
                    
                    -ERR <errorText>
            */

            lock(m_pRule.VirtualServer.Server.LockSynchronizer){
                // Call TCP GetGlobalMessageRuleActions
                m_pRule.VirtualServer.Server.Socket.WriteLine("GetGlobalMessageRuleActions " + m_pRule.VirtualServer.VirtualServerID + " " + TextUtils.QuoteString(m_pRule.ID));

                string response = m_pRule.VirtualServer.Server.Socket.ReadLine();
                if(!response.ToUpper().StartsWith("+OK")){
                    throw new Exception(response);
                }

                int sizeOfData = Convert.ToInt32(response.Split(new char[]{' '},2)[1]);
                MemoryStream ms = new MemoryStream();
                m_pRule.VirtualServer.Server.Socket.ReadSpecifiedLength(sizeOfData,ms);
                
                // Decompress dataset
                DataSet ds = Utils.DecompressDataSet(ms);
               
                if(ds.Tables.Contains("GlobalMessageRuleActions")){
                    foreach(DataRow dr in ds.Tables["GlobalMessageRuleActions"].Rows){
                        m_pActions.Add(GetAction(
                            dr["ActionID"].ToString(),
                            dr["Description"].ToString(),
                            (GlobalMessageRuleAction_enum)Convert.ToInt32(dr["ActionType"]),
                            Convert.FromBase64String(dr["ActionData"].ToString())
                        ));
                    }
                }
            }
        }

        #endregion

        #region method GetAction

        /// <summary>
        /// Gets global message rule action.
        /// </summary>
        /// <param name="actionID">Action ID.</param>
        /// <param name="description">Action description.</param>
        /// <param name="actionType">Action type.</param>
        /// <param name="actionData">Action data.</param>
        /// <returns></returns>
        private GlobalMessageRuleActionBase GetAction(string actionID,string description,GlobalMessageRuleAction_enum actionType,byte[] actionData)
        {
            if(actionType == GlobalMessageRuleAction_enum.AddHeaderField){
                return new GlobalMessageRuleAction_AddHeaderField(m_pRule,this,actionID,description,actionData);
            }
            else if(actionType == GlobalMessageRuleAction_enum.AutoResponse){
                return new GlobalMessageRuleAction_AutoResponse(m_pRule,this,actionID,description,actionData);
            }
            else if(actionType == GlobalMessageRuleAction_enum.DeleteMessage){
                return new GlobalMessageRuleAction_DeleteMessage(m_pRule,this,actionID,description);
            }
            else if(actionType == GlobalMessageRuleAction_enum.ExecuteProgram){
                return new GlobalMessageRuleAction_ExecuteProgram(m_pRule,this,actionID,description,actionData);
            }
            else if(actionType == GlobalMessageRuleAction_enum.ForwardToEmail){
                return new GlobalMessageRuleAction_ForwardToEmail(m_pRule,this,actionID,description,actionData);
            }
            else if(actionType == GlobalMessageRuleAction_enum.ForwardToHost){
                return new GlobalMessageRuleAction_ForwardToHost(m_pRule,this,actionID,description,actionData);
            }
            else if(actionType == GlobalMessageRuleAction_enum.MoveToIMAPFolder){
                return new GlobalMessageRuleAction_MoveToImapFolder(m_pRule,this,actionID,description,actionData);
            }
            else if(actionType == GlobalMessageRuleAction_enum.PostToHTTP){
                return new GlobalMessageRuleAction_PostToHttp(m_pRule,this,actionID,description,actionData);
            }
            else if(actionType == GlobalMessageRuleAction_enum.PostToNNTPNewsGroup){
                return new GlobalMessageRuleAction_PostToNntpNewsgroup(m_pRule,this,actionID,description,actionData);
            }
            else if(actionType == GlobalMessageRuleAction_enum.RemoveHeaderField){
                return new GlobalMessageRuleAction_RemoveHeaderField(m_pRule,this,actionID,description,actionData);
            }
            else if(actionType == GlobalMessageRuleAction_enum.SendErrorToClient){
                return new GlobalMessageRuleAction_SendError(m_pRule,this,actionID,description,actionData);
            }
            else if(actionType == GlobalMessageRuleAction_enum.StoreToDiskFolder){
                return new GlobalMessageRuleAction_StoreToDiskFolder(m_pRule,this,actionID,description,actionData);
            }
            else if(actionType == GlobalMessageRuleAction_enum.StoreToFTPFolder){
                return new GlobalMessageRuleAction_StoreToFtp(m_pRule,this,actionID,description,actionData);
            }

            throw new Exception("Invalid action type !");
        }

        #endregion


        #region interface IEnumerator

        /// <summary>
		/// Gets enumerator.
		/// </summary>
		/// <returns></returns>
		public IEnumerator GetEnumerator()
		{
			return m_pActions.GetEnumerator();
		}

		#endregion


        #region Properties Implementation

        /// <summary>
        /// Gets owner message rule where this actions apply.
        /// </summary>
        public GlobalMessageRule Rule
        {
            get{ return m_pRule; }
        }

        /// <summary>
        /// Gets number of global message rule actions.
        /// </summary>
        public int Count
        {
            get{ return m_pActions.Count; }
        }

        /// <summary>
        /// Gets a GlobalMessageRuleActionBase object in the collection by index number.
        /// </summary>
        /// <param name="index">An Int32 value that specifies the position of the GlobalMessageRuleActionBase object in the GlobalMessageRuleActionCollection collection.</param>
        /// <returns>A GlobalMessageRuleActionBase object value that represents the global message rule action in virtual server.</returns>
        public GlobalMessageRuleActionBase this[int index]
        {
            get{ return m_pActions[index]; }
        }

        /// <summary>
        /// Gets a GlobalMessageRuleActionBase object in the collection by global message rule ID.
        /// </summary>
        /// <param name="globalMessageRuleActionID">A String value that specifies the global message rule action ID of the GlobalMessageRuleActionBase object in the GlobalMessageRuleActionCollection collection.</param>
        /// <returns>A GlobalMessageRuleActionBase object value that represents the global message rule action in virtual server.</returns>
        public GlobalMessageRuleActionBase this[string globalMessageRuleActionID]
        {
            get{ 
                foreach(GlobalMessageRuleActionBase action in m_pActions){
                    if(action.ID.ToLower() == globalMessageRuleActionID.ToLower()){
                        return action;
                    }
                }

                throw new Exception("GlobalMessageRule action with specified ID '" + globalMessageRuleActionID + "' doesn't exist !"); 
            }
        }

        #endregion

    }
}

By viewing downloads associated with this article you agree to the Terms of use and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Ivar Lumi

Estonia Estonia
No Biography provided

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130619.1 | Last Updated 17 Nov 2006
Article Copyright 2006 by Ivar Lumi
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid