81 lines
2.9 KiB
C#
81 lines
2.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Runtime.Serialization.Json;
|
|
using System.Web.SessionState;
|
|
using Dapper;
|
|
using Dapper.Contrib.Extensions;
|
|
using System.Data.SqlClient;
|
|
using System.IO.Compression;
|
|
|
|
namespace abbott_2024_event.BackEnd.api
|
|
{
|
|
/// <summary>
|
|
/// babyRec 的摘要描述
|
|
/// </summary>
|
|
public class babyRecList : IHttpHandler
|
|
{
|
|
SqlConnection conn = new SqlConnection(globalClass.appsettings("DBConnectionString"));
|
|
public authToken authToken;
|
|
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", "*");
|
|
|
|
string acceptEncoding = context.Request.Headers["Accept-Encoding"].ToString().ToUpperInvariant();
|
|
if (!String.IsNullOrEmpty(acceptEncoding))
|
|
{
|
|
if (acceptEncoding.Contains("GZIP"))
|
|
{
|
|
//输出流头部GZIP压缩
|
|
context.Response.AppendHeader("Content-encoding", "gzip");
|
|
context.Response.Filter = new GZipStream(context.Response.Filter, CompressionMode.Compress);
|
|
}
|
|
else if (acceptEncoding.Contains("DEFLATE"))
|
|
{
|
|
//输出流头部DEFLATE压缩
|
|
context.Response.AppendHeader("Content-encoding", "deflate");
|
|
context.Response.Filter = new DeflateStream(context.Response.Filter, CompressionMode.Compress);
|
|
}
|
|
}
|
|
|
|
authToken objAuth = new authToken();
|
|
|
|
if (!objAuth.user_isLogin)
|
|
{
|
|
objRet.ret = "no";
|
|
objRet.err_code = "0001";
|
|
objRet.message = "尚未登入,請登入後使用";
|
|
json.WriteObject(context.Response.OutputStream, objRet);
|
|
return;
|
|
}
|
|
|
|
string baby_uid = (context.Request["baby_uid"] == null) ? "" : context.Request["baby_uid"].ToString();
|
|
|
|
objRet.recs = conn.Query<babyRec>("select * from babyRec where babyData_uid = @babyData_uid order by babyRec_recdate desc, babyRec_months desc", new { babyData_uid = baby_uid }).ToList();
|
|
|
|
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<babyRec> recs = new List<babyRec>();
|
|
}
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
} |