master
dk96 2024-12-03 19:01:28 +08:00
parent 06ae6ffe5a
commit 8029f50dd9
20 changed files with 1179 additions and 16 deletions

View File

@ -6,6 +6,58 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Web; using System.Web;
[Table("babyRec")]
public class babyRec
{
[JsonIgnore]
[Key]
public int babyRec_sn { get; set; } = 0;
public string babyRec_uid { get; set; } = "";
public string babyData_uid { get; set; } = "";
public string babyRec_key { get; set; } = "";
public string line_uid { get; set; } = "";
public double babyRec_height { get; set; } = 0;
public double babyRec_inpercent { get; set; } = 0;
public double babyRec_middleHeight { get; set; } = 0;
public DateTime babyRec_recdate { get; set; } = DateTime.Now;
public int babyRec_recYear { get; set; } = 0;
public int babyRec_recMonth { get; set; } = 0;
public int babyRec_recDay { get; set; } = 0;
public int babyRec_months { get; set; } = 0;
public string babyRec_yearMonthStr { get; set; } = "";
public DateTime babyRec_createdate { get; set; } = DateTime.Now;
}
[Table("babyData")]
public class babyData
{
[JsonIgnore]
[Key]
public int babyData_sn { get; set; } = 0;
public string babyData_uid { get; set; } = "";
public string line_uid { get; set; } = "";
public string babyData_name { get; set; } = "";
public DateTime babyData_birthday { get; set; } = DateTime.Now;
public string babyData_sexual { get; set; } = "";
public string babyData_bindedLine { get; set; } = "";
public DateTime babyData_createdate { get; set; } = DateTime.Now;
public DateTime babyData_bindeddate { get; set; } = DateTime.Now;
}
[Table("lineUser")]
public class lineUser
{
[JsonIgnore]
[Key]
public int lineUser_sn { get; set; } = 0;
public string lineUser_uid { get; set; } = "";
public string line_uid { get; set; } = "";
public string line_displayName { get; set; } = "";
public DateTime lineUser_createdate { get; set; } = DateTime.Now;
public DateTime lineUser_modifydate { get; set; } = DateTime.Now;
}
[Table("login")] [Table("login")]
public class login public class login
{ {
@ -26,4 +78,45 @@ public class token
public string token_isremember { get; set; } = ""; public string token_isremember { get; set; } = "";
public DateTime token_createdate { get; set; } = DateTime.Now; public DateTime token_createdate { get; set; } = DateTime.Now;
public DateTime token_expireddate { get; set; } = DateTime.Now; public DateTime token_expireddate { get; set; } = DateTime.Now;
} }
[Table("temp_m")]
public class temp_m
{
[JsonIgnore]
[Key]
public string temp_month { get; set; } = "";
public double temp_3 { get; set; } = 0;
public double temp_15 { get; set; } = 0;
public double temp_25 { get; set; } = 0;
public double temp_50 { get; set; } = 0;
public double temp_75 { get; set; } = 0;
public double temp_85 { get; set; } = 0;
public double temp_97 { get; set; } = 0;
}
[Table("lenHeiTable")]
public class lenHeiTable
{
[JsonIgnore]
[Key]
public int lenHeiTable_sn { get; set; } = 0;
public string lenHeiTable_sexual { get; set; } = "";
public int lenHeiTable_month { get; set; } = 0;
public double lenHeiTable_minVal { get; set; } = 0;
public double lenHeiTable_maxVal { get; set; } = 0;
public int lenHeiTable_percent { get; set; } = 0;
}
[Table("ipTable")]
public class ipTable
{
[JsonIgnore]
[Key]
public int ipTable_sn { get; set; } = 0;
public string ipTable_address { get; set; } = "";
public DateTime ipTable_createdate { get; set; } = DateTime.Now;
public DateTime ipTable_modifydate { get; set; } = DateTime.Now;
public string ipTable_create_user_uid { get; set; } = "";
}

View File

