updates
parent
1875b96124
commit
e5ae18ad87
|
|
@ -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:
|
||||
{
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ namespace abbott_2024_event.BackEnd.api
|
|||
string inpercent = "";
|
||||
|
||||
|
||||
switch (view.babyRec_inpercent)
|
||||
switch ((int)view.babyRec_inpercent)
|
||||
{
|
||||
case 3:
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
<%@ WebHandler Language="C#" CodeBehind="importTestBaby.ashx.cs" Class="abbott_2024_event.BackEnd.api.importTestBaby" %>
|
||||
|
|
@ -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
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// importTestBaby 的摘要描述
|
||||
/// </summary>
|
||||
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<lenHeiTable>("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<lenHeiTable>("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<lenHeiTable>("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<lenHeiTable>("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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
14
Web.config
14
Web.config
|
|
@ -80,7 +80,7 @@
|
|||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<system.codedom>
|
||||
<!--<system.codedom>
|
||||
<compilers>
|
||||
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4">
|
||||
<providerOption name="CompilerVersion" value="v4.1" />
|
||||
|
|
@ -92,11 +92,11 @@
|
|||
<providerOption name="WarnAsError" value="false" />
|
||||
</compiler>
|
||||
</compilers>
|
||||
</system.codedom>-->
|
||||
<system.codedom>
|
||||
<compilers>
|
||||
<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701;612;618" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008,40000,40008 /define:_MYTYPE=\"Web\" /optionInfer+" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
</compilers>
|
||||
</system.codedom>
|
||||
<!--<system.codedom>
|
||||
<compilers>
|
||||
<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701;612;618" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008,40000,40008 /define:_MYTYPE=\"Web\" /optionInfer+" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
</compilers>
|
||||
</system.codedom>-->
|
||||
</configuration>
|
||||
|
|
@ -33,6 +33,7 @@
|
|||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>6</LangVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
|
@ -42,6 +43,7 @@
|
|||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<LangVersion>6</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="AutoMapper, Version=10.0.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
|
||||
|
|
@ -26453,6 +26455,7 @@
|
|||
<Content Include="Line\page1.html" />
|
||||
<Content Include="BackEnd\api\clearAllData.ashx" />
|
||||
<Content Include="BackEnd\api\clearLineUid.ashx" />
|
||||
<Content Include="BackEnd\api\importTestBaby.ashx" />
|
||||
<None Include="Scripts\jquery-3.7.1.intellisense.js" />
|
||||
<Content Include="Redirect\Default.aspx" />
|
||||
<Content Include="Scripts\jquery-3.7.1.js" />
|
||||
|
|
@ -26461,6 +26464,7 @@
|
|||
<Content Include="Scripts\jquery-3.7.1.slim.min.js" />
|
||||
<Content Include="Web.config" />
|
||||
<Content Include="webapi\tempKeyQuery.ashx" />
|
||||
<Content Include="webapi\babyRecList.ashx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="App_Code\authToken.cs" />
|
||||
|
|
@ -26485,6 +26489,9 @@
|
|||
<Compile Include="BackEnd\api\exportExcel.ashx.cs">
|
||||
<DependentUpon>exportExcel.ashx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BackEnd\api\importTestBaby.ashx.cs">
|
||||
<DependentUpon>importTestBaby.ashx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BackEnd\api\importTestData.ashx.cs">
|
||||
<DependentUpon>importTestData.ashx</DependentUpon>
|
||||
</Compile>
|
||||
|
|
@ -26573,6 +26580,9 @@
|
|||
<Compile Include="webapi\babyList.ashx.cs">
|
||||
<DependentUpon>babyList.ashx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="webapi\babyRecList.ashx.cs">
|
||||
<DependentUpon>babyRecList.ashx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="webapi\bindBabyData.ashx.cs">
|
||||
<DependentUpon>bindBabyData.ashx</DependentUpon>
|
||||
</Compile>
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -80,7 +80,7 @@
|
|||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<system.codedom>
|
||||
<!--<system.codedom>
|
||||
<compilers>
|
||||
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4">
|
||||
<providerOption name="CompilerVersion" value="v4.1" />
|
||||
|
|
@ -92,11 +92,11 @@
|
|||
<providerOption name="WarnAsError" value="false" />
|
||||
</compiler>
|
||||
</compilers>
|
||||
</system.codedom>-->
|
||||
<system.codedom>
|
||||
<compilers>
|
||||
<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701;612;618" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008,40000,40008 /define:_MYTYPE=\"Web\" /optionInfer+" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
</compilers>
|
||||
</system.codedom>
|
||||
<!--<system.codedom>
|
||||
<compilers>
|
||||
<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701;612;618" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008,40000,40008 /define:_MYTYPE=\"Web\" /optionInfer+" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
</compilers>
|
||||
</system.codedom>-->
|
||||
</configuration>
|
||||
|
|
@ -0,0 +1 @@
|
|||
<%@ WebHandler Language="C#" CodeBehind="importTestBaby.ashx.cs" Class="abbott_2024_event.BackEnd.api.importTestBaby" %>
|
||||
|
|
@ -79,24 +79,24 @@
|
|||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<system.codedom>
|
||||
<compilers>
|
||||
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4">
|
||||
<providerOption name="CompilerVersion" value="v4.1" />
|
||||
<providerOption name="WarnAsError" value="false" />
|
||||
</compiler>
|
||||
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4">
|
||||
<providerOption name="CompilerVersion" value="v4.1" />
|
||||
<providerOption name="OptionInfer" value="true" />
|
||||
<providerOption name="WarnAsError" value="false" />
|
||||
</compiler>
|
||||
</compilers>
|
||||
</system.codedom>
|
||||
<!--<system.codedom>
|
||||
<compilers>
|
||||
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4">
|
||||
<providerOption name="CompilerVersion" value="v4.1" />
|
||||
<providerOption name="WarnAsError" value="false" />
|
||||
</compiler>
|
||||
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4">
|
||||
<providerOption name="CompilerVersion" value="v4.1" />
|
||||
<providerOption name="OptionInfer" value="true" />
|
||||
<providerOption name="WarnAsError" value="false" />
|
||||
</compiler>
|
||||
</compilers>
|
||||
</system.codedom>-->
|
||||
<system.codedom>
|
||||
<compilers>
|
||||
<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701;612;618" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008,40000,40008 /define:_MYTYPE=\"Web\" /optionInfer+" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
</compilers>
|
||||
</system.codedom>-->
|
||||
</system.codedom>
|
||||
</configuration>
|
||||
<!--ProjectGuid: E7FB4619-BA57-41A3-9039-21B51787518A-->
|
||||
Binary file not shown.
|
|
@ -0,0 +1 @@
|
|||
<%@ WebHandler Language="C#" CodeBehind="babyRecList.ashx.cs" Class="abbott_2024_event.webapi.babyRecList" %>
|
||||
|
|
@ -0,0 +1 @@
|
|||
<%@ WebHandler Language="C#" CodeBehind="babyRecList.ashx.cs" Class="abbott_2024_event.webapi.babyRecList" %>
|
||||
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// babyRecList 的摘要描述
|
||||
/// </summary>
|
||||
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<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;
|
||||
}
|
||||
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<babyRec> babyRecs = new List<babyRec>();
|
||||
if (type == "day") {
|
||||
babyRecs = conn.Query<babyRec>("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<babyRec>("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<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 double babyRec_inpercent = 0;
|
||||
public string babyRec_testdate = "";
|
||||
}
|
||||
|
||||
public bool IsReusable
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue