Exemplo n.º 1
0
 // Método para lançar o evento que envia o test case para o controller
 protected virtual void OnCallController(TestCase testCase)
 {
     CallController?.Invoke(this, new TestCaseEventArgs()
     {
         TestCase = testCase
     });
 }
Exemplo n.º 2
0
        /// <summary>非同期</summary>
        /// <param name="param">引数</param>
        /// <returns>結果</returns>
        /// <remarks>
        /// ここは副スレッドから実行されるので注意。
        /// 非同期処理クラスに非同期処理を定義すると、
        /// メンバ変数を引数として利用できる。
        /// </remarks>
        public object btn6_Exec(object param)
        {
            // 戻り値(キャスト)
            TestParameterValue testParameterValue = (TestParameterValue)param;

            // 戻り値
            TestReturnValue testReturnValue;

            // 呼出し制御部品(スレッドセーフでないため副スレッド内で作る)
            CallController callCtrl = new CallController("");

            // Invoke
            testReturnValue = (TestReturnValue)callCtrl.Invoke(
                "testWebService", testParameterValue);

            //// 進捗表示のテスト
            //this.ChangeProgress = delegate(object o)
            //{
            //    MessageBox.Show(o.ToString());
            //};

            //this.ExecChangeProgress("進捗表示");

            //// 非同期メッセージボックス表示のテスト
            //DialogResult dr = this.ShowAsyncMessageBoxWin(
            //    "メッセージ", "タイトル", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
            //// 非同期メッセージボックス表示のテスト(エラー)
            //System.Windows.MessageBoxResult mr = this.ShowAsyncMessageBoxWPF("メッセージ", "タイトル",
            //    System.Windows.MessageBoxButton.YesNo, System.Windows.MessageBoxImage.Information);

            // 結果表示
            return(testReturnValue);
        }
    /// <summary>
    /// btnMButton8のクリックイベント(更新処理)
    /// </summary>
    /// <param name="fxEventArgs">イベントハンドラの共通引数</param>
    /// <returns>URL</returns>
    protected string UOC_sampleScreen_btnMButton8_Click(FxEventArgs fxEventArgs)
    {
        // 引数クラスを生成
        // 下位(B・D層)は、テスト クラスを流用する
        TestParameterValue testParameterValue
            = new TestParameterValue(
                  this.ContentPageFileNoEx, fxEventArgs.ButtonID, "Update",
                  this.ddlDap.SelectedValue + "%"
                  + this.ddlMode1.SelectedValue + "%"
                  + this.ddlMode2.SelectedValue + "%"
                  + this.ddlExRollback.SelectedValue,
                  this.UserInfo);

        // 情報の設定
        testParameterValue.ShipperID   = int.Parse(this.TextBox1.Text);
        testParameterValue.CompanyName = this.TextBox2.Text;
        testParameterValue.Phone       = this.TextBox3.Text;

        // 戻り値
        TestReturnValue testReturnValue;

        // 呼出し制御部品
        CallController cctrl = new CallController(this.UserInfo);

        // Invoke
        testReturnValue = (TestReturnValue)cctrl.Invoke(
            this.ddlCmctCtrl.SelectedValue, testParameterValue);

        // 結果表示するメッセージ エリア
        Label label = (Label)this.GetMasterWebControl("Label1");

        label.Text = "";

        if (testReturnValue.ErrorFlag == true)
        {
            // 結果(業務続行可能なエラー)
            label.Text  = "ErrorMessageID:" + testReturnValue.ErrorMessageID + "\r\n";
            label.Text += "ErrorMessage:" + testReturnValue.ErrorMessage + "\r\n";
            label.Text += "ErrorInfo:" + testReturnValue.ErrorInfo + "\r\n";
        }
        else
        {
            // 結果(正常系)
            label.Text = testReturnValue.Obj.ToString() + "件更新";
        }

        // 画面遷移しないポストバックの場合は、urlを空文字列に設定する
        return("");
    }
    /// <summary>
    /// btnMButton5のクリックイベント(一覧取得(動的sql))
    /// </summary>
    /// <param name="fxEventArgs">イベントハンドラの共通引数</param>
    /// <returns>URL</returns>
    protected string UOC_sampleScreen_btnMButton5_Click(FxEventArgs fxEventArgs)
    {
        // 引数クラスを生成
        // 下位(B・D層)は、テスト クラスを流用する
        TestParameterValue testParameterValue
            = new TestParameterValue(
                  this.ContentPageFileNoEx, fxEventArgs.ButtonID, "SelectAll_DSQL",
                  this.ddlDap.SelectedValue + "%"
                  + this.ddlMode1.SelectedValue + "%"
                  + this.ddlMode2.SelectedValue + "%"
                  + this.ddlExRollback.SelectedValue,
                  this.UserInfo);

        // 動的SQLの要素を設定
        testParameterValue.OrderColumn   = this.ddlOrderColumn.SelectedValue;
        testParameterValue.OrderSequence = this.ddlOrderSequence.SelectedValue;

        // 戻り値
        TestReturnValue testReturnValue;

        // 呼出し制御部品
        CallController cctrl = new CallController(this.UserInfo);

        // Invoke
        testReturnValue = (TestReturnValue)cctrl.Invoke(
            this.ddlCmctCtrl.SelectedValue, testParameterValue);

        // 結果表示するメッセージ エリア
        Label label = (Label)this.GetMasterWebControl("Label1");

        label.Text = "";

        if (testReturnValue.ErrorFlag == true)
        {
            // 結果(業務続行可能なエラー)
            label.Text  = "ErrorMessageID:" + testReturnValue.ErrorMessageID + "\r\n";
            label.Text += "ErrorMessage:" + testReturnValue.ErrorMessage + "\r\n";
            label.Text += "ErrorInfo:" + testReturnValue.ErrorInfo + "\r\n";
        }
        else
        {
            // 結果(正常系)
            this.GridView1.DataSource = testReturnValue.Obj;
            this.GridView1.DataBind();
        }

        // 画面遷移しないポストバックの場合は、urlを空文字列に設定する
        return("");
    }
