使用Dispose进行审核? [英] Using Dispose for auditing?

查看:81
本文介绍了使用Dispose进行审核?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!


我正在用VB.NET开发ASP.NET应用程序的middletiers。我有一个商业逻辑层

我想在其中对

数据库进行审核。而不是在我的类的每个方法中进行审计调用,

将基类中的IDisposable实现为BLL类的所有

然后是一种可行的方法在Dispose方法中进行审计调用?我是否需要确保所有BLL-classes的使用都以调用

Dispose-method结束,或者我可以依靠垃圾收集器?


TIA


Jonas

Hi!

I''m developing the middletiers of an ASP.NET application in VB.NET. I''ve got
a business logic layer in which I would like to perform auditing to a
database. Instead of making an auditing call in every method of my classes,
would it be a workable way to implement IDisposable in the base class to all
the BLL-classes and then in the Dispose method to do the audit call? Do I
then have to make sure that all uses of the BLL-classes end with a call to
the Dispose-method or can I count on the garbage collector for this?

TIA

Jonas

推荐答案

First of所有,我不清楚如何弄清楚什么时候垃圾收集?收集的b $ b将有助于审核对数据库的更改?或者你正在审核

别的什么?你能否清楚这个吗?


另外,只是因为一个对象调用了Dispose它没有*意味着它是垃圾收集的
垃圾。对象实现IDisposable,因此垃圾收集器

可以在收集它之前调用Dispose - 以确保所有资源

在收集之前关闭。但是调用Dispose并没有做什么让GC运行
。既不将变量设置为Nothing,也不设置任何其他的



GC将在运行时认为必要时运行。


" Jonas" <乔*** @ no.spam.pl>在消息中写道

news:en ************** @ TK2MSFTNGP11.phx.gbl ...
First of all, I am not clear on how figuring out when classes get garbage
collected are going to help audit changes to a database? Or are you auditing
something else? Can you please be clear on this?

Also, just because an object had Dispose called on it does *not* mean it is
garbage collected. Objects implement IDisposable, so the garbage collector
can call Dispose on it before collecting it - to make sure all resources
were closed prior to collection. But calling Dispose does nothing to make
the GC run. Neither does setting the variable to Nothing, or any other
thing.

The GC will run when it is deemed necessary by the runtime.

"Jonas" <jo***@no.spam.pl> wrote in message
news:en**************@TK2MSFTNGP11.phx.gbl...
嗨!

我正在用VB.NET开发ASP.NET应用程序的middletiers。我有一个业务逻辑层,我想在其中对数据库进行审计。不是在我的
类的每个方法中进行审计调用,而是将基本类中的IDisposable实现到所有BLL类,然后在Dispose方法中执行<审计电话?那么我是否必须确保BLL类的所有用途都以调用Dispose方法结束,或者我可以依靠垃圾
收集器吗?
TIA

Jonas
Hi!

I''m developing the middletiers of an ASP.NET application in VB.NET. I''ve
got a business logic layer in which I would like to perform auditing to a
database. Instead of making an auditing call in every method of my
classes, would it be a workable way to implement IDisposable in the base
class to all the BLL-classes and then in the Dispose method to do the
audit call? Do I then have to make sure that all uses of the BLL-classes
end with a call to the Dispose-method or can I count on the garbage
collector for this?

TIA

Jonas



再次嗨!


我想我不是'我的想法很清楚:-)


我的业务层中有很多类可以处理不同种类的商业实体(车辆,用户,患者...)每个班级都有一个我想要审核的方法(列表,创建,阅读,更新,删除)的数量。

例如如果用户A做了车辆列表并决定删除一辆

车辆,我希望将其显示在我在

数据库中的审计日志中。这对于能够追踪谁做了什么是必要的。现在

我的方法看起来像这样(当然非常简化):


类车辆


功能列表(userId as Integer)as DataSet

Dim dc as New VehicleDataAccessLayerComponent


如果Permission.Check(" VehicleList",userId)则

dc = dc.List()

结束如果


Audit.Create(" VehicleList",userId,....)

结束功能


结束班


我没有在每种方法中调用Audit.Create,而是认为可能

可以在Vehicle类的Dispose方法中执行此操作(或者

,最好是基类):


Class Vehicle2


Dim _methodName as String

Dim _userId as Integer


Sub New(userId as Integer )

_userId = userId

End Sub


函数列表(userId as int)as DataSet

将DC作为新的VehicleDataAccessLayer调暗组件

_methodName =" VehicleList"


如果Permission.Check(_methodName,userId)那么

dc = dc.List ()

结束如果


结束功能


Sub Dispose()

Audit.Create(_methodName,_ userId,....)

End Sub


结束班级


想法是为所有方法在一个地方完成审计,但

或许这给我带来的问题比它解决的更多....


TIA


Jonas


" Marina" <所以***** @ nospam.com>在消息中写道

新闻:eE ************** @ tk2msftngp13.phx.gbl ...
Hi again!

I guess I wasn''t as clear as I thought :-)

