updates
parent
0873e20a38
commit
102d095c06
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13213,9 +13213,15 @@
|
|||
<Compile Include="webapi\babyData.ashx.cs">
|
||||
<DependentUpon>babyData.ashx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="webapi\babyHistory.ashx.cs">
|
||||
<DependentUpon>babyHistory.ashx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="webapi\babyList.ashx.cs">
|
||||
<DependentUpon>babyList.ashx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="webapi\bindBabyData.ashx.cs">
|
||||
<DependentUpon>bindBabyData.ashx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="webapi\lineLogin.ashx.cs">
|
||||
<DependentUpon>lineLogin.ashx</DependentUpon>
|
||||
</Compile>
|
||||
|
|
@ -17696,6 +17702,8 @@
|
|||
<Content Include="webapi\babyData.ashx" />
|
||||
<Content Include="webapi\babyList.ashx" />
|
||||
<Content Include="webapi\lineLogin.ashx" />
|
||||
<Content Include="webapi\bindBabyData.ashx" />
|
||||
<Content Include="webapi\babyHistory.ashx" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
|
|
|
|||
|
|
@ -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<babyRec>(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
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
<%@ WebHandler Language="C#" CodeBehind="babyHistory.ashx.cs" Class="abbott_2024_event.webapi.babyHistory" %>
|
||||
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// babyHistory 的摘要描述
|
||||
/// </summary>
|
||||
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<lineUser>("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<babyData>("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<babyRec> babyRecs = conn.Query<babyRec>("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<height_data> datas = new List<height_data>();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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<lineUser>("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<babyData> babyDatas = conn.Query<babyData>("select * from babyData where line_uid = @line_uid", new { line_uid = line_uid }).ToList();
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
<%@ WebHandler Language="C#" CodeBehind="bindBabyData.ashx.cs" Class="abbott_2024_event.webapi.bindBabyData" %>
|
||||
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// bindBabyData 的摘要描述
|
||||
/// </summary>
|
||||
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<lineUser>("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<babyData>("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>(babyData);
|
||||
conn.Update<babyRec>(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>(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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<lineUser>("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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue