3

我们有一个 Web 应用程序,可以访问不同项目中的业务逻辑和数据访问。

按照它的设计方式,键值永远不会传递给数据访问层或业务逻辑。相反,业务层有一个包含公共只读属性的类,DAL 层通过该属性访问值。

业务逻辑层位于不同的项目中。Web 项目获取参考。业务逻辑层有这个类:Public NotInheritable Class clsUserProfile 它有这个属性:

Public ReadOnly Property AgencyCode() As Integer

    Get
        If clsAppInfo.IsWebApplication Then
            If (HttpContext.Current.Session(_AgencyCodeKey) Is Nothing) Then
                Return 0
            Else
                Return HttpContext.Current.Session(_AgencyCodeKey)
            End If
        Else
            Return AgencyCodeWIN
        End If
    End Get

End Property

/ **对于 windows 代理代码被声明为共享

 Public Shared Property AgencyCodeWIN() As Integer
        Get
            Return _AgencyCodeWIN
        End Get
        Set(ByVal value As Integer)
            _AgencyCodeWIN = value
        End Set

    End Property

/ * ** * 判断是否为网页应用.......

Public Shared ReadOnly Property IsWebApplication() As Boolean
    Get
        If AppCodeWIN IsNot String.Empty Then      
                 'Desk top App is required to pass AppInfo
            Return False
        Else                                                  
                 'Web App is default
            Return True
        End If
    End Get
End Property

当多个用户登录时,数据是否会被覆盖。很多人说不推荐,但找不到任何可证明的理由不推荐?

如果有人能给出明确的理由,那就太好了。

谢谢,桑迪。

4

1 回答 1

0

多用户登录时数据是否会被覆盖

很多人说不推荐,但找不到任何可证明的理由不推荐?

在这种情况下,添加第三种运行模式会很痛苦。

实际上,您的类 clsUserProfile 不应该知道您的应用程序运行模式(webapp 或桌面)。它甚至不应该知道 HttpContext 和 Session 或者在两种运行模式之间进行选择,只是为了得到一个 AgencyCode。

clsUserProfile 应该是一个普通的 C# 对象。运行模式应在您的应用程序中的更高级别处理。

于 2012-11-08T16:43:48.987 回答