I have a bunch of classes in my business layer that handle different kinds
of business entities (vehicles, users, patients ...) Each class has a number
of methods (List, Create, Read, Update, Delete) that I would like to audit.
For example if user A does a List of vehicles and the decides to Delete a
vehicle, I want this to be show in an audit log which I have in the
database. This is necessary for being able to trace who has done what . Now
my methods look like this (very much simplified of course):

Class Vehicle

Function List(userId as Integer) as DataSet
Dim dc as New VehicleDataAccessLayerComponent

If Permission.Check("VehicleList", userId) Then
dc = dc.List()
End If

Audit.Create("VehicleList", userId, ....)
End Function

End Class

Instead of having a call to Audit.Create in every method, I thought it might
be possible to do this in the Dispose method of the Vehicle class (or a
preferably a base class perhaps):

Class Vehicle2

Dim _methodName as String
Dim _userId as Integer

Sub New(userId as Integer)
_userId = userId
End Sub

Function List(userId as int) as DataSet
Dim dc as New VehicleDataAccessLayerComponent
_methodName = "VehicleList"

If Permission.Check(_methodName, userId) Then
dc = dc.List()
End If

End Function

Sub Dispose()
Audit.Create(_methodName, _userId, ....)
End Sub

End Class

The ideas was to get the auditing done in one place for all methods, but
perhaps this give me more problems than it solves ....

TIA

Jonas

"Marina" <so*****@nospam.com> wrote in message
news:eE**************@tk2msftngp13.phx.gbl...
首先,我我不清楚如何搞清楚什么时候收集垃圾收集来帮助审核对数据库的更改?或者你是否在审核别的东西?你能否清楚这个呢?

另外,只是因为一个对象调用了它就不会*意味着它被垃圾收集了。对象实现IDisposable,因此垃圾收集器可以在收集它之前调用Dispose - 以确保在收集之前关闭所有资源。但是调用Dispose确实没有什么可以让GC运行。也没有将变量设置为Nothing,
或任何其他东西。

GC将在运行时认为必要时运行。

Jonas <乔*** @ no.spam.pl>在消息中写道
新闻:en ************** @ TK2MSFTNGP11.phx.gbl ...
First of all, I am not clear on how figuring out when classes get garbage
collected are going to help audit changes to a database? Or are you
auditing something else? Can you please be clear on this?

Also, just because an object had Dispose called on it does *not* mean it
is garbage collected. Objects implement IDisposable, so the garbage
collector can call Dispose on it before collecting it - to make sure all
resources were closed prior to collection. But calling Dispose does
nothing to make the GC run. Neither does setting the variable to Nothing,
or any other thing.

The GC will run when it is deemed necessary by the runtime.

"Jonas" <jo***@no.spam.pl> wrote in message
news:en**************@TK2MSFTNGP11.phx.gbl...
嗨!
我正在用VB.NET开发ASP.NET应用程序的middletiers。我有一个业务逻辑层,我想在其中对数据库进行审计。不是在我的
类的每个方法中进行审计调用,而是将基本类中的IDisposable实现到所有BLL类,然后在Dispose方法中执行<审计电话?那么我是否必须确保BLL类的所有用途都以调用Dispose方法结束,或者我可以依靠垃圾
收集器吗?
TIA

Jonas
Hi!

I''m developing the middletiers of an ASP.NET application in VB.NET. I''ve
got a business logic layer in which I would like to perform auditing to a
database. Instead of making an auditing call in every method of my
classes, would it be a workable way to implement IDisposable in the base
class to all the BLL-classes and then in the Dispose method to do the
audit call? Do I then have to make sure that all uses of the BLL-classes
end with a call to the Dispose-method or can I count on the garbage
collector for this?

TIA

Jonas




我明白了。您不是在数据库级别查找

列从哪些值更改为值的审计。你想要一个更高级别发生的所有事件的记录。


好​​吧,如果你读了我对垃圾收集工作方式的描述,你会

看到你的方法无法解决你想要实现的问题。


另外,使用该模型只对对象的最后一个动作是

审计。不是全部。


" Jonas" <乔*** @ no.spam.pl>在消息中写道

新闻:eA **************** @ TK2MSFTNGP12.phx.gbl ...
I see. You are not looking for an audit at the database level of what
columns changed from what values to what values. You want a record of
everything that happened at a higher level.

Well, if you read my description of how garbage collection works, you will
see that your method will not solve the problem you are trying to achieve.

Additionally, using that model only the last action on the object would be
audited. Not all of them.

"Jonas" <jo***@no.spam.pl> wrote in message
news:eA****************@TK2MSFTNGP12.phx.gbl...
嗨再次!

我想我并不像我想的那样清晰:-)

我的业务层中有很多类可以处理不同的类
商业实体(车辆,用户,患者......)每个班级都有一些我想要审核的方法(列表,创建,阅读,更新,删除)。例如,如果用户A执行车辆列表并决定删除车辆,我希望将其显示在我在数据库中的审计日志中。这对于能够追踪谁做了什么来说是必要的。现在我的方法看起来像这样(当然非常简化):