Exemplo n.º 5
0
        /// <summary>
        /// btnMButton1のClickイベント(件数取得)
        /// </summary>
        /// <param name="fxEventArgs">Event Handlerの共通引数</param>
        /// <returns>URL</returns>
        protected string UOC_sampleScreen_btnMButton1_Click(FxEventArgs fxEventArgs)
        {
            // 引数クラスを生成
            // 下位(B・D層)は、テスト クラスを流用する
            TestParameterValue testParameterValue
                = new TestParameterValue(
                      this.ContentPageFileNoEx, fxEventArgs.ButtonID, "SelectCount",
                      this.ddlDap.SelectedValue + "%"
                      + this.ddlMode1.SelectedValue + "%"
                      + this.ddlMode2.SelectedValue + "%"
                      + this.ddlExRollback.SelectedValue,
                      this.UserInfo);

            // 戻り値
            TestReturnValue testReturnValue;

            // 呼出し制御部品
            CallController cctrl = new CallController(this.UserInfo);

            // Invoke
            testReturnValue = (TestReturnValue)cctrl.Invoke(
                this.ddlCmctCtrl.SelectedValue, testParameterValue);

            // 結果表示するMessage エリア
            Label label = (Label)this.GetMasterWebControl("Label1");

            label.Text = "";

            if (testReturnValue.ErrorFlag == true)
            {
                // 結果(業務続行可能なエラー)
                label.Text  = "ErrorMessageID:" + testReturnValue.ErrorMessageID + "\r\n";
                label.Text += "ErrorMessage:" + testReturnValue.ErrorMessage + "\r\n";
                label.Text += "ErrorInfo:" + testReturnValue.ErrorInfo + "\r\n";
            }
            else
            {
                // 結果(正常系)
                label.Text = testReturnValue.Obj.ToString() + "件のデータがあります";
            }

            // 画面遷移しないPost Backの場合は、urlを空文字列に設定する
            return("");
        }
