diff --git a/App_Code/dbClass.cs b/App_Code/dbClass.cs
index 9d6489a..565de9f 100644
--- a/App_Code/dbClass.cs
+++ b/App_Code/dbClass.cs
@@ -25,6 +25,7 @@ public class babyRec
public int babyRec_recDay { get; set; } = 0;
public int babyRec_months { get; set; } = 0;
+ public string babyRec_monthLastRec { get; set; } = "N";
public string babyRec_yearMonthStr { get; set; } = "";
public DateTime babyRec_createdate { get; set; } = DateTime.Now;
}
diff --git a/abbott_2024_event.csproj b/abbott_2024_event.csproj
index ae1503c..80d9282 100644
--- a/abbott_2024_event.csproj
+++ b/abbott_2024_event.csproj
@@ -13213,9 +13213,15 @@
babyData.ashx
+
+ babyHistory.ashx
+
babyList.ashx
+
+ bindBabyData.ashx
+
lineLogin.ashx
@@ -17696,6 +17702,8 @@
+
+
10.0
diff --git a/webapi/babyData.ashx.cs b/webapi/babyData.ashx.cs
index b3a3e22..5d666f1 100644
--- a/webapi/babyData.ashx.cs
+++ b/webapi/babyData.ashx.cs
@@ -48,6 +48,7 @@ namespace abbott_2024_event.webapi
objRet.message = "請輸入寶貝姓名!";
json.WriteObject(context.Response.OutputStream, objRet);
+ return;
}
DateTime dateBirthDay;
@@ -64,6 +65,7 @@ namespace abbott_2024_event.webapi
objRet.message = "請輸入正確的寶貝生日!" + ex.Message;
json.WriteObject(context.Response.OutputStream, objRet);
+ return;
}
}
@@ -74,6 +76,7 @@ namespace abbott_2024_event.webapi
objRet.message = "請輸入正確的寶貝性別!";
json.WriteObject(context.Response.OutputStream, objRet);
+ return;
}
double dblHeight;
@@ -88,6 +91,7 @@ namespace abbott_2024_event.webapi
objRet.message = "請輸入寶貝身高!" + ex.Message;
json.WriteObject(context.Response.OutputStream, objRet);
+ return;
}
if (line_uid != null) {
@@ -176,6 +180,7 @@ namespace abbott_2024_event.webapi
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_monthLastRec = "Y";
newRec.babyRec_yearMonthStr = globalClass.YearMonthDiff(newBaby.babyData_birthday, newRec.babyRec_recdate);
if (newRec.babyRec_months > 120) {
@@ -184,11 +189,10 @@ namespace abbott_2024_event.webapi
objRet.message = "寶貝年齡超過10歲,已過紀錄範圍!";
json.WriteObject(context.Response.OutputStream, objRet);
+ return;
}
- 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 });
@@ -199,11 +203,16 @@ namespace abbott_2024_event.webapi
objRet.message = "無符合此身高年齡條件的數據!";
json.WriteObject(context.Response.OutputStream, objRet);
+ return;
}
newRec.babyRec_inpercent = objLenHei.lenHeiTable_percent;
newRec.babyRec_middleHeight = objMidHei.lenHeiTable_maxVal;
+ if (newRec.babyData_uid != "") {
+ conn.Execute("update babyRec set babyRec_monthLastRec = 'N' where babyData_uid = @babyData_uid and babyRec_recYear = @babyRec_recYear and babyRec_recMonth = @babyRec_recMonth", new { babyData_uid = babyData_uid, babyRec_recYear = newRec.babyRec_recYear, babyRec_recMonth = newRec.babyRec_recMonth });
+ }
+
conn.Insert(newRec);
objRet.temp_key = babyRec_key;
@@ -214,6 +223,7 @@ namespace abbott_2024_event.webapi
objRet.ret = "yes";
json.WriteObject(context.Response.OutputStream, objRet);
+
}
public class result
diff --git a/webapi/babyHistory.ashx b/webapi/babyHistory.ashx
new file mode 100644
index 0000000..e4ec999
--- /dev/null
+++ b/webapi/babyHistory.ashx
@@ -0,0 +1 @@
+<%@ WebHandler Language="C#" CodeBehind="babyHistory.ashx.cs" Class="abbott_2024_event.webapi.babyHistory" %>
diff --git a/webapi/babyHistory.ashx.cs b/webapi/babyHistory.ashx.cs
new file mode 100644
index 0000000..0cd67df
--- /dev/null
+++ b/webapi/babyHistory.ashx.cs
@@ -0,0 +1,115 @@
+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
+{
+ ///
+ /// babyHistory 的摘要描述
+ ///
+ public class babyHistory : 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 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();
+
+ 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;
+ }
+
+ int minNum = 0;
+ int maxNum = 120;
+
+ if (start != "") {
+ try
+ {
+ minNum = int.Parse(start) * 12;
+ }
+ catch {
+
+ }
+ }
+
+ if (end != "") {
+ try
+ {
+ maxNum = int.Parse(end) * 12;
+ }
+ catch {
+
+ }
+ }
+
+ List babyRecs = conn.Query("select * from babyRec where line_uid = @line_uid and babyData_uid = @babyData_uid and babyRec_monthLastRec = 'Y' order by babyRec_months", new { line_uid = line_uid, babyData_uid = babyData_uid }).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;
+
+ objRet.datas.Add(height_Data);
+ }
+
+ 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 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 bool IsReusable
+ {
+ get
+ {
+ return false;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/webapi/babyList.ashx.cs b/webapi/babyList.ashx.cs
index 3451fbf..64496d6 100644
--- a/webapi/babyList.ashx.cs
+++ b/webapi/babyList.ashx.cs
@@ -30,6 +30,7 @@ namespace abbott_2024_event.webapi
objRet.err_code = "2001";
objRet.message = "line_uid為空字串!";
json.WriteObject(context.Response.OutputStream, objRet);
+ return;
}
lineUser lineUser = conn.QueryFirstOrDefault("select * from lineUser where line_uid = @line_uid", new { line_uid = line_uid });
@@ -39,6 +40,7 @@ namespace abbott_2024_event.webapi
objRet.err_code = "2002";
objRet.message = "無此line_uid的資料!";
json.WriteObject(context.Response.OutputStream, objRet);
+ return;
}
List babyDatas = conn.Query("select * from babyData where line_uid = @line_uid", new { line_uid = line_uid }).ToList();
diff --git a/webapi/bindBabyData.ashx b/webapi/bindBabyData.ashx
new file mode 100644
index 0000000..690d512
--- /dev/null
+++ b/webapi/bindBabyData.ashx
@@ -0,0 +1 @@
+<%@ WebHandler Language="C#" CodeBehind="bindBabyData.ashx.cs" Class="abbott_2024_event.webapi.bindBabyData" %>
diff --git a/webapi/bindBabyData.ashx.cs b/webapi/bindBabyData.ashx.cs
new file mode 100644
index 0000000..46192d8
--- /dev/null
+++ b/webapi/bindBabyData.ashx.cs
@@ -0,0 +1,135 @@
+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
+{
+ ///
+ /// bindBabyData 的摘要描述
+ ///
+ public class bindBabyData : 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 line_uid = (context.Request["line_uid"] == null) ? "" : context.Request["line_uid"].ToString();
+ string bind_type = (context.Request["bind_type"] == null) ? "" : context.Request["bind_type"].ToString();
+ string babyData_uid = (context.Request["babyData_uid"] == null) ? "" : context.Request["babyData_uid"].ToString();
+ string temp_key = (context.Request["temp_key"] == null) ? "" : context.Request["temp_key"].ToString();
+
+ if (temp_key == "") {
+ objRet.ret = "no";
+ objRet.err_code = "3001";
+ objRet.message = "沒有temp_key!";
+ json.WriteObject(context.Response.OutputStream, objRet);
+ return;
+ }
+
+ if (bind_type != "new" && bind_type != "append") {
+ objRet.ret = "no";
+ objRet.err_code = "3003";
+ objRet.message = "bind_type值錯誤!";
+ json.WriteObject(context.Response.OutputStream, objRet);
+ return;
+ }
+
+ babyRec babyRec = conn.QueryFirstOrDefault("select * from babyRec where babyRec_key = @babyRec_key", new { babyRec_key = temp_key });
+
+ if (babyRec == null) {
+ objRet.ret = "no";
+ objRet.err_code = "3002";
+ objRet.message = "沒有此temp_key資料!";
+ json.WriteObject(context.Response.OutputStream, objRet);
+ return;
+ }
+
+ 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;
+ }
+
+
+
+ //新增寶寶
+ if (bind_type == "new") {
+ babyData_uid = babyRec.babyData_uid;
+ babyData babyData = conn.QueryFirstOrDefault("select * from babyData where babyData_uid = @babyData_uid", new { babyData_uid = babyData_uid });
+
+ if (babyData == null) {
+ objRet.ret = "no";
+ objRet.err_code = "3004";
+ objRet.message = "沒有此babyData資料!";
+ json.WriteObject(context.Response.OutputStream, objRet);
+ return;
+ }
+
+ if (babyData.babyData_bindedLine == "Y") {
+ objRet.ret = "no";
+ objRet.err_code = "3005";
+ objRet.message = "此寶貝資料已經綁定過Line帳號了!";
+ json.WriteObject(context.Response.OutputStream, objRet);
+ return;
+ }
+
+ babyData.line_uid = line_uid;
+ babyData.babyData_bindedLine = "Y";
+ babyData.babyData_bindeddate = DateTime.Now;
+
+ babyRec.babyRec_monthLastRec = "Y";
+ babyRec.line_uid = line_uid;
+
+ conn.Update(babyData);
+ conn.Update(babyRec);
+
+ objRet.ret = "yes";
+ json.WriteObject(context.Response.OutputStream, objRet);
+ return;
+ }
+
+ //綁定寶寶
+ if (bind_type == "append") {
+ babyRec.babyData_uid = babyData_uid;
+ babyRec.babyRec_monthLastRec = "Y";
+
+ conn.Execute("update babyRec set babyRec_monthLastRec = 'N' where babyData_uid = @babyData_uid and babyRec_recYear = @babyRec_recYear and babyRec_recMonth = @babyRec_recMonth", new { babyData_uid = babyData_uid, babyRec_recYear = babyRec.babyRec_recYear, babyRec_recMonth = babyRec.babyRec_recMonth });
+
+ babyRec.line_uid = babyData_uid;
+
+ conn.Update(babyRec);
+ 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 bool IsReusable
+ {
+ get
+ {
+ return false;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/webapi/lineLogin.ashx.cs b/webapi/lineLogin.ashx.cs
index 073c952..1f6e4e3 100644
--- a/webapi/lineLogin.ashx.cs
+++ b/webapi/lineLogin.ashx.cs
@@ -32,14 +32,16 @@ namespace abbott_2024_event.webapi
objRet.err_code = "2001";
objRet.message = "line_uid或line_displayname為空字串!";
json.WriteObject(context.Response.OutputStream, objRet);
+ return;
}
if (line_displayName == "")
{
objRet.ret = "no";
- objRet.err_code = "2001";
- objRet.message = "line_uid或line_displayname為空字串!";
+ objRet.err_code = "1005";
+ objRet.message = "line_displayname為空字串!";
json.WriteObject(context.Response.OutputStream, objRet);
+ return;
}
lineUser lineUser = conn.QueryFirstOrDefault("select * from lineUser where line_uid = @line_uid", new { line_uid = line_uid });
@@ -56,6 +58,7 @@ namespace abbott_2024_event.webapi
objRet.isFirst = "Y";
json.WriteObject(context.Response.OutputStream, objRet);
+ return;
}
if (lineUser != null) {
@@ -78,6 +81,7 @@ namespace abbott_2024_event.webapi
objRet.isFirst = "N";
objRet.ret = "yes";
json.WriteObject(context.Response.OutputStream, objRet);
+ return;
}