<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
|
<%Session.CodePage=65001%>
|
<!--#include file="JsonPost_user.gds"-->
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
<%
|
Set rs = Server.CreateObject("ADODB.Recordset")
|
departmentID = trim(Request("departmentID"))
|
If departmentID="" Then Response.Redirect "/"
|
|
appUrl="https://qyapi.weixin.qq.com/cgi-bin/user/simplelist"
|
|
method="user_simplelist"
|
Origin="access_token="&access_token&"&department_id="&departmentID&"fetch_child=0&status=0"
|
|
'Response.Write Origin &"<BR>"
|
|
HTMLCODE= GetBody(appUrl,Origin)
|
|
JsonID=""
|
If Mid(HTMLCODE,12,1)<>"0" Then
|
Response.Write HTMLCODE
|
Else
|
'结果写入数据库
|
reserve=departmentID
|
JsonID = API_JsonSql(method,HTMLCODE,reserve)
|
End If
|
|
If JsonID<>"" Then
|
json = HTMLCODE
|
Sum_I = 0
|
%>
|
<script language="JScript" runat="Server">
|
function toObject(json) {
|
eval("var o=" + json);
|
return o;
|
}
|
function toArray(s){
|
var dic = Server.CreateObject("Scripting.Dictionary")
|
eval("var a=" + json);
|
for(var i=0;i<a.length;i++){
|
var obj = Server.CreateObject("Scripting.Dictionary")
|
for(x in a[i]) obj.Add(x,a[i][x])
|
dic.Add(i, obj);
|
}
|
return dic
|
}
|
</script>
|
|
<script language="jscript" runat="server">
|
Array.prototype.get = function(i)
|
{
|
return this[i];
|
};
|
function getjson(str){
|
try{
|
eval("var jsonStr = (" + str + ")");
|
}catch(ex){
|
var jsonStr = null;
|
}
|
return jsonStr;
|
}
|
</script>
|
<%
|
str=json
|
str=right(str,len(str)-instr(str,"[")+1)
|
str=left(str,InstrRev(str,"]"))
|
dim obj
|
set obj = getjson(str)
|
str0=""
|
for i=0 to obj.length-1
|
OA_weixinUserID = obj.get(i).userid '部门id
|
'department_name = obj.get(i).name '部门名称
|
'department_parentid= obj.get(i).parentid '父亲部门id。根部门为1
|
'department_order = obj.get(i).order '在父部门中的次序值。order值小的排序靠前。
|
Response.Write OA_weixinUserID &"<BR>"
|
'更新库存数据
|
If department_id<>"" And department_name<>"" Then
|
sql="select id from dictionary where vtitle='OA_Department' and vID="&department_id
|
rs.open sql,objConn,1,1
|
if not rs.Eof then
|
ID = rs("id")
|
sql="update dictionary set vID="&department_id&",vtext='"&department_name&"',vType="&department_parentid&",vOrder="&department_order&" where id="&ID
|
objConn.Execute sql
|
Else
|
sql="Insert into dictionary (vID,vtext,vType,vOrder,vtitle) values ("&department_id&",'"&department_name&"',"&department_parentid&","&department_order&",'OA_Department')"
|
objConn.Execute sql
|
end If
|
rs.close()
|
Sum_I=Sum_I+1
|
End if
|
Next
|
|
sql="update API_Json set is_Json=is_Json+1,is_Json_time=getdate() where id="&JsonID
|
'objConn.Execute sql
|
|
'Response.Redirect "/AdminUser_Department.gds?SystemMessageType=3&SMT=1"
|
End if
|
%>
|