public wfrm_User_General(ServerAPI serverAPI,string domainID)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //

            try
            {
                m_ServerAPI = serverAPI;

                DataView dvDomains = m_ServerAPI.GetDomainList();
                foreach(DataRowView vDr in dvDomains){
                    m_pDomains.Items.Add(vDr["DomainName"].ToString(),vDr["DomainID"].ToString());
                }

                if(m_pDomains.Items.Count > 0){
                    m_pDomains.SelectedIndex = 0;
                }
                if(domainID != "ALL"){
                    m_pDomains.SelectItemByTag(domainID);
                }
            }
            catch(Exception x)
            {
                wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                frm.ShowDialog(this);
            }
        }
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="serverAPI"></param>
        /// <param name="frame"></param>
        public wfrm_Domains(ServerAPI serverAPI,WFrame frame)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //

            try
            {
                m_ServerAPI = serverAPI;

                //---- Toolbar stuff
                frame.Frame_ToolBar = wToolBar1;

                InitGrid();

                m_Dv = serverAPI.GetDomainList();
                grid.DataSource = m_Dv;

                UpdateButtons();
            }
            catch(Exception x)
            {
                wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                frm.ShowDialog(this);
            }
        }
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="serverAPI"></param>
        public wfrm_Aliases(ServerAPI serverAPI,WFrame frame)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //

            try
            {
                m_ServerAPI = serverAPI;

                //---- Toolbar stuff
                frame.Frame_ToolBar = wToolBar1;

                InitGrid();

                RefreshForm();
            }
            catch(Exception x)
            {
                wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                frm.ShowDialog(this);
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="serverAPI"></param>
        public wfrm_System_Frame(ServerAPI serverAPI)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //

            try
            {
                m_ServerAPI = serverAPI;

                dsSettings = m_ServerAPI.GetSettings();
                dsSettings.AcceptChanges();
            }
            catch(Exception x){
                wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                frm.ShowDialog(this);
            }

            InitTab();
        }
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="serverAPI"></param>
        public wfrm_Domain(ServerAPI serverAPI)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //

            try
            {
                m_ServerAPI = serverAPI;
            }
            catch(Exception x)
            {
                wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                frm.ShowDialog(this);
            }
        }
        private void m_pOk_Click(object sender, System.EventArgs e)
        {
            try
            {
                string content = "";
                long   StartIP = 0;
                long   EndIP   = 0;

                if(m_pType.Text == "IP"){
                    content = m_pStartIP.Text;

                    if(!IsIpValid(content)){
                        MessageBox.Show("IP address isn't valid!!!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                        return;
                    }

                    StartIP = IP_to_long(m_pStartIP.Text);
                    EndIP   = IP_to_long(m_pStartIP.Text);
                }

                if(m_pType.Text == "IP Range"){
                    content = m_pStartIP.Text + "-" + m_pEndIP.Text;

                    if(!IsIpValid(m_pStartIP.Text)){
                        MessageBox.Show("Start IP address isn't valid!!!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                        return;
                    }
                    if(!IsIpValid(m_pEndIP.Text)){
                        MessageBox.Show("End IP address isn't valid!!!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                        return;
                    }

                    StartIP = IP_to_long(m_pStartIP.Text);
                    EndIP   = IP_to_long(m_pEndIP.Text);
                }

                if(m_pType.Text == "Domain"){
                    content = m_pDomain.Text;
                }

                m_Description = m_pDescription.Text;
                m_Protocol    = m_pProtocol.Text;
                m_Type        = m_pType.Text;
                m_Action      = m_pAction.Text;
                m_Content     = content;
                m_StartIP     = StartIP;
                m_EndIP       = EndIP;
            }
            catch(Exception x)
            {
                wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                frm.ShowDialog(this);
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
        private void LoadData(DataSet ds)
        {
            try
            {
                DataRow dr = ds.Tables["Settings"].Rows[0];
                m_pIMAPIPAddresses.Text = dr["IMAP_IPAddress"].ToString();
                m_pIMAP.Text            = dr["IMAP_Port"].ToString();
                m_pIMAP_Threads.Text    = dr["IMAP_Threads"].ToString();
                m_pIMAPSessionIdle.Text = dr["IMAP_SessionIdleTimeOut"].ToString();
                m_pIMAPCommandIdle.Text = dr["IMAP_CommandIdleTimeOut"].ToString();
                m_pMaxIMAPbadCmds.Text  = dr["IMAP_MaxBadCommands"].ToString();
                m_pEnabled.Checked      = Convert.ToBoolean(dr["IMAP_Enabled"]);

            }
            catch(Exception x)
            {
                wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                frm.ShowDialog(this);
            }
        }
        private void m_pOk_ButtonPressed(object sender, System.EventArgs e)
        {
            wTab1.SelectFirstTab();

            // Validate user general settings
            if(!m_wfrm_User_General.ValidateValues()){
                return;
            }

            try
            {
                if(m_New && m_ServerAPI.MailboxExists(m_wfrm_User_General.UserName)){
                    MessageBox.Show("User alredy exists!!!\nPlease select another User Name.","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
            //		m_pLogOnName.FlashControl();
                    return;
                }
            }
            catch(Exception x)
            {
                wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                frm.ShowDialog(this);
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
        /// <summary>
        /// Edit constructor.
        /// </summary>
        /// <param name="serverAPI"></param>
        /// <param name="dr"></param>
        public wfrm_Alias(ServerAPI serverAPI,DataRow dr)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //

            try
            {
                m_ServerAPI = serverAPI;

                m_pName.Text        = dr["AliasName"].ToString().Split(new char[]{'@'})[0];
                m_pDescription.Text = dr["Description"].ToString();
                m_pIsPublic.Checked = Convert.ToBoolean(dr["IsPublic"]);

                string[] member = dr["AliasMembers"].ToString().Split(new char[]{';'});
                foreach(string adr in member){
                    m_pMembers.Items.Add(adr);
                }

                DataView dvDomains = m_ServerAPI.GetDomainList();
                foreach(DataRowView vDr in dvDomains){
                    m_pDomains.Items.Add(vDr["DomainName"].ToString(),vDr["DomainID"].ToString());
                }

                if(m_pMembers.Items.Count > 0){
                    m_pDomains.SelectItemByTag(dr["DomainID"].ToString());
                    m_pDomains.Enabled = false;
                }
            }
            catch(Exception x)
            {
                wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                frm.ShowDialog(this);
            }
        }
        private void m_pOk_Click(object sender, System.EventArgs e)
        {
            if(m_pName.Text.Length <= 0){
                MessageBox.Show("AliasName name cannot be empty!!!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                m_pName.FlashControl();
                return;
            }

            if(m_pMembers.Items.Count == 0){
                MessageBox.Show("Please add at least one member!!!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                return;
            }

            try
            {
                string member = "";
                foreach(string str in m_pMembers.Items){
                    member += str + ";";
                }
                // remove ";" from end
                member = member.Substring(0,member.Length-1);

                m_AliasName   = m_pName.Text + "@" + m_pDomains.Text;
                m_Descriprion = m_pDescription.Text;
                m_Members     = member;
                m_DomainID    = m_pDomains.SelectedItem.Tag.ToString();
                m_IsPublic    = m_pIsPublic.Checked;
            }
            catch(Exception x)
            {
                wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                frm.ShowDialog(this);
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
 private void LoadData(DataSet ds)
 {
     try
     {
         DataRow dr = ds.Tables["Settings"].Rows[0];
         m_pSMTPIPAddresses.Text = dr["SMTP_IPAddress"].ToString();
         m_pSMTP.Text            = dr["SMTP_Port"].ToString();
         m_pSMTP_Threads.Text    = dr["SMTP_Threads"].ToString();
         m_pSessionIdle.Text     = dr["SMTP_SessionIdleTimeOut"].ToString();
         m_pCommandIdle.Text     = dr["SMTP_CommandIdleTimeOut"].ToString();
         m_pMaxSMTPbadCmds.Text  = dr["SMTP_MaxBadCommands"].ToString();
         m_pMessageSize.Text     = dr["MaxMessageSize"].ToString();
         m_pMaxRecipients.Text   = dr["MaxRecipients"].ToString();
         m_pDefaultDomain.Text   = dr["SMTP_DefaultDomain"].ToString();
         m_pEnabled.Checked      = Convert.ToBoolean(dr["SMTP_Enabled"]);
     }
     catch(Exception x)
     {
         wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
         frm.ShowDialog(this);
     }
 }
        private void m_pAdd_Click(object sender, System.EventArgs e)
        {
            try
            {
                if(m_pDomain.Text.Length <= 0){
                    MessageBox.Show("Domain name cannot be empty!!!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                    m_pDomain.FlashControl();
                    return;
                }

                if(m_ServerAPI.DomainExists(m_pDomain.Text)){
                    MessageBox.Show("Domain already exists!!!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                    return;
                }

                m_Domain      = m_pDomain.Text;
                m_Description = m_pDescription.Text;

            //	m_DataRow = m_ServerAPI.AddDomain(m_pDomain.Text,m_pDescription.Text);
            //	if(m_DataRow == null){
            //		MessageBox.Show("Error creating domain!!!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
            //		return;
            //	}

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch(Exception x)
            {
                wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                frm.ShowDialog(this);
            }
        }
        private void m_pRestoreServer_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                if(MessageBox.Show(this,"Warning: Restore overwrites current settings. BackUp Recommended!!!\nDo you want to continue?","Restore confirmation",MessageBoxButtons.YesNo,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    System.Windows.Forms.OpenFileDialog filedlg = new System.Windows.Forms.OpenFileDialog();
                    filedlg.Filter = "(*.bcp)|*.bcp";
                    filedlg.InitialDirectory = Application.StartupPath + "\\BackUP";
                    filedlg.RestoreDirectory = true;

                    if(filedlg.ShowDialog() == DialogResult.OK){
                        m_ServerAPI.RestoreBackUp(filedlg.FileName);
                    }
                }
            }
            catch(Exception x)
            {
                wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                frm.ShowDialog(this);
            }
        }
        private void m_pBackUpServer_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                System.Windows.Forms.SaveFileDialog filedlg = new System.Windows.Forms.SaveFileDialog();
                filedlg.Filter = "(*.bcp)|*.bcp";
                filedlg.InitialDirectory = Application.StartupPath + "\\BackUP";
                filedlg.RestoreDirectory = true;
                filedlg.FileName = DateTime.Now.ToString("yyyy_MM_dd");

                if(filedlg.ShowDialog() == DialogResult.OK){
                    m_ServerAPI.CreateBackUp(filedlg.FileName);
                }
            }
            catch(Exception x)
            {
                wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                frm.ShowDialog(this);
            }
        }
        private void LoadDomains()
        {
            try
            {
                m_pDomains.Items.Clear();

                m_pDomains.Items.Add("ALL","ALL");

                DataView dvDomains = m_ServerAPI.GetDomainList();
                foreach(DataRowView vDr in dvDomains){
                    m_pDomains.Items.Add(vDr["DomainName"].ToString(),vDr["DomainID"].ToString());
                }

                if(m_pDomains.Items.Count > 0){
                    m_pDomains.SelectedIndex = 0;
                }
            }
            catch(Exception x)
            {
                wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                frm.ShowDialog(this);
            }
        }
        private void wToolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
        {
            //--- Add new
            if(e.Button.Equals(toolBarButton_Add)){
                if(m_pDomains.Items.Count > 1){
                    wfrm_User_Frame frm = new wfrm_User_Frame(m_ServerAPI,m_pDomains.SelectedItem.Tag.ToString());
                    if(frm.ShowDialog(this) == DialogResult.OK){

                        DataRow dr = m_ServerAPI.AddUser(frm.FullName,frm.UserName,frm.Password,frm.Description,frm.Emails,frm.DomainID,frm.MailboxSize,frm.UserEnabled,frm.AllowRelay,frm.wp_RemoteAccounts);
                        if(dr == null){
                            MessageBox.Show("Error adding user!!!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                            return;
                        }

                        m_DvUsers.Table.ImportRow(dr);

                        UpdateButtons();
                    }
                }
                else{
                    MessageBox.Show("Please open Emails domain before!!!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                }

                return;
            }

            //--- Delete
            if(e.Button.Equals(toolBarButton_Delete)){
                try
                {
                    if(MessageBox.Show(this,"Warning: Deleting user!!!\nDo you want to continue?","Delete confirmation",MessageBoxButtons.YesNo,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                    {
                        DataRow dr = ((DataView)(grid.DataSource))[grid.CurrentRowIndex].Row;
                        if(dr != null){
                            m_ServerAPI.DeleteUser(dr["UserID"].ToString());
                            dr.Delete();
                        }

                        UpdateButtons();
                    }
                }
                catch(Exception x)
                {
                    wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                    frm.ShowDialog(this);
                }

                return;
            }

            //--- Edit
            if(e.Button.Equals(toolBarButton_Edit)){
                try
                {
                    DataRow dr = ((DataView)(grid.DataSource))[grid.CurrentRowIndex].Row;

                    if(dr != null){
                        wfrm_User_Frame frm = new wfrm_User_Frame(m_ServerAPI,dr);
                        if(frm.ShowDialog(this) == DialogResult.OK){

                            m_ServerAPI.UpdateUser(dr["UserID"].ToString(),frm.FullName,frm.Password,frm.Description,frm.Emails,frm.DomainID,frm.MailboxSize,frm.UserEnabled,frm.AllowRelay,frm.wp_RemoteAccounts);

                            dr["FULLNAME"]     = frm.FullName;
                            dr["USERNAME"]     = frm.UserName;
                            dr["PASSWORD"]     = frm.Password;
                            dr["Description"]  = frm.Description;
                            dr["Emails"]       = frm.Emails;
                            dr["DomainID"]     = frm.DomainID;
                            dr["Mailbox_Size"] = frm.MailboxSize;
                            dr["Enabled"]      = frm.UserEnabled;
                            dr["AllowRelay"]   = frm.AllowRelay;

                            if(frm.wp_RemoteAccounts != null){
                                dr["RemotePop3Servers"] = frm.wp_RemoteAccounts;
                            }
                            else{
                                dr["RemotePop3Servers"] = System.DBNull.Value;
                            }
                        }
                    }
                }
                catch(Exception x)
                {
                    wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                    frm.ShowDialog(this);
                }

                return;
            }
        }
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose( bool disposing )
        {
            try
            {
                m_pGene.SaveData();
                m_pSMTP.SaveData();
                m_pPOP3.SaveData();
                m_pIMAP.SaveData();
                m_pDely.SaveData();

                if(dsSettings.HasChanges()){
                    if(MessageBox.Show(null,"Do you want to save settings?","Save",MessageBoxButtons.YesNo,MessageBoxIcon.Question) == DialogResult.Yes){
                        m_ServerAPI.UpdateSettings(dsSettings);
                        m_ServerAPI.DatabaseTypeChanged();
                    }
                }
            }
            catch(Exception x){
                wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                frm.ShowDialog(this);
            }

            if( disposing )
            {
                if(components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose( disposing );
        }
        private void LoadData(DataSet ds)
        {
            try
            {
                DataRow dr = ds.Tables["Settings"].Rows[0];
                m_pMailStorePath.Text  = dr["MailRoot"].ToString();
                m_pLogSMTPCmds.Checked = Convert.ToBoolean(dr["LogSMTPCmds"]);
                m_pLogPOP3Cmds.Checked = Convert.ToBoolean(dr["LogPOP3Cmds"]);
                m_pLogIMAPCmds.Checked = Convert.ToBoolean(dr["LogIMAPCmds"]);
                m_pSMTPpath.Text       = dr["SMTP_LogPath"].ToString();
                m_pPOP3path.Text       = dr["POP3_LogPath"].ToString();
                m_pIMAPpath.Text       = dr["IMAP_LogPath"].ToString();
                m_pServerLogPath.Text  = dr["Server_LogPath"].ToString();
                m_pConStr.Text         = dr["ConnectionString"].ToString();

                m_pDbType.SelectItemByTag(dr["DataBaseType"].ToString());

                if(m_pDbType.Text == "MSSQL"){
                    m_pConStr.Enabled = true;
            //					m_pTest.Enabled = true;
                }
            }
            catch(Exception x)
            {
                wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                frm.ShowDialog(this);
            }
        }
        private void wToolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
        {
            //--- Add new
            if(e.Button.Equals(toolBarButton_Add)){
                try
                {
                    if(m_pDomains.Items.Count > 0){
                        wfrm_Alias frm = new wfrm_Alias(m_ServerAPI,m_pDomains.SelectedItem.Tag.ToString());
                        if(frm.ShowDialog(this) == DialogResult.OK){

                            DataRow dr = m_ServerAPI.AddAlias(frm.AliasName,frm.Descriprion,frm.Members,frm.DomainID,frm.IsPublic);
                            if(dr == null){
                                MessageBox.Show("Error adding alias!!!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                                return;
                            }

                            m_DvAliases.Table.ImportRow(dr);

                            UpdateButtons();
                        }
                    }
                    else{
                        MessageBox.Show("Please open Emails domain before!!!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                    }
                }
                catch(Exception x)
                {
                    wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                    frm.ShowDialog(this);
                }

                return;
            }

            //--- Delete
            if(e.Button.Equals(toolBarButton_Delete)){
                try
                {
                    if(MessageBox.Show(this,"Warning: Deleting alias!!!\nDo you want to continue?","Delete confirmation",MessageBoxButtons.YesNo,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                    {
                        DataRow dr = ((DataView)(grid.DataSource))[grid.CurrentRowIndex].Row;

                        if(dr != null){
                            m_ServerAPI.DeleteAlias(dr["AliasID"].ToString());
                            dr.Delete();
                        }

                        UpdateButtons();
                    }
                }
                catch(Exception x)
                {
                    wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                    frm.ShowDialog(this);
                }

                return;
            }

            //--- Edit
            if(e.Button.Equals(toolBarButton_Edit)){
                try
                {
                    DataRow dr = ((DataView)(grid.DataSource))[grid.CurrentRowIndex].Row;

                    if(dr != null){
                        wfrm_Alias frm = new wfrm_Alias(m_ServerAPI,dr);
                        if(frm.ShowDialog(this) == DialogResult.OK){
                            m_ServerAPI.UpdateAlias(dr["AliasID"].ToString(),frm.AliasName,frm.Descriprion,frm.Members,frm.DomainID,frm.IsPublic);

                            dr["AliasName"]    = frm.AliasName;
                            dr["Description"]  = frm.Descriprion;
                            dr["AliasMembers"] = frm.Members;
                            dr["DomainID"]     = frm.DomainID;
                            dr["IsPublic"]     = frm.IsPublic;
                        }
                    }
                }
                catch(Exception x)
                {
                    wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                    frm.ShowDialog(this);
                }

                return;
            }
        }
        public wfrm_User_General(ServerAPI serverAPI,DataRow dr)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //

            try
            {
                m_ServerAPI = serverAPI;
                drUser      = dr;

                m_pFullName.Text      = dr["FullName"].ToString();
                m_pLogOnName.Text     = dr["UserName"].ToString();
                m_pPassword.Text      = dr["Password"].ToString();
                m_pDescription.Text   = dr["Description"].ToString();
                m_pMailboxSize.Text   = dr["Mailbox_Size"].ToString();
                m_pEnabled.Checked    = Convert.ToBoolean(dr["Enabled"]);
                m_pAllowRelay.Checked = Convert.ToBoolean(dr["AllowRelay"]);

                string[] addresses = dr["Emails"].ToString().Split(new char[]{';'});
                foreach(string adr in addresses){
                    m_pAddresses.Items.Add(adr);
                }

                DataView dvDomains = m_ServerAPI.GetDomainList();
                foreach(DataRowView vDr in dvDomains){
                    m_pDomains.Items.Add(vDr["DomainName"].ToString(),vDr["DomainID"].ToString());
                }

                if(m_pAddresses.Items.Count > 0){
                    m_pDomains.SelectItemByTag(dr["DomainID"].ToString());
                    m_pDomains.Enabled = false;
                }
            }
            catch(Exception x)
            {
                wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                frm.ShowDialog(this);
            }
        }
        private void wToolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
        {
            //--- Add new
            if(e.Button.Equals(toolBarButton_Add)){
                try
                {

                    wfrm_Filter frm = new wfrm_Filter(m_ServerAPI);
                    if(frm.ShowDialog(this) == DialogResult.OK){

                        DataRow dr = m_ServerAPI.AddFilter(frm.wp_Description,frm.wp_Assembly,frm.wp_Class,frm.wp_Cost,frm.wp_Enabled);
                        if(dr == null){
                            MessageBox.Show("Error filter alias!!!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                            return;
                        }

                        m_DV.Table.ImportRow(dr);
                    }
                }
                catch(Exception x)
                {
                    wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                    frm.ShowDialog(this);
                }

                return;
            }

            //--- Delete
            if(e.Button.Equals(toolBarButton_Delete)){
                try
                {
                    if(MessageBox.Show(this,"Warning: Deleting filter!!!\nDo you want to continue?","Delete confirmation",MessageBoxButtons.YesNo,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                    {
                        DataRow dr = ((DataView)(grid.DataSource))[grid.CurrentRowIndex].Row;
                        if(dr != null){
                            m_ServerAPI.DeleteFilter(dr["FilterID"].ToString());
                            dr.Delete();
                        }

                //		UpdateButtons();
                    }
                }
                catch(Exception x)
                {
                    wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                    frm.ShowDialog(this);
                }

                return;
            }

            //--- Edit
            if(e.Button.Equals(toolBarButton_Edit)){
                try
                {
                    DataRow dr = ((DataView)(grid.DataSource))[grid.CurrentRowIndex].Row;
                    if(dr != null){
                        wfrm_Filter frm = new wfrm_Filter(m_ServerAPI,dr);
                        if(frm.ShowDialog(this) == DialogResult.OK){
                            m_ServerAPI.UpdateFilter(dr["FilterID"].ToString(),frm.wp_Description,frm.wp_Assembly,frm.wp_Class,frm.wp_Cost,frm.wp_Enabled);

                            dr["Description"] = frm.wp_Description;
                            dr["Assembly"]    = frm.wp_Assembly;
                            dr["ClassName"]   = frm.wp_Class;
                            dr["Cost"]        = frm.wp_Cost;
                            dr["Enabled"]     = frm.wp_Enabled;
                        }
                    }
                }
                catch(Exception x)
                {
                    wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                    frm.ShowDialog(this);
                }

                return;
            }
        }
        private void wToolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
        {
            //--- Add new
            if(e.Button.Equals(toolBarButton_Add)){
                try
                {
                    wfrm_SecurityEntry frm = new wfrm_SecurityEntry();
                    if(frm.ShowDialog(this) == DialogResult.OK){

                        DataRow dr = m_ServerAPI.AddSecurityEntry(frm.wp_Description,frm.wp_Protocol,frm.wp_Type,frm.wp_Action,frm.wp_Content,frm.wp_StartIP,frm.wp_EndIP);
                        if(dr == null){
                            MessageBox.Show("Error updating alias!!!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                            return;
                        }

                        m_DvSec.Table.ImportRow(dr);

                        UpdateButtons();
                    }
                }
                catch(Exception x)
                {
                    wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                    frm.ShowDialog(this);
                }

                return;
            }

            //--- Delete
            if(e.Button.Equals(toolBarButton_Delete)){
                try
                {
                    if(MessageBox.Show(this,"Warning: Deleting security entry!!!\nDo you want to continue?","Delete confirmation",MessageBoxButtons.YesNo,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                    {
                        DataRow dr = ((DataView)(grid.DataSource))[grid.CurrentRowIndex].Row;

                        if(dr != null){
                            m_ServerAPI.DeleteSecurityEntry(dr["SecurityID"].ToString());
                            dr.Delete();
                        }

                        UpdateButtons();
                    }
                }
                catch(Exception x)
                {
                    wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                    frm.ShowDialog(this);
                }

                return;
            }

            //--- Edit
            if(e.Button.Equals(toolBarButton_Edit)){
                try
                {
                    DataRow dr = ((DataView)(grid.DataSource))[grid.CurrentRowIndex].Row;
                    if(dr != null){
                        wfrm_SecurityEntry frm = new wfrm_SecurityEntry(dr);
                        if(frm.ShowDialog(this) == DialogResult.OK){
                            m_ServerAPI.UpdateSecurityEntry(dr["SecurityID"].ToString(),frm.wp_Description,frm.wp_Protocol,frm.wp_Type,frm.wp_Action,frm.wp_Content,frm.wp_StartIP,frm.wp_EndIP);

                            dr["Description"] = frm.wp_Description;
                            dr["Protocol"]    = frm.wp_Protocol;
                            dr["Type"]        = frm.wp_Type;
                            dr["Action"]      = frm.wp_Action;
                            dr["Content"]     = frm.wp_Content;
                            dr["StartIP"]     = frm.wp_StartIP;
                            dr["EndIP"]       = frm.wp_EndIP;
                        }
                    }
                }
                catch(Exception x)
                {
                    wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                    frm.ShowDialog(this);
                }

                return;
            }
        }
        private void LoadData(DataSet ds)
        {
            try
            {
                DataRow dr = ds.Tables["Settings"].Rows[0];
                m_pSmartHost.Text          = dr["SmartHost"].ToString();
                m_pPriDNS.Text             = dr["Dns1"].ToString();
                m_pSecDNS.Text             = dr["Dns2"].ToString();
                m_pMaxThreads.Text         = dr["MaxRelayThreads"].ToString();
                m_pRelayInterval.Text      = dr["RelayInterval"].ToString();
                m_pRelayRetryInterval.Text = dr["RelayRetryInterval"].ToString();
                m_pUndelivered.Text        = dr["RelayUndelivered"].ToString();
                m_pUndeliveredWarning.Text = dr["RelayUndeliveredWarning"].ToString();
                m_pStoreUndeliveredMessages.Checked = Convert.ToBoolean(dr["StoreUndeliveredMessages"]);

                bool UseSmartHost = Convert.ToBoolean(dr["UseSmartHost"]);
                if(UseSmartHost){
                    m_pUseSmartHost.Checked = true;
                }
                else{
                    m_pDNS.Checked = true;
                }

            }
            catch(Exception x)
            {
                wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                frm.ShowDialog(this);
            }
        }
Exemplo n.º 24
0
 //Handle the exception  event
 public void OnThreadException(object sender, ThreadExceptionEventArgs t)
 {
     wfrm_Error frm = new wfrm_Error(t.Exception,new System.Diagnostics.StackTrace());
     frm.ShowDialog(null);
 }