LightSwitch Web App 中的表单身份验证和活动用户 [英] Form Authentication and Active users in LightSwitch Web App

查看:15
本文介绍了LightSwitch Web App 中的表单身份验证和活动用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以跟踪用户何时登录(即在日志表中插入登录时间)以及当前有多少用户处于活动状态.我正在使用表单身份验证.我有搜索,但我得到了关于自定义登录页面的东西.是否可以使用表单身份验证进行跟踪?

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?

我尝试在 Application_LoggedIn 上的表中插入日志

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.

有什么办法可以在客户端调用 applicationdataservice 公共函数吗?

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

推荐答案

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

You're creating two separate data workspaces, once when you add the record, then another one when you save the changes. The two workspaces are not connected, so when you ask the second workspace to saves changes, there are none, because it's not aware of the record added in the first workspace.

您的代码应该是(我还没有测试过,但根据我在您的代码中看到的错误):

Your code should be (I haven't tested this, but based on what I see wrong in your code):

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

这篇关于LightSwitch Web App 中的表单身份验证和活动用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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