Exemplo n.º 6
0
        /// <summary>件数取得</summary>
        /// <param name="rcFxEventArgs">イベントハンドラの共通引数</param>
        /// <remarks>
        /// 非同期フレームワークを使用してB層の呼び出し処理を非同期化
        /// (非同期実行、結果表示の双方に匿名デリゲードを使用するパターン)
        /// </remarks>
        protected void UOC_btnButton1_Click(RcFxEventArgs rcFxEventArgs)
        {
            // 非同期処理クラスを生成
            // 匿名デリゲードの場合は、ベース2で良い。
            MyBaseAsyncFunc af = new MyBaseAsyncFunc(this);

            // 引数を纏める
            af.Parameter = (object)new TestParameterValue(
                this.Name, rcFxEventArgs.ControlName, "SelectCount",
                ((ComboBoxItem)this.ddlDap.SelectedItem).Value + "%"
                + ((ComboBoxItem)this.ddlMode1.SelectedItem).Value + "%"
                + ((ComboBoxItem)this.ddlMode2.SelectedItem).Value + "%"
                + ((ComboBoxItem)this.ddlExRollback.SelectedItem).Value,
                MyBaseControllerWin.UserInfo);

            // 非同期実行するメソッドを指定(匿名デリゲード)
            // ここは副スレッドから実行されるので注意
            // (画面上のメンバに触らないこと!)。
            af.AsyncFunc = delegate(object param)
            {
                // 引数クラス(キャスト)
                TestParameterValue testParameterValue = (TestParameterValue)param;

                // 戻り値
                TestReturnValue testReturnValue;

                // 呼出し制御部品(スレッドセーフでないため副スレッド内で作る)
                CallController callCtrl = new CallController("");

                // Invoke
                testReturnValue = (TestReturnValue)callCtrl.Invoke(
                    "testWebService", testParameterValue);

                //// 進捗表示のテスト
                //af.ChangeProgress = delegate(object o)
                //{
                //    MessageBox.Show(o.ToString());
                //};

                //af.ExecChangeProgress("進捗表示");

                //// 非同期メッセージボックス表示のテスト
                //DialogResult dr = af.ShowAsyncMessageBoxWin(
                //    "メッセージ", "タイトル", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                //// 非同期メッセージボックス表示のテスト(エラー)
                //System.Windows.MessageBoxResult mr = af.ShowAsyncMessageBoxWPF("メッセージ", "タイトル",
                //    System.Windows.MessageBoxButton.YesNo, System.Windows.MessageBoxImage.Information);

                // 結果表示
                return(testReturnValue);
            };

            // 結果表示のメソッドを指定(匿名デリゲード)
            // このメソッドは必ず主スレッドで実行される。
            // (画面上のメンバを更新できる!)。
            af.SetResult = delegate(object retVal)
            {
                if (retVal is Exception)
                {
                    // 例外発生時
                    MessageBox.Show(retVal.ToString(), "非同期処理で例外発生!");
                }
                else
                {
                    // 正常時

                    // 戻り値(キャスト)
                    TestReturnValue testReturnValue = (TestReturnValue)retVal;

                    // 結果表示するメッセージ エリア
                    this.labelMessage.Text = "";

                    if (testReturnValue.ErrorFlag == true)
                    {
                        // 結果(業務続行可能なエラー)
                        this.labelMessage.Text  = "ErrorMessageID:" + testReturnValue.ErrorMessageID + "\r\n";
                        this.labelMessage.Text += "ErrorMessage:" + testReturnValue.ErrorMessage + "\r\n";
                        this.labelMessage.Text += "ErrorInfo:" + testReturnValue.ErrorInfo + "\r\n";
                    }
                    else
                    {
                        // 結果(正常系)
                        this.labelMessage.Text = testReturnValue.Obj.ToString() + "件のデータがあります";
                    }
                }
            };

            // 非同期実行する。
            if (!af.Start())
            {
                MessageBox.Show("別の非同期処理が実行中です。");
            }
        }
        /// <summary>
        ///  Maintains the single worker thread functionalities. 
        /// </summary>
        /// <param name="asyncTask">Selected Asynchronous Task</param>
        private void WorkerThreadCallBack(object asyncTask)
        {
            AsyncProcessingServiceReturnValue selectedAsyncTask = (AsyncProcessingServiceReturnValue)asyncTask;

            // A new worker thread started an Async task
            this._workerThreadCount++;

            try
            {
                // To handle unstable "Register" state, when you invoke [Abort] at this state
                if (selectedAsyncTask.CommandId == (int)AsyncProcessingServiceParameterValue.AsyncCommand.Abort)
                {
                    throw new BusinessSystemException("APSAbortCommand", GetMessage.GetMessageDescription("CTE0004"));
                }

                // Call User Program to execute by using communication control function
                AsyncProcessingServiceParameterValue asyncParameterValue = new AsyncProcessingServiceParameterValue("AsyncProcessingService", "StartCopyFromBlob", "StartCopyFromBlob", "SQL",
                                                                                        new MyUserInfo(selectedAsyncTask.UserId, selectedAsyncTask.TaskId.ToString()));
                asyncParameterValue.TaskId = selectedAsyncTask.TaskId;
                asyncParameterValue.Data = selectedAsyncTask.Data;
                CallController callController = new CallController(asyncParameterValue.User);
                AsyncProcessingServiceReturnValue asyncReturnValue = (AsyncProcessingServiceReturnValue)callController.Invoke(selectedAsyncTask.ProcessName, asyncParameterValue);

                if (asyncReturnValue.ErrorFlag == true)
                {
                    if (asyncReturnValue.ErrorMessageID == "APSStopCommand")
                    {
                        string exceptionInfo = "ErrorMessageID: " + asyncReturnValue.ErrorMessageID + Environment.NewLine + "ErrorMessage: " + asyncReturnValue.ErrorMessage;
                        // Asynchronous task is stopped due to user 'stop' command.
                        this.UpdateAsyncTask(selectedAsyncTask, AsyncTaskUpdate.RETRY, exceptionInfo);
                        LogIF.ErrorLog("ASYNC-SERVICE", string.Format(GetMessage.GetMessageDescription("E0001") + asyncReturnValue.ErrorMessage, selectedAsyncTask.TaskId));
                    }
                    else
                    {
                        // Exception occurred by other than BusinessApplicationException

                        if (selectedAsyncTask.NumberOfRetries < this._maxNumberOfRetries)
                        {
                            // Asynchronous task does not exceeds the maximum number of retries
                            // Updated as retry later
                            string exceptionInfo = "ErrorMessageID: " + asyncReturnValue.ErrorMessageID + Environment.NewLine + "ErrorMessage: " + asyncReturnValue.ErrorMessage;
                            selectedAsyncTask.NumberOfRetries += 1;
                            this.UpdateAsyncTask(selectedAsyncTask, AsyncTaskUpdate.RETRY, exceptionInfo);
                            LogIF.ErrorLog("ASYNC-SERVICE", string.Format(GetMessage.GetMessageDescription("E0004"), selectedAsyncTask.TaskId));
                        }
                        else
                        {
                            // Asynchronous task exceeds maximum number of retries
                            // Update task as abort
                            string exceptionInfo = "ErrorMessageID: " + asyncReturnValue.ErrorMessageID + Environment.NewLine + "ErrorMessage: " + asyncReturnValue.ErrorMessage;
                            this.UpdateAsyncTask(selectedAsyncTask, AsyncTaskUpdate.FAIL, exceptionInfo);
                            LogIF.ErrorLog("ASYNC-SERVICE", string.Format(GetMessage.GetMessageDescription("E0005"), selectedAsyncTask.TaskId));
                        }
                    }
                }
                else
                {
                    // Selected Asynchronous task is completed successfully.
                    this.UpdateAsyncTask(selectedAsyncTask, AsyncTaskUpdate.SUCCESS);
                    LogIF.InfoLog("ASYNC-SERVICE", string.Format(GetMessage.GetMessageDescription("I0003"), selectedAsyncTask.TaskId));
                }
            }
            catch (BusinessSystemException ex)
            {
                // Asynchronous task is aborted due to BusinessSystemException sent by user program.
                string exceptionInfo = "ErrorMessageID: " + ex.messageID + Environment.NewLine + "ErrorMessage: " + ex.Message;
                this.UpdateAsyncTask(selectedAsyncTask, AsyncTaskUpdate.FAIL, exceptionInfo);
                LogIF.ErrorLog("ASYNC-SERVICE", string.Format(GetMessage.GetMessageDescription("E0006"), selectedAsyncTask.TaskId, ex.Message));
            }
            catch (Exception ex)
            {
                // Asynchronous task is aborted due to unexpected exception.
                string exceptionInfo = "ErrorMessageID: " + ex.GetType().Name + Environment.NewLine + "ErrorMessage: " + ex.Message;
                this.UpdateAsyncTask(selectedAsyncTask, AsyncTaskUpdate.FAIL, exceptionInfo);
                LogIF.ErrorLog("ASYNC-SERVICE", string.Format(GetMessage.GetMessageDescription("E0006"), selectedAsyncTask.TaskId, ex.Message));
            }
            finally
            {
                // Async task is over
                this._workerThreadCount--;
            }
        }
