diff --git a/BackEnd/api/babyRecList.ashx b/BackEnd/api/babyRecList.ashx new file mode 100644 index 0000000..da814e3 --- /dev/null +++ b/BackEnd/api/babyRecList.ashx @@ -0,0 +1 @@ +<%@ WebHandler Language="C#" CodeBehind="babyRecList.ashx.cs" Class="abbott_2024_event.BackEnd.api.babyRecList" %> diff --git a/BackEnd/api/babyRecList.ashx.cs b/BackEnd/api/babyRecList.ashx.cs new file mode 100644 index 0000000..477542b --- /dev/null +++ b/BackEnd/api/babyRecList.ashx.cs @@ -0,0 +1,81 @@ +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 +{ + /// + /// babyRec 的摘要描述 + /// + 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("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 recs = new List(); + } + + public bool IsReusable + { + get + { + return false; + } + } + } +} \ No newline at end of file diff --git a/BackEnd/api/lineData.ashx b/BackEnd/api/lineData.ashx new file mode 100644 index 0000000..4498366 --- /dev/null +++ b/BackEnd/api/lineData.ashx @@ -0,0 +1 @@ +<%@ WebHandler Language="C#" CodeBehind="lineData.ashx.cs" Class="abbott_2024_event.BackEnd.api.lineData" %> diff --git a/BackEnd/api/lineData.ashx.cs b/BackEnd/api/lineData.ashx.cs new file mode 100644 index 0000000..493b5bf --- /dev/null +++ b/BackEnd/api/lineData.ashx.cs @@ -0,0 +1,129 @@ +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 +{ + /// + /// lineData 的摘要描述 + /// + public class lineData : 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 line_uid = (context.Request["line_uid"] == null) ? "" : context.Request["line_uid"].ToString(); + + lineUser lineUser = conn.QueryFirstOrDefault("select * from lineUser where line_uid = @line_uid", new { line_uid = line_uid }); + + if (lineUser == null) + { + objRet.ret = "no"; + objRet.err_code = "0002"; + objRet.message = "無此Line Uid資料!"; + json.WriteObject(context.Response.OutputStream, objRet); + return; + } + + List list = conn.Query("select * from babyData where line_uid = @line_uid", new { line_uid = line_uid }).ToList(); + + objRet.user.line_uid = line_uid; + objRet.user.line_displayName = lineUser.line_displayName; + + foreach (babyData babyData in list) { + baby objData = new baby(); + objData.baby_uid = babyData.babyData_uid; + objData.baby_gender = babyData.babyData_sexual; + objData.baby_birthday = babyData.babyData_birthday.ToString("yyyy/MM/dd"); + objData.baby_name = babyData.babyData_name; + + objRet.user.babyDatas.Add(objData); + } + + 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 userData user = new userData(); + } + + public class userData + { + public string line_uid { get; set; } = ""; + public string line_displayName { get; set; } = ""; + public string testdate { get; set; } = ""; + + public List babyDatas = new List(); + } + + public class baby + { + public string baby_uid { get; set; } = ""; + public string baby_name { get; set; } = ""; + public string baby_gender { get; set; } = ""; + public string baby_birthday { get; set; } = ""; + public string baby_age { get; set; } = ""; + public string baby_months { get; set; } = ""; + public string baby_testdate { get; set; } = ""; + + public string baby_height { get; set; } = ""; + public double baby_percent { get; set; } = 0; + } + + public bool IsReusable + { + get + { + return false; + } + } + } +} \ No newline at end of file diff --git a/BackEnd/assets/javascript/custom/userList.js b/BackEnd/assets/javascript/custom/userList.js index 0c746ea..850abdd 100644 --- a/BackEnd/assets/javascript/custom/userList.js +++ b/BackEnd/assets/javascript/custom/userList.js @@ -56,11 +56,94 @@ $(document).ready(function () { loadDataTable(); + initSubTable(); - + $('#baby_select').on('change', function () { + loadBabyRec(); + }); + }); +function loadBabyRec() { + var baby_uid = $('#baby_select').val(); + + var formData = { + baby_uid: baby_uid + } + + $.ajax({ + url: "api/babyRecList.ashx", + type: "POST", + data: formData, + success: function (data, textStatus, jqXHR) { + if (data.ret == "yes") { + $('#dt-responsive-baby').dataTable().fnClearTable(); + if (data.recs.length > 0) { + + $('#dt-responsive-baby').dataTable().fnAddData(data.recs); + } + + } else { + alert(data.message); + + } + }, + error: function (jqXHR, textStatus, errorThrown) { + alert('网絡或伺服器发生错误,请稍后重试!'); + } + }); +} + +function buttonClick(obj) { + var uid = obj.getAttribute('data-uid'); + + var formData = { + line_uid: uid + } + + $.ajax({ + url: "api/lineData.ashx", + type: "POST", + data: formData, + success: function (data, textStatus, jqXHR) { + if (data.ret == "yes") { + $('#LineTitle').val("Line 名稱:" + data.user.line_displayName + ", Line Uid:" + data.user.line_uid); + + $("#baby_select option").remove(); + + $.each(data.user.babyDatas, function (i, item) { + + var gender = ""; + + if (item.baby_gender == "M") { + gender = "男"; + } else { + gender = "女"; + } + + var babyTxt = item.baby_name + " (" + gender + "), 生日:" + item.baby_birthday; + + $("#baby_select").append($("").attr("value", item.baby_uid).text(babyTxt)); + }); + + loadBabyRec(); + + $('#clientHistoryListModal').modal('toggle'); + + } else { + alert(data.message); + + } + }, + error: function (jqXHR, textStatus, errorThrown) { + alert('网絡或伺服器发生错误,请稍后重试!'); + } + }); + + +} + function loadDataTable() { var dataTables = { init: function init() { @@ -236,3 +319,78 @@ function loadDataTable() { dataTables.init(); } +function initSubTable() { + $("#dt-responsive-baby").DataTable({ + dom: '<\'text-muted\'Bi>\n <\'table-fixed\'trl>\n <\'mt-4\'p>', + lengthChange: true, + lengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]], + pageLength: 25, + buttons: [], + language: { + paginate: { + previous: '', + next: '' + }, + buttons: { + copyTitle: 'Data copied', + copyKeys: 'Use your keyboard or menu to select the copy command' + } + }, + deferRender: true, + rowId: 'babyRec_uid', + deferRender: true, + order: [[0, 'desc']], + columns: [ + { data: 'babyRec_recdate', className: 'align-middle text-left', orderable: true, searchable: false }, + { data: 'babyRec_yearMonthStr', className: 'align-middle text-left', orderable: true, searchable: false }, + { data: 'babyRec_height', className: 'align-middle text-left', orderable: true, searchable: false }, + { data: 'babyRec_inpercent', className: 'align-middle text-left', orderable: true, searchable: false } + ], + columnDefs: [ + { + targets: 0, + orderable: true, + searchable: false, + render: function render(data, type, row, meta) { + tMonth = row.babyRec_recMonth; + tDay = row.babyRec_recDay; + + if (tDay < 10) { + tDay = '0' + tDay; + } + + if (tMonth < 10) { + tMonth = '0' + tMonth; + } + + return row.babyRec_recYear + "/" + tMonth + "/" + tDay; + + + + } + }, + { + targets: 3, + orderable: false, + searchable: false, + render: function render(data, type, row, meta) { + + if (row.babyRec_inpercent > 97) { + return "> 97%"; + } else { + return row.babyRec_inpercent + "%" + } + + + } + } + + ], + initComplete: function () { + + }, + info: false, + ordering: true, + paging: true + }); +} \ No newline at end of file diff --git a/BackEnd/userList.aspx b/BackEnd/userList.aspx index ed723cc..06e5a32 100644 --- a/BackEnd/userList.aspx +++ b/BackEnd/userList.aspx @@ -118,8 +118,79 @@ + +
+ +
- + diff --git a/abbott_2024_event.csproj b/abbott_2024_event.csproj index 2be8026..ae05e28 100644 --- a/abbott_2024_event.csproj +++ b/abbott_2024_event.csproj @@ -13319,6 +13319,9 @@ + + babyRecList.ashx + chgPassword.ashx @@ -13331,6 +13334,9 @@ ipList.ashx + + lineData.ashx + signin.ashx @@ -17888,6 +17894,8 @@ + + Web.config diff --git a/bin/abbott_2024_event.dll b/bin/abbott_2024_event.dll index 07ca58b..5e02001 100644 Binary files a/bin/abbott_2024_event.dll and b/bin/abbott_2024_event.dll differ