0

Is there any way i can trace when user has Login (i.e. insert time of login in a log table) and how many users are currently active. I am using Form Authentication. I have search but i got stuff regarding custom login page. Is it possible to trace this using form authentication?

i have tried to insert a log into table on Application_LoggedIn

 Private Sub Application_LoggedIn()

        Dim A = Application.Current.CreateDataWorkspace.ApplicationData.Logtable.AddNew()
        A.name = User.Name
        A.time = DateTime.Now
        A.dates = DateTime.Now.Date
        A.Activity = "Login"
        Application.Current.CreateDataWorkspace.ApplicationData.SaveChanges()

    End Sub

But it does not seems to working. I checked in debug mode, the pointer passed but data is not inserted. I am not getting where i am doing wrong.

Is there any way i can call applicationdataservice public functions on client end?

4

1 回答 1

2

您正在创建两个单独的数据工作区,一次是在添加记录时,另一个是在您保存更改时。这两个工作区没有连接,所以当你要求第二个工作区保存更改时,没有,因为它不知道第一个工作区中添加的记录。

您的代码应该是(我没有对此进行测试,但基于我在您的代码中看到的错误):

Private Sub Application_LoggedIn()
    Using ws = Application.Current.CreateDataWorkspace
        Dim A = ws.ApplicationData.Logtable.AddNew()
        A.name = User.Name
        A.time = DateTime.Now
        A.dates = DateTime.Now.Date
        A.Activity = "Login"
        ws.ApplicationData.SaveChanges()
    End Using
End Sub
于 2013-04-24T13:10:06.487 回答