Try
Dim cmd As New SQLCommand
cmd.ConnectionName= gs_strActiveConnLog
cmd.CommandText="Sel ect a.工号,a.账号,a.部门ID,a.用户名称,b.部门名称 from 用户名表 a left join 公司部门表 b on a.部门ID=b.部门编号"
Dim dt As DataTable=cmd.ExecuteReader
Dim st As String = e.UserName.Split(".")(0) & "." & e.UserName.Split(".")(1)
Dim dr1 As DataRow= dt.Find("部门名称='" & e.UserName.Split(".")(0) & "' and 用户名称='" & e.UserName.Split(".")(1) & "'")
If dr1 IsNot Nothing Then
PopMessage(e.UserName & "正在尝试登陆,已查询到用户信息!","提示", PopIconEnum.Infomation, 5)
e.Success = True '允许用户登录
If dt.DataRows.Count>0 Then
'添加所有同事为好友
For Each dr As DataRow In dt.DataRows
'If (dr("部门名称") & "." & dr("用户名称")) <> e.UserName Then '如果不是登录者本人
If (dr("部门名称") & "." & dr("用户名称")) <> st Then '如果不是登录者本人
If e.Buddies.Contains(dr("部门名称") & "." & dr("用户名称") & "." & dr("账号"))=False Then
e.Buddies.Add(dr("部门名称") & "." & dr("用户名称") & "." & dr("账号"))
End If
End If
Next
End If
Else
PopMessage(e.UserName & "正在尝试登陆,但未能在数据库查询到相关数据,登录失败!","提示", PopIconEnum.Infomation, 5)
e.Success = False '拒绝用户登录
e.Message= Functions.Execute("Xml发送信息","用户不存在!请重新确认用户名称!")
End If
Catch ex As Exception
e.Success = False
e.Message=Functions.Execute("Xml发送信息","服务器端错误:" & ex.Message)
End Try
症状如下:
1、代码已经执行到红色部分,也就是e.Success = True,但是UserLoged事件还是不会触发。这个是怎么回事?
2、我的UserName是由部门名称+用户名称+用户ID构成,在别的项目已经测试成功没问题的,而且当前也正常运行的。