Compare commits

...

2 Commits

Author SHA1 Message Date
嘉祥 詹 3f7fe64880 updates new redirect 2025-03-29 00:28:02 +08:00
嘉祥 詹 21cc733766 updates 2025-03-28 15:58:18 +08:00
21 changed files with 718 additions and 17 deletions

View File

@ -6,6 +6,55 @@ using System.Collections.Generic;
using System.Linq;
using System.Web;
[Table("babyDataRecView")]
public class babyDataRecView2
{
[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 string line_phone { get; set; } = "";
public DateTime lineUser_createdate { get; set; } = DateTime.Now;
public DateTime lineUser_modifydate { get; set; } = DateTime.Now;
public string babyData_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;
public DateTime babyData_lastTestDate { get; set; } = DateTime.Now;
public string babyRec_uid { get; set; } = "";
public string babyRec_key { 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_monthLastRec { get; set; } = "N";
public string babyRec_newestRec { get; set; } = "N";
public string babyRec_yearMonthStr { get; set; } = "";
public string utm_source { get; set; } = "";
public string utm_medium { get; set; } = "";
public string utm_campaign { get; set; } = "";
public string utm_term { get; set; } = "";
public string utm_content { get; set; } = "";
public string rec_source { get; set; } = "";
public string rec_medium { get; set; } = "";
public string rec_campaign { get; set; } = "";
public string rec_term { get; set; } = "";
public string rec_content { get; set; } = "";
}
[Table("babyDataRecView")]
public class babyDataRecView
{

View File

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

View File

@ -0,0 +1,137 @@
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;
using System.IO.Compression;
namespace abbott_2024_event.BackEnd.api
{
/// <summary>
/// clearAllData 的摘要描述
/// </summary>
public class clearAllData : IHttpHandler
{
SqlConnection conn = new SqlConnection(globalClass.appsettings("DBConnectionString"));
public authToken authToken;
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();
if (!objAuth.user_isLogin)
{
objRet.ret = "no";
objRet.err_code = "0001";
objRet.message = "尚未登入,請登入後使用";
json.WriteObject(context.Response.OutputStream, objRet);
return;
}
string type = (context.Request["type"] == null) ? "" : context.Request["type"].ToString();
string myIP = globalClass.GetIPAddress();
if (myIP == "::1")
{
myIP = "127.0.0.1";
}
Boolean isAllow = false;
if (myIP == "127.0.0.1")
{
isAllow = true;
}
string myIP_2 = myIP.Substring(0, myIP.LastIndexOf('.'));
if (myIP_2 == "60.251.161")
{
isAllow = true;
}
//isAllow = false;
if (isAllow == false) {
objRet.ret = "no";
objRet.err_code = "0002";
objRet.message = "IP錯誤無法操作!";
json.WriteObject(context.Response.OutputStream, objRet);
return;
}
if (type == "") {
objRet.ret = "no";
objRet.err_code = "0003";
objRet.message = "無type!";
json.WriteObject(context.Response.OutputStream, objRet);
return;
}
if (type == "all")
{
conn.Execute("delete from babyRec where babyRec_createdate <= '2025/3/31 23:59:59' ");
conn.Execute("delete from babyData where babyData_createdate <= '2025/3/31 23:59:59' ");
conn.Execute("delete from lineUser where lineUser_createdate <= '2025/3/31 23:59:59' ");
}
if (type == "babyRec")
{
conn.Execute("delete from babyRec where babyRec_createdate <= '2025/3/31 23:59:59' ");
}
if (type == "babyData")
{
conn.Execute("delete from babyData where babyData_createdate <= '2025/3/31 23:59:59' ");
conn.Execute("delete from babyRec where babyRec_createdate <= '2025/3/31 23:59:59' ");
}
objRet.ret = "yes";
json.WriteObject(context.Response.OutputStream, objRet);
return;
}
public bool IsReusable
{
get
{
return false;
}
}
public class result
{
public string ret = "no";
public string err_code = "0000";
public string message = "";
}
}
}

View File

@ -69,16 +69,16 @@ namespace abbott_2024_event.BackEnd.api
string filiterString = "";
filiterString += " Where babyData_bindedLine = 'Y' and babyRec_newestRec = 'Y' and babyRec_recdate >= '" + dateStart.ToString("yyyy/MM/dd") + "' and babyRec_recdate <= '" + dateEnd.ToString("yyyy/MM/dd HH:mm:ss") + "' ";
filiterString += " Where A.babyRec_uid = B.babyRec_uid and A.babyData_bindedLine = 'Y' and A.babyRec_newestRec = 'Y' and A.babyRec_recdate >= '" + dateStart.ToString("yyyy/MM/dd") + "' and A.babyRec_recdate <= '" + dateEnd.ToString("yyyy/MM/dd HH:mm:ss") + "' ";
if (gender != "%")
{
filiterString += " and babyData_sexual = '" + gender + "' ";
filiterString += " and A.babyData_sexual = '" + gender + "' ";
}
filiterString += " and babyRec_months >= " + (int.Parse(min_age) * 12).ToString() + " and babyRec_months <= " + (int.Parse(max_age) * 12).ToString();
filiterString += " and A.babyRec_months >= " + (int.Parse(min_age) * 12).ToString() + " and A.babyRec_months <= " + (int.Parse(max_age) * 12).ToString();
List<babyDataRecView> babyDataRecViews = conn.Query<babyDataRecView>("select * from babyDataRecView " + filiterString + " order by babyRec_recdate desc ").ToList();
List<babyDataRecView2> babyDataRecViews = conn.Query<babyDataRecView2>("select A.*, B.utm_source as rec_source, B.utm_medium as rec_medium, B.utm_campaign as rec_campaign, B.utm_content as rec_content, B.utm_term as rec_term from babyDataRecView A, babyRec B " + filiterString + " order by babyRec_recdate desc ").ToList();
HSSFWorkbook workbook = new HSSFWorkbook();
MemoryStream ms = new MemoryStream();
@ -95,15 +95,20 @@ namespace abbott_2024_event.BackEnd.api
headerRow.CreateCell(7).SetCellValue("測驗時年齡");
headerRow.CreateCell(8).SetCellValue("寶寶身高");
headerRow.CreateCell(9).SetCellValue("寶寶成長百分比");
headerRow.CreateCell(10).SetCellValue("utm_source");
headerRow.CreateCell(11).SetCellValue("utm_medium");
headerRow.CreateCell(12).SetCellValue("utm_campaign");
headerRow.CreateCell(13).SetCellValue("utm_content");
headerRow.CreateCell(14).SetCellValue("utm_term");
headerRow.CreateCell(10).SetCellValue("成為會員utm_source");
headerRow.CreateCell(11).SetCellValue("成為會員utm_medium");
headerRow.CreateCell(12).SetCellValue("成為會員utm_campaign");
headerRow.CreateCell(13).SetCellValue("成為會員utm_content");
headerRow.CreateCell(14).SetCellValue("成為會員utm_term");
headerRow.CreateCell(15).SetCellValue("寶寶紀錄utm_source");
headerRow.CreateCell(16).SetCellValue("寶寶紀錄utm_medium");
headerRow.CreateCell(17).SetCellValue("寶寶紀錄utm_campaign");
headerRow.CreateCell(18).SetCellValue("寶寶紀錄utm_content");
headerRow.CreateCell(19).SetCellValue("寶寶紀錄utm_term");
int pageNum = 1;
foreach (babyDataRecView view in babyDataRecViews)
foreach (babyDataRecView2 view in babyDataRecViews)
{
string baby_gender = "";
@ -179,11 +184,16 @@ namespace abbott_2024_event.BackEnd.api
excelRow.CreateCell(12).SetCellValue(view.utm_campaign);
excelRow.CreateCell(13).SetCellValue(view.utm_content);
excelRow.CreateCell(14).SetCellValue(view.utm_term);
excelRow.CreateCell(15).SetCellValue(view.rec_source);
excelRow.CreateCell(16).SetCellValue(view.rec_medium);
excelRow.CreateCell(17).SetCellValue(view.rec_campaign);
excelRow.CreateCell(18).SetCellValue(view.rec_content);
excelRow.CreateCell(19).SetCellValue(view.rec_term);
pageNum++;
}
for (int j = 0; j <= 14; j++)
for (int j = 0; j <= 19; j++)
{
sheet.AutoSizeColumn(j);
sheet.SetColumnWidth(j, sheet.GetColumnWidth(j) * 17 / 10);

View File

@ -29,6 +29,92 @@
});
$("#ctl00_ContentPlaceHolder1_clearAll").click(function () {
if (confirm("確定要刪除2025/3/31(含)以前的所有資料?")) {
if (confim("再次確定要刪除?")) {
var formData = {
type: 'all'
}
$.ajax({
url: "api/clearAllData.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('網路或伺服器發生錯誤或!');
}
});
}
}
});
$("#ctl00_ContentPlaceHolder1_clearData").click(function () {
if (confirm("確定要刪除2025/3/31(含)以前的所有寶寶資料(含紀錄)?")) {
if (confim("再次確定要刪除?")) {
var formData = {
type: 'babyData'
}
$.ajax({
url: "api/clearAllData.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('網路或伺服器發生錯誤或!');
}
});
}
}
});
$("#ctl00_ContentPlaceHolder1_clearRec").click(function () {
if (confirm("確定要刪除2025/3/31(含)以前的寶寶紀錄?")) {
if (confim("再次確定要刪除?")) {
var formData = {
type: 'babyRec'
}
$.ajax({
url: "api/clearAllData.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('網路或伺服器發生錯誤或!');
}
});
}
}
});
$("#saveBtn").click(function () {
var array = $("#ip_list").val().split("\n");
var iplist = JSON.stringify(array);
@ -109,6 +195,18 @@
<div class="form-row">
<button type="button" class="btn btn-primary" id="saveBtn">套用設定</button>
</div>
<br/>
<div class="form-row">
<button type="button" class="btn btn-danger" id="clearAll" runat="server">清除2025/3/31以前的所有會員資料</button>
</div>
<br/>
<div class="form-row">
<button type="button" class="btn btn-danger" id="clearData" runat="server">清除2025/3/31以前的寶寶資料(含紀錄)</button>
</div>
<br/>
<div class="form-row">
<button type="button" class="btn btn-danger" id="clearRec" runat="server">清除2025/3/31以前的寶寶紀錄</button>
</div>
</div>
</section>
</div>

View File

@ -11,7 +11,40 @@ namespace abbott_2024_event.BackEnd
{
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;
}
string myIP_2 = myIP.Substring(0, myIP.LastIndexOf('.'));
if (myIP_2 == "60.251.161")
{
isAllow = true;
}
//isAllow = false;
if (isAllow == true)
{
clearAll.Visible = true;
clearData.Visible = true;
clearRec.Visible = true;
}
else {
clearAll.Visible = false;
clearData.Visible = false;
clearRec.Visible = false;
}
}
}
}

