Пример #1
0
        /// <summary>業務例外発生時の処理を実装</summary>
        /// <param name="baEx">BusinessApplicationException</param>
        /// <param name="rcFxEventArgs">イベントハンドラの共通引数</param>
        /// <remarks>画面コード親クラス1から利用される派生の末端</remarks>
        protected override void UOC_ABEND(BusinessApplicationException baEx, RcFxEventArgs rcFxEventArgs)
        {
            // 業務例外発生時の処理を実装
            // TODO:

            // ここに、メッセージの組み立てロジックを実装する。

            // メッセージ編集処理 ------------------------------------------

            // -------------------------------------------------------------

            // メッセージ表示処理 ------------------------------------------

            // -------------------------------------------------------------

            // 性能測定終了

            // イベント処理開始前にエラーが発生した場合は、
            // this.perfRecがnullの場合があるので、null対策コードを挿入する。
            if (this.perfRec == null)
            {
                // nullの場合、新しいインスタンスを生成し、性能測定開始。
                this.perfRec = new PerformanceRecorder();
                perfRec.StartsPerformanceRecord();
            }

            this.perfRec.EndsPerformanceRecord();

            // ACCESSログ出力-----------------------------------------------

            if (MyBaseControllerWin.CanOutPutLog)
            {
                // ------------
                // メッセージ部
                // ------------
                // ユーザ名, レイヤ, 画面名, コントロール名,
                // 処理時間(実行時間), 処理時間(CPU時間)
                // エラーメッセージID, エラーメッセージ等
                // ------------
                string strLogMessage =
                    "," + UserInfo.UserName +
                    "," + "<-----" +
                    "," + this.Name +
                    "," + rcFxEventArgs.ControlName +
                    "," + this.perfRec.ExecTime +
                    "," + this.perfRec.CpuTime +
                    "," + baEx.messageID +
                    "," + baEx.Message;

                // Log4Netへログ出力
                LogIF.WarnLog("ACCESS", strLogMessage);
            }

            // -------------------------------------------------------------
        }
Пример #2
0
        public override async Task <InputFormatterResult> ReadRequestBodyAsync(InputFormatterContext context, Encoding encoding)
        {
            HttpRequest request = context.HttpContext.Request;
            bool        flag    = _options.SuppressInputFormatterBuffering;

            if (!request.Body.CanSeek && !flag)
            {
                request.EnableBuffering();
                await request.Body.DrainAsync(CancellationToken.None);

                request.Body.Seek(0L, SeekOrigin.Begin);
            }
            using (TextReader reader = context.ReaderFactory(request.Body, encoding))
            {
                using (JsonTextReader jsonTextReader = new JsonTextReader(reader))
                {
                    jsonTextReader.ArrayPool  = _charPool;
                    jsonTextReader.CloseInput = false;
                    Type           modelType      = context.ModelType;
                    JsonSerializer jsonSerializer = CreateJsonSerializer();
                    Request        model;
                    try
                    {
                        model = jsonSerializer.Deserialize <Request>(jsonTextReader);
                    }
                    finally
                    {
                        ReleaseJsonSerializer(jsonSerializer);
                    }

                    switch (model?.Data)
                    {
                    case null when context.TreatEmptyInputAsDefaultValue:
                        return(await InputFormatterResult.SuccessAsync(model));

                    case null:
                        return(await InputFormatterResult.NoValueAsync());
                    }

                    string expectedType = modelType.GetCustomAttributes <ResourceTypeAttribute>().FirstOrDefault()?.Type;

                    if (!string.IsNullOrWhiteSpace(model.Data.Type) && model.Data.Type.Equals(expectedType, StringComparison.OrdinalIgnoreCase))
                    {
                        return(await InputFormatterResult.SuccessAsync(model.Data.Attributes.ToObject(modelType)));
                    }

                    BusinessApplicationException exception        = new BusinessApplicationException(ExceptionType.BadRequest, ErrorCodes.ResourceType, "The provided resource type is invalid");
                    ApplicationError             applicationError = new ApplicationError
                    {
                        Exception      = exception,
                        HttpStatusCode = HttpStatusCode.BadRequest
                    };
                    string response = JsonConvert.SerializeObject(FormattedError.Create(applicationError.FormatError()), _jsonSerializerSettings);

                    context.HttpContext.Response.Clear();
                    context.HttpContext.Response.StatusCode  = (int)HttpStatusCode.BadRequest;
                    context.HttpContext.Response.ContentType = new MediaTypeHeaderValue("application/json").ToString();

                    await context.HttpContext.Response.WriteAsync(response);

                    throw exception;
                }
            }
        }
