以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 不知道什么问题的问题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=148981) |
-- 作者:133198609 -- 发布时间:2020/4/20 17:35:00 -- 不知道什么问题的问题 之前做的工资条程序,近期进行了功能升级。修改后的HttpRequest事件代码为: 前面省略 \'--------------------------------------------------------------------------------------- Select Case e.path Case "Remuneration" \'工资信息 Dim UserId As String Dim UserName As String 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") End If Else UserId = e.Cookies("userid") End If Dim Verified As Boolean Dim drc As DataRow = DataTables("员工花名册").SQLFind("企业微信号ID =\'" & UserId & "\'") \'根据openid找出对应的行 If UserId > "" AndAlso drc IsNot Nothing AndAlso drc("微信权限") = True \'授权成功 Verified = True UserName = drc("姓名") e.AppendCookie("userid",UserId) \'将userid存储在Cookie中 ElseIf e.GetValues.ContainsKey("code") = False Then \'如果授权失败,且不是通过授权链接跳转而来,那么就跳转到授权链接 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")) sb.Append("<meta http-equiv=\'Refresh\' c>") \'跳转到授权链接%3a8090 e.WriteString(sb.ToString) Return End If If Verified = False Then e.AppendCookie("userid",UserId) e.WriteString("<meta http-equiv=\'Refresh\' c>") Else e.WriteString("<meta http-equiv=\'Refresh\' c>") End If e.WriteString(sb.ToString) Case "Remuneration3" If e.Cookies.ContainsKey("userid") =False Then e.WriteString("非法访问") Return End If e.AsyncExecute = True Functions.AsyncExecute("Remuneration3",e) Case "Remuneration2" If e.Cookies.ContainsKey("userid") =False Then e.WriteString("非法访问") Return End If e.AsyncExecute = True Functions.AsyncExecute("Remuneration2",e) End Select 新增的内部函数Remuneration3: Dim e As RequestEventArgs = args(0) Dim wb As New weui Dim UserId As String UserId = e.Cookies("userid") Dim xingming As String Dim sfz As String If e.PostValues.ContainsKey("xingming") AndAlso e.PostValues.ContainsKey("sfz") Then xingming = e.PostValues("xingming") sfz = e.PostValues("sfz") End If Dim drc9 As DataRow = DataTables("员工花名册").SQLFind("身份证号 = \'"& sfz &"\'") If drc9 IsNot Nothing AndAlso drc9("姓名") = xingming AndAlso drc9.IsNull("企业微信号ID") Then drc9.SQLSetValue("企业微信号ID",userid) e.WriteString("<meta http-equiv=\'Refresh\' c>") ElseIf drc9 IsNot Nothing AndAlso drc9.IsNull("企业微信号ID") = False Then e.WriteString(drc9("姓名") & "的企业微信号已占用,请联系公司人力资源部进行核对!") End If wb.AddPageTitle("","pageheader","薪酬管理平台",Vars("dwmc")) If e.PostValues.ContainsKey("xingming") AndAlso e.PostValues.ContainsKey("sfz") Then wb.AddTopTips("","toptip2","无授权信息,请与公司人力资源管理部门核对!").msec = 2000 \' End If wb.AddForm("","form1","Remuneration3") With wb.AddInputGroup("form1","ipg1") .AddInput("xingming","姓名:","text") .AddInput("sfz","身份证号:","text") End With With wb.AddButtonGroup("form1","btg1",True) .Add("btn1", "实名认证", "submit") End With wb.AddToast("","t3", "初次使用,请进行实名认证",0).msec= 1000 e.WriteString(wb.Build) \'生成网页 e.Handled = True 现在少数人访问没问题,人稍微多点就报错,一个错误提示的HttpRequest出错,具体不详,另外一个就是直接程序奔溃,非法关闭。请帮看看哪里需要调整 |
-- 作者:有点蓝 -- 发布时间:2020/4/20 17:53:00 -- 试试 Dim e As RequestEventArgs = args(0) Dim wb As New weui Dim UserId As String UserId = e.Cookies("userid") Dim xingming As String Dim sfz As String If e.PostValues.ContainsKey("xingming") AndAlso e.PostValues.ContainsKey("sfz") Then xingming = e.PostValues("xingming") sfz = e.PostValues("sfz") End If If sfz > "" Then Dim cmd As new SQLCommand cmd.C cmd.CommandText = "SELECT * FROM {员工花名册} WHERE 身份证号 = ?" cmd.Parameters.Add("@身份证号",sfz) Dim dt As DataTable = cmd.ExecuteReader(True) If dt.DataRows.Count > 0 Dim drc9 As DataRow = dt.DataRows(0) If drc9("姓名") = xingming AndAlso drc9.IsNull("企业微信号ID") Then drc9("企业微信号ID") = userid dt.Save e.WriteString("<meta http-equiv=\'Refresh\' c>") 这里1楼不全,自己补上 e.Handled = True Return ElseIf drc9.IsNull("企业微信号ID") = False Then e.WriteString(drc9("姓名") & "的企业微信号已占用,请联系公司人力资源部进行核对!") e.Handled = True Return End If End If End If wb.AddPageTitle("","pageheader","薪酬管理平台",Vars("dwmc")) If e.PostValues.ContainsKey("xingming") AndAlso e.PostValues.ContainsKey("sfz") Then wb.AddTopTips("","toptip2","无授权信息,请与公司人力资源管理部门核对!").msec = 2000 \' End If wb.AddForm("","form1","Remuneration3") With wb.AddInputGroup("form1","ipg1") .AddInput("xingming","姓名:","text") .AddInput("sfz","身份证号:","text") End With With wb.AddButtonGroup("form1","btg1",True) .Add("btn1", "实名认证", "submit") End With wb.AddToast("","t3", "初次使用,请进行实名认证",0).msec= 1000 e.WriteString(wb.Build) \'生成网页 e.Handled = True |
-- 作者:133198609 -- 发布时间:2020/4/20 21:10:00 -- .NET Framework 版本:4.0.30319.42000 Foxtable 版本:2020.1.19.19 错误所在事件:自定义函数Remuneration3 详细错误信息: 调用的目标发生了异常。 OleDbCommand.Prepare 方法要求所有参数具有显式设置的类型。 |
-- 作者:有点蓝 -- 发布时间:2020/4/20 21:21:00 -- 调试看哪句代码出错? Dim cmd As new SQLCommand cmd.ConnectionName = “数据源名称” |
-- 作者:133198609 -- 发布时间:2020/4/20 21:42:00 -- 报错 |
-- 作者:有点蓝 -- 发布时间:2020/4/20 21:48:00 -- 看不出错在哪里。删除项目里的bin目录,重启项目测试 |
-- 作者:133198609 -- 发布时间:2020/4/20 21:58:00 -- 我这是在内部函数里面,异步函数。 会不会和这个有关?
|
-- 作者:有点蓝 -- 发布时间:2020/4/20 22:08:00 -- 应该不是异步的问题,这个去掉试试就知道了。 报错2之前出错还是之后,报错2能不能弹出
|
-- 作者:133198609 -- 发布时间:2020/4/20 22:09:00 -- 报错1弹出,然后就是提示这个错误: .NET Framework 版本:4.0.30319.42000 Foxtable 版本:2020.1.19.19 错误所在事件:自定义函数Remuneration3 详细错误信息: 调用的目标发生了异常。 OleDbCommand.Prepare 方法要求所有参数具有显式设置的类型。 报错2不弹出
|
-- 作者:2900819580 -- 发布时间:2020/4/20 22:14:00 -- Dim dt As DataTable = cmd.ExecuteReader(True) MessageBox.Show(dt.DataRows.Count )
这里检查 一下 身份请输入是否有误。
If dt.DataRows.Count > 0
|