View File

@ -13,5 +13,32 @@ namespace abbott_2024_event.BackEnd
public partial class ip_management
{
/// <summary>
/// clearAll 控制項。
/// </summary>
/// <remarks>
/// 自動產生的欄位。
/// 若要修改,請將欄位宣告從設計工具檔案移到程式碼後置檔案。
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlButton clearAll;
/// <summary>
/// clearData 控制項。
/// </summary>
/// <remarks>
/// 自動產生的欄位。
/// 若要修改,請將欄位宣告從設計工具檔案移到程式碼後置檔案。
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlButton clearData;
/// <summary>
/// clearRec 控制項。
/// </summary>
/// <remarks>
/// 自動產生的欄位。
/// 若要修改,請將欄位宣告從設計工具檔案移到程式碼後置檔案。
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlButton clearRec;
}
}

16
Redirect/Default.aspx Normal file
View File

@ -0,0 +1,16 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="abbott_2024_event.Redirect.Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>

65
Redirect/Default.aspx.cs Normal file
View File

@ -0,0 +1,65 @@
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;
using System.Runtime.Serialization.Json;
using System.Web.SessionState;
using Dapper;
using Dapper.Contrib.Extensions;
namespace abbott_2024_event.Redirect
{
public partial class Default : System.Web.UI.Page
{
SqlConnection conn = new SqlConnection(globalClass.appsettings("DBConnectionString"));
protected void Page_Load(object sender, EventArgs e)
{
string utm_source = (Request["utm_source"] == null) ? "" : Request["utm_source"].ToString();
string utm_medium = (Request["utm_medium"] == null) ? "" : Request["utm_medium"].ToString();
string uid = (Request["uid"] == null) ? "" : Request["uid"].ToString();
string phone = (Request["phone"] == null) ? "" : Request["phone"].ToString();
string username = (Request["username"] == null) ? "" : Request["username"].ToString();
if (utm_source == "") {
Response.Write("無utm_source");
Response.End();
}
string redirectUrl = "";
if (utm_medium == "prod") {
redirectUrl = "https://abbott-2024-event.azurewebsites.net/";
}
if (utm_medium == "dev")
{
redirectUrl = "https://abbott-2024-event.bremennetwork.tw/abbott-2024/";
}
if (redirectUrl == "") {
Response.Write("無此utm_medium資料");
Response.End();
}
string temp_key = utm_source;
babyRec tmpRec = conn.QueryFirstOrDefault<babyRec>("select * from babyRec where babyRec_key = @babyRec_key", new { babyRec_key = temp_key });
if (tmpRec == null) {
Response.Write("無此temp_key資料");
Response.End();
}
redirectUrl += "?uid=" + uid + "&phone=" + phone + "&username=" + username + "&temp_key=" + temp_key +"&utm_source=" + tmpRec.utm_source + "&utm_medium=" + tmpRec.utm_medium + "&utm_campaign=" + tmpRec.utm_campaign + "&utm_content=" + tmpRec.utm_content + "&utm_term=" + tmpRec.utm_term;
Response.Redirect(redirectUrl);
}
}
}