Пример #3
0
        /// <summary>
        /// B層の業務例外による異常終了の後処理を実装するUOCメソッド。
        /// </summary>
        /// <param name="parameterValue">引数クラス</param>
        /// <param name="returnValue">戻り値クラス</param>
        /// <param name="baEx">BusinessApplicationException</param>
        /// <remarks>業務コード親クラス1から利用される派生の末端</remarks>
        protected override void UOC_ABEND(BaseParameterValue parameterValue, BaseReturnValue returnValue, BusinessApplicationException baEx)
        {
            // 業務例外発生時の処理を実装
            // TODO:

            // nullチェック
            if (this.perfRec == null)
            {
                // なにもしない
            }
            else
            {
                // 性能測定終了
                this.perfRec.EndsPerformanceRecord();

                // ACCESSログ出力-----------------------------------------------

                MyParameterValue myPV = (MyParameterValue)parameterValue;

                // ------------
                // メッセージ部
                // ------------
                // ユーザ名, IPアドレス, レイヤ,
                // 画面名, コントロール名, メソッド名, 処理名
                // 処理時間(実行時間), 処理時間(CPU時間)
                // エラーメッセージID, エラーメッセージ等
                // ------------
                string strLogMessage =
                    "," + myPV.User.UserName +
                    "," + myPV.User.IPAddress +
                    "," + "<<-----" +
                    "," + myPV.ScreenId +
                    "," + myPV.ControlId +
                    "," + myPV.MethodName +
                    "," + myPV.ActionType +
                    "," + this.perfRec.ExecTime +
                    "," + this.perfRec.CpuTime +
                    "," + baEx.messageID +
                    "," + baEx.Message;

                // Log4Netへログ出力
                LogIF.WarnLog("ACCESS", strLogMessage);
            }

            // -------------------------------------------------------------
        }
Пример #4
0
        /// <summary>業務例外発生時の処理を実装</summary>
        /// <param name="baEx">BusinessApplicationException</param>
        /// <param name="fxEventArgs">イベントハンドラの共通引数</param>
        /// <remarks>画面コード親クラス1から利用される派生の末端</remarks>
        protected override void UOC_ABEND(BusinessApplicationException baEx, FxEventArgs fxEventArgs)
        {
            // 業務例外発生時の処理を実装
            // TODO:

            // ここに、メッセージの組み立てロジックを実装する。

            // メッセージ編集処理 ------------------------------------------

            string messageID          = baEx.messageID;
            string messageDescription = "";

            // メッセージIDから、対応するメッセージを取得する。
            messageDescription = GetMessage.GetMessageDescription(messageID);
            if (messageDescription == "")
            {
                // メッセージが取得できなかった場合
                messageDescription = baEx.Message;
            }
            else
            {
                // メッセージが取得できた場合、
                // 必要なら、メッセージに、可変文字列を組み込む。

                // 方式は、プロジェクト毎に検討のこと。
                messageDescription = messageDescription.Replace("%1", baEx.Message);
                messageDescription = messageDescription.Replace("%2", baEx.Information);
            }

            // -------------------------------------------------------------

            // メッセージ表示処理 ------------------------------------------

            #region メッセージボックスを使用して表示する場合。

            // 「OK」メッセージダイアログの表示処理
            this.ShowOKMessageDialog(
                messageID, messageDescription,
                FxEnum.IconType.Exclamation,
                "BusinessApplicationExceptionを使用したダイアログ表示");

            #endregion

            #region マスタ ページ上のラベルに表示する場合。

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

            //// 結果(業務続行可能なエラー)
            //label.Text = "ErrorMessageID:" + baEx.messageID + "\r\n";
            //label.Text += "ErrorMessage:" + baEx.Message + "\r\n";
            //label.Text += "ErrorInfo:" + baEx.Information + "\r\n";

            #endregion

            // -------------------------------------------------------------

            // 性能測定終了

            // イベント処理開始前にエラーが発生した場合は、
            // this.perfRecがnullの場合があるので、null対策コードを挿入する。
            if (this.perfRec == null)
            {
                // nullの場合、新しいインスタンスを生成し、性能測定開始。
                this.perfRec = new PerformanceRecorder();
                perfRec.StartsPerformanceRecord();
            }

            this.perfRec.EndsPerformanceRecord();

            // 認証ユーザ情報を取得する ------------------------------------
            this.GetUserInfo();

            // ACCESSログ出力-----------------------------------------------

            // ------------
            // メッセージ部
            // ------------
            // ユーザ名, IPアドレス,
            // レイヤ, 画面名, コントロール名, 処理名
            // 処理時間(実行時間), 処理時間(CPU時間)
            // エラーメッセージID, エラーメッセージ等
            // ------------
            string strLogMessage =
                "," + UserInfo.UserName +
                "," + Request.UserHostAddress +
                "," + "<-----" +
                "," + this.ContentPageFileNoEx +
                "," + fxEventArgs.ButtonID +
                "," + "" +
                "," + this.perfRec.ExecTime +
                "," + this.perfRec.CpuTime +
                "," + baEx.messageID +
                "," + baEx.Message;

            // Log4Netへログ出力
            LogIF.WarnLog("ACCESS", strLogMessage);

            // -------------------------------------------------------------
        }
Пример #5
0
 /// <summary>
 /// B層の業務例外による異常終了の後処理を実装するUOCメソッド。
 /// </summary>
 /// <param name="parameterValue">引数クラス</param>
 /// <param name="returnValue">戻り値クラス</param>
 /// <param name="baEx">BusinessApplicationException</param>
 /// <remarks>派生の業務コード親クラス2でオーバーライドする。</remarks>
 protected virtual void UOC_ABEND(BaseParameterValue parameterValue, BaseReturnValue returnValue, BusinessApplicationException baEx)
 {
 }