Beispiel #1
0
        /// <summary>
        /// Validates the form controls.
        /// </summary>
        private bool ValidateControls()
        {
            StringBuilder sbError = new();

            if (string.IsNullOrWhiteSpace(txtName.Text))
            {
                sbError.AppendError(lblName, CommonPhrases.NonemptyRequired);
            }

            if (string.IsNullOrWhiteSpace(cbExtension.Text))
            {
                sbError.AppendError(lblExtension, CommonPhrases.NonemptyRequired);
            }

            if (!string.IsNullOrWhiteSpace(txtWebUrl.Text) && !ScadaUtils.IsValidUrl(txtWebUrl.Text))
            {
                sbError.AppendError(lblWebUrl, CommonPhrases.ValidUrlRequired);
            }

            if (sbError.Length > 0)
            {
                ScadaUiUtils.ShowError(CommonPhrases.CorrectErrors + Environment.NewLine + sbError);
                return(false);
            }

            if (ExistingProfileNames != null && ExistingProfileNames.Contains(txtName.Text.Trim()))
            {
                ScadaUiUtils.ShowError(AppPhrases.ProfileNameDuplicated);
                return(false);
            }

            return(true);
        }
Beispiel #2
0
 private void lblLink_Click(object sender, EventArgs e)
 {
     if (ScadaUtils.IsValidUrl(linkUrl))
     {
         Process.Start(linkUrl);
         Close();
     }
 }
Beispiel #3
0
        /// <summary>
        /// Validates the form fields.
        /// </summary>
        private bool ValidateFields()
        {
            StringBuilder sbError = new StringBuilder();

            if (string.IsNullOrWhiteSpace(txtProfileName.Text))
            {
                sbError.AppendError(lblProfileName, CommonPhrases.NonemptyRequired);
            }

            if (!string.IsNullOrWhiteSpace(txtWebUrl.Text) && !ScadaUtils.IsValidUrl(txtWebUrl.Text))
            {
                sbError.AppendError(lblWebUrl, AppPhrases.ValidUrlRequired);
            }

            if (string.IsNullOrWhiteSpace(txtHost.Text))
            {
                sbError.AppendError(lblHost, CommonPhrases.NonemptyRequired);
            }

            if (string.IsNullOrWhiteSpace(txtUsername.Text))
            {
                sbError.AppendError(lblUsername, CommonPhrases.NonemptyRequired);
            }

            if (string.IsNullOrWhiteSpace(txtPassword.Text))
            {
                sbError.AppendError(lblPassword, CommonPhrases.NonemptyRequired);
            }

            if (string.IsNullOrWhiteSpace(txtSecretKey.Text))
            {
                sbError.AppendError(lblSecretKey, CommonPhrases.NonemptyRequired);
            }

            if (sbError.Length > 0)
            {
                sbError.Insert(0, AppPhrases.CorrectErrors + Environment.NewLine);
                ScadaUiUtils.ShowError(sbError.ToString());
                return(false);
            }

            if (ExistingProfileNames != null && ExistingProfileNames.Contains(txtProfileName.Text.Trim()))
            {
                ScadaUiUtils.ShowError(AppPhrases.ProfileNameDuplicated);
                return(false);
            }

            if (!ScadaUtils.HexToBytes(txtSecretKey.Text.Trim(), out byte[] bytes))