예제 #1
0
        /// <summary> 各項目のチェック処理(登録)</summary>
        private bool InputCheck()
        {
            // ジョブID
            string jobIdForChange = Properties.Resources.err_message_job_id;
            String jobId          = txtJobId.Text;

            // 未入力の場合
            if (CheckUtil.IsNullOrEmpty(jobId))
            {
                CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_001,
                                             new string[] { jobIdForChange });
                return(false);
            }
            // バイト数チェック
            if (CheckUtil.IsLenOver(jobId, 32))
            {
                CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_003,
                                             new string[] { jobIdForChange, "32" });
                return(false);
            }
            // 半角英数値、「-」、「_」チェック
            if (!CheckUtil.IsHankakuStrAndHyphenAndUnderbar(jobId))
            {
                CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_013,
                                             new string[] { jobIdForChange });
                return(false);
            }
            // 予約語(START)チェック
            if (CheckUtil.IsHoldStrSTART(jobId))
            {
                CommonDialog.ShowErrorDialog(Consts.ERROR_JOBEDIT_001);
                return(false);
            }
            // すでに登録済みの場合
            DataRow[] rowJob = _myJob.Container.JobControlTable.Select("job_id='" + jobId + "'");
            if (rowJob != null && rowJob.Length > 0)
            {
                foreach (DataRow row in rowJob)
                {
                    if (!jobId.Equals(_oldJobId) && jobId.Equals(row["job_id"]))
                    {
                        CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_004,
                                                     new string[] { jobIdForChange });
                        return(false);
                    }
                }
            }

            // ジョブ名
            string jobNameForChange = Properties.Resources.err_message_job_name;
            String jobName          = txtJobName.Text;

            // バイト数チェック
            if (CheckUtil.IsLenOver(jobName, 64))
            {
                CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_003,
                                             new string[] { jobNameForChange, "64" });
                return(false);
            }

            // 入力不可文字「"'\,」チェック
            if (CheckUtil.IsImpossibleStr(jobName))
            {
                CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_025,
                                             new string[] { jobNameForChange });
                return(false);
            }

            // ホスト(変数名)
            if (rbVariableName.IsChecked == true)
            {
                string hostValueNameForChange = Properties.Resources.err_message_host_value_name;
                string hostValueName          = Convert.ToString(textVariableName.Text);
                // 未入力の場合
                if (CheckUtil.IsNullOrEmpty(hostValueName))
                {
                    CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_001,
                                                 new string[] { hostValueNameForChange });
                    return(false);
                }
                // バイト数チェック
                if (CheckUtil.IsLenOver(hostValueName, 128))
                {
                    CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_003,
                                                 new string[] { hostValueNameForChange, "128" });
                    return(false);
                }
                // 半角英数値、アンダーバー、最初文字数値以外チェック
                if (!CheckUtil.IsHankakuStrAndUnderbarAndFirstNotNum(hostValueName))
                {
                    CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_015,
                                                 new string[] { hostValueNameForChange });
                    return(false);
                }
            }
            // ホスト名
            if (rbHostName.IsChecked == true)
            {
                string hostNameForChange = Properties.Resources.err_message_host_name;
                string hostName          = Convert.ToString(combHostName.SelectedValue);
                if (CheckUtil.IsNullOrEmpty(hostName))
                {
                    CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_001,
                                                 new string[] { hostNameForChange });
                    return(false);
                }
            }

            // 停止コマンド
            if (cbStop.IsChecked == true)
            {
                string stopCmdForChange = Properties.Resources.err_message_stop_command;
                string stopCmd          = Convert.ToString(txtStopCmd.Text);
                // 未入力の場合
                if (CheckUtil.IsNullOrEmpty(stopCmd))
                {
                    CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_001,
                                                 new string[] { stopCmdForChange });
                    return(false);
                }
                // ASCII文字チェック
                if (!CheckUtil.IsASCIIStr(stopCmd))
                {
                    CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_002,
                                                 new string[] { stopCmdForChange });
                    return(false);
                }
                // バイト数チェック
                if (CheckUtil.IsLenOver(stopCmd, 4000))
                {
                    CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_003,
                                                 new string[] { stopCmdForChange, "4000" });
                    return(false);
                }
            }

            // 実行欄
            string scriptCmdForChange = Properties.Resources.err_message_exec;
            string scriptCmd          = "";

            scriptCmd = txtCmd.Text;
            // 未入力の場合
            if (CheckUtil.IsNullOrEmpty(scriptCmd))
            {
                CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_001,
                                             new string[] { scriptCmdForChange });
                return(false);
            }
            // バイト数チェック
            if (CheckUtil.IsLenOver(scriptCmd, 4000))
            {
                CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_003,
                                             new string[] { scriptCmdForChange, "4000" });
                return(false);
            }

            // タイムアウト警告
            string timeOutForChange = Properties.Resources.err_message_timeout;
            string timeOut          = Convert.ToString(txtTimeOut.Text);

            // 未入力の場合
            if (CheckUtil.IsNullOrEmpty(timeOut))
            {
                CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_001,
                                             new string[] { timeOutForChange });
                return(false);
            }
            // 半角数字チェック
            if (!CheckUtil.IsHankakuNum(timeOut))
            {
                CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_007,
                                             new string[] { timeOutForChange });
                return(false);
            }
            // 桁数チェック
            if (CheckUtil.IsLenOver(timeOut, 5))
            {
                CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_003,
                                             new string[] { timeOutForChange, "5" });
                return(false);
            }

            // ジョブ停止コード
            string stopCodeForChange = Properties.Resources.err_message_stop_code;
            string stopCode          = Convert.ToString(txtStopCode.Text);

            // 半角数字、カンマ、ハイフンチェック
            if (!CheckUtil.IsHankakuNumAndCommaAndHyphen(stopCode))
            {
                CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_008,
                                             new string[] { stopCodeForChange });
                return(false);
            }
            // カンマ、およびハイフンの前後が数字チェック
            if (!CheckUtil.IsHankakuNumBeforeOrAfterCommaAndHyphen(stopCode))
            {
                CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_009,
                                             new string[] { stopCodeForChange });
                return(false);
            }
            // 桁数チェック
            if (CheckUtil.IsLenOver(stopCode, 32))
            {
                CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_003,
                                             new string[] { stopCodeForChange, "32" });
                return(false);
            }

            //added by YAMA 2014/08/15
            // 実行ユーザー(日本語入力可、省略可)
            string runUserForChange = Properties.Resources.err_message_run_user;
            String runUser          = txtRunUser.Text;
            bool   runUserFlg       = false;

            // 入力時は以下をチェック
            if (CheckUtil.IsNullOrEmpty(runUser) == false)
            {
                // バイト数チェック
                if (CheckUtil.IsLenOver(runUser, 256))
                {
                    CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_003,
                                                 new string[] { runUserForChange, "256" });
                    return(false);
                }

                // 禁則文字チェック
                if (!CheckUtil.IsProhibitedCharacterUserName(runUser))
                {
                    CommonDialog.ShowErrorDialog(Consts.ERROR_JOBEDIT_014,
                                                 new string[] { runUserForChange });
                    return(false);
                }

                runUserFlg = true;
            }

            // パスワード(省略可、パスワードのみは不可)
            string runUserPWForChange = Properties.Resources.err_message_run_user_pw;
            String runUserPW          = txtRunUserPW.Text;

            // 入力時は以下をチェック
            if (CheckUtil.IsNullOrEmpty(runUserPW) == false)
            {
                // 実行ユーザーが未設定
                if (runUserFlg == false)
                {
                    CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_001,
                                                 new string[] { runUserForChange });
                    return(false);
                }

                // 全角文字チェック
                if (CheckUtil.isHankaku(runUserPW) == false)
                {
                    CommonDialog.ShowErrorDialog(Consts.ERROR_JOBEDIT_015,
                                                 new string[] { runUserForChange });
                    return(false);
                }

                // バイト数チェック
                if (CheckUtil.IsLenOver(runUserPW, 256))
                {
                    CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_003,
                                                 new string[] { runUserPWForChange, "256" });
                    return(false);
                }

                // 禁則文字チェック
                if (!CheckUtil.IsProhibitedCharacterUserPW(runUserPW))
                {
                    CommonDialog.ShowErrorDialog(Consts.ERROR_JOBEDIT_015,
                                                 new string[] { runUserForChange });
                    return(false);
                }
            }


            return(true);
        }