Exemplo n.º 8
0
        /// <summary>非同期</summary>
        /// <param name="param">引数</param>
        /// <returns>結果</returns>
        /// <remarks>
        /// ここは副スレッドから実行されるので注意。
        /// 非同期処理クラスに非同期処理を定義すると、
        /// メンバ変数を引数として利用できる。
        /// </remarks>
        public object btn6_Exec(object param)
        {
            // 戻り値(キャスト)
            TestParameterValue testParameterValue = (TestParameterValue)param;

            // 戻り値
            TestReturnValue testReturnValue;

            // 呼出し制御部品(スレッドセーフでないため副スレッド内で作る)
            CallController callCtrl = new CallController("");

            // Invoke
            testReturnValue = (TestReturnValue)callCtrl.Invoke(
                "testWebService", testParameterValue);

            //// 進捗表示のテスト
            //this.ChangeProgress = delegate(object o)
            //{
            //    MessageBox.Show(o.ToString());
            //};

            //this.ExecChangeProgress("進捗表示");

            //// 非同期メッセージボックス表示のテスト
            //MessageBoxResult mr = this.ShowAsyncMessageBoxWPF(
            //    "メッセージ", "タイトル", MessageBoxButton.YesNo, MessageBoxImage.Information);
            //// 非同期メッセージボックス表示のテスト(エラー)
            //System.Windows.Forms.DialogResult dr = this.ShowAsyncMessageBoxWin("メッセージ", "タイトル",
            //    System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Information);

            // 結果表示
            return testReturnValue;
        }
