Exemplo n.º 1
0
        /// <summary>
        /// アクション メソッドによって返されたアクション結果が実行された後に呼び出されます。
        /// Controller.OnResultExecuted メソッド (System.Web.Mvc)
        /// http://msdn.microsoft.com/ja-jp/library/system.web.mvc.controller.onresultexecuted.aspx
        /// </summary>
        /// <param name="filterContext">
        /// 型: System.Web.Mvc.ResultExecutingContext
        /// 現在の要求およびアクション結果に関する情報。
        /// </param>
        protected override void OnResultExecuted(ResultExecutedContext filterContext)
        {
            // Calling base class method.
            base.OnResultExecuted(filterContext);

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

            this.perfRec.EndsPerformanceRecord();

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

            LogIF.DebugLog("ACCESS", strLogMessage);
        }
        /// <summary>トランザクション開始</summary>
        /// <param name="iso">
        /// 分離レベル
        ///  1. NoTransaction:トランザクションを開始しない。
        ///  2. DefaultTransaction:規定の分離レベルでトランザクションを開始する。
        ///  3. ReadUncommitted:非コミット読み取りの分離レベルでトランザクションを開始する。
        ///  4. ReadCommitted:コミット済み読み取りの分離レベルでトランザクションを開始する。
        ///  5. RepeatableRead:反復可能読み取りの分離レベルでトランザクションを開始する。
        ///  6. Serializable:直列化可能の分離レベルでトランザクションを開始する。
        ///  7. Snapshot:スナップショット分離レベルでトランザクションを開始する(SQL Server2005からの機能)。
        /// </param>
        /// <remarks>
        /// ○ 基本的に「ReadCommitted」で良い。
        /// ○ 参照データしたデータが、Tx中に変更されては困る場合のみ、次の分離レベルを使用する。
        ///    1. 「RepeatableRead」:Tx中、参照したデータの共有ロックが持続され、変更されない。
        ///    2. 「Serializable」:Tx中、検索したキー範囲のロックが持続され、変更されない。
        ///    3. 「Snapshot」:上記1.、2.の分離レベルでは同時実効性に問題がある時に使用する。
        ///     ※ SQL Server2005からの機能であり、DBの設定でSnapshotを有効にする必要がある。
        ///     ※ 上記(3.)の方式は、悲観排他方式(ホールドロック)を使用できないので注意する。
        /// ○ ノートランザクションは、通常、デフォルトの分離レベルの「ReadCommitted」の自動コミットになる。
        /// ○ デッドロックになりかねないとき、参照時、更新ロックを使用する。
        /// ○「ReadUncommitted」はダーティーリードのため、基本的に使用しない。
        /// 必要に応じて利用する。
        /// </remarks>
        public override void BeginTransaction(DbEnum.IsolationLevelEnum iso)
        {
            // 分離レベル設定のチェック
            if (iso == DbEnum.IsolationLevelEnum.NoTransaction)
            {
                // トランザクションを開始しない(nullのまま)。
            }
            else if (iso == DbEnum.IsolationLevelEnum.DefaultTransaction)
            {
                LogIF.DebugLog("ACCESS", "Transaction not supported (BeginTransaction)");
            }
            else if (iso == DbEnum.IsolationLevelEnum.ReadUncommitted)
            {
                LogIF.DebugLog("ACCESS", "Transaction not supported (BeginTransaction)");
            }
            else if (iso == DbEnum.IsolationLevelEnum.ReadCommitted)
            {
                LogIF.DebugLog("ACCESS", "Transaction not supported (BeginTransaction)");
            }
            else if (iso == DbEnum.IsolationLevelEnum.RepeatableRead)
            {
                LogIF.DebugLog("ACCESS", "Transaction not supported (BeginTransaction)");
            }
            else if (iso == DbEnum.IsolationLevelEnum.Serializable)
            {
                LogIF.DebugLog("ACCESS", "Transaction not supported (BeginTransaction)");
            }
            else if (iso == DbEnum.IsolationLevelEnum.Snapshot)
            {
                LogIF.DebugLog("ACCESS", "Transaction not supported (BeginTransaction)");
            }
            else if (iso == DbEnum.IsolationLevelEnum.User)
            {
                // 無効な分離レベル(ユーザ指定)。
                throw new ArgumentException(
                          PublicExceptionMessage.DB_ISO_LEVEL_PARAM_ERROR_USR);
            }
            else if (iso == DbEnum.IsolationLevelEnum.NotConnect)
            {
                // 2009/03/29 -- 追加したNotConnectの対応(このコードブロック)。

                // 無効な分離レベル(NotConnect指定)。
                throw new ArgumentException(
                          PublicExceptionMessage.DB_ISO_LEVEL_PARAM_ERROR_NC);
            }
            else
            {
                // 通らない予定
            }

            // 分離レベル(iso)をメンバ変数に保存
            _iso = iso;
        }
