Example #1
0
 public static bool BeforeDo(ProxyBase __instance)
 {
     try
     {
         if (__instance == null)
         {
             return(true);
         }
         Type type = __instance.GetType();
         Logger.Error(type.FullName + "-BeforeDo-SessionID:" + ServiceSession.SessionID);
         ProxyType proxyType = null;
         if (!string.IsNullOrEmpty(type.FullName))
         {
             ProxyTypeDict.TryGetValue(type.FullName, out proxyType);
         }
         Logger.Error("PostData:" + (proxyType == null
             ? ProxyJsonHelper.ProxyObjectToJsonString(__instance)
             : ProxyJsonHelper.ProxyObjectToJsonString(__instance, false, proxyType.UseDataMemberTransData,
                                                       proxyType.InMaxExpandDepth)));
         //输出调用堆栈
         Logger.Error("StackTrace:\r\n" + StackTraceHelper.GetCurrentStackTraceString(3));
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
     }
     return(true);
 }
Example #2
0
        public static void PostfixTransactionAttributeProcess(TransactionAttribute __instance, object obj)
        {
            if (_debugConfig == null)
            {
                return;
            }
            string enterpriseID = PlatformContext.Current.EnterpriseID;
            string orgCode      = PlatformContext.Current.OrgCode;
            string userCode     = PlatformContext.Current.UserCode;

            if (!IsLog(enterpriseID, orgCode, userCode))
            {
                return;
            }
            StringBuilder sb         = new StringBuilder();
            StackTrace    stackTrace = new StackTrace(true);

            for (int i = 0; i < stackTrace.FrameCount; i++)
            {
                StackFrame frame  = stackTrace.GetFrame(i);
                MethodBase method = frame.GetMethod();
                if (method.DeclaringType == null)
                {
                    continue;
                }
                var transactionAttribute = Attribute.GetCustomAttribute(method, typeof(TransactionAttribute));
                if (transactionAttribute == null)
                {
                    continue;
                }
                string assemblyFullName = method.DeclaringType.Assembly.FullName;
                sb.AppendFormat("BPSV事务:");
                if (!string.IsNullOrEmpty(assemblyFullName))
                {
                    sb.Append(assemblyFullName.Split(',')[0]);
                    sb.Append("!");
                }
                sb.AppendFormat("{0}.{1} 事务类型:{2} 事务ID:{3}",
                                method.DeclaringType.FullName,
                                method.Name, __instance.TransactionOption, Transaction.Current == null
                        ? string.Empty
                        : Transaction.Current.TransactionInformation.LocalIdentifier);
                break;
            }
            if (_debugConfig.IsOutputTransactionStack)
            {
                sb.AppendLine();
                sb.Append(StackTraceHelper.GetCurrentStackTraceString(4));
            }
            Logger.Debug(sb.ToString());
        }
Example #3
0
        /// <summary>
        ///     写入日志
        /// </summary>
        /// <param name="methodName"></param>
        /// <param name="enterpriseID"></param>
        /// <param name="orgCode"></param>
        /// <param name="userCode"></param>
        /// <param name="cmdType"></param>
        /// <param name="commandText"></param>
        /// <param name="dataParamsString"></param>
        private static void WriteSQLLog(string methodName, string enterpriseID, string orgCode, string userCode,
                                        CommandType cmdType, string commandText, string dataParamsString)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine().Append("   ").AppendFormat("SQL语句:{0}", commandText);
            sb.AppendLine().Append("   ").AppendFormat("SQL参数:{0}", dataParamsString);
            sb.AppendLine()
            .Append("   ")
            .AppendFormat("上下文信息:企业ID:{0} 组织编码:{1} 用户编码:{2} ", enterpriseID, orgCode, userCode);
            sb.AppendLine().Append("   ").AppendFormat("调用方法:{0} 命令类型:{1}", methodName, cmdType);
            if (_debugConfig.IsOutputSQLStack)
            {
                sb.AppendLine().Append("   ").Append("调用堆栈:");
                sb.AppendLine().AppendFormat("{0}", StackTraceHelper.GetCurrentStackTraceString(4));
            }
            Logger.Debug(sb.ToString());
        }