Exemplo n.º 9
0
        /// <summary>
        ///  Maintains the single worker thread functionalities.
        /// </summary>
        /// <param name="asyncTask">Selected Asynchronous Task</param>
        private void WorkerThreadCallBack(object asyncTask)
        {
            AsyncProcessingServiceReturnValue selectedAsyncTask = (AsyncProcessingServiceReturnValue)asyncTask;

            // A new worker thread started an Async task
            this._workerThreadCount++;

            try
            {
                // To handle unstable "Register" state, when you invoke [Abort] at this state
                if (selectedAsyncTask.CommandId == (int)AsyncProcessingServiceParameterValue.AsyncCommand.Abort)
                {
                    throw new BusinessSystemException("APSAbortCommand", GetMessage.GetMessageDescription("CTE0004"));
                }

                // Call User Program to execute by using communication control function
                AsyncProcessingServiceParameterValue asyncParameterValue = new AsyncProcessingServiceParameterValue("AsyncProcessingService", "Start", "Start", "SQL",
                                                                                                                    new MyUserInfo(selectedAsyncTask.UserId, selectedAsyncTask.TaskId.ToString()));
                asyncParameterValue.TaskId = selectedAsyncTask.TaskId;
                asyncParameterValue.Data   = selectedAsyncTask.Data;
                CallController callController = new CallController(asyncParameterValue.User);
                AsyncProcessingServiceReturnValue asyncReturnValue = (AsyncProcessingServiceReturnValue)callController.Invoke(selectedAsyncTask.ProcessName, asyncParameterValue);

                if (asyncReturnValue.ErrorFlag == true)
                {
                    if (asyncReturnValue.ErrorMessageID == "APSStopCommand")
                    {
                        string exceptionInfo = "ErrorMessageID: " + asyncReturnValue.ErrorMessageID + Environment.NewLine + "ErrorMessage: " + asyncReturnValue.ErrorMessage;
                        // Asynchronous task is stopped due to user 'stop' command.
                        this.UpdateAsyncTask(selectedAsyncTask, AsyncTaskUpdate.RETRY, exceptionInfo);
                        LogIF.ErrorLog("ASYNC-SERVICE", string.Format(GetMessage.GetMessageDescription("E0001") + asyncReturnValue.ErrorMessage, selectedAsyncTask.TaskId));
                    }
                    else
                    {
                        // Exception occurred by other than BusinessApplicationException

                        if (selectedAsyncTask.NumberOfRetries < this._maxNumberOfRetries)
                        {
                            // Asynchronous task does not exceeds the maximum number of retries
                            // Updated as retry later
                            string exceptionInfo = "ErrorMessageID: " + asyncReturnValue.ErrorMessageID + Environment.NewLine + "ErrorMessage: " + asyncReturnValue.ErrorMessage;
                            selectedAsyncTask.NumberOfRetries += 1;
                            this.UpdateAsyncTask(selectedAsyncTask, AsyncTaskUpdate.RETRY, exceptionInfo);
                            LogIF.ErrorLog("ASYNC-SERVICE", string.Format(GetMessage.GetMessageDescription("E0004"), selectedAsyncTask.TaskId));
                        }
                        else
                        {
                            // Asynchronous task exceeds maximum number of retries
                            // Update task as abort
                            string exceptionInfo = "ErrorMessageID: " + asyncReturnValue.ErrorMessageID + Environment.NewLine + "ErrorMessage: " + asyncReturnValue.ErrorMessage;
                            this.UpdateAsyncTask(selectedAsyncTask, AsyncTaskUpdate.FAIL, exceptionInfo);
                            LogIF.ErrorLog("ASYNC-SERVICE", string.Format(GetMessage.GetMessageDescription("E0005"), selectedAsyncTask.TaskId));
                        }
                    }
                }
                else
                {
                    // Selected Asynchronous task is completed successfully.
                    this.UpdateAsyncTask(selectedAsyncTask, AsyncTaskUpdate.SUCCESS);
                    LogIF.InfoLog("ASYNC-SERVICE", string.Format(GetMessage.GetMessageDescription("I0003"), selectedAsyncTask.TaskId));
                }
            }
            catch (BusinessSystemException ex)
            {
                // Asynchronous task is aborted due to BusinessSystemException sent by user program.
                string exceptionInfo = "ErrorMessageID: " + ex.messageID + Environment.NewLine + "ErrorMessage: " + ex.Message;
                this.UpdateAsyncTask(selectedAsyncTask, AsyncTaskUpdate.FAIL, exceptionInfo);
                LogIF.ErrorLog("ASYNC-SERVICE", string.Format(GetMessage.GetMessageDescription("E0006"), selectedAsyncTask.TaskId, ex.Message));
            }
            catch (Exception ex)
            {
                // Asynchronous task is aborted due to unexpected exception.
                string exceptionInfo = "ErrorMessageID: " + ex.GetType().Name + Environment.NewLine + "ErrorMessage: " + ex.Message;
                this.UpdateAsyncTask(selectedAsyncTask, AsyncTaskUpdate.FAIL, exceptionInfo);
                LogIF.ErrorLog("ASYNC-SERVICE", string.Format(GetMessage.GetMessageDescription("E0006"), selectedAsyncTask.TaskId, ex.Message));
            }
            finally
            {
                // Async task is over
                this._workerThreadCount--;
            }
        }