26
Redirect/Default.aspx.designer.cs generated Normal file
View File

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 這段程式碼是由工具產生的。
//
// 變更這個檔案可能會導致不正確的行為,而且如果已重新產生
// 程式碼,變更將會遺失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace abbott_2024_event.Redirect
{
public partial class Default
{
/// <summary>
/// form1 控制項。
/// </summary>
/// <remarks>
/// 自動產生的欄位。
/// 若要修改,請將欄位宣告從設計工具檔案移至程式碼後置檔案。
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
}
}

View File

@ -26451,12 +26451,15 @@
<Content Include="Line\jquery\jquery.min.js" />
<Content Include="Line\jquery\jquery.slim.min.js" />
<Content Include="Line\page1.html" />
<Content Include="BackEnd\api\clearAllData.ashx" />
<None Include="Scripts\jquery-3.7.1.intellisense.js" />
<Content Include="Redirect\Default.aspx" />
<Content Include="Scripts\jquery-3.7.1.js" />
<Content Include="Scripts\jquery-3.7.1.min.js" />
<Content Include="Scripts\jquery-3.7.1.slim.js" />
<Content Include="Scripts\jquery-3.7.1.slim.min.js" />
<Content Include="Web.config" />
<Content Include="webapi\tempKeyQuery.ashx" />
</ItemGroup>
<ItemGroup>
<Compile Include="App_Code\authToken.cs" />
@ -26469,6 +26472,9 @@
<Compile Include="BackEnd\api\chgPassword.ashx.cs">
<DependentUpon>chgPassword.ashx</DependentUpon>
</Compile>
<Compile Include="BackEnd\api\clearAllData.ashx.cs">
<DependentUpon>clearAllData.ashx</DependentUpon>
</Compile>
<Compile Include="BackEnd\api\exportBabyRec.ashx.cs">
<DependentUpon>exportBabyRec.ashx</DependentUpon>
</Compile>
@ -26547,6 +26553,13 @@
<DependentUpon>Default.aspx</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Redirect\Default.aspx.cs">
<DependentUpon>Default.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Redirect\Default.aspx.designer.cs">
<DependentUpon>Default.aspx</DependentUpon>
</Compile>
<Compile Include="webapi\babyData.ashx.cs">
<DependentUpon>babyData.ashx</DependentUpon>
</Compile>
@ -26562,6 +26575,9 @@
<Compile Include="webapi\lineLogin.ashx.cs">
<DependentUpon>lineLogin.ashx</DependentUpon>
</Compile>
<Compile Include="webapi\tempKeyQuery.ashx.cs">
<DependentUpon>tempKeyQuery.ashx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />

