78 lines
2.7 KiB
Plaintext
78 lines
2.7 KiB
Plaintext
<%@ WebHandler Language="C#" Class="urlsList" %>
|
|
|
|
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 urlsList : 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();
|
|
|
|
string project_uid = (context.Request["project_uid"] == null) ? "" : context.Request["project_uid"].ToString();
|
|
|
|
if (!objAuth.isLogin())
|
|
{
|
|
objRet.ret = "no";
|
|
objRet.err_code = "0001";
|
|
objRet.message = "尚未登入,請登入後使用";
|
|
json.WriteObject(context.Response.OutputStream, objRet);
|
|
return;
|
|
}
|
|
|
|
objRet.user_perm = objAuth.user_perm;
|
|
|
|
if (objAuth.user_perm != "A")
|
|
{
|
|
string projectString = string.Format("select A.* from projects A, projectUser B where A.project_uid = B.project_uid and A.project_isRevoke = 'N' and A.project_uid = '{0}' and B.user_uid = '{1}'", project_uid, objAuth.user_uid);
|
|
autoBindDataTable projectSQL = new autoBindDataTable(projectString);
|
|
|
|
if (projectSQL.dataRows.Count == 0 && project_uid != "") {
|
|
objRet.ret = "no";
|
|
objRet.err_code = "0002";
|
|
objRet.message = "無權限讀取此專案的短網址資料!";
|
|
json.WriteObject(context.Response.OutputStream, objRet);
|
|
return;
|
|
}
|
|
}
|
|
|
|
string urlString = string.Format("select * from url where project_uid = '{0}' and url_isRevoke = 'N'", project_uid);
|
|
autoBindDataTable urlSQL = new autoBindDataTable(urlString);
|
|
|
|
foreach (DataRow objRow in urlSQL.dataRows) {
|
|
urlBase objUrl = new urlBase(objRow);
|
|
objRet.urllist.Add(objUrl);
|
|
}
|
|
|
|
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 string user_perm = "N";
|
|
public List<urlBase> urllist = new List<urlBase>();
|
|
}
|
|
|
|
public bool IsReusable {
|
|
get {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
} |