master
dk96 2025-03-04 10:59:28 +08:00
parent 4e89791865
commit 65696a340d
7 changed files with 176 additions and 17 deletions

View File

@ -0,0 +1,102 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
/// <summary>
/// autoBindDataTable 的摘要描述
/// </summary>
public class autoBindDataTable
{
private string _strSQL = "";
private SqlConnection _objConn = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString);
private SqlCommand _objCmd;
private SqlDataAdapter _objDataAdapter;
private SqlCommandBuilder _objDataCommandBuilder;
private DataTable _objDataTable = new DataTable();
public autoBindDataTable(string strSQL)
{
//
// TODO: 在這裡新增建構函式邏輯
//
_strSQL = strSQL;
try
{
_objConn.Open();
_objCmd = new SqlCommand(_strSQL, _objConn);
_objDataAdapter = new SqlDataAdapter(_objCmd);
_objDataCommandBuilder = new SqlCommandBuilder(_objDataAdapter);
_objDataAdapter.Fill(_objDataTable);
_objConn.Close();
}
catch (Exception ex)
{
_objConn.Close();
throw new Exception("Bind DataTable 發生錯誤! " + ex.Message);
}
}
public DataRow newRow
{
get
{
DataRow objRow = this._objDataTable.NewRow();
return objRow;
}
}
public void updateDataTable()
{
try
{
_objConn.Open();
_objDataAdapter.Update(_objDataTable);
_objConn.Close();
}
catch (Exception ex)
{
_objConn.Close();
throw new Exception("DataTable 資料庫更新發生錯誤[" + _objDataTable.TableName + "], " + ex.Message);
}
}
public void disConnection()
{
_objConn.Close();
_objConn.Dispose();
}
public DataRowCollection dataRows
{
get { return this._objDataTable.Rows; }
}
public DataRow[] selectedRows(string value)
{
return this._objDataTable.Select(value);
}
public int columnNumber
{
get { return this._objDataTable.Columns.Count; }
}
public string columnName(int columnIndex) {
string colName = "";
try
{
colName = this._objDataTable.Columns[columnIndex].ColumnName;
}
catch {
}
return colName;
}
}

View File

@ -6,6 +6,7 @@ using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using abbott_2024_event;
namespace abbott_2024_event.BackEnd
{
@ -34,9 +35,37 @@ namespace abbott_2024_event.BackEnd
isAllow = true;
}
string myIP_2 = myIP.Substring(0, myIP.LastIndexOf('.')) + ".*";
autoBindDataTable objAllow2 = new autoBindDataTable(string.Format("select * from ipTable where ipTable_address = '{0}'", myIP_2));
if (objAllow2.dataRows.Count > 0)
{
isAllow = true;
}
string myIP_3 = myIP_2.Substring(0, myIP_2.Replace(".*", "").LastIndexOf('.')) + ".*.*";
autoBindDataTable objAllow3 = new autoBindDataTable(string.Format("select * from ipTable where ipTable_address = '{0}'", myIP_3));
if (objAllow3.dataRows.Count > 0)
{
isAllow = true;
}
string myIP_4 = myIP.Substring(0, myIP.IndexOf('.')) + ".*.*.*";
autoBindDataTable objAllow4 = new autoBindDataTable(string.Format("select * from ipTable where ipTable_address = '{0}'", myIP_4));
if (objAllow4.dataRows.Count > 0)
{
isAllow = true;
}
if (isAllow == false)
{
Response.Redirect("auth-error-v3.html");
Response.Redirect("auth-error-v3.html?ip=" + myIP);
return;
}
}

View File

@ -37,6 +37,33 @@ namespace abbott_2024_event.BackEnd
isAllow = true;
}
string myIP_2 = myIP.Substring(0, myIP.LastIndexOf('.')) + ".*";
autoBindDataTable objAllow2 = new autoBindDataTable(string.Format("select * from ipTable where ipTable_address = '{0}'", myIP_2));
if (objAllow2.dataRows.Count > 0)
{
isAllow = true;
}
string myIP_3 = myIP_2.Substring(0, myIP_2.Replace(".*", "").LastIndexOf('.')) + ".*.*";
autoBindDataTable objAllow3 = new autoBindDataTable(string.Format("select * from ipTable where ipTable_address = '{0}'", myIP_3));
if (objAllow3.dataRows.Count > 0)
{
isAllow = true;
}
string myIP_4 = myIP.Substring(0, myIP.IndexOf('.')) + ".*.*.*";
autoBindDataTable objAllow4 = new autoBindDataTable(string.Format("select * from ipTable where ipTable_address = '{0}'", myIP_4));
if (objAllow4.dataRows.Count > 0)
{
isAllow = true;
}
if (isAllow == false)
{
Response.Redirect("auth-error-v3.html");

View File

@ -26491,6 +26491,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="App_Code\authToken.cs" />
<Compile Include="App_Code\autoBindDataTable.cs" />
<Compile Include="App_Code\globalClass.cs" />
<Compile Include="App_Code\dbClass.cs" />
<Compile Include="BackEnd\api\babyRecList.ashx.cs">

Binary file not shown.

View File

@ -36,23 +36,23 @@ namespace abbott_2024_event.webapi
return;
}
if (line_displayName == "")
{
objRet.ret = "no";
objRet.err_code = "2002";
objRet.message = "line_displayname為空字串!";
json.WriteObject(context.Response.OutputStream, objRet);
return;
}
//if (line_displayName == "")
//{
// objRet.ret = "no";
// objRet.err_code = "2002";
// objRet.message = "line_displayname為空字串!";
// json.WriteObject(context.Response.OutputStream, objRet);
// return;
//}
if (line_phone == "")
{
objRet.ret = "no";
objRet.err_code = "2003";
objRet.message = "line_phone為空字串!";
json.WriteObject(context.Response.OutputStream, objRet);
return;
}
//if (line_phone == "")
//{
// objRet.ret = "no";
// objRet.err_code = "2003";
// objRet.message = "line_phone為空字串!";
// json.WriteObject(context.Response.OutputStream, objRet);
// return;
//}
lineUser lineUser = conn.QueryFirstOrDefault<lineUser>("select * from lineUser where line_uid = @line_uid", new { line_uid = line_uid });