Exemplo n.º 10
0
        /// <summary>件数取得</summary>
        /// <param name="rcFxEventArgs">イベントハンドラの共通引数</param>
        /// <remarks>
        /// 非同期フレームワークを使用してB層の呼び出し処理を非同期化
        /// (非同期実行、結果表示の双方に匿名デリゲードを使用するパターン)
        /// </remarks>
        protected void UOC_btnButton1_Click(RcFxEventArgs rcFxEventArgs)
        {
            // 非同期処理クラスを生成
            // 匿名デリゲードの場合は、ベース2で良い。
            MyBaseAsyncFunc af = new MyBaseAsyncFunc(this);

            // 引数を纏める
            af.Parameter = (object)new TestParameterValue(
                this.Name, rcFxEventArgs.ControlName, "SelectCount",
                ((ComboBoxItem)this.ddlDap.SelectedItem).Value + "%"
                + ((ComboBoxItem)this.ddlMode1.SelectedItem).Value + "%"
                + ((ComboBoxItem)this.ddlMode2.SelectedItem).Value + "%"
                + ((ComboBoxItem)this.ddlExRollback.SelectedItem).Value,
                MyBaseControllerWin.UserInfo);

            // 非同期実行するメソッドを指定(匿名デリゲード)
            // ここは副スレッドから実行されるので注意
            // (画面上のメンバに触らないこと!)。
            af.AsyncFunc = delegate(object param)
            {
                // 引数クラス(キャスト)
                TestParameterValue testParameterValue = (TestParameterValue)param;

                // 戻り値
                TestReturnValue testReturnValue;

                // 呼出し制御部品(スレッドセーフでないため副スレッド内で作る)
                CallController callCtrl = new CallController("");

                // Invoke
                testReturnValue = (TestReturnValue)callCtrl.Invoke(
                    "testWebService", testParameterValue);

                //// 進捗表示のテスト
                //af.ChangeProgress = delegate(object o)
                //{
                //    MessageBox.Show(o.ToString());
                //};

                //af.ExecChangeProgress("進捗表示");

                //// 非同期メッセージボックス表示のテスト
                //DialogResult dr = af.ShowAsyncMessageBoxWin(
                //    "メッセージ", "タイトル", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                //// 非同期メッセージボックス表示のテスト(エラー)
                //System.Windows.MessageBoxResult mr = af.ShowAsyncMessageBoxWPF("メッセージ", "タイトル",
                //    System.Windows.MessageBoxButton.YesNo, System.Windows.MessageBoxImage.Information);

                // 結果表示
                return testReturnValue;
            };

            // 結果表示のメソッドを指定(匿名デリゲード)
            // このメソッドは必ず主スレッドで実行される。
            // (画面上のメンバを更新できる!)。
            af.SetResult = delegate(object retVal)
            {
                if (retVal is Exception)
                {
                    // 例外発生時
                    MessageBox.Show(retVal.ToString(), "非同期処理で例外発生!");
                }
                else
                {
                    // 正常時

                    // 戻り値(キャスト)
                    TestReturnValue testReturnValue = (TestReturnValue)retVal;

                    // 結果表示するメッセージ エリア
                    this.labelMessage.Text = "";

                    if (testReturnValue.ErrorFlag == true)
                    {
                        // 結果(業務続行可能なエラー)
                        this.labelMessage.Text = "ErrorMessageID:" + testReturnValue.ErrorMessageID + "\r\n";
                        this.labelMessage.Text += "ErrorMessage:" + testReturnValue.ErrorMessage + "\r\n";
                        this.labelMessage.Text += "ErrorInfo:" + testReturnValue.ErrorInfo + "\r\n";
                    }
                    else
                    {
                        // 結果(正常系)
                        this.labelMessage.Text = testReturnValue.Obj.ToString() + "件のデータがあります";
                    }
                }
            };

            // 非同期実行する。
            if (!af.Start())
            {
                MessageBox.Show("別の非同期処理が実行中です。");
            }
        }
        /// <summary>件数取得</summary>
        /// <remarks>
        /// 非同期フレームワークを使用してB層の呼び出し処理を非同期化
        /// (非同期実行、結果表示の双方に匿名デリゲードを使用するパターン)
        /// </remarks>
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            // 非同期処理クラスを生成
            // 匿名デリゲードの場合は、ベース2で良い。
            MyBaseAsyncFunc af = new MyBaseAsyncFunc(this);

            // 引数を纏め非同期処理クラスに設定
            af.Parameter = (object)new TestParameterValue(
                this.Name, ((Button)sender).Name, "SelectCount",
                ((ComboBoxItem)this.ddlDap.SelectedItem).Value + "%"
                + ((ComboBoxItem)this.ddlMode1.SelectedItem).Value + "%"
                + ((ComboBoxItem)this.ddlMode2.SelectedItem).Value + "%"
                + ((ComboBoxItem)this.ddlExRollback.SelectedItem).Value,
                this.myUserInfo);

            // 画面上のデータは退避する
            //(オブジェクトであれば、クローンする。)
            string logicalName = ((ComboBoxItem)this.ddlTransmission.SelectedItem).Value;

            // 非同期実行するメソッドを指定(匿名デリゲード)
            // ここは副スレッドから実行されるので注意
            // (画面上のメンバに触らないこと!)。
            af.AsyncFunc = delegate(object param)
            {
                // 引数クラス(キャスト)
                TestParameterValue testParameterValue = (TestParameterValue)param;

                // 戻り値
                TestReturnValue testReturnValue;

                // 呼出し制御部品(スレッドセーフでないため副スレッド内で作る)
                CallController callCtrl = new CallController("");

                // Invoke
                testReturnValue = (TestReturnValue)callCtrl.Invoke(
                    logicalName, testParameterValue);

                //// 進捗表示のテスト
                //af.ChangeProgress = delegate(object o)
                //{
                //    MessageBox.Show(o.ToString());
                //};

                //af.ExecChangeProgress("進捗表示");

                //// 非同期メッセージボックス表示のテスト
                //MessageBoxResult mr = af.ShowAsyncMessageBoxWPF(
                //    "メッセージ", "タイトル", MessageBoxButton.YesNo, MessageBoxImage.Information);
                //// 非同期メッセージボックス表示のテスト(エラー)
                //System.Windows.Forms.DialogResult dr = af.ShowAsyncMessageBoxWin("メッセージ", "タイトル",
                //    System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Information);

                // 結果表示
                return(testReturnValue);
            };

            // 結果表示のメソッドを指定(匿名デリゲード)
            // このメソッドは必ず主スレッドで実行される。
            // (画面上のメンバを更新できる!)。
            af.SetResult = delegate(object retVal)
            {
                if (retVal is Exception)
                {
                    // 例外発生時
                    RcMyCmnFunction.ShowErrorMessageWPF((Exception)retVal, "非同期処理で例外発生!");
                }
                else
                {
                    // 正常時

                    // 戻り値(キャスト)
                    TestReturnValue testReturnValue = (TestReturnValue)retVal;

                    // 結果表示するメッセージ エリア
                    this.labelMessage.Content = "";

                    if (testReturnValue.ErrorFlag == true)
                    {
                        // 結果(業務続行可能なエラー)
                        this.labelMessage.Content  = "ErrorMessageID:" + testReturnValue.ErrorMessageID + "\r\n";
                        this.labelMessage.Content += "ErrorMessage:" + testReturnValue.ErrorMessage + "\r\n";
                        this.labelMessage.Content += "ErrorInfo:" + testReturnValue.ErrorInfo + "\r\n";
                    }
                    else
                    {
                        // 結果(正常系)
                        this.labelMessage.Content = testReturnValue.Obj.ToString() + "件のデータがあります";
                    }
                }
            };

            // 非同期実行する。
            if (!af.StartByThreadPool())
            {
                MessageBox.Show("別の非同期処理が実行中です。");
            }
        }
