For Each dt As DataTable In DataTables
dt.GlobalHandler.DataColChanged = True
dt.GlobalHandler.DataRowAdded = True
Next
If e.DataTable.Name <> "操作日志" Then \'”数据操作日志“是表名
If e.DataRow.RowState = 2 Then
Return
Else
Dim dr As DataRow = DataTables("操作日志").AddNew
dr("ID") = e.DataRow("_Identify")
\' dr("用户") = User.Name
dr("用户") = _User.Name
dr("涉及表") = e.DataTable.Name
dr("涉及列") = e.DataCol.Name
dr("涉及行") = e.DataRow("_Identify")
dr("时间") = Date.Now
dr("操作") = """" & e.OldValue & """ 改成了 """ & e.NewValue & """"
Dim str As String = ""
For Each c As DataCol In e.DataTable.DataCols
str += c.Name & "=" & e.DataRow(c.Name) & "|"
Next
dr("原行数据") = str
End If
End If
If e.DataTable.Name <> "操作日志" Then
Dim dr As DataRow = DataTables("操作日志").AddNew
dr("ID") = e.DataRow("_Identify")
\' dr("用户") = User.Name
dr("用户") = _User.Name
dr("涉及表") = e.DataTable.Name
dr("涉及列") = Nothing
dr("涉及行") = e.DataRow("_Identify")
dr("时间") = Date.Now
dr("操作") = "增加了一行"
Dim str As String = ""
For Each c As DataCol In e.DataTable.DataCols
str += c.Name & "=" & e.DataRow(c.Name) & "|"
Next
dr("原行数据") = str
End If
上面代码,在表,列,行都各生成一条记,我测试一下,录入一个入库单,生成420条记录,原行数据是字符最大255都不够,要备注型才行,
假如一个人一天录100单入库420*100=42000,一个月26天其日志就1092000条,一年就 13104000条,一年就生成1000万多条日志,其他业务记录没算,
这个日志数据太可怕,会把系统搞崩,
如何优化?能不能录完一单生成对应一条日志,一天录100单,生成日志也就100条,这样相对友好。如何能实现?