diff --git a/App_Code/dbClass.cs b/App_Code/dbClass.cs index f4f3612..e0e1b0c 100644 --- a/App_Code/dbClass.cs +++ b/App_Code/dbClass.cs @@ -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 { diff --git a/BackEnd/api/clearAllData.ashx b/BackEnd/api/clearAllData.ashx new file mode 100644 index 0000000..7e9ba3e --- /dev/null +++ b/BackEnd/api/clearAllData.ashx @@ -0,0 +1 @@ +<%@ WebHandler Language="C#" CodeBehind="clearAllData.ashx.cs" Class="abbott_2024_event.BackEnd.api.clearAllData" %> diff --git a/BackEnd/api/clearAllData.ashx.cs b/BackEnd/api/clearAllData.ashx.cs new file mode 100644 index 0000000..57ce2cc --- /dev/null +++ b/BackEnd/api/clearAllData.ashx.cs @@ -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 +{ + /// + /// clearAllData 的摘要描述 + /// + 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 = ""; + } + } +} \ No newline at end of file diff --git a/BackEnd/api/exportExcel.ashx.cs b/BackEnd/api/exportExcel.ashx.cs index c61b769..a90322c 100644 --- a/BackEnd/api/exportExcel.ashx.cs +++ b/BackEnd/api/exportExcel.ashx.cs @@ -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 babyDataRecViews = conn.Query("select * from babyDataRecView " + filiterString + " order by babyRec_recdate desc ").ToList(); + List babyDataRecViews = conn.Query("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); diff --git a/BackEnd/ip-management.aspx b/BackEnd/ip-management.aspx index 5d4e57f..d30e712 100644 --- a/BackEnd/ip-management.aspx +++ b/BackEnd/ip-management.aspx @@ -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 @@
+
+
+ +
+
+
+ +
+
+
+ +
diff --git a/BackEnd/ip-management.aspx.cs b/BackEnd/ip-management.aspx.cs index c448ab6..853b8d4 100644 --- a/BackEnd/ip-management.aspx.cs +++ b/BackEnd/ip-management.aspx.cs @@ -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; + } } } } \ No newline at end of file diff --git a/BackEnd/ip-management.aspx.designer.cs b/BackEnd/ip-management.aspx.designer.cs index 32f2387..92d5481 100644 --- a/BackEnd/ip-management.aspx.designer.cs +++ b/BackEnd/ip-management.aspx.designer.cs @@ -13,5 +13,32 @@ namespace abbott_2024_event.BackEnd public partial class ip_management { + + /// + /// clearAll 控制項。 + /// + /// + /// 自動產生的欄位。 + /// 若要修改,請將欄位宣告從設計工具檔案移到程式碼後置檔案。 + /// + protected global::System.Web.UI.HtmlControls.HtmlButton clearAll; + + /// + /// clearData 控制項。 + /// + /// + /// 自動產生的欄位。 + /// 若要修改,請將欄位宣告從設計工具檔案移到程式碼後置檔案。 + /// + protected global::System.Web.UI.HtmlControls.HtmlButton clearData; + + /// + /// clearRec 控制項。 + /// + /// + /// 自動產生的欄位。 + /// 若要修改,請將欄位宣告從設計工具檔案移到程式碼後置檔案。 + /// + protected global::System.Web.UI.HtmlControls.HtmlButton clearRec; } } diff --git a/abbott_2024_event.csproj b/abbott_2024_event.csproj index 480ad94..360897c 100644 --- a/abbott_2024_event.csproj +++ b/abbott_2024_event.csproj @@ -26451,6 +26451,7 @@ + @@ -26469,6 +26470,9 @@ chgPassword.ashx + + clearAllData.ashx + exportBabyRec.ashx diff --git a/bin/abbott_2024_event.dll b/bin/abbott_2024_event.dll index d66b286..7187a02 100644 Binary files a/bin/abbott_2024_event.dll and b/bin/abbott_2024_event.dll differ diff --git a/bin/app.publish/BackEnd/api/clearAllData.ashx b/bin/app.publish/BackEnd/api/clearAllData.ashx new file mode 100644 index 0000000..7e9ba3e --- /dev/null +++ b/bin/app.publish/BackEnd/api/clearAllData.ashx @@ -0,0 +1 @@ +<%@ WebHandler Language="C#" CodeBehind="clearAllData.ashx.cs" Class="abbott_2024_event.BackEnd.api.clearAllData" %> diff --git a/bin/app.publish/BackEnd/ip-management.aspx b/bin/app.publish/BackEnd/ip-management.aspx index 5d4e57f..d30e712 100644 --- a/bin/app.publish/BackEnd/ip-management.aspx +++ b/bin/app.publish/BackEnd/ip-management.aspx @@ -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 @@
+
+
+ +
+
+
+ +
+
+
+ +
diff --git a/bin/app.publish/bin/abbott_2024_event.dll b/bin/app.publish/bin/abbott_2024_event.dll index b95b1f7..7187a02 100644 Binary files a/bin/app.publish/bin/abbott_2024_event.dll and b/bin/app.publish/bin/abbott_2024_event.dll differ diff --git a/webapi/babyData.ashx.cs b/webapi/babyData.ashx.cs index b46a5c2..476aae9 100644 --- a/webapi/babyData.ashx.cs +++ b/webapi/babyData.ashx.cs @@ -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("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("select * from babyRec where babyData_uid = @babyData_uid order by babyRec_createdate desc", new { babyData_uid = babyData_uid }); if(lastestBabyRec != null) {