类车辆功能列表(userId as Integer)as DataSet
Dim dc as New VehicleDataAccessLayerComponent

如果Permission.Check(" VehicleList",userId)那么
dc = dc.List()
结束如果

Audit.Create( " VehicleList",userId,....)
结束功能

结束类

我没有在每种方法中调用Audit.Create,而是认为
可能可以在Vehicle类的Dispose方法中执行此操作
(或者最好是基类):

类Vehicle2

Dim _methodName as String
Dim _userId as Integer

Sub New(userId as Integer)
_userId = userId
End Sub

函数列表(userId as int)as DataSet
Dim dc as New VehicleDataAccessLayerComponent
_methodName =" Vehi cleList

如果Permission.Check(_methodName,userId)那么
dc = dc.List()
结束如果

结束函数
Sub Dispose()
Audit.Create(_methodName,_userId,....)
End Sub

结束课

这些想法是为所有方法在一个地方完成审计,但也许这给了我更多的问题而不是解决....

TIA

Jonas

Marina <所以***** @ nospam.com>在消息中写道
新闻:eE ************** @ tk2msftngp13.phx.gbl ...
Hi again!

I guess I wasn''t as clear as I thought :-)

I have a bunch of classes in my business layer that handle different kinds
of business entities (vehicles, users, patients ...) Each class has a
number of methods (List, Create, Read, Update, Delete) that I would like
to audit. For example if user A does a List of vehicles and the decides to
Delete a vehicle, I want this to be show in an audit log which I have in
the database. This is necessary for being able to trace who has done what
. Now my methods look like this (very much simplified of course):

Class Vehicle

Function List(userId as Integer) as DataSet
Dim dc as New VehicleDataAccessLayerComponent

If Permission.Check("VehicleList", userId) Then
dc = dc.List()
End If

Audit.Create("VehicleList", userId, ....)
End Function

End Class

Instead of having a call to Audit.Create in every method, I thought it
might be possible to do this in the Dispose method of the Vehicle class
(or a preferably a base class perhaps):

Class Vehicle2

Dim _methodName as String
Dim _userId as Integer

Sub New(userId as Integer)
_userId = userId
End Sub

Function List(userId as int) as DataSet
Dim dc as New VehicleDataAccessLayerComponent
_methodName = "VehicleList"

If Permission.Check(_methodName, userId) Then
dc = dc.List()
End If

End Function

Sub Dispose()
Audit.Create(_methodName, _userId, ....)
End Sub

End Class

The ideas was to get the auditing done in one place for all methods, but
perhaps this give me more problems than it solves ....

TIA

Jonas

"Marina" <so*****@nospam.com> wrote in message
news:eE**************@tk2msftngp13.phx.gbl...
首先,我不清楚如何弄清楚什么时候收集垃圾收集来帮助审核对数据库的更改?或者你是否在审核别的东西?你能否清楚这个呢?

另外,只是因为一个对象调用了它就不会*意味着它被垃圾收集了。对象实现IDisposable,因此垃圾收集器可以在收集它之前调用Dispose - 以确保在收集之前关闭所有资源。但是调用Dispose确实没有什么可以让GC运行。也没有将变量设置为Nothing,
或任何其他东西。

GC将在运行时认为必要时运行。

Jonas <乔*** @ no.spam.pl>在消息中写道
新闻:en ************** @ TK2MSFTNGP11.phx.gbl ...
First of all, I am not clear on how figuring out when classes get garbage
collected are going to help audit changes to a database? Or are you
auditing something else? Can you please be clear on this?

Also, just because an object had Dispose called on it does *not* mean it
is garbage collected. Objects implement IDisposable, so the garbage
collector can call Dispose on it before collecting it - to make sure all
resources were closed prior to collection. But calling Dispose does
nothing to make the GC run. Neither does setting the variable to Nothing,
or any other thing.

The GC will run when it is deemed necessary by the runtime.

"Jonas" <jo***@no.spam.pl> wrote in message
news:en**************@TK2MSFTNGP11.phx.gbl...
嗨!
我正在用VB.NET开发ASP.NET应用程序的middletiers。我有一个业务逻辑层,我想在其中对数据库进行审计。不是在我的
类的每个方法中进行审计调用,而是将基本类中的IDisposable实现到所有BLL类,然后在Dispose方法中执行<审计电话?那么我是否必须确保
BLL-classes的所有用途都以调用Dispose方法结束,或者我可以依靠
垃圾收集器吗?
TIA

Jonas
Hi!

I''m developing the middletiers of an ASP.NET application in VB.NET. I''ve
got a business logic layer in which I would like to perform auditing to
a database. Instead of making an auditing call in every method of my
classes, would it be a workable way to implement IDisposable in the base
class to all the BLL-classes and then in the Dispose method to do the
audit call? Do I then have to make sure that all uses of the
BLL-classes end with a call to the Dispose-method or can I count on the
garbage collector for this?

TIA

Jonas





这篇关于使用Dispose进行审核?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