Dim fl As String = "c:\web\" & e.Path
If filesys.FileExists(fl)
Dim idx As Integer = fl.LastIndexOf(".")
Dim ext As String = fl.SubString(idx)
Select Case ext
Case ".jpg",".gif",".png",".bmp",".wmf",".js",".css" ,".html",".htm",".zip",".rar"
e.WriteFile(fl)
Return '这里必须返回
End Select
End If
Dim wb As New weui
Dim Verified As Boolean
Dim UserId As String
Dim UserName As String
Select Case e.path
Case "Remuneration" '工资信息
' Dim e As RequestEventArgs = args(0)
Dim sb As New StringBuilder
sb.AppendLine("<meta name='viewport' c>")
If e.GetValues.ContainsKey("code") Then '如果通过授权链接跳转而来,就根据传递过来的code参数调用接口,获取用户的UserId
'MessageBox.Show("通过授权链接进入")
Dim ul As String = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token={0}&code={1}"
ul = CExp(ul,Functions.Execute("GetQYAccessToken"),e.GetValues("code"))
Dim hc As new HttpClient(ul)
Dim jo As JObject = JObject.Parse(hc.GetData)
If jo("UserId") IsNot Nothing Then
UserId = jo("UserId")
'MessageBox.Show("通过授权链接包含信息:" & userid)
End If
Else
UserId = e.Cookies("userid") '否则从cookie中提取userid
Vars("userid")= e.Cookies("userid")
'MessageBox.Show("通过cookies获取:" & userid)
End If
Dim drc As DataRow = DataTables("员工花名册").Find("企业微信号ID ='" & UserId & "'") '根据openid找出对应的行
If UserId <> "" AndAlso drc IsNot Nothing AndAlso drc("微信权限") = 1 '授权成功
Verified = True
UserName = drc("姓名")
wb.AppendCookie("userid",UserId) '将userid和username存储在Cookie中
e.AppendCookie("userid",UserId)
ElseIf e.GetValues.ContainsKey("code") = False Then '如果授权失败,且不是通过授权链接跳转而来,那么就跳转到授权链接
'MessageBox.Show("跳转授权链接" & userid)
Dim ul As String = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={0}&redirect_uri={1}&response_type=code&scope=snsapi_base&agentid={2}&state=STATE#wechat_redirect"
Dim ul2 As String = UrlEncode(Vars("yyzy"))
ul = CExp(ul,Vars("qyid"),ul2,Vars("yyid"))
'Dim ul As String = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww8bbc1c6c7bd8a2e7&redirect_uri=http%3a%2f%2fgz.crucg.top%3a8090%2fRemuneration&response_type=code&scope=snsapi_base&agentid=1000002&state=STATE#wechat_redirect"
sb.Append("<meta http-equiv='Refresh' c>") '跳转到授权链接%3a8090
wb.InsertHTML(sb.ToString)
e.WriteString(wb.Build)
Return
End If
If Verified = False Then
'MessageBox.Show("授权不通过:" & userid)
sb.AppendLine("你无权访问本系统")
Else
'MessageBox.Show("通过,进入主页")
wb.InsertHTML ("<meta http-equiv='Refresh' c>")
e.WriteString(wb.Build)
' sb.AppendLine("欢迎" & UserName & "同志使用本系统,授权成功!请" & " , <a href='http://www.crucg.top/Remuneration2'>刷新页面后进去</a>")
End If
wb.InsertHTML(sb.ToString)
e.WriteString(wb.Build)
wb.AppendCookie("userid",UserId)
Case "Remuneration2"
If e.Cookies.ContainsKey("userid") =False Then
e.WriteString("非法访问")
Return
End If
e.AsyncExecute = True
Functions.AsyncExecute("Remuneration2",e)
MessageBox.Show("Remuneration2:" & e.Cookies("userid") ) 这里 e.Cookies("userid") 还有值, 下面 在访问
Case "mx"
If e.Cookies.ContainsKey("userid") =False Then
e.WriteString("非法访问")
Return
End If
e.AsyncExecute = True
Functions.AsyncExecute("mx",e)
MessageBox.Show("mx:" & e.Cookies("userid") )
Case "order.xls"
If e.Cookies.ContainsKey("userid") =False Then
e.WriteString("非法访问")
Return
End If
e.AsyncExecute = True
Functions.AsyncExecute("CreateXLS",e)
Case "tongji"
MessageBox.Show("6:" & e.Cookies("userid") ) 这里 e.Cookies("userid") 就没有值了,访问到这里 提示 非法访问
If e.Cookies.ContainsKey("userid") =False Then
e.WriteString("非法访问")
Return
End If
e.AsyncExecute = True
Functions.AsyncExecute("tongji",e)
MessageBox.Show("7:" & e.Cookies("userid") )
Case "tongjit"
If e.Cookies.ContainsKey("userid") =False Then
e.WriteString("非法访问")
Return
End If
e.AsyncExecute = True
Functions.AsyncExecute("tongjit",e)
End Select