示例#1
0
        private void BindValues()
        {
            SmtpBox box = SmtpBox.Load(_boxId);

            txtTitle.Text       = box.Name;
            txtServer.Text      = box.Server;
            txtPort.Text        = box.Port.ToString();
            cbIsDefault.Checked = box.IsDefault;

            switch (box.SecureConnection)
            {
            case SecureConnectionType.None:
                rbSecurity.SelectedValue = "0";
                break;

            case SecureConnectionType.Ssl:
                rbSecurity.SelectedValue = "1";
                break;

            case SecureConnectionType.Tls:
                rbSecurity.SelectedValue = "2";
                break;

            default:
                break;
            }

            cbAuthenticate.Checked = box.Authenticate;
            txtUser.Text           = box.User;
            ViewState["Password"]  = box.Password;
        }
示例#2
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            this.imbSave.ServerClick   += new EventHandler(imbSave_ServerClick);
            this.lbCheck.Click         += new EventHandler(lbCheck_Click);
            this.btCheckSettings.Click += new EventHandler(btCheckSettings_Click);

            ApplyLocalization();
            BindToolBar();
            if (!Page.IsPostBack)
            {
                ViewState["IsInChecking"] = false.ToString();
                BindTypes();
                if (_boxId > 0)
                {
                    BindValues();
                }
            }
            if (_boxId > 0)
            {
                SmtpBox box = SmtpBox.Load(_boxId);
                if (box.Checked)
                {
                    ViewState["IsInChecking"] = false.ToString();
                    lblMessage.Text           = LocRM.GetString("tSetsAreCorrect");
                    lbCheck.ForeColor         = Color.Green;
                    lbCheck.Visible           = true;
                }
                else
                {
                    lblMessage.Text   = LocRM.GetString("tNeedToCheck");
                    lbCheck.ForeColor = Color.Red;
                    lbCheck.Visible   = true;
                }
            }
            else
            {
                divCheck.Visible         = false;
                rbSecurity.SelectedIndex = 0;
                txtPort.Text             = "25";
            }
        }
示例#3
0
        private void imbSave_ServerClick(object sender, EventArgs e)
        {
            Page.Validate();
            if (!Page.IsValid)
            {
                return;
            }
            SmtpBox box;

            if (_boxId > 0)
            {
                box = SmtpBox.Load(_boxId);
            }
            else
            {
                box = SmtpBox.Initialize();
            }
            box.Name   = txtTitle.Text;
            box.Server = txtServer.Text;
            box.Port   = int.Parse(txtPort.Text);
            switch (rbSecurity.SelectedValue)
            {
            case "0":
                box.SecureConnection = SecureConnectionType.None;
                break;

            case "1":
                box.SecureConnection = SecureConnectionType.Ssl;
                break;

            case "2":
                box.SecureConnection = SecureConnectionType.Tls;
                break;

            default:
                break;
            }

            box.Authenticate = cbAuthenticate.Checked;
            if (cbAuthenticate.Checked)
            {
                box.User = txtUser.Text;
                if (txtPassword.Text.Length > 0 || txtUser.Text.Length == 0)
                {
                    box.Password = txtPassword.Text;
                }
            }
            //PortalConfig.SmtpSettings.IsChecked = false;
            //PortalConfig.SmtpSettings.CheckUid = Guid.NewGuid();

            if (_boxId > 0)
            {
                SmtpBox.Update(box);
            }
            else
            {
                SmtpBox.Create(box);
            }

            if (cbIsDefault.Checked)
            {
                SmtpBox.SetDefault(box.SmtpBoxId);
            }

            Response.Redirect("~/Admin/SMTPList.aspx", true);
        }