diff --git a/BackEnd/api/exportBabyRec.ashx.cs b/BackEnd/api/exportBabyRec.ashx.cs
index 96e84f3..0650719 100644
--- a/BackEnd/api/exportBabyRec.ashx.cs
+++ b/BackEnd/api/exportBabyRec.ashx.cs
@@ -125,9 +125,12 @@ namespace abbott_2024_event.BackEnd.api
string inpercent = "";
+ // Replace the switch statement with an if-else block since babyRec_inpercent is a double and cannot be used in a switch statement.
+
+
- switch (rec.babyRec_inpercent)
+ switch ((int)rec.babyRec_inpercent)
{
case 3:
{
diff --git a/BackEnd/api/exportExcel.ashx.cs b/BackEnd/api/exportExcel.ashx.cs
index a90322c..068cf6f 100644
--- a/BackEnd/api/exportExcel.ashx.cs
+++ b/BackEnd/api/exportExcel.ashx.cs
@@ -123,7 +123,7 @@ namespace abbott_2024_event.BackEnd.api
string inpercent = "";
- switch (view.babyRec_inpercent)
+ switch ((int)view.babyRec_inpercent)
{
case 3:
{
diff --git a/BackEnd/api/importTestBaby.ashx b/BackEnd/api/importTestBaby.ashx
new file mode 100644
index 0000000..d15a454
--- /dev/null
+++ b/BackEnd/api/importTestBaby.ashx
@@ -0,0 +1 @@
+<%@ WebHandler Language="C#" CodeBehind="importTestBaby.ashx.cs" Class="abbott_2024_event.BackEnd.api.importTestBaby" %>
diff --git a/BackEnd/api/importTestBaby.ashx.cs b/BackEnd/api/importTestBaby.ashx.cs
new file mode 100644
index 0000000..6c52342
--- /dev/null
+++ b/BackEnd/api/importTestBaby.ashx.cs
@@ -0,0 +1,192 @@
+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 System.Web.UI.HtmlControls;
+using Dapper;
+using Dapper.Contrib.Extensions;
+
+namespace abbott_2024_event.BackEnd.api
+{
+
+
+ ///
+ /// importTestBaby 的摘要描述
+ ///
+ public class importTestBaby : IHttpHandler
+ {
+ SqlConnection conn = new SqlConnection(globalClass.appsettings("DBConnectionString"));
+ public void ProcessRequest(HttpContext context)
+ {
+ context.Response.ContentType = "text/plain";
+ context.Response.Write("Hello World");
+
+ string line_uid = "U648c5f8a6eb8bcc39291136c8f522106";
+ string baby_uid = "";
+ string baby_name = "十年女寶寶";
+ string babyData_sexual = "F";
+ string babyData_birthday = "2025/4/11";
+
+ if (baby_uid == "") {
+ baby_uid = globalClass.CreateRandomCode(10);
+ }
+
+ babyData tmpBaby = new babyData();
+ tmpBaby.babyData_uid = baby_uid;
+ tmpBaby.babyData_name = baby_name;
+ tmpBaby.babyData_sexual = babyData_sexual;
+ tmpBaby.babyData_birthday = Convert.ToDateTime(babyData_birthday);
+ tmpBaby.babyData_createdate = DateTime.Now;
+ tmpBaby.babyData_bindedLine = "Y";
+ tmpBaby.babyData_bindeddate = DateTime.Now;
+ tmpBaby.babyData_lastTestDate = DateTime.Now;
+ tmpBaby.line_uid = line_uid;
+
+ DateTime tmpDate = Convert.ToDateTime(babyData_birthday);
+ DateTime endDate = tmpDate.AddYears(10);
+
+ lenHeiTable minLenHei = conn.QueryFirstOrDefault("select * from lenHeiTable where lenHeiTable_percent = 3 and lenHeiTable_month = @lenHeiTable_month and lenHeiTable_sexual = @lenHeiTable_sexual", new { lenHeiTable_month = 0, lenHeiTable_sexual = babyData_sexual });
+
+ double minHeight = 42.5;
+ double maxHeight = 0.0;
+
+ while (tmpDate <= endDate)
+ {
+ int intmonth = globalClass.MonthDiff(tmpBaby.babyData_birthday, tmpDate);
+
+ int thisMonth = tmpDate.Month;
+ int thisYear = tmpDate.Year;
+ int nextMonth = tmpDate.AddDays(1).Month;
+ int nextYear = tmpDate.AddDays(1).Year;
+
+ string lastMonth = "N";
+ string lastYear = "N";
+ string newsest = "N";
+
+ if (thisMonth != nextMonth)
+ {
+ lastMonth = "Y";
+ }
+
+ if (thisYear != nextYear) {
+ lastYear = "Y";
+ }
+
+ if (tmpDate.ToString("yyyy/MM/dd") == endDate.ToString("yyyy/MM/dd"))
+ {
+ lastMonth = "Y";
+ lastYear = "Y";
+ newsest = "Y";
+ }
+
+ lenHeiTable maxLenHei = conn.QueryFirstOrDefault("select * from lenHeiTable where lenHeiTable_percent = 85 and lenHeiTable_month = @lenHeiTable_month and lenHeiTable_sexual = @lenHeiTable_sexual", new { lenHeiTable_month = intmonth, lenHeiTable_sexual = babyData_sexual });
+
+ maxHeight = maxLenHei.lenHeiTable_maxVal;
+
+
+
+ int intMin = (int)(minHeight * 10);
+ int intMax = (int)(maxHeight * 10);
+
+ if (intmonth <= 12) {
+ if (intMax - intMin > 3)
+ {
+ intMax = intMin + 3;
+ }
+ }
+
+ if (intmonth > 12 && intmonth <= 36)
+ {
+ if (intMax - intMin > 3)
+ {
+ intMax = intMin + 3;
+ }
+ }
+
+ if (intmonth > 36 && intmonth <= 72)
+ {
+ if (intMax - intMin > 4)
+ {
+ intMax = intMin + 4;
+ }
+ }
+
+ if (intmonth > 72 && intmonth <= 90)
+ {
+ if (intMax - intMin > 3)
+ {
+ intMax = intMin + 3;
+ }
+ }
+
+ if (intmonth > 90 )
+ {
+ if (intMax - intMin > 5)
+ {
+ intMax = intMin + 5;
+ }
+ }
+
+ Random rnd = new Random();
+
+ if (intMax < intMin) {
+ intMax = intMin + 1;
+ }
+
+ int getHei = rnd.Next(intMin, intMax);
+
+ double getHeight = (double)getHei / 10;
+
+ minHeight = getHeight;
+
+ babyRec objRec = new babyRec();
+
+ objRec.babyData_uid = baby_uid;
+ objRec.line_uid = line_uid;
+ objRec.babyRec_uid = globalClass.CreateRandomCode(16);
+ objRec.babyRec_key = globalClass.CreateRandomCode(16);
+ objRec.babyRec_recdate = tmpDate;
+ objRec.babyRec_recYear = tmpDate.Year;
+ objRec.babyRec_recMonth = tmpDate.Month;
+ objRec.babyRec_recDay = tmpDate.Day;
+ objRec.babyRec_height = getHeight;
+ objRec.babyRec_dayLastRec = "Y";
+ objRec.babyRec_monthLastRec = lastMonth;
+ objRec.babyRec_yearLastRec = lastYear;
+ objRec.babyRec_months = intmonth;
+ objRec.babyRec_yearMonthStr = globalClass.YearMonthDiff(tmpBaby.babyData_birthday, objRec.babyRec_recdate);
+ objRec.babyRec_yearMonthStr = globalClass.YearMonthDiff(tmpBaby.babyData_birthday, objRec.babyRec_recdate);
+ objRec.utm_source = "test";
+ objRec.utm_medium = "test";
+ objRec.utm_campaign = "test";
+ objRec.utm_term = "test";
+ objRec.utm_content = "test";
+
+ 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 = tmpBaby.babyData_sexual, month = objRec.babyRec_months, height1 = getHeight, height2 = getHeight });
+ lenHeiTable objMidHei = conn.QueryFirstOrDefault("select * from lenHeiTable where lenHeiTable_sexual = @gender and lenHeiTable_month = @month and lenHeiTable_percent = 50", new { gender = tmpBaby.babyData_sexual, month = objRec.babyRec_months });
+
+ objRec.babyRec_inpercent = objLenHei.lenHeiTable_percent;
+ objRec.babyRec_middleHeight = objMidHei.lenHeiTable_maxVal;
+ objRec.babyRec_newestRec = newsest;
+
+ conn.Insert(objRec);
+
+ tmpDate = tmpDate.AddDays(1);
+
+ }
+
+ conn.Insert(tmpBaby);
+ }
+
+ public bool IsReusable
+ {
+ get
+ {
+ return false;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Web.config b/Web.config
index ac9253a..f7eb363 100644
--- a/Web.config
+++ b/Web.config
@@ -80,7 +80,7 @@
-
+
+
+
+
+
+
-
\ No newline at end of file
diff --git a/abbott_2024_event.csproj b/abbott_2024_event.csproj
index 32f399a..fc06f1c 100644
--- a/abbott_2024_event.csproj
+++ b/abbott_2024_event.csproj
@@ -33,6 +33,7 @@
prompt
4
true
+ 6
true
@@ -42,6 +43,7 @@
TRACE
prompt
4
+ 6
@@ -26453,6 +26455,7 @@
+
@@ -26461,6 +26464,7 @@
+
@@ -26485,6 +26489,9 @@
exportExcel.ashx
+
+ importTestBaby.ashx
+
importTestData.ashx
@@ -26573,6 +26580,9 @@
babyList.ashx
+
+ babyRecList.ashx
+
bindBabyData.ashx
diff --git a/bin/abbott_2024_event.dll b/bin/abbott_2024_event.dll
index 4807824..7ea1d3b 100644
Binary files a/bin/abbott_2024_event.dll and b/bin/abbott_2024_event.dll differ
diff --git a/bin/abbott_2024_event.dll.config b/bin/abbott_2024_event.dll.config
index ac9253a..f7eb363 100644
--- a/bin/abbott_2024_event.dll.config
+++ b/bin/abbott_2024_event.dll.config
@@ -80,7 +80,7 @@
-
+
+
+
+
+
+
-
\ No newline at end of file
diff --git a/bin/app.publish/BackEnd/api/importTestBaby.ashx b/bin/app.publish/BackEnd/api/importTestBaby.ashx
new file mode 100644
index 0000000..d15a454
--- /dev/null
+++ b/bin/app.publish/BackEnd/api/importTestBaby.ashx
@@ -0,0 +1 @@
+<%@ WebHandler Language="C#" CodeBehind="importTestBaby.ashx.cs" Class="abbott_2024_event.BackEnd.api.importTestBaby" %>
diff --git a/bin/app.publish/Web.config b/bin/app.publish/Web.config
index 581df8e..34ba0fe 100644
--- a/bin/app.publish/Web.config
+++ b/bin/app.publish/Web.config
@@ -79,24 +79,24 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
- -->
+
\ No newline at end of file
diff --git a/bin/app.publish/bin/abbott_2024_event.dll b/bin/app.publish/bin/abbott_2024_event.dll
index 4807824..7ea1d3b 100644
Binary files a/bin/app.publish/bin/abbott_2024_event.dll and b/bin/app.publish/bin/abbott_2024_event.dll differ
diff --git a/bin/app.publish/webapi/babyRecList.ashx b/bin/app.publish/webapi/babyRecList.ashx
new file mode 100644
index 0000000..4f69882
--- /dev/null
+++ b/bin/app.publish/webapi/babyRecList.ashx
@@ -0,0 +1 @@
+<%@ WebHandler Language="C#" CodeBehind="babyRecList.ashx.cs" Class="abbott_2024_event.webapi.babyRecList" %>
diff --git a/webapi/babyRecList.ashx b/webapi/babyRecList.ashx
new file mode 100644
index 0000000..4f69882
--- /dev/null
+++ b/webapi/babyRecList.ashx
@@ -0,0 +1 @@
+<%@ WebHandler Language="C#" CodeBehind="babyRecList.ashx.cs" Class="abbott_2024_event.webapi.babyRecList" %>
diff --git a/webapi/babyRecList.ashx.cs b/webapi/babyRecList.ashx.cs
new file mode 100644
index 0000000..65b3a65
--- /dev/null
+++ b/webapi/babyRecList.ashx.cs
@@ -0,0 +1,132 @@
+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
+{
+ ///
+ /// babyRecList 的摘要描述
+ ///
+ public class babyRecList : 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";
+ context.Response.AddHeader("Access-Control-Allow-Origin", "*");
+
+ string line_uid = (context.Request["line_uid"] == null) ? "" : context.Request["line_uid"].ToString();
+ string babyData_uid = (context.Request["babyData_uid"] == null) ? "" : context.Request["babyData_uid"].ToString();
+ string start = (context.Request["start"] == null) ? "" : context.Request["start"].ToString();
+ string end = (context.Request["end"] == null) ? "" : context.Request["end"].ToString();
+ string type = (context.Request["type"] == null) ? "day" : context.Request["type"].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 = "2002";
+ objRet.message = "無此line_uid的資料!";
+ json.WriteObject(context.Response.OutputStream, objRet);
+ return;
+ }
+
+ babyData babyData = conn.QueryFirstOrDefault("select * from babyData where line_uid = @line_uid and babyData_uid = @babyData_uid", new { line_uid = line_uid, babyData_uid = babyData_uid });
+
+ if (babyData == null)
+ {
+ objRet.ret = "no";
+ objRet.err_code = "3004";
+ objRet.message = "沒有此babyData資料!";
+ json.WriteObject(context.Response.OutputStream, objRet);
+ return;
+ }
+ DateTime startDate = DateTime.Now;
+ DateTime endDate = DateTime.Now;
+
+ try
+ {
+ startDate = DateTime.Parse(start + "/1");
+ endDate = DateTime.Parse(end + "/1");
+ endDate = endDate.AddMonths(1).AddDays(-1);
+ }
+ catch (Exception ex) {
+ objRet.ret = "no";
+ objRet.err_code = "4004";
+ objRet.message = "start 或 end資料格式錯誤,請使用 2025/3 此種格式代表2025年3月,不需要日期! " + ex.Message;
+ json.WriteObject(context.Response.OutputStream, objRet);
+ return;
+ }
+
+ if (type != "day" && type != "month") {
+ objRet.ret = "no";
+ objRet.err_code = "4005";
+ objRet.message = "type資料錯誤,只能為day或month";
+ json.WriteObject(context.Response.OutputStream, objRet);
+ return;
+ }
+
+ string sqlString = "";
+ List babyRecs = new List();
+ if (type == "day") {
+ babyRecs = conn.Query("select * from babyRec where babyRec_dayLastRec = 'Y' and line_uid = @line_uid and babyData_uid = @babyData_uid and babyRec_recdate >= @rec_start and babyRec_recdate <= @rec_end ", new { line_uid = line_uid, babyData_uid = babyData_uid, rec_start = startDate.ToString("yyyy/MM/dd"), rec_end = endDate.ToString("yyyy/MM/dd") }).ToList();
+ }
+
+ if (type == "month")
+ {
+ babyRecs = conn.Query("select * from babyRec where babyRec_dayLastRec = 'Y' and babyRec_monthLastRec = 'Y' and line_uid = @line_uid and babyData_uid = @babyData_uid and babyRec_recdate >= @rec_start and babyRec_recdate <= @rec_end ", new { line_uid = line_uid, babyData_uid = babyData_uid, rec_start = startDate.ToString("yyyy/MM/dd"), rec_end = endDate.ToString("yyyy/MM/dd") }).ToList();
+ }
+
+ foreach (babyRec rec in babyRecs)
+ {
+ height_data height_Data = new height_data();
+ height_Data.babyRec_height = rec.babyRec_height;
+ height_Data.babyRec_months = rec.babyRec_months;
+ height_Data.babyRec_yearMonthStr = rec.babyRec_yearMonthStr;
+ height_Data.babyRec_middleHeight = rec.babyRec_middleHeight;
+ height_Data.babyRec_inpercent = rec.babyRec_inpercent;
+ height_Data.babyRec_testdate = rec.babyRec_recdate.ToString("yyyy/MM/dd");
+
+ objRet.datas.Add(height_Data);
+ }
+
+ 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 List datas = new List();
+ }
+
+ public class height_data
+ {
+ public double babyRec_height = 0;
+ public double babyRec_middleHeight = 0;
+ public string babyRec_yearMonthStr = "";
+ public int babyRec_months = 0;
+ public double babyRec_inpercent = 0;
+ public string babyRec_testdate = "";
+ }
+
+ public bool IsReusable
+ {
+ get
+ {
+ return false;
+ }
+ }
+ }
+}
\ No newline at end of file