85 lines
2.7 KiB
Plaintext
85 lines
2.7 KiB
Plaintext
<%@ WebHandler Language="C#" Class="elab_userslist" %>
|
|
|
|
using System;
|
|
using System.Web;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.Serialization.Json;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using System.Web.Services.Protocols;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
using System.Web.SessionState;
|
|
using System.Data;
|
|
|
|
public class elab_userslist : IHttpHandler, IReadOnlySessionState {
|
|
|
|
public void ProcessRequest (HttpContext context) {
|
|
result objRet = new result();
|
|
DataContractJsonSerializer json = new DataContractJsonSerializer(objRet.GetType());
|
|
context.Response.ContentType = "application/json;charset=utf-8";
|
|
context.Response.AddHeader("Access-Control-Allow-Origin", "*");
|
|
authPermission objAuth = new authPermission();
|
|
|
|
if (!objAuth.isLogin())
|
|
{
|
|
objRet.ret = "no";
|
|
objRet.err_code = "0001";
|
|
objRet.message = "尚未登入,請登入後使用";
|
|
json.WriteObject(context.Response.OutputStream, objRet);
|
|
return;
|
|
}
|
|
|
|
if (objAuth.user_perm != "A" && objAuth.user_perm != "B")
|
|
{
|
|
objRet.ret = "no";
|
|
objRet.err_code = "0002";
|
|
objRet.message = "權限不足,無法使用";
|
|
json.WriteObject(context.Response.OutputStream, objRet);
|
|
return;
|
|
}
|
|
|
|
autoBindDataTable userSQL = new autoBindDataTable("select * from users where user_type = 'N' and user_onjob = 'Y' ");
|
|
|
|
string users_list = "''";
|
|
|
|
foreach (DataRow tmpRow in userSQL.dataRows) {
|
|
users_list += string.Format(", '{0}'", tmpRow["user_id"].ToString());
|
|
}
|
|
|
|
autoBindElab elabSQL = new autoBindElab(string.Format("select * from new_userdata where onjob = 0 and userid not in ({0})", users_list));
|
|
|
|
foreach (DataRow tmpRow in elabSQL.dataRows) {
|
|
elab_userdata tmpUser = new elab_userdata();
|
|
objRet.userslist.Add(tmpUser);
|
|
|
|
tmpUser.userid = tmpRow["userid"].ToString();
|
|
tmpUser.username = tmpRow["username"].ToString();
|
|
tmpUser.mail = tmpRow["mail"].ToString();
|
|
}
|
|
|
|
objRet.ret = "yes";
|
|
json.WriteObject(context.Response.OutputStream, objRet);
|
|
return;
|
|
}
|
|
|
|
public class result {
|
|
public string ret = "no";
|
|
public string err_code = "0000";
|
|
public string message = "";
|
|
public List<elab_userdata> userslist = new List<elab_userdata>();
|
|
}
|
|
|
|
public class elab_userdata {
|
|
public string userid = "";
|
|
public string username = "";
|
|
public string mail = "";
|
|
}
|
|
|
|
public bool IsReusable {
|
|
get {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
} |