Exemple #1
0
        /// <summary>
        ///     开启SQL调试
        /// </summary>
        /// <returns></returns>
        public ReturnMessage <bool> SetupSQLDebug(SQLDebugConfig debugConfig)
        {
            ReturnMessage <bool> ret = new ReturnMessage <bool>();

            ret.IsSuccess = true;
            ret.Result    = SQLDebug.SetupDebug(debugConfig);
            return(ret);
        }
Exemple #2
0
 /// <summary>
 ///     设置配置
 /// </summary>
 /// <param name="debugConfig"></param>
 private static void SetConfig(SQLDebugConfig debugConfig)
 {
     if (debugConfig == null)
     {
         throw new ArgumentException("debugConfig is null");
     }
     lock (LockObject)
     {
         _debugConfig = debugConfig;
     }
 }
Exemple #3
0
        /// <summary>
        ///     启用调试
        /// </summary>
        /// <returns></returns>
        public static bool SetupDebug(SQLDebugConfig debugConfig)
        {
            //设置参数
            SetConfig(debugConfig);
            HarmonyInstance instance = HarmonyInstance.Create(DebugID);

            if (instance.HasAnyPatches(DebugID))
            {
                instance.UnpatchAll(DebugID);
            }
            DebugGuid = Guid.NewGuid().ToString();
            try
            {
                if (debugConfig.IsContainInsert || debugConfig.IsContainDelete || debugConfig.IsContainUpdate ||
                    debugConfig.IsContainSelect)
                {
                    //启用SQL调试
                    Logger.Debug("启用SQL追踪:{0}", DebugGuid);
                    SetupSQLDebug(instance);
                }
                if (debugConfig.IsTraceBPSVTransaction || debugConfig.IsTraceCustomizeTransaction)
                {
                    //启用事务追踪
                    Logger.Debug("启用事务追踪:{0}", DebugGuid);
                    SetupTransactionScopeDebug(instance);
                }
            }
            catch (Exception ex)
            {
                try
                {
                    Logger.Debug("开启调试异常:{0}", DebugGuid);
                    Logger.Debug(ex);
                    //停止追踪
                    StopDebug();
                }
                catch (Exception)
                {
                }
                throw;
            }
            return(true);
        }