Exemplo n.º 3
0
 public void DebugLog_Test(string message, string loggerName)
 {
     try
     {
         LogIF.DebugLog(loggerName, message);
     }
     catch (Exception ex)
     {
         // Print a stack trace when an exception occurs.
         Console.WriteLine(ex.StackTrace);
         throw;
     }
 }
Exemplo n.º 4
0
        /// <summary>MyDebugSQLTrace</summary>
        /// <param name="log">string</param>
        public static void MyDebugSQLTrace(string log)
        {
            // デバッグ時
            if (ASPNETIdentityConfig.IsDebug)
            {
                Debug.WriteLine(log);
            }

            // プロビジョニング、プロダクト環境
            if (ASPNETIdentityConfig.EnabeDebugTraceLog)
            {
                LogIF.DebugLog("SQLTRACE", log);
            }
        }
Exemplo n.º 5
0
 /// <summary>MyDebugLogForEx</summary>
 /// <param name="log">string</param>
 public static void MyDebugLogForEx(Exception ex)
 {
     if (ASPNETIdentityConfig.IsDebug)
     {
         // デバッグ時
         Debug.WriteLine(ex.ToString());
         LogIF.DebugLog("ACCESS", ex.ToString());
     }
     else
     {
         // プロビジョニング、プロダクト環境
         LogIF.DebugLog("ACCESS", ex.ToString());
     }
 }
Exemplo n.º 6
0
 /// <summary>MyOperationTrace</summary>
 /// <param name="log">string</param>
 public static void MyOperationTrace(string log)
 {
     if (ASPNETIdentityConfig.IsDebug)
     {
         // デバッグ時
         Debug.WriteLine(log);
         LogIF.DebugLog("OPERATION", log);
     }
     else
     {
         // 本番時
         LogIF.DebugLog("OPERATION", log);
     }
 }
Exemplo n.º 7
0
        /// <summary>MySQLLogForEx</summary>
        /// <param name="log">string</param>
        public static void MySQLLogForEx(Exception ex)
        {
            if (ASPNETIdentityConfig.IsDebug)
            {
                // デバッグ時
                Debug.WriteLine(ex.ToString());
                LogIF.DebugLog("SQLTRACE", ex.ToString());
            }
            else
            {
                // プロビジョニング、プロダクト環境
                LogIF.DebugLog("SQLTRACE", ex.ToString());
            }

            if (ex is StopUserStoreException)
            {
                // ユーザストアを停止させる例外

                // スタックトレースを保って ex を throw
                //string trace = Environment.StackTrace;
                ExceptionDispatchInfo.Capture(ex).Throw();
            }
        }
Exemplo n.º 8
0
        ///////////////////////////////////////////////////////////////////
        // ページの実行が⑥~⑦の間に入る。
        ///////////////////////////////////////////////////////////////////

        /// <summary>
        /// ⑦ ページの実行を完了した直後に発生
        /// </summary>
        void Application_OnPostRequestHandlerExecute(object sender, EventArgs e)
        {
            // nullチェック
            if (this.perfRec == null)
            {
                // なにもしない
            }
            else
            {
                // 性能測定終了
                this.perfRec.EndsPerformanceRecord();

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

                // ------------
                // Message部
                // ------------
                // ユーザ名, IPアドレス, レイヤ,
                // 画面名, Control名, メソッド名, 処理名
                // 処理時間(実行時間), 処理時間(CPU時間)
                // ------------
                string strLogMessage =
                    "," + "-" +
                    "," + Request.UserHostAddress +
                    "," + "-----↑" +
                    "," + "Global.asax" +
                    "," + "Application_OnPostRequest" +
                    "," + "-" +
                    "," + "-" +
                    "," + this.perfRec.ExecTime +
                    "," + this.perfRec.CpuTime;

                // Log4Netへログ出力
                LogIF.DebugLog("ACCESS", strLogMessage);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// ⑥ ページの実行を開始する直前に発生
        /// </summary>
        void Application_OnPreRequestHandlerExecute(object sender, EventArgs e)
        {
            // ------------
            // Message部
            // ------------
            // ユーザ名, IPアドレス, レイヤ,
            // 画面名, Control名, メソッド名, 処理名
            // ------------
            string strLogMessage =
                "," + "-" +
                "," + Request.UserHostAddress +
                "," + "-----↓" +
                "," + "Global.asax" +
                "," + "Application_OnPreRequest";

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

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

            // 性能測定開始
            this.perfRec = new PerformanceRecorder();
            this.perfRec.StartsPerformanceRecord();
        }
Exemplo n.º 10
0
 /// <summary>トランザクションのロールバック</summary>
 /// <remarks>必要に応じて利用する。</remarks>
 public override void RollbackTransaction()
 {
     LogIF.DebugLog("ACCESS", "Transaction not supported (RollbackTransaction)");
 }
Exemplo n.º 11
0
 /// <summary>トランザクションのコミット</summary>
 /// <remarks>必要に応じて利用する。</remarks>
 public override void CommitTransaction()
 {
     LogIF.DebugLog("ACCESS", "Transaction not supported (CommitTransaction)");
 }