python插件调用堆栈原创
4人赞赏了该文章
128次浏览
编辑于2024年01月26日 08:33:47
场景】打调用堆栈
【代码】
import clr clr.AddReference("mscorlib") clr.AddReference("System.Data")#本次引用clr.AddReference("Kingdee.BOS.Core") clr.AddReference("Kingdee.BOS.Log")from System import *from System.Collections.Generic import *from System.Data import *##本次引用from Kingdee.BOS.Core.DynamicForm.PlugIn import *from Kingdee.BOS.Core.DynamicForm.PlugIn.Args import *from Kingdee.BOS.Log import *from System.Diagnostics import *def BeginOperationTransaction(e): billNoProp = this.BusinessInfo.GetBillNoField().PropertyName; billInfos = ''; for idx in range(len(e.DataEntitys)): dataEntity = e.DataEntitys[idx]; pk = dataEntity[0]; billNo = dataEntity[billNoProp]; billInfos += str(pk) +'('+ str(billNo) +'),'; logMsgList = List[str](); logMsgList.Add(billInfos); stackFrames = StackTrace().GetFrames(); for idx in range(len(stackFrames)): curStack = stackFrames[idx]; method = curStack.GetMethod(); fullName = '' if method.DeclaringType == None else method.DeclaringType.FullName; msg = str(method.Module)+'=> ' + (fullName) +' , ' +str(method); logMsgList.Add(msg); totalMsg = '\r\n'.join(logMsgList); Logger.Error("SHOW STACKTRACE", totalMsg, None);
【效果】
赞 4
4人点赞
还没有人点赞,快来当第一个点赞的人吧!
打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!
推荐阅读