Exemplo n.º 12
0
    /// <summary>
    /// btnMButton1のクリックイベント(件数取得)
    /// </summary>
    /// <param name="fxEventArgs">イベントハンドラの共通引数</param>
    /// <returns>URL</returns>
    protected string UOC_sampleScreen_btnMButton1_Click(FxEventArgs fxEventArgs)
    {
        // 引数クラスを生成
        // 下位(B・D層)は、テスト クラスを流用する
        TestParameterValue testParameterValue
            = new TestParameterValue(
                this.ContentPageFileNoEx, fxEventArgs.ButtonID, "SelectCount",
                this.ddlDap.SelectedValue + "%"
                + this.ddlMode1.SelectedValue + "%"
                + this.ddlMode2.SelectedValue + "%"
                + this.ddlExRollback.SelectedValue,
                this.UserInfo);

        // 戻り値
        TestReturnValue testReturnValue;

        // 呼出し制御部品
        CallController cctrl = new CallController(this.UserInfo);

        // Invoke
        testReturnValue = (TestReturnValue)cctrl.Invoke(
            this.ddlCmctCtrl.SelectedValue, testParameterValue);

        // 結果表示するメッセージ エリア
        Label label = (Label)this.GetMasterWebControl("Label1");
        label.Text = "";

        if (testReturnValue.ErrorFlag == true)
        {
            // 結果(業務続行可能なエラー)
            label.Text = "ErrorMessageID:" + testReturnValue.ErrorMessageID + "\r\n";
            label.Text += "ErrorMessage:" + testReturnValue.ErrorMessage + "\r\n";
            label.Text += "ErrorInfo:" + testReturnValue.ErrorInfo + "\r\n";
        }
        else
        {
            // 結果(正常系)
            label.Text = testReturnValue.Obj.ToString() + "件のデータがあります";
        }

        // 画面遷移しないポストバックの場合は、urlを空文字列に設定する
        return "";
    }
