master
嘉祥 詹 2025-03-28 15:58:18 +08:00
parent 1776a578d7
commit 21cc733766
13 changed files with 470 additions and 12 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;
}
}

View File

@ -26451,6 +26451,7 @@
<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="Scripts\jquery-3.7.1.js" />
<Content Include="Scripts\jquery-3.7.1.min.js" />
@ -26469,6 +26470,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>

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

@ -245,7 +245,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)
{