@ -15,9 +15,83 @@ using System.Drawing;
using System.IO; using System.IO;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Configuration; using System.Configuration;
using Org.BouncyCastle.Asn1.X509;
public static class globalClass public static class globalClass
{ {
public static string YearMonthDiff(DateTime self, DateTime target) {
int years, months, days;
// 因為只需取量不決定誰大誰小所以如果self < target時要交換將大的擺前面
if (self < target)
{
DateTime tmp = target;
target = self;
self = tmp;
}
// 將年轉換成月份以便用來計算
months = 12 * (self.Year - target.Year) + (self.Month - target.Month);
// 如果天數要相減的量不夠時要向月份借天數補滿該月再來相減
if (self.Day < target.Day)
{
months--;
days = DateTime.DaysInMonth(target.Year, target.Month) - target.Day + self.Day;
}
else
{
days = self.Day - target.Day;
}
// 天數計算完成後將月份轉成年
years = months / 12;
months = months % 12;
return years.ToString() + "歲" + months.ToString() + "月";
}
public static int MonthDiff(DateTime self, DateTime target)
{
int years, months, days;
// 因為只需取量不決定誰大誰小所以如果self < target時要交換將大的擺前面
if (self < target)
{
DateTime tmp = target;
target = self;
self = tmp;
}
// 將年轉換成月份以便用來計算
months = 12 * (self.Year - target.Year) + (self.Month - target.Month);
// 如果天數要相減的量不夠時要向月份借天數補滿該月再來相減
if (self.Day < target.Day)
{
months--;
days = DateTime.DaysInMonth(target.Year, target.Month) - target.Day + self.Day;
}
else
{
days = self.Day - target.Day;
}
return months;
}
public static string GetIPAddress()
{
System.Web.HttpContext context = System.Web.HttpContext.Current;
string sIPAddress = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (string.IsNullOrEmpty(sIPAddress))
{
return context.Request.ServerVariables["REMOTE_ADDR"];
}
else
{
string[] ipArray = sIPAddress.Split(new Char[] { ',' });
return ipArray[0];
}
}
public static string CreateRandomCode(int Number) public static string CreateRandomCode(int Number)
{ {
string allChar = "0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"; string allChar = "0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z";

100
BackEnd/Login.aspx Normal file
View File

@ -0,0 +1,100 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="abbott_2024_event.BackEnd.Login" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><!-- End Required meta tags -->
<!-- Begin SEO tag -->
<title> 後台登入 </title>
<!-- End SEO tag -->
<!-- Favicons -->
<link rel="apple-touch-icon" sizes="144x144" href="assets/favicon.png">
<link rel="shortcut icon" href="assets/favicon.ico">
<meta name="theme-color" content="#3063A0"><!-- Google font -->
<link href="https://fonts.googleapis.com/css?family=Fira+Sans:400,500,600" rel="stylesheet"><!-- End Google font -->
<!-- BEGIN PLUGINS STYLES -->
<link rel="stylesheet" href="assets/vendor/@fortawesome/fontawesome-free/css/all.min.css"><!-- END PLUGINS STYLES -->
<!-- BEGIN THEME STYLES -->
<link rel="stylesheet" href="assets/stylesheets/theme.min.css" data-skin="default">
<link rel="stylesheet" href="assets/stylesheets/theme-dark.min.css" data-skin="dark">
<link rel="stylesheet" href="assets/stylesheets/custom.css">
<script>
var skin = localStorage.getItem('skin') || 'default';
var isCompact = JSON.parse(localStorage.getItem('hasCompactMenu'));
var disabledSkinStylesheet = document.querySelector('link[data-skin]:not([data-skin="' + skin + '"])');
// Disable unused skin immediately
disabledSkinStylesheet.setAttribute('rel', '');
disabledSkinStylesheet.setAttribute('disabled', true);
// add flag class to html immediately
if (isCompact == true) document.querySelector('html').classList.add('preparing-compact-menu');
</script><!-- END THEME STYLES -->
</head>
<body>
<!--[if lt IE 10]>
<div class="page-message" role="alert">You are using an <strong>outdated</strong> browser. Please <a class="alert-link" href="http://browsehappy.com/">upgrade your browser</a> to improve your experience and security.</div>
<![endif]-->
<!-- .auth -->
<main class="auth">
<header id="auth-header" class="auth-header" style="background-image: url(assets/images/illustration/img-1.png);">
<h1>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="64" viewbox="0 0 351 100">
<defs>
<path id="a" d="M156.538 45.644v1.04a6.347 6.347 0 0 1-1.847 3.98L127.708 77.67a6.338 6.338 0 0 1-3.862 1.839h-1.272a6.34 6.34 0 0 1-3.862-1.839L91.728 50.664a6.353 6.353 0 0 1 0-9l9.11-9.117-2.136-2.138a3.171 3.171 0 0 0-4.498 0L80.711 43.913a3.177 3.177 0 0 0-.043 4.453l-.002.003.048.047 24.733 24.754-4.497 4.5a6.339 6.339 0 0 1-3.863 1.84h-1.27a6.337 6.337 0 0 1-3.863-1.84L64.971 50.665a6.353 6.353 0 0 1 0-9l26.983-27.008a6.336 6.336 0 0 1 4.498-1.869c1.626 0 3.252.622 4.498 1.87l26.986 27.006a6.353 6.353 0 0 1 0 9l-9.11 9.117 2.136 2.138a3.171 3.171 0 0 0 4.498 0l13.49-13.504a3.177 3.177 0 0 0 .046-4.453l.002-.002-.047-.048-24.737-24.754 4.498-4.5a6.344 6.344 0 0 1 8.996 0l26.983 27.006a6.347 6.347 0 0 1 1.847 3.98zm-46.707-4.095l-2.362 2.364a3.178 3.178 0 0 0 0 4.501l2.362 2.364 2.361-2.364a3.178 3.178 0 0 0 0-4.501l-2.361-2.364z"></path>
</defs>
<g fill="none" fill-rule="evenodd">
<path fill="currentColor" fill-rule="nonzero" d="M39.252 80.385c-13.817 0-21.06-8.915-21.06-22.955V13.862H.81V.936h33.762V58.1c0 6.797 4.346 9.026 9.026 9.026 2.563 0 5.237-.446 8.58-1.783l3.677 12.034c-5.794 1.894-9.694 3.009-16.603 3.009zM164.213 99.55V23.78h13.372l1.225 5.571h.335c4.457-4.011 10.585-6.908 16.491-6.908 13.817 0 22.174 11.031 22.174 28.08 0 18.943-11.588 29.863-23.957 29.863-4.903 0-9.694-2.117-13.594-6.017h-.446l.78 9.025V99.55h-16.38zm25.852-32.537c6.128 0 10.92-4.903 10.92-16.268 0-9.917-3.232-14.932-10.14-14.932-3.566 0-6.797 1.56-10.252 5.126v22.397c3.12 2.674 6.686 3.677 9.472 3.677zm69.643 13.372c-17.272 0-30.643-10.586-30.643-28.972 0-18.163 13.928-28.971 28.748-28.971 17.049 0 26.075 11.477 26.075 26.52 0 3.008-.558 6.017-.78 7.354h-37.663c1.56 8.023 7.465 11.589 16.491 11.589 5.014 0 9.36-1.337 14.263-3.9l5.46 9.917c-6.351 4.011-14.597 6.463-21.951 6.463zm-1.338-45.463c-6.462 0-11.031 3.454-12.702 10.363h23.622c-.78-6.797-4.568-10.363-10.92-10.363zm44.238 44.126V23.779h13.371l1.337 12.034h.334c5.46-9.025 13.595-13.371 22.398-13.371 4.902 0 7.465.78 10.697 2.228l-3.343 13.706c-3.454-1.003-5.683-1.56-9.806-1.56-6.797 0-13.928 3.566-18.608 13.483v28.749h-16.38z"></path>
<use class="fill-warning" xlink:href="#a"></use>
</g>
</svg> <span class="sr-only">Sign In</span>
</h1>
</header><!-- form -->
<form class="auth-form">
<!-- .form-group -->
<div class="form-group">
<div class="form-label-group">
<input type="text" id="login_id" class="form-control" placeholder="帳號" autofocus=""> <label for="login_id">帳號</label>
</div>
</div><!-- /.form-group -->
<!-- .form-group -->
<div class="form-group">
<div class="form-label-group">
<input type="password" id="login_pwd" class="form-control" placeholder="密碼"> <label for="login_pwd">密碼</label>
</div>
</div><!-- /.form-group -->
<!-- .form-group -->
<div class="form-group">
<button id="login_btn" class="btn btn-lg btn-primary btn-block" type="button">登入</button>
</div><!-- /.form-group -->
</form><!-- /.auth-form -->
</main><!-- /.auth -->
<!-- BEGIN BASE JS -->
<script src="assets/vendor/jquery/jquery.min.js"></script>
<script src="assets/vendor/jquery.cookie/jquery.cookie.js"></script>
<script src="assets/vendor/popper.js/umd/popper.min.js"></script>
<script src="assets/vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/javascript/sha256.js"></script>
<script src="assets/javascript/custom/globalJS.js"></script>
<script src="assets/javascript/custom/Login.js?v=2" ></script>
<!-- END BASE JS -->
<!-- BEGIN PLUGINS JS -->
<script src="assets/vendor/particles.js/particles.js"></script>
<script>
/**
* Keep in mind that your scripts may not always be executed after the theme is completely ready,
* you might need to observe the `theme:load` event to make sure your scripts are executed after the theme is ready.
*/
$(document).on('theme:init', () => {
/* particlesJS.load(@dom-id, @path-json, @callback (optional)); */
particlesJS.load('auth-header', 'assets/javascript/pages/particles.json');
})
</script> <!-- END PLUGINS JS -->
<!-- BEGIN THEME JS -->
<script src="assets/javascript/theme.js"></script> <!-- END THEME JS -->
</body>
</html>

44
BackEnd/Login.aspx.cs Normal file
View File

@ -0,0 +1,44 @@
using Dapper;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace abbott_2024_event.BackEnd
{
public partial class Login : System.Web.UI.Page
{
SqlConnection conn = new SqlConnection(globalClass.appsettings("DBConnectionString"));
protected void Page_Load(object sender, EventArgs e)
{
string myIP = globalClass.GetIPAddress();
if (myIP == "::1")
{
myIP = "127.0.0.1";
}
Boolean isAllow = false;
if (myIP == "127.0.0.1")
{
isAllow = true;
}
ipTable ipTable = conn.QueryFirstOrDefault<ipTable>("select * from ipTable where ipTable_address = @ipTable_address", new { ipTable_address = myIP });
if (ipTable != null) {
isAllow = true;
}
if (isAllow == false)
{
Response.Redirect("auth-error-v3.html");
return;
}
}
}
}

17
BackEnd/Login.aspx.designer.cs generated Normal file
View File

@ -0,0 +1,17 @@
//------------------------------------------------------------------------------
// <自動產生>
// 這段程式碼是由工具產生的。
//
// 變更這個檔案可能會導致不正確的行為,而且如果已重新產生
// 程式碼,則會遺失變更。
// </自動產生>
//------------------------------------------------------------------------------
namespace abbott_2024_event.BackEnd
{
public partial class Login
{
}
}

View File

@ -34,8 +34,7 @@
if (isCompact == true) document.querySelector('html').classList.add('preparing-compact-menu'); if (isCompact == true) document.querySelector('html').classList.add('preparing-compact-menu');
</script> </script>
<!-- END THEME STYLES --> <!-- END THEME STYLES -->
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head> </head>
<body> <body>
<form id="form1" runat="server"> <form id="form1" runat="server">
@ -120,7 +119,10 @@
<li class="menu-item"> <li class="menu-item">
<a href="index.html" class="menu-link"><span class="menu-icon fas fa-home"></span> <span class="menu-text">Dashboard</span></a> <a href="index.html" class="menu-link"><span class="menu-icon fas fa-home"></span> <span class="menu-text">Dashboard</span></a>
</li><!-- /.menu-item --> </li><!-- /.menu-item -->
<!-- .menu-item -->
<li class="menu-item">
<a href="ip-management.aspx" class="menu-link"><span class="menu-icon oi oi-wrench"></span> <span class="menu-text">IP白名單</span></a>
</li><!-- /.menu-item -->
</ul><!-- /.menu --> </ul><!-- /.menu -->
</nav><!-- /.stacked-menu --> </nav><!-- /.stacked-menu -->
</div><!-- /.aside-menu --> </div><!-- /.aside-menu -->
@ -153,7 +155,8 @@
<script src="assets/vendor/perfect-scrollbar/perfect-scrollbar.min.js"></script> <!-- END PLUGINS JS --> <script src="assets/vendor/perfect-scrollbar/perfect-scrollbar.min.js"></script> <!-- END PLUGINS JS -->
<!-- BEGIN THEME JS --> <!-- BEGIN THEME JS -->
<script src="assets/javascript/theme.min.js"></script> <!-- END THEME JS --> <script src="assets/javascript/theme.min.js"></script> <!-- END THEME JS -->
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</form> </form>
</body> </body>
</html> </html>

View File

@ -1,5 +1,7 @@
using System; using Dapper;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq; using System.Linq;
using System.Web; using System.Web;
using System.Web.UI; using System.Web.UI;
@ -10,9 +12,39 @@ namespace abbott_2024_event.BackEnd
public partial class Main : System.Web.UI.MasterPage public partial class Main : System.Web.UI.MasterPage
{ {
SqlConnection conn = new SqlConnection(globalClass.appsettings("DBConnectionString"));
public authToken authToken; public authToken authToken;
protected void Page_Load(object sender, EventArgs e) protected void Page_Load(object sender, EventArgs e)
{ {
string myIP = globalClass.GetIPAddress();
if (myIP == "::1")
{
myIP = "127.0.0.1";
}
Boolean isAllow = false;
if (myIP == "127.0.0.1")
{
isAllow = true;
}
ipTable ipTable = conn.QueryFirstOrDefault<ipTable>("select * from ipTable where ipTable_address = @ipTable_address", new { ipTable_address = myIP });
if (ipTable != null)
{
isAllow = true;
}
if (isAllow == false)
{
Response.Redirect("auth-error-v3.html");
return;
}
authToken = new authToken(); authToken = new authToken();
if (authToken.user_isLogin == false) { if (authToken.user_isLogin == false) {

View File

@ -14,15 +14,6 @@ namespace abbott_2024_event.BackEnd
public partial class Main public partial class Main
{ {
/// <summary>
/// head 控制項。
/// </summary>
/// <remarks>
/// 自動產生的欄位。
/// 若要修改,請將欄位宣告從設計工具檔案移到程式碼後置檔案。
/// </remarks>
protected global::System.Web.UI.WebControls.ContentPlaceHolder head;
/// <summary> /// <summary>
/// form1 控制項。 /// form1 控制項。
/// </summary> /// </summary>
@ -40,5 +31,14 @@ namespace abbott_2024_event.BackEnd
/// 若要修改,請將欄位宣告從設計工具檔案移到程式碼後置檔案。 /// 若要修改,請將欄位宣告從設計工具檔案移到程式碼後置檔案。
/// </remarks> /// </remarks>
protected global::System.Web.UI.WebControls.ContentPlaceHolder ContentPlaceHolder1; protected global::System.Web.UI.WebControls.ContentPlaceHolder ContentPlaceHolder1;
/// <summary>
/// head 控制項。
/// </summary>
/// <remarks>
/// 自動產生的欄位。
/// 若要修改,請將欄位宣告從設計工具檔案移到程式碼後置檔案。
/// </remarks>
protected global::System.Web.UI.WebControls.ContentPlaceHolder head;
} }
} }

View File

@ -0,0 +1 @@
<%@ WebHandler Language="C#" CodeBehind="importTestData.ashx.cs" Class="abbott_2024_event.BackEnd.api.importTestData" %>

View File

@ -0,0 +1,150 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Runtime.Serialization.Json;
using System.Web;
using System.Web.SessionState;
using Dapper;
using Dapper.Contrib.Extensions;
namespace abbott_2024_event.BackEnd.api
{
/// <summary>
/// importTestData 的摘要描述
/// </summary>
public class importTestData : IHttpHandler
{
SqlConnection conn = new SqlConnection(globalClass.appsettings("DBConnectionString"));
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
List<temp_m> tempList = conn.Query<temp_m>("select * from temp_f").ToList();
int intmonth = 0;
foreach (temp_m tempm in tempList) {
double minVal = 0;
double maxVal = 0;
for (int i = 1; i <= 8; i++) {
lenHeiTable newData = new lenHeiTable();
newData.lenHeiTable_month = intmonth;
newData.lenHeiTable_sexual = "F";
if (i == 1) {
maxVal = tempm.temp_3;
newData.lenHeiTable_minVal = minVal;
newData.lenHeiTable_maxVal = maxVal;
newData.lenHeiTable_percent = 3;
minVal = tempm.temp_3;
}
if (i == 2)
{
maxVal = tempm.temp_15;
newData.lenHeiTable_minVal = minVal;
newData.lenHeiTable_maxVal = maxVal;
newData.lenHeiTable_percent = 15;
minVal = tempm.temp_15;
}
if (i == 3)
{
maxVal = tempm.temp_25;
newData.lenHeiTable_minVal = minVal;
newData.lenHeiTable_maxVal = maxVal;
newData.lenHeiTable_percent = 25;
minVal = tempm.temp_25;
}
if (i == 4)
{
maxVal = tempm.temp_50;
newData.lenHeiTable_minVal = minVal;
newData.lenHeiTable_maxVal = maxVal;
newData.lenHeiTable_percent = 50;
minVal = tempm.temp_50;
}
if (i == 5)
{
maxVal = tempm.temp_75;
newData.lenHeiTable_minVal = minVal;
newData.lenHeiTable_maxVal = maxVal;
newData.lenHeiTable_percent = 75;
minVal = tempm.temp_75;
}
if (i == 6)
{
maxVal = tempm.temp_85;
newData.lenHeiTable_minVal = minVal;
newData.lenHeiTable_maxVal = maxVal;
newData.lenHeiTable_percent = 85;
minVal = tempm.temp_85;
}
if (i == 7)
{
maxVal = tempm.temp_97;
newData.lenHeiTable_minVal = minVal;
newData.lenHeiTable_maxVal = maxVal;
newData.lenHeiTable_percent = 97;
minVal = tempm.temp_97;
}
if (i == 8)
{
maxVal = 999;
newData.lenHeiTable_minVal = minVal;
newData.lenHeiTable_maxVal = maxVal;
newData.lenHeiTable_percent = 100;
minVal = 0;
}
conn.Insert<lenHeiTable>(newData);
}
intmonth++;
}
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
}
public bool IsReusable
{
get
{
return false;
}
}
}
}

1
BackEnd/api/ipList.ashx Normal file
View File

@ -0,0 +1 @@
<%@ WebHandler Language="C#" CodeBehind="ipList.ashx.cs" Class="abbott_2024_event.BackEnd.api.ipList" %>

125
BackEnd/api/ipList.ashx.cs Normal file
View File

@ -0,0 +1,125 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
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;
using System.IO.Compression;
using System.Data.SqlClient;
using Dapper;
using Dapper.Contrib.Extensions;
namespace abbott_2024_event.BackEnd.api
{
/// <summary>
/// ipList 的摘要描述
/// </summary>
public class ipList : IHttpHandler, IReadOnlySessionState
{
SqlConnection conn = new SqlConnection(globalClass.appsettings("DBConnectionString"));
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();
string allowAnyIP = (context.Request["allow"] == null) ? "" : context.Request["allow"].ToString();
string iplist = (context.Request["iplist"] == null) ? "[]" : context.Request["iplist"].ToString();
string method = (context.Request["method"] == null) ? "" : context.Request["method"].ToString();
if (!objAuth.user_isLogin)
{
objRet.ret = "no";
objRet.err_code = "0001";
objRet.message = "尚未登入,請登入後使用";
json.WriteObject(context.Response.OutputStream, objRet);
return;
}
if (method == "")
{
objRet.ret = "no";
objRet.err_code = "0003";
objRet.message = "無method";
json.WriteObject(context.Response.OutputStream, objRet);
return;
}
if (method == "get") {
List<ipTable> ipTables = conn.Query<ipTable>("select * from ipTable").ToList();
foreach (ipTable ipTable in ipTables) {
objRet.ipList.Add(ipTable.ipTable_address);
}
objRet.ret = "yes";
json.WriteObject(context.Response.OutputStream, objRet);
return;
}
if (method == "edit") {
dynamic ipJsonObj;
ipJsonObj = JValue.Parse(iplist);
conn.Execute("delete ipTable");
foreach (string item in ipJsonObj)
{
if (item != "") {
ipTable newIp = new ipTable();
newIp.ipTable_address = item;
newIp.ipTable_create_user_uid = "admin";
conn.Insert<ipTable>(newIp);
}
}
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 allowAnyIP = "N";
public List<string> ipList = new List<string>();
}
public bool IsReusable
{
get
{
return false;
}
}
}
}

View File

@ -0,0 +1,99 @@
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><!-- End Required meta tags -->
<!-- Begin SEO tag -->
<title> Error 404: Page not found | Looper - Bootstrap 4 Admin Theme </title>
<meta property="og:title" content="Error 404: Page not found">
<meta name="author" content="Beni Arisandi">
<meta property="og:locale" content="en_US">
<meta name="description" content="Responsive admin theme build on top of Bootstrap 4">
<meta property="og:description" content="Responsive admin theme build on top of Bootstrap 4">
<link rel="canonical" href="https://uselooper.com">
<meta property="og:url" content="https://uselooper.com">
<meta property="og:site_name" content="Looper - Bootstrap 4 Admin Theme">
<script type="application/ld+json">
{
"name": "Looper - Bootstrap 4 Admin Theme",
"description": "Responsive admin theme build on top of Bootstrap 4",
"author":
{
"@type": "Person",
"name": "Beni Arisandi"
},
"@type": "WebSite",
"url": "",
"headline": "Error 404: Page not found",
"@context": "http://schema.org"
}
</script><!-- End SEO tag -->
<!-- Favicons -->
<link rel="apple-touch-icon" sizes="144x144" href="assets/apple-touch-icon.png">
<link rel="shortcut icon" href="assets/favicon.ico">
<meta name="theme-color" content="#3063A0"><!-- Google font -->
<link href="https://fonts.googleapis.com/css?family=Fira+Sans:400,500,600" rel="stylesheet"><!-- End Google font -->
<!-- BEGIN PLUGINS STYLES -->
<link rel="stylesheet" href="assets/vendor/@fortawesome/fontawesome-free/css/all.min.css"><!-- END PLUGINS STYLES -->
<!-- BEGIN THEME STYLES -->
<link rel="stylesheet" href="assets/stylesheets/theme.min.css" data-skin="default">
<link rel="stylesheet" href="assets/stylesheets/theme-dark.min.css" data-skin="dark">
<link rel="stylesheet" href="assets/stylesheets/custom.css">
<script>
var skin = localStorage.getItem('skin') || 'default';
var isCompact = JSON.parse(localStorage.getItem('hasCompactMenu'));
var disabledSkinStylesheet = document.querySelector('link[data-skin]:not([data-skin="' + skin + '"])');
// Disable unused skin immediately
disabledSkinStylesheet.setAttribute('rel', '');
disabledSkinStylesheet.setAttribute('disabled', true);
// add flag class to html immediately
if (isCompact == true) document.querySelector('html').classList.add('preparing-compact-menu');
</script><!-- END THEME STYLES -->
</head>
<body>
<!--[if lt IE 10]>
<div class="page-message" role="alert">You are using an <strong>outdated</strong> browser. Please <a class="alert-link" href="http://browsehappy.com/">upgrade your browser</a> to improve your experience and security.</div>
<![endif]-->
<!-- .empty-state -->
<main id="notfound-state" class="empty-state empty-state-fullpage bg-black">
<!-- .empty-state-container -->
<div class="empty-state-container">
<div class="card">
<div class="card-header bg-light text-left">
<i class="fa fa-fw fa-circle text-red"></i> <i class="fa fa-fw fa-circle text-yellow"></i> <i class="fa fa-fw fa-circle text-teal"></i>
</div>
<div class="card-body">
<h1 class="state-header display-1 font-weight-bold">
<span>4</span> <i class="far fa-frown text-red"></i> <span>4</span>
</h1>
<h3> Page not found! </h3>
<p class="state-description lead"> Sorry, we've misplaced that URL or it's pointing to something that doesn't exist. </p>
<div class="state-action">
<a href="auth-error-v1.html" class="btn btn-lg btn-light"><i class="fa fa-angle-right"></i> Go Home</a>
</div>
</div>
</div>
</div><!-- /.empty-state-container -->
</main><!-- /.empty-state -->
<!-- BEGIN BASE JS -->
<script src="assets/vendor/jquery/jquery.min.js"></script>
<script src="assets/vendor/popper.js/umd/popper.min.js"></script>
<script src="assets/vendor/bootstrap/js/bootstrap.min.js"></script> <!-- END BASE JS -->
<!-- BEGIN PLUGINS JS -->
<script src="assets/vendor/particles.js/particles.js"></script>
<script>
/**
* Keep in mind that your scripts may not always be executed after the theme is completely ready,
* you might need to observe the `theme:load` event to make sure your scripts are executed after the theme is ready.
*/
$(document).on('theme:init', () =>
{
/* particlesJS.load(@dom-id, @path-json, @callback (optional)); */
particlesJS.load('notfound-state', 'assets/javascript/pages/particles-error.json');
})
</script> <!-- END PLUGINS JS -->
<!-- BEGIN THEME JS -->
<script src="assets/javascript/theme.min.js"></script> <!-- END THEME JS -->
</body>
</html>

116
BackEnd/ip-management.aspx Normal file
View File

@ -0,0 +1,116 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/BackEnd/Main.Master" AutoEventWireup="true" CodeBehind="ip-management.aspx.cs" Inherits="abbott_2024_event.BackEnd.ip_management" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script>
$(document).ready(function () {
var formData = {
method: 'get'
}
$.ajax({
url: "api/ipList.ashx",
type: "POST",
data: formData,
success: function (data, textStatus, jqXHR) {
if (data.ret == "yes") {
//$("input[name=rdGroup3][value=" + data.allowAnyIP + "]").prop("checked", true);
$.each(data.ipList, function (i, item) {
$("#ip_list").val($("#ip_list").val() + item + "\n");
});
} else {
alert(data.message);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('网絡或伺服器发生错误,请稍后重试!');
}
});
$("#saveBtn").click(function () {
var array = $("#ip_list").val().split("\n");
var iplist = JSON.stringify(array);
var allowAnyIP = $('input[name*=rdGroup3]:checked').val();
var formData = {
method: 'edit',
iplist: iplist
}
$.ajax({
url: "api/ipList.ashx",
type: "POST",
data: formData,
success: function (data, textStatus, jqXHR) {
if (data.ret == "yes") {
alert("套用成功");
} else {
alert(data.message);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('网絡或伺服器发生错误,请稍后重试!');
}
});
});
});
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<!-- .page-inner -->
<div class="page-inner">
<!-- .page-title-bar -->
<header class="page-title-bar">
<!-- .breadcrumb -->
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item active">
<a href="#">
<i class="breadcrumb-icon fa fa-angle-left mr-2"></i>允許IP清單</a>
</li>
</ol>
</nav>
<!-- title and toolbar -->
<div class="d-md-flex align-items-md-start">
<h1 class="page-title mr-sm-auto">IP清單 </h1>
<!-- .btn-toolbar -->
<div id="dt-buttons" class="btn-toolbar"></div>
<!-- /.btn-toolbar -->
</div>
<!-- /title and toolbar -->
</header>
<div class="page-section">
<!-- .card -->
<section class="card card-fluid">
<!-- .card-body -->
<div class="card-body">
<!-- .form-row -->
<div class="form-row">
<div class="col-md-6">
<div class="form-group">
<label for="rd7">IP白名單</label>
<div class="custom-control custom-radio mb-1">
<div class="mt-1">
<textarea id="ip_list" class="form-control" rows="6" placeholder="允許存取的IP位置以換行分隔"></textarea>
</div>
<div class="text-muted">請在上方輸入可以存取的IP位置每行一組IP。 </div>
</div>
</div>
</div>
</div>
<div class="form-row">
<button type="button" class="btn btn-primary" id="saveBtn">套用設定</button>
</div>
</div>
</section>
</div>
</div>
</asp:Content>

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace abbott_2024_event.BackEnd
{
public partial class ip_management : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}

17
BackEnd/ip-management.aspx.designer.cs generated Normal file
View File

@ -0,0 +1,17 @@
//------------------------------------------------------------------------------
// <自動產生>
// 這段程式碼是由工具產生的。
//
// 變更這個檔案可能會導致不正確的行為,而且如果已重新產生
// 程式碼,則會遺失變更。
// </自動產生>
//------------------------------------------------------------------------------
namespace abbott_2024_event.BackEnd
{
public partial class ip_management
{
}
}

View File

@ -13152,7 +13152,10 @@
<Content Include="BackEnd\assets\vendor\wnumb\wNumb.min.js" /> <Content Include="BackEnd\assets\vendor\wnumb\wNumb.min.js" />
<Content Include="BackEnd\assets\vendor\zxcvbn\._zxcvbn.js" /> <Content Include="BackEnd\assets\vendor\zxcvbn\._zxcvbn.js" />
<Content Include="BackEnd\assets\vendor\zxcvbn\zxcvbn.js" /> <Content Include="BackEnd\assets\vendor\zxcvbn\zxcvbn.js" />
<Content Include="BackEnd\auth-error-v3.html" />
<Content Include="BackEnd\Index.aspx" /> <Content Include="BackEnd\Index.aspx" />
<Content Include="BackEnd\ip-management.aspx" />
<Content Include="BackEnd\Login.aspx" />
<Content Include="BackEnd\Login.html" /> <Content Include="BackEnd\Login.html" />
<Content Include="Default.aspx" /> <Content Include="Default.aspx" />
<Content Include="favicon.ico" /> <Content Include="favicon.ico" />
@ -13162,6 +13165,12 @@
<Compile Include="App_Code\authToken.cs" /> <Compile Include="App_Code\authToken.cs" />
<Compile Include="App_Code\globalClass.cs" /> <Compile Include="App_Code\globalClass.cs" />
<Compile Include="App_Code\dbClass.cs" /> <Compile Include="App_Code\dbClass.cs" />
<Compile Include="BackEnd\api\importTestData.ashx.cs">
<DependentUpon>importTestData.ashx</DependentUpon>
</Compile>
<Compile Include="BackEnd\api\ipList.ashx.cs">
<DependentUpon>ipList.ashx</DependentUpon>
</Compile>
<Compile Include="BackEnd\api\signin.ashx.cs"> <Compile Include="BackEnd\api\signin.ashx.cs">
<DependentUpon>signin.ashx</DependentUpon> <DependentUpon>signin.ashx</DependentUpon>
</Compile> </Compile>
@ -13172,6 +13181,20 @@
<Compile Include="BackEnd\Index.aspx.designer.cs"> <Compile Include="BackEnd\Index.aspx.designer.cs">
<DependentUpon>Index.aspx</DependentUpon> <DependentUpon>Index.aspx</DependentUpon>
</Compile> </Compile>
<Compile Include="BackEnd\ip-management.aspx.cs">
<DependentUpon>ip-management.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="BackEnd\ip-management.aspx.designer.cs">
<DependentUpon>ip-management.aspx</DependentUpon>
</Compile>
<Compile Include="BackEnd\Login.aspx.cs">
<DependentUpon>Login.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="BackEnd\Login.aspx.designer.cs">
<DependentUpon>Login.aspx</DependentUpon>
</Compile>
<Compile Include="BackEnd\Main.Master.cs"> <Compile Include="BackEnd\Main.Master.cs">
<DependentUpon>Main.Master</DependentUpon> <DependentUpon>Main.Master</DependentUpon>
<SubType>ASPXCodeBehind</SubType> <SubType>ASPXCodeBehind</SubType>
@ -13187,10 +13210,12 @@
<DependentUpon>Default.aspx</DependentUpon> <DependentUpon>Default.aspx</DependentUpon>
</Compile> </Compile>
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="webapi\babyData.ashx.cs">
<DependentUpon>babyData.ashx</DependentUpon>
</Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="App_Data\" /> <Folder Include="App_Data\" />
<Folder Include="BackEnd\assets\BackEndApi\" />
<Folder Include="BackEnd\assets\vendor\%40fortawesome\fontawesome-free\less\" /> <Folder Include="BackEnd\assets\vendor\%40fortawesome\fontawesome-free\less\" />
<Folder Include="BackEnd\assets\vendor\%40fortawesome\fontawesome-free\metadata\" /> <Folder Include="BackEnd\assets\vendor\%40fortawesome\fontawesome-free\metadata\" />
<Folder Include="BackEnd\assets\vendor\%40fortawesome\fontawesome-free\scss\" /> <Folder Include="BackEnd\assets\vendor\%40fortawesome\fontawesome-free\scss\" />
@ -17653,6 +17678,8 @@
<Content Include="BackEnd\assets\vendor\zxcvbn\zxcvbn.js.map" /> <Content Include="BackEnd\assets\vendor\zxcvbn\zxcvbn.js.map" />
<Content Include="BackEnd\Main.Master" /> <Content Include="BackEnd\Main.Master" />
<Content Include="BackEnd\api\signin.ashx" /> <Content Include="BackEnd\api\signin.ashx" />
<Content Include="BackEnd\api\importTestData.ashx" />
<Content Include="BackEnd\api\ipList.ashx" />
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="Web.Debug.config"> <None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon> <DependentUpon>Web.config</DependentUpon>
@ -17660,6 +17687,7 @@
<None Include="Web.Release.config"> <None Include="Web.Release.config">
<DependentUpon>Web.config</DependentUpon> <DependentUpon>Web.config</DependentUpon>
</None> </None>
<Content Include="webapi\babyData.ashx" />
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>

Binary file not shown.

1
webapi/babyData.ashx Normal file
View File

@ -0,0 +1 @@
<%@ WebHandler Language="C#" CodeBehind="babyData.ashx.cs" Class="abbott_2024_event.webapi.babyData" %>

245
webapi/babyData.ashx.cs Normal file
View File

@ -0,0 +1,245 @@
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;
namespace abbott_2024_event.webapi
{
/// <summary>
/// babyData 的摘要描述
/// </summary>
public class babyDataAshx : IHttpHandler
{
SqlConnection conn = new SqlConnection(globalClass.appsettings("DBConnectionString"));
public void ProcessRequest(HttpContext context)
{
result objRet = new result();
DataContractJsonSerializer json = new DataContractJsonSerializer(objRet.GetType());
context.Response.ContentType = "application/json;charset=utf-8";
string name = (context.Request["name"] == null) ? "" : context.Request["name"].ToString();
string birthday = (context.Request["birthday"] == null) ? "" : context.Request["birthday"].ToString();
string gender = (context.Request["gender"] == null) ? "" : context.Request["gender"].ToString();
string height = (context.Request["height"] == null) ? "" : context.Request["height"].ToString();
string line_uid = (context.Request["line_uid"] == null) ? "" : context.Request["line_uid"].ToString();
string line_displayname = (context.Request["line_displayname"] == null) ? "" : context.Request["line_displayname"].ToString();
string babyData_uid = (context.Request["babyData_uid"] == null) ? "" : context.Request["babyData_uid"].ToString();
string babyRec_key = globalClass.CreateRandomCode(32);
string delSQLDatastring = string.Format("delete babyData where line_uid = '' and babyData_createdate <= '{0}'", DateTime.Now.AddDays(-5).ToString("yyyy/MM/dd 23:59:59"));
string delSQLRecstring = string.Format("delete babyRec where line_uid = '' and babyRec_createdate <= '{0}'", DateTime.Now.AddDays(-5).ToString("yyyy/MM/dd 23:59:59"));
conn.Execute(delSQLDatastring);
conn.Execute(delSQLRecstring);
if (babyData_uid == "" && name == "") {
objRet.ret = "no";
objRet.err_code = "1001";
objRet.message = "請輸入寶貝姓名!";
json.WriteObject(context.Response.OutputStream, objRet);
}
DateTime dateBirthDay;
if (babyData_uid == "") {
try
{
dateBirthDay = DateTime.Parse(birthday + " 23:59:59");
}
catch (Exception ex)
{
objRet.ret = "no";
objRet.err_code = "1002";
objRet.message = "請輸入正確的寶貝生日!" + ex.Message;
json.WriteObject(context.Response.OutputStream, objRet);
}
}
if (babyData_uid == "" && gender != "M" && gender != "F") {
objRet.ret = "no";
objRet.err_code = "1003";
objRet.message = "請輸入正確的寶貝性別!";
json.WriteObject(context.Response.OutputStream, objRet);
}
double dblHeight;
try
{
dblHeight = Double.Parse(height);
}
catch (Exception ex) {
objRet.ret = "no";
objRet.err_code = "1004";
objRet.message = "請輸入寶貝身高!" + ex.Message;
json.WriteObject(context.Response.OutputStream, objRet);
}
if (line_uid != null) {
lineUser lineUser = conn.QueryFirstOrDefault<lineUser>("select * from lineUser where line_uid = @line_uid", new { line_uid = line_uid });
if (lineUser != null)
{
if (line_displayname != lineUser.line_displayName && line_displayname != "")
{
lineUser.line_displayName = line_displayname;
lineUser.lineUser_modifydate = DateTime.Now;
conn.Update<lineUser>(lineUser);
}
List<babyData> babyDatas = conn.Query<babyData>("select * from babyData where line_uid = @line_uid", new { line_uid = line_uid }).ToList();
if (babyDatas.Count > 0) {
objRet.more_data = "Y";
}
}
else {
lineUser = new lineUser();
if (line_displayname == null) {
objRet.ret = "no";
objRet.err_code = "1005";
objRet.message = "請輸入Line Display Name!";
json.WriteObject(context.Response.OutputStream, objRet);
}
lineUser.lineUser_uid = globalClass.CreateRandomCode(32);
lineUser.line_uid = line_uid;
lineUser.line_displayName = line_displayname;
conn.Insert<lineUser>(lineUser);
}
}
babyData newBaby;
if (babyData_uid == "")
{
babyData_uid = globalClass.CreateRandomCode(32);
newBaby = new babyData();
newBaby.babyData_uid = babyData_uid;
newBaby.babyData_birthday = DateTime.Parse(birthday + " 23:59:59");
newBaby.babyData_name = name;
newBaby.babyData_sexual = gender;
if (line_uid != "")
{
newBaby.line_uid = line_uid;
newBaby.babyData_bindedLine = "Y";
newBaby.babyData_bindeddate = DateTime.Now;
}
conn.Insert<babyData>(newBaby);
}
else {
newBaby = conn.QueryFirstOrDefault<babyData>("select * from babyData where babyData_uid = @babyData_uid", new { babyData_uid = babyData_uid });
if (newBaby == null) {
objRet.ret = "no";
objRet.err_code = "1008";
objRet.message = "無此babyData_uid的寶貝資料!";
json.WriteObject(context.Response.OutputStream, objRet);
}
babyData_uid = newBaby.babyData_uid;
}
babyRec newRec = new babyRec();
newRec.babyData_uid = babyData_uid;
newRec.line_uid = line_uid;
newRec.babyRec_key = babyRec_key;
newRec.babyRec_recdate = DateTime.Now;
newRec.babyRec_uid = "r_" + globalClass.CreateRandomCode(32);
newRec.babyRec_recYear = newRec.babyRec_recdate.Year;
newRec.babyRec_recMonth = newRec.babyRec_recdate.Month;
newRec.babyRec_recDay = newRec.babyRec_recdate.Day;
newRec.babyRec_height = double.Parse(height);
newRec.babyRec_months = globalClass.MonthDiff(newBaby.babyData_birthday, newRec.babyRec_recdate);
newRec.babyRec_yearMonthStr = globalClass.YearMonthDiff(newBaby.babyData_birthday, newRec.babyRec_recdate);
if (newRec.babyRec_months > 120) {
objRet.ret = "no";
objRet.err_code = "1006";
objRet.message = "寶貝年齡超過10歲已過紀錄範圍!";
json.WriteObject(context.Response.OutputStream, objRet);
}
if (line_uid != "") {
}
lenHeiTable objLenHei = conn.QueryFirstOrDefault("select * from lenHeiTable where lenHeiTable_sexual = @gender and lenHeiTable_month = @month and lenHeiTable_minVal < @height1 and lenHeiTable_maxVal >= @height2 ", new { gender = gender, month = newRec.babyRec_months, height1 = height, height2 = height});
lenHeiTable objMidHei = conn.QueryFirstOrDefault("select * from lenHeiTable where lenHeiTable_sexual = @gender and lenHeiTable_month = @month and lenHeiTable_percent = 50", new { gender = gender, month=newRec.babyRec_months });
if (objLenHei == null) {
objRet.ret = "no";
objRet.err_code = "1007";
objRet.message = "無符合此身高年齡條件的數據!";
json.WriteObject(context.Response.OutputStream, objRet);
}
newRec.babyRec_inpercent = objLenHei.lenHeiTable_percent;
newRec.babyRec_middleHeight = objMidHei.lenHeiTable_maxVal;
conn.Insert<babyRec>(newRec);
objRet.temp_key = babyRec_key;
objRet.baby_data.baby_birthday = birthday;
objRet.baby_data.baby_height = newRec.babyRec_height;
objRet.baby_data.baby_age = newRec.babyRec_yearMonthStr;
objRet.baby_data.average_height = newRec.babyRec_middleHeight;
objRet.ret = "yes";
json.WriteObject(context.Response.OutputStream, objRet);
}
public class result
{
public string ret = "no";
public string err_code = "0000";
public string message = "";
public string temp_key = "";
public string more_data = "N";
public baby baby_data = new baby();
}
public class baby
{
public string baby_birthday { get; set; } = "";
public string baby_age { get; set; } = "";
public double baby_height { get; set; } = 0.0;
public double average_height { get; set; } = 0.0;
}
public bool IsReusable
{
get
{
return false;
}
}
}
}