DataTables("users").LoadFilter = "shifolizhi = 0"
DataTables("users").Load
For Each r As Row In Tables("users").Rows
Dim ul As String = "https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token={0}&userid={1}"
ul= CExp(ul,Functions.Execute("GetQYAccessToken"),r("userid"))
Dim hc As new HttpClient(ul)
Dim jo As JObject = JObject.Parse(hc.GetData)
If jo("errcode") = "0" Then
With Tables("错误日志")
.AddNew
.Current("时间") = Date.Now
.Current("表名") = "微信成员"
.Current("类型") = "提醒"
.Current("记录") = "成员" & r("name") & "已存在,所以不用添加"
End With
Else
Dim ul1 As String = "https://qyapi.weixin.qq.com/cgi-bin/user/create?access_token={0}"
Dim hc1 As New HttpClient(CExp(ul1,Functions.Execute("GetQYAccessToken")))
Dim jo1 As New JObject
jo1("userid") = cstr(r("userid"))
jo1("name") = cstr(r("name"))
jo1("department") = cstr(r("department"))
jo1("mobile") = cstr(r("mobile"))
hc1.Content = Jo1.ToString
jo1 = JObject.Parse(hc1.GetData)
If jo1("errcode") = "0" Then
With Tables("错误日志")
.AddNew
.Current("时间") = Date.Now
.Current("表名") = "微信成员"
.Current("类型") = "成功"
.Current("记录") = "成员" & r("name") & "添加成功"
End With
Else
With Tables("错误日志")
.AddNew
.Current("时间") = Date.Now
.Current("表名") = "微信成员"
.Current("类型") = "错误"
.Current("记录") = "成员" & r("name") & "添加失败"
End With
End If
End If
Next