private void m_pOk_Click(object sender, EventArgs e) { if (this.m_pPattern.Text.Length == 0) { MessageBox.Show(this, "Please specify match pattern !", "Error:", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } RouteAction routeAction_enum = (RouteAction)((WComboBoxItem)this.m_pAction.SelectedItem).Tag; RouteActionBase action = null; if (routeAction_enum == RouteAction.RouteToMailbox) { if (this.m_pRouteToMailbox_Mailbox.Text == "") { MessageBox.Show(this, "Mailbox: value can't empty !", "Error:", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } action = new RouteAction_RouteToMailbox(this.m_pRouteToMailbox_Mailbox.Text); } else if (routeAction_enum == RouteAction.RouteToEmail) { if (this.m_pRouteToEmail_Email.Text == "") { MessageBox.Show(this, "Email: value can't empty !", "Error:", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } action = new RouteAction_RouteToEmail(this.m_pRouteToEmail_Email.Text); } else if (routeAction_enum == RouteAction.RouteToHost) { if (this.m_pRouteToHost_Host.Text == "") { MessageBox.Show(this, "Host: value can't empty !", "Error:", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } action = new RouteAction_RouteToHost(this.m_pRouteToHost_Host.Text, (int)this.m_pRouteToHost_Port.Value); } if (this.m_pRoute == null) { this.m_pRoute = this.m_pVirtualServer.Routes.Add(this.m_pDescription.Text, this.m_pPattern.Text, this.m_pEnabled.Checked, action); } else { this.m_pRoute.Description = this.m_pDescription.Text; this.m_pRoute.Pattern = this.m_pPattern.Text; this.m_pRoute.Enabled = this.m_pEnabled.Checked; this.m_pRoute.Action = action; this.m_pRoute.Commit(); } base.DialogResult = DialogResult.OK; base.Close(); }
private void m_pOk_Click(object sender, EventArgs e) { if (m_pPattern.Text.Length == 0) { MessageBox.Show(this, "Please specify match pattern !", "Error:", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } RouteAction_enum action = (RouteAction_enum)((WComboBoxItem)m_pAction.SelectedItem).Tag; RouteActionBase actionData = null; #region Route To Mailbox if (action == RouteAction_enum.RouteToMailbox) { //--- Validate values ------------------------------------------------// if (m_pRouteToMailbox_Mailbox.Text == "") { MessageBox.Show(this, "Mailbox: value can't empty !", "Error:", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //--------------------------------------------------------------------// actionData = new RouteAction_RouteToMailbox(m_pRouteToMailbox_Mailbox.Text); } #endregion #region Route To Email else if (action == RouteAction_enum.RouteToEmail) { //--- Validate values ------------------------------------------------// if (m_pRouteToEmail_Email.Text == "") { MessageBox.Show(this, "Email: value can't empty !", "Error:", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //--------------------------------------------------------------------// actionData = new RouteAction_RouteToEmail(m_pRouteToEmail_Email.Text); } #endregion #region Route To Host else if (action == RouteAction_enum.RouteToHost) { //--- Validate values ------------------------------------------------// if (m_pRouteToHost_Host.Text == "") { MessageBox.Show(this, "Host: value can't empty !", "Error:", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //--------------------------------------------------------------------// actionData = new RouteAction_RouteToHost(m_pRouteToHost_Host.Text, (int)m_pRouteToHost_Port.Value); } #endregion if (m_pRoute == null) { m_pRoute = m_pVirtualServer.Routes.Add( m_pDescription.Text, m_pPattern.Text, m_pEnabled.Checked, actionData ); } else { m_pRoute.Description = m_pDescription.Text; m_pRoute.Pattern = m_pPattern.Text; m_pRoute.Enabled = m_pEnabled.Checked; m_pRoute.Action = actionData; m_pRoute.Commit(); } this.DialogResult = DialogResult.OK; this.Close(); }