Exemplo n.º 13
0
    /// <summary>
    /// btnMButton5のクリックイベント(一覧取得(動的sql))
    /// </summary>
    /// <param name="fxEventArgs">イベントハンドラの共通引数</param>
    /// <returns>URL</returns>
    protected string UOC_sampleScreen_btnMButton5_Click(FxEventArgs fxEventArgs)
    {
        // 引数クラスを生成
        // 下位(B・D層)は、テスト クラスを流用する
        TestParameterValue testParameterValue
            = new TestParameterValue(
                this.ContentPageFileNoEx, fxEventArgs.ButtonID, "SelectAll_DSQL",
                this.ddlDap.SelectedValue + "%"
                + this.ddlMode1.SelectedValue + "%"
                + this.ddlMode2.SelectedValue + "%"
                + this.ddlExRollback.SelectedValue,
                this.UserInfo);

        // 動的SQLの要素を設定
        testParameterValue.OrderColumn = this.ddlOrderColumn.SelectedValue;
        testParameterValue.OrderSequence = this.ddlOrderSequence.SelectedValue;

        // 戻り値
        TestReturnValue testReturnValue;

        // 呼出し制御部品
        CallController cctrl = new CallController(this.UserInfo);

        // Invoke
        testReturnValue = (TestReturnValue)cctrl.Invoke(
            this.ddlCmctCtrl.SelectedValue, testParameterValue);

        // 結果表示するメッセージ エリア
        Label label = (Label)this.GetMasterWebControl("Label1");
        label.Text = "";

        if (testReturnValue.ErrorFlag == true)
        {
            // 結果(業務続行可能なエラー)
            label.Text = "ErrorMessageID:" + testReturnValue.ErrorMessageID + "\r\n";
            label.Text += "ErrorMessage:" + testReturnValue.ErrorMessage + "\r\n";
            label.Text += "ErrorInfo:" + testReturnValue.ErrorInfo + "\r\n";
        }
        else
        {
            // 結果(正常系)
            this.GridView1.DataSource = testReturnValue.Obj;
            this.GridView1.DataBind();
        }

        // 画面遷移しないポストバックの場合は、urlを空文字列に設定する
        return "";
    }