自定义操作,记录操作日志
目前标准产品中只记录了标准的新增保存修改上机操作日志,没有记录某个字段保存后的修改,这个时候其实我们是可以自己二开记录日志的,下面是记录上机操作日志方法
引用类:
Kingee.BOS.dll
Kingdee.BOS.App.dll
Kingdee.BOS.Core.dll
Kingdee.BOS.Contracts.dll
实例:
var logService = ServiceHelper.GetService<Kingdee.BOS.Contracts.ILogService>();
var logObject = new Kingdee.BOS.Core.Log.LogObject()
{
Description = string.Format(Kingdee.BOS.Resource.ResManager.LoadKDString("发送失败,消息内码:{0} 失败原因:{1}", "002002030036948", Kingdee.BOS.Resource.SubSystemType.BOS), message.PKValue, control.GetRefrenceInfo()),
Environment = BOS.Core.Log.OperatingEnvironment.BizOperate,
ObjectTypeId = "BOS_XunTongMessage",
OperateName = Kingdee.BOS.Resource.ResManager.LoadKDString("推送讯通消息", "002525030026642", Kingdee.BOS.Resource.SubSystemType.BOS),
pkValue = message.PKValue
};
logService.WriteLog(Context, logObject);
保存时,记录某一字段的修改
public class UserComprehensiveQueryPlugIn : AbstractSysReportPlugIn
{
string name = string.Empty;
public override void AfterBarItemClick(Core.DynamicForm.PlugIn.Args.AfterBarItemClickEventArgs e)
{
if (e.BarItemKey == "Save")
{
string newName = this.Model.GetValue("FName").GetString();
if(newName.EqualsIgnoreCase(name)==false)
{
this.WriteLog();
}
}
base.AfterBarItemClick(e);
}
public override void AfterBindData(EventArgs e)
{
base.AfterBindData(e);
DynamicFormOpenParameter Para = this.View.OpenParameter;
this.View.GetMainBarItem("Print").Visible = false;
name = this.Model.GetValue("FName").GetString();
}
private void WriteLog()
{
var logObject = new Kingdee.BOS.Core.Log.LogObject()
{
Description = string.Format(Kingdee.BOS.Resource.ResManager.LoadKDString("发送失败,消息内码:{0} 失败原因:{1}", "002002030036948", Kingdee.BOS.Resource.SubSystemType.BOS), message.PKValue, control.GetRefrenceInfo()),
Environment = BOS.Core.Log.OperatingEnvironment.BizOperate,
ObjectTypeId = "BOS_XunTongMessage",
OperateName = Kingdee.BOS.Resource.ResManager.LoadKDString("推送讯通消息", "002525030026642", Kingdee.BOS.Resource.SubSystemType.BOS),
pkValue = System.Guid.NewGuid().ToString()
};
Kingdee.BOS.ServiceHelper.LogServiceHelper.WriteLog(Context, logObject);
}
}
自定义操作,记录操作日志
本文2024-09-23 03:52:03发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-161605.html