updates new redirect

master
嘉祥 詹 2025-03-29 00:28:02 +08:00
parent 21cc733766
commit 3f7fe64880
12 changed files with 248 additions and 5 deletions

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

@ -26453,11 +26453,13 @@
<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" />
@ -26551,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>
@ -26566,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,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) {

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;
}
}
}
}