Binary file not shown.

View File

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

View File

@ -29,6 +29,92 @@
});
$("#ctl00_ContentPlaceHolder1_clearAll").click(function () {
if (confirm("確定要刪除2025/3/31(含)以前的所有資料?")) {
if (confim("再次確定要刪除?")) {
var formData = {
type: 'all'
}
$.ajax({
url: "api/clearAllData.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('網路或伺服器發生錯誤或!');
}
});
}
}
});
$("#ctl00_ContentPlaceHolder1_clearData").click(function () {
if (confirm("確定要刪除2025/3/31(含)以前的所有寶寶資料(含紀錄)?")) {
if (confim("再次確定要刪除?")) {
var formData = {
type: 'babyData'
}
$.ajax({
url: "api/clearAllData.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('網路或伺服器發生錯誤或!');
}
});
}
}
});
$("#ctl00_ContentPlaceHolder1_clearRec").click(function () {
if (confirm("確定要刪除2025/3/31(含)以前的寶寶紀錄?")) {
if (confim("再次確定要刪除?")) {
var formData = {
type: 'babyRec'
}
$.ajax({
url: "api/clearAllData.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('網路或伺服器發生錯誤或!');
}
});
}
}
});
$("#saveBtn").click(function () {
var array = $("#ip_list").val().split("\n");
var iplist = JSON.stringify(array);
@ -109,6 +195,18 @@
<div class="form-row">
<button type="button" class="btn btn-primary" id="saveBtn">套用設定</button>
</div>
<br/>
<div class="form-row">
<button type="button" class="btn btn-danger" id="clearAll" runat="server">清除2025/3/31以前的所有會員資料</button>
</div>
<br/>
<div class="form-row">
<button type="button" class="btn btn-danger" id="clearData" runat="server">清除2025/3/31以前的寶寶資料(含紀錄)</button>
</div>
<br/>
<div class="form-row">
<button type="button" class="btn btn-danger" id="clearRec" runat="server">清除2025/3/31以前的寶寶紀錄</button>
</div>
</div>
</section>
</div>

View File

@ -0,0 +1,16 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="abbott_2024_event.Redirect.Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>

View File

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

View File

@ -117,14 +117,16 @@ namespace abbott_2024_event.webapi
if (line_displayname != lineUser.line_displayName && line_displayname != "")
{
lineUser.line_displayName = line_displayname;
lineUser.lineUser_modifydate = DateTime.Now;
lineUser.lineUser_modifydate = DateTime.Now.AddMinutes(3);
conn.Update<lineUser>(lineUser);
}
else {
lineUser.lineUser_modifydate = DateTime.Now;
lineUser.lineUser_modifydate = DateTime.Now.AddMinutes(3);
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) {
@ -245,7 +247,7 @@ namespace abbott_2024_event.webapi
conn.Execute("update babyRec set babyRec_newestRec = 'N' where babyData_uid = @babyData_uid", new { babyData_uid = babyData_uid });
babyRec lastestBabyRec = conn.QueryFirstOrDefault<babyRec>("select * from babyRec where babyData_uid = @babyData_uid order by babyRec_months desc, babyRec_sn desc, babyRec_monthLastRec desc", new { babyData_uid = babyData_uid });
babyRec lastestBabyRec = conn.QueryFirstOrDefault<babyRec>("select * from babyRec where babyData_uid = @babyData_uid order by babyRec_createdate desc", new { babyData_uid = babyData_uid });
if(lastestBabyRec != null)
{

View File

@ -98,14 +98,14 @@ namespace abbott_2024_event.webapi
}
if (lineUser != null) {
if (lineUser.line_displayName != line_displayName) {
if (lineUser.line_displayName != line_displayName && line_displayName != "") {
lineUser.line_displayName= line_displayName;
lineUser.lineUser_modifydate = DateTime.Now;
conn.Update<lineUser>(lineUser);
}
if (lineUser.line_phone != line_phone) {
if (lineUser.line_phone != line_phone && line_phone != "") {
lineUser.line_phone= line_phone;
lineUser.lineUser_modifydate = DateTime.Now;

1
webapi/tempKeyQuery.ashx Normal file
View File

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

104
webapi/tempKeyQuery.ashx.cs Normal file
View File

@ -0,0 +1,104 @@
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>
/// tempKeyQuery 的摘要描述
/// </summary>
public class tempKeyQuery : 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 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;
}
babyRec tmpRec = conn.QueryFirstOrDefault<babyRec>("select * from babyRec where babyRec_key = @babyRec_key", new { babyRec_key = temp_key });
if (tmpRec == null)
{
objRet.ret = "no";
objRet.err_code = "3002";
objRet.message = "沒有此temp_key資料!";
json.WriteObject(context.Response.OutputStream, objRet);
return;
}
string babyData_uid = tmpRec.babyData_uid;
babyData tmpData = conn.QueryFirstOrDefault<babyData>("select * from babyData where babyData_uid = @babyData_uid", new { babyData_uid = babyData_uid });
if (tmpData == null)
{
objRet.ret = "no";
objRet.err_code = "3003";
objRet.message = "沒有此babyData資料!";
json.WriteObject(context.Response.OutputStream, objRet);
return;
}
objRet.baby_data.babyData_uid = tmpData.babyData_uid;
objRet.baby_data.baby_name = tmpData.babyData_name;
objRet.baby_data.baby_gender = tmpData.babyData_sexual;
objRet.baby_data.baby_birthday = tmpData.babyData_birthday.ToString("yyyy/MM/dd");
objRet.baby_data.baby_age = tmpRec.babyRec_yearMonthStr;
objRet.baby_data.baby_height = tmpRec.babyRec_height;
objRet.baby_data.average_height = tmpRec.babyRec_middleHeight;
objRet.baby_data.baby_inpercent = tmpRec.babyRec_inpercent;
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 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 string babyData_uid { get; set; } = "";
public string baby_name { get; set; } = "";
public string baby_gender { get; set; } = "";
public double baby_inpercent { get; set; } = 0;
}
public bool IsReusable
{
get
{
return false;
}
}
}
}