migrate to new git

This commit is contained in:
2025-08-29 01:27:25 +08:00
parent 946eb9961e
commit af2c152ef6
8623 changed files with 1000453 additions and 1 deletions

View File

@@ -0,0 +1,210 @@
# appapi/appfollower (信眾管理)
```C#
[RoutePrefix("api/appfollower")]
public class appFollowerController : ApiController
```
## Get()
### 介面
``` C#
public IEnumerable<Model.follower> Get()
```
取得所有信眾資料列表
### 傳回
``` C#
IEnumerable<Model.follower>
```
### 介面
``` C#
public IEnumerable<Model.follower> Get
(int page, int pageSize = 10,
string sortBy="", bool sortDesc=false)
```
取得指定分頁信眾資料列表
### 傳回
``` C#
IEnumerable<Model.follower>
```
### 介面
``` C#
// GET appapi/<controller>/5
public Model.follower Get(int id)
```
依ID取得指定單筆信眾
### 傳回
``` C#
Model.follower
```
## Post()
### 介面
``` C#
// POST appapi/<controller>
public void Post([FromBody] Model.follower item)
```
新增信眾
### 傳回
``` C#
```
## Put()
### 介面
``` C#
// PUT appapi/<controller>/5
public void Put(int id, [FromBody] Model.follower item)
```
修改信眾
### 傳回
``` C#
```
## Delete()
### 介面
``` C#
// DELETE appapi/<controller>/5
public void Delete(int id)
```
刪除指定ID信眾
### 傳回
``` C#
```
## [HttpDelete] api/appfollower/Delete/{nums}
### 介面
``` C#
[HttpDelete]
[Route("api/appfollower/Delete/{nums}")]
public void Delete(string nums)
```
刪除指定信眾編號信眾
### 傳回
``` C#
```
## [HttpGet] api/appfollower/count
### 介面
``` C#
[HttpGet]
[Route("api/appfollower/count")]
public int Count()
```
傳回筆數
### 傳回
``` C#
int
```
## [HttpPost] api/appfollower/GetList
### 介面
``` C#
[HttpPost]
[Route("api/appfollower/GetList")]
public IHttpActionResult GetList(
[FromBody] Model.ViewModel.follower q,
int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false)
```
對信眾資料:分頁查詢, 排序, 傳回列表
### 傳回
``` C#
{
list = IEnumerable<Model.follower>, //分頁列表
count = int //筆數
}
```
<!--
## [HttpPost] api/appfollower/GetFamilyList
### 介面
``` C#
[HttpPost]
[Route("api/appfollower/GetFamilyList")]
public IHttpActionResult GetFamilyList([FromBody] Model.ViewModel.follower q,
qry = qry.OrderByDescending(o => o.num);
MyWeb.encrypt encrypt = new MyWeb.encrypt();
var tdesc = publicFun.enum_desc<Model.follower.type>();
```
取得指定信眾的家人資訊
### 傳回
``` C#
IEnumerable<Model.follower>
```
## [HttpPost] api/appfollower/familySave
### 介面
``` C#
[HttpPost]
[Route("api/appfollower/familySave")]
public IHttpActionResult SaveDetailData([FromBody] Model.ViewModel.follower item)
```
取得指定信眾的家人資訊
### 傳回
``` C#
```
## [HttpPost] api/appfollower/familyDelete
### 介面
``` C#
[HttpPost]
[Route("api/appfollower/familyDelete")]
public IHttpActionResult familyDelete([FromBody] Model.ViewModel.follower item)
```
移陁指定信眾的家人資訊
### 傳回
``` C#
```
-->
## [HttpPost] api/appfollower/GetTabletList
### 介面
``` C#
[HttpPost]
[Route("api/appfollower/GetTabletList")]
public IHttpActionResult GetTabletList([FromBody] Model.follower q,
int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false)
```
取得牌位資訊
### 傳回
``` C#
List of: new
{
id = i++,
num = x.num,
f_num = x.f_num,
type = x.type, //型式
title = x.title, //標題
})
```
## [HttpPost] api/appfollower/tabletSave
### 介面
``` C#
[HttpPost]
[Route("api/appfollower/tabletSave")]
public IHttpActionResult tabletSave([FromBody] Model.ViewModel.followers_tablet item)
```
儲存牌位資訊
### 傳回
``` C#
int //牌位編號
```
## [HttpDelete] api/appfollower/tabletDelete/{id}
### 介面
``` C#
[HttpDelete]
[Route("api/appfollower/tabletDelete/{id}")]
public void tabletDelete(int id)
```
刪除牌位資訊
### 傳回
``` C#
```

View File

@@ -0,0 +1,366 @@
# appapi/apporder (報名管理)
### 介面
``` C#
public class apporderController : ApiController
```
## Get()
### 介面
```
// GET appapi/<controller>
public IEnumerable<Model.pro_order> Get()
```
取得全部報名資料列表
### 傳回
``` C#
IEnumerable<Model.pro_order>
```
### 介面
``` C#
public IEnumerable<Model.pro_order> Get(int page, int pageSize = 10,
string sortBy="", bool sortDesc=false)
```
取得指定分頁報名資料列表
### 傳回
``` C#
IEnumerable<Model.pro_order>
```
### 介面
``` C#
// GET appapi/<controller>/5
public Model.pro_order Get(string id)
```
取得指定ID(報名編號)分頁報名
### 傳回
``` C#
Model.pro_order
```
## Post()
### 介面
``` C#
// POST appapi/<controller>
public void Post([FromBody] Model.pro_order item)
```
新增報名資料
### 傳回
``` C#
void
```
## Put()
### 介面
``` C#
// PUT appapi/<controller>/5
public void Put(int id, [FromBody] Model.pro_order item)
```
修改報名資料
### 傳回
``` C#
```
## Delete()
### 介面
``` C#
// DELETE appapi/<controller>/5
public void Delete(string id)
```
刪除指定ID(報名編號)報名資料(主檔)
### 傳回
``` C#
```
## [HttpDelete] api/apporder/DeleteItem/{id}
### 介面
``` C#
[HttpDelete]
[Route("api/apporder/DeleteItem/{id}")]
public void DeleteDetail(int id) //刪除訂單明細
```
刪除指定ID(報名編號)報名資料(明細)
### 傳回
``` C#
```
## [HttpDelete] api/apporder/DeleteAll/{nums}
### 介面
``` C#
[HttpDelete]
[Route("api/apporder/DeleteAll/{nums}")]
public void DeleteAll(string nums)
```
刪除指定ID(報名編號)報名資料(整筆)
### 傳回
``` C#
```
## [HttpGet] api/apporder/count
### 介面
``` C#
[HttpGet]
[Route("api/apporder/count")]
public int Count()
```
傳回筆數
### 傳回
``` C#
int
```
## [HttpPost] api/apporder/GetList
### 介面
``` C#
[HttpPost]
[Route("api/apporder/GetList")]
public IHttpActionResult GetList([FromBody] Model.ViewModel.pro_order q,
int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false)
```
對報名資料:分頁查詢, 排序, 傳回列表
### 傳回
``` C#
{
list = IEnumerable<Model.pro_order>, //分頁列表
count = int //筆數
}
```
## [HttpPost] api/apporder/GetItemList
### 介面
``` C#
[HttpPost]
[Route("api/apporder/GetItemList")]
public IHttpActionResult GetItemList(
[FromBody] Model.ViewModel.pro_order_detail q,
int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false)
```
取得報名明細
### 傳回
``` C#
new{
list = List of pro_order_detail
count = int
}
```
## [HttpPost] api/apporder/SaveDetailData
### 介面
``` C#
[HttpPost]
[Route("api/apporder/SaveDetailData")]
public IHttpActionResult SaveDetailData([FromBody] Model.pro_order_detail item)
```
儲存報名明細
### 傳回
``` C#
new
{
num = order.num,
customize_data = order.customize_data,
}
```
## [HttpPost] api/apporder/GetUnpayList
### 介面
``` C#
[HttpPost]
[Route("api/apporder/GetUnpayList")]
public IHttpActionResult GetUnpayList([FromBody] Model.ViewModel.follower q,
string order_no , int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false)
```
傳回未付款的訂單列表
### 傳回
``` C#
new
{
list = List of new
{
id ,
order_no ,
up_time ,
reg_time ,
f_num ,
u_name ,
totalPrice , //訂單金額
payPrice = , //已收金額
}),
count = orderDt.Count(),
}
```
## [HttpPost] api/apporder/GetUnpayDetail
### 介面
``` C#
[HttpPost]
[Route("api/apporder/GetUnpayDetail")]
public IHttpActionResult GetUnpayDetail([FromBody] Model.ViewModel.pro_order q,
int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false)
```
傳回未付款的訂單明細
### 傳回
``` C#
new {
list = List of new {
id,
order_no,
actItem_num,
actItem_numTxt,
f_num,
u_name,
price, //訂單金額
pay, //已收金額
},
count = unpayDt.Count(),
}
```
##
### 介面
``` C#
[HttpGet]
[Route("api/apporder/printFileLog/{num}/{detail}")]
public IHttpActionResult printFileLog(int num , int detail)
```
更新已列印記錄
### 傳回
``` C#
order.printed_files //已列印記錄
```
## [HttpPost] api/apporder/printMultiFileLog
### 介面
``` C#
[HttpPost]
[Route("api/apporder/printMultiFileLog")]
public IHttpActionResult printMultiFileLog([FromBody] List<int> list,
int item, int file)
```
更新多筆列印記錄
### 傳回
``` C#
```
## [HttpGet] api/apporder/copyDetailData/{num}/{qty}
### 介面
``` C#
[HttpGet]
[Route("api/apporder/copyDetailData/{num}/{qty}")]
public IHttpActionResult copyDetailData(int num, int qty)
```
複製指定的報名項目
### 傳回
``` C#
```
## [HttpPost] api/apporder/GetPastOrderList
### 介面
``` C#
[HttpPost]
[Route("api/apporder/GetPastOrderList")]
public IHttpActionResult GetPastOrderList([FromBody] Model.pro_order q,
int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false)
```
複製以往報名
### 傳回
``` C#
new
{
list = List of new
{
id,
num,
order_no,
up_time,
activity_selected = new
{
text,
val,
},
actitem_num_selected = new
{
text,
val,
},
}),
count = qry.Count(),
}
```
<!--
-->
## [HttpPost] api/apporder/copyMultiPastItem
### 介面
``` C#
[HttpPost]
[Route("api/apporder/copyMultiPastItem")]
public IHttpActionResult copyMultiPastItem([FromBody] List<int> list,
string order_no)
```
複製以往報名(勾選多筆)
### 傳回
``` C#
```
## [HttpPost] api/apporder/GetPayOrderList
### 介面
``` C#
[HttpPost]
[Route("api/apporder/GetPayOrderList")]
public IHttpActionResult GetPayOrderList([FromBody] Model.pro_order_record q,
int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false)
```
收款註記
### 傳回
``` C#
new
{
list = List of new
{
id ,
num ,
order_no ,
pay_date ,
payment_selected = new
{
text,
val ,
},
price,
organization,
bank_code,
}),
count,
}
```
## [HttpDelete] api/apporder/DeleteRecordDetail/{id}")]
刪除收款註記
### 介面
``` C#
[HttpDelete]
[Route("api/apporder/DeleteRecordDetail/{id}")]//刪除收款註記
public void DeleteRecordDetail(int id)
```
### 傳回
``` C#
```
## [HttpPost] api/apporder/SaveRecordDetail
### 介面
``` C#
[HttpPost]
[Route("api/apporder/SaveRecordDetail")]
public IHttpActionResult SaveRecordDetail([FromBody] Model.pro_order_record item)
```
儲存收款紀錄
### 傳回
``` C#
```

Binary file not shown.

View File

@@ -0,0 +1,4 @@
# 17168 API DOOC
* [信眾API](./appFollowerController.html)
* [報名API](./apporderController.html.html)

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,125 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Web;
using System.Web.Security;
/// <summary>
/// 加密相關
/// </summary>
///
namespace MyWeb
{
public class encrypt
{
public string MD5(string str, int bits = 32) //MD5加密
{
if (bits == 16)
{
return FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").ToLower().Substring(8, 16);
}
else
{
return FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").ToLower();
}
}
public string SHA1(string SourceStr) //SHA1加密
{
return FormsAuthentication.HashPasswordForStoringInConfigFile(SourceStr, "SHA1");
}
private byte[] Keys = { 0xEF, 0xAB, 0x56, 0x78, 0x90, 0x34, 0xCD, 0x12 };
public string EncryptDes(string SourceStr, string skey) //使用標準DES對稱加密, skey請帶入8位數自訂KEY
{
try
{
byte[] rgbKey = Encoding.UTF8.GetBytes(skey.Substring(0, 8));
byte[] rgbIV = Keys;
byte[] inputByteArray = Encoding.UTF8.GetBytes(SourceStr);
DESCryptoServiceProvider dCSP = new DESCryptoServiceProvider();
MemoryStream mStream = new MemoryStream();
CryptoStream cStream = new CryptoStream(mStream, dCSP.CreateEncryptor(rgbKey, rgbIV), CryptoStreamMode.Write);
cStream.Write(inputByteArray, 0, inputByteArray.Length);
cStream.FlushFinalBlock();
string str = Convert.ToBase64String(mStream.ToArray());
return str;
}
catch
{
return SourceStr;
}
}
public string DecryptDes(string SourceStr, string skey) //使用標準DES對稱解密, skey請帶入8位數自訂KEY
{
try
{
byte[] rgbKey = Encoding.UTF8.GetBytes(skey.Substring(0, 8));
byte[] rgbIV = Keys;
byte[] inputByteArray = Convert.FromBase64String(SourceStr);
DESCryptoServiceProvider DCSP = new DESCryptoServiceProvider();
MemoryStream mStream = new MemoryStream();
CryptoStream cStream = new CryptoStream(mStream, DCSP.CreateDecryptor(rgbKey, rgbIV), CryptoStreamMode.Write);
cStream.Write(inputByteArray, 0, inputByteArray.Length);
cStream.FlushFinalBlock();
return Encoding.UTF8.GetString(mStream.ToArray());
}
catch
{
return SourceStr;
}
}
public string EncryptAutoKey(string str)
{
function f = new function();
if (!f.isStrNull(str))
{
string key = f.randKey(8);
string encode = EncryptDes(str, key);
str = f.randKey(3) + f.Left(key, 5) + f.Left(encode, encode.Length - 2) + f.Right(key, 3) + f.Right(encode, 2);
return str;
}
return "";
}
public string DecryptAutoKey(string str)
{
try
{
function f = new function();
if (!string.IsNullOrEmpty(str))
{
string str2 = str?.Substring(3, (str ?? "").Length - 3);
string key = f.Left(str2, 5) + f.Left(f.Right(str2, 5), 3);
str2 = str2.Substring(5, str2.Length - 10) + f.Right(str2, 2);
return DecryptDes(str2, key);
}
}
catch (Exception ex)
{
}
return str;
}
public string SHA256(string str)
{
using (SHA256 hash = SHA256Managed.Create())
{
return string.Concat(hash
.ComputeHash(Encoding.UTF8.GetBytes(str))
.Select(item => item.ToString("x2")));
}
}
}
}

View File

@@ -0,0 +1,587 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Web;
using System.Web.UI;
using System.Text;
using System.Text.RegularExpressions;
using System.Net;
using System.Reflection;
using System.ComponentModel;
using System.Web.UI.WebControls;
namespace MyWeb
{
public class function : System.Web.UI.Page
{
public function()
{
//
// TODO: 在這裡新增建構函式邏輯
//
}
public string randCode(int count)
{
//產生驗證碼
Random rnd = new Random(Guid.NewGuid().GetHashCode());
string[] code = {
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"m",
"n",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z"
};
string rnd_code = null;
//產生10碼
for (int i = 1; i <= count; i++)
{
rnd_code += "" + code[rnd.Next(0, code.Length - 1)];
}
return rnd_code;
}
public string randKey(int count)
{
//產生驗證碼
Random rnd = new Random(Guid.NewGuid().GetHashCode());
string[] code = {
"0","1","2","3","4","5","6","7","8","9",
"a","b","c","d","e","f","g","h","i", "j","k","l","m", "n", "o","p","q","r","s","t","u","v","w","x","y","z",
"A","B","B","D","E","F","G","H","I", "J","K","L","M", "N", "O","P","Q","R","S","T","U","V","W","X","Y","Z",
"+","/"
};
string rnd_code = null;
//產生10碼
for (int i = 1; i <= count; i++)
{
rnd_code += "" + code[rnd.Next(0, code.Length - 1)];
}
return rnd_code;
}
public bool IsNumeric(object Expression)
{
bool isNum;
double retNum;
isNum = Double.TryParse(Convert.ToString(Expression), System.Globalization.NumberStyles.Any, System.Globalization.NumberFormatInfo.InvariantInfo, out retNum);
return isNum;
}
public bool isDate(object chkString)
{
DateTime dt;
return DateTime.TryParse(Convert.ToString(chkString), out dt);
}
public DateTime ValDate(object Expression)
{
DateTime _DateTime = Convert.ToDateTime(Expression);
return _DateTime;
}
public int Val(object Expression)
{
int _Int = 0;
if (IsNumeric(Expression))
{
_Int = Convert.ToInt32(Expression.ToString().Replace(",", ""));
}
return _Int;
}
public float ValFloat(object Expression)
{
float _Int = 0;
if (!isStrNull(Expression))
{
_Int = Convert.ToSingle(ValString(Expression).Replace(",", ""));
}
return _Int;
}
public string ValMoney(object Expression, int DecimalLength = 2) //千分位預設最多到小數點第2位
{
string format = "N0";
string[] m = ValString(Expression).Replace(",", "").Split('.');
if (ValString(Expression).IndexOf(".") > -1)
{
int ML = (m[m.Length - 1].Length > DecimalLength ? DecimalLength : m[m.Length - 1].Length);
if (!isStrNull(m[m.Length - 1])) { format = "N" + ML.ToString(); }
}
return ValFloat(Expression).ToString(format);
}
public string ValString(object Expression)
{
string _String = "";
_String = Convert.ToString(Expression);
return _String;
}
public string ValMoneyCh(object Expression)
{
string price = Expression.ToString().Split('.')[0]; //去除小數點
string i = price.Replace(",", ""); //去除千分位
string[] numc_arr = ("零,壹,貳,參,肆,伍,陸,柒,捌,玖").Split(',');
string[] unic_arr = (",拾,佰,仟").Split(',');
string[] unic1_arr = ("元整,萬,億,兆,京").Split(',');
int c0 = 0;
List<string> str = new List<string>();
do
{
int aa = 0;
int c1 = 0;
string s = "";
//取最右邊四位數跑迴圈,不足四位就全取
int lan = (i.Length >= 4 ? 4 : i.Length);
int j = Convert.ToInt32(i.Substring(i.Length - lan, lan));
while (j > 0)
{
int k = j % 10; //餘數
if (k > 0) { aa = 1; s = numc_arr[k] + unic_arr[c1] + s; }
else if (k == 0 && aa == 1) { s = "0" + s; }
j = j / 10; //商
c1++;
}
//轉成中文後丟入陣列,全部為零不加單位
str.Add((s == "" ? "" : s + unic1_arr[c0]));
//計算剩餘字串長度
int count_len = i.Length - 4;
i = (count_len > 0 ? i.Substring(0, count_len) : "");
c0++;
} while (!string.IsNullOrEmpty(i));
string chstring = "";
while (str.Count > 0) { chstring += str[str.Count - 1]; str.Remove(str[str.Count - 1]); }
string pattern = "0+";
string replacement = "零";
Regex rgx = new Regex(pattern);
string result = rgx.Replace(chstring, replacement);
return result;
}
public string Left(object Expression, int Length)
{
string str = "";
str = ValString(Expression);
if (Length > str.Length) { Length = str.Length; }
str = str.Substring(0, Length);
return str;
}
public string Right(object Expression, int Length)
{
string str = "";
str = ValString(Expression);
int startIndex = str.Length - Length;
if (startIndex < 0)
{
startIndex = 0;
Length = str.Length;
}
str = str.Substring(startIndex, Length);
return str;
}
public bool isStrNull(object value)
{
return (value == null || value == DBNull.Value || Convert.ToString(value) == "" ? true : false);
}
//截字
public string cut_str(string str, int limit)
{
return str; //不截字避免顏文字之類的圖在viewstate會出錯
MatchCollection findCount;
string Based = "[\u0080-\uFFFF]";
//中日韓3byte以上的字符
string tmp = null;
int j = 0;
for (int i = 0; i < str.Length; i++)
{
findCount = Regex.Matches(str.Substring(i, 1), Based, RegexOptions.Compiled);
//找str裡面是否有Based指定的字
if (findCount.Count == 0)
{
j += 1;
}
else
{
j += 2;
//一個中文字占兩個
}
if (j <= limit)
{
tmp = tmp + str.Substring(i, 1);
}
else
{
i -= 1;
if (i < str.Length)
{
if (!isStrNull(str.Substring(i, 1).Trim()))
{
//捨棄不完整的英文單字或數字
int n = 0;
for (int t = tmp.Length - 1; t >= 0; t--)
{
n++;
if (Regex.Matches(tmp.Substring(t, 1), Based, RegexOptions.Compiled).Count > 0) //中文字
{
tmp = Left(tmp, tmp.Length - n + 1);
break;
}
else if (isStrNull(tmp.Substring(t, 1).Trim()))
{
tmp = Left(tmp, tmp.Length - n);
break;
}
}
}
tmp = tmp + "...";
}
break;
}
}
return tmp;
}
public enum msgIcon : int
{
none = 0,
success = 1,
error = 2,
warning = 3,
info = 4,
question = 5
}
public void ScriptMsg(string txt, string url="", msgIcon icon= msgIcon.none)
{
ScriptManager.RegisterClientScriptBlock((Page)HttpContext.Current.Handler, typeof(string), "js", "msgbox('" + txt + "','" + (icon != msgIcon.none ? icon.ToString() : "") + "','" + url + "');", true);
}
public void ScriptMsgTop(string txt, msgIcon icon)
{
ScriptManager.RegisterClientScriptBlock((Page)HttpContext.Current.Handler, typeof(string), "js", "msgtop('" + txt + "','" + (icon != msgIcon.none ? icon.ToString() : "") + "');", true);
}
public void ScriptJS(string script)
{
ScriptManager.RegisterClientScriptBlock((Page)HttpContext.Current.Handler, typeof(string), "js", script, true);
}
public void ScriptMsg2(string txt, string url = "", msgIcon icon = msgIcon.none)
{
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "init", "msgbox('" + txt + "','" + (icon != msgIcon.none ? icon.ToString() : "") + "','" + url + "');", true);
}
public void ScriptMsgTop2(string txt, msgIcon icon)
{
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "init", "msgtop('" + txt + "','" + (icon != msgIcon.none ? icon.ToString() : "") + "');", true);
}
public void ScriptJS2(string script)
{
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "init", script, true);
}
public string br(string str)
{
return str.Replace(Convert.ToString((char)10), "<br>").Replace(Convert.ToString((char)13), "");
}
//日期格式
public string datetype(string dtmp)
{
if (dtmp != null)
{
System.DateTime d = ValDate(dtmp);
return d.ToString("yyyy-MM-dd");
}
else
{
return null;
}
}
public string datetype(string dtmp, string format)
{
if (dtmp != null)
{
System.DateTime d = ValDate(dtmp);
return d.ToString(format);
}
else
{
return null;
}
}
string allowReqAtt = System.Configuration.ConfigurationManager.AppSettings["allowReqAtt"].ToString();
public bool AllowReq(string name)
{
if (!isStrNull(allowReqAtt))
{
string[] qns = allowReqAtt.Split(',');
foreach (string qn in qns)
if (qn.ToLower() == name.ToLower())
return true;
return false;
}
return true;
}
//傳回GET值並拿掉不要的回傳格式為?xxxx=xxxx&yyyy=yyyy
public string rtnQueryString(string noUseQuery)
{
string new_query = "";
if (HttpContext.Current.Request.Url.AbsoluteUri.Split('?').Length == 2)
{
string[] query = HttpContext.Current.Request.Url.AbsoluteUri.Split('?')[1].Split('&');
for (int i = 0; i < query.Length; i++)
{
string[] qs = query[i].Split('=');
if (qs.Length == 2 && qs[0].ToLower() != noUseQuery.ToLower())
{
if (AllowReq(qs[0]))
new_query += (new_query == "" ? "?" : "&") + qs[0] + "=" + Server.UrlEncode(Server.UrlDecode(qs[1]));
}
}
}
return new_query;
}
public string rtnQueryString(Array noUseQuery)
{
string new_query = "";
if (HttpContext.Current.Request.Url.AbsoluteUri.Split('?').Length == 2)
{
string[] query = HttpContext.Current.Request.Url.AbsoluteUri.Split('?')[1].Split('&');
for (int i = 0; i < query.Length; i++)
{
string[] qs = query[i].Split('=');
if (qs.Length == 2)
{
bool setAdd = true;
foreach (string nq in noUseQuery)
{
if (qs[0].ToLower() == nq.ToLower())
{
setAdd = false;
break;
}
}
if (setAdd)
{
if (AllowReq(qs[0]))
new_query += (new_query == "" ? "?" : "&") + qs[0] + "=" + Server.UrlEncode(Server.UrlDecode(qs[1]));
}
}
}
}
return new_query;
}
public string UrlHost()
{
string url = (IsHttps() ? "https://" : "http://")
//+ HttpContext.Current.Request.Url.Host
+ Request.ServerVariables["HTTP_HOST"]
+ VirtualPathUtility.ToAbsolute("~/");
return url;
}
public string UrlAddr()
{
string url = (IsHttps() ? "https://" : "http://") + HttpContext.Current.Request.Url.Host + HttpContext.Current.Request.Url.AbsolutePath;
return url;
}
public static bool IsHttps()
{
return HttpContext.Current.Request.IsSecureConnection;
}
#region
public string GetEnumsDescription(Enum value)
{
FieldInfo fi = value.GetType().GetField(value.ToString());
DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
return attributes.Length > 0 ? attributes[0].Description : value.ToString();
}
public void InitEnumsOptions<T>(Control obj)
{
foreach (object value in Enum.GetValues(typeof(T)))
if (obj is DropDownList)
((DropDownList)obj).Items.Add(new ListItem(GetEnumsDescription((Enum)value), ((int)value).ToString()));
else if (obj is RadioButtonList)
((RadioButtonList)obj).Items.Add(new ListItem(GetEnumsDescription((Enum)value), ((int)value).ToString()));
else if (obj is CheckBoxList)
((CheckBoxList)obj).Items.Add(new ListItem(GetEnumsDescription((Enum)value), ((int)value).ToString()));
}
#endregion
public class WreqInfo
{
public string log = "";
public string data = "";
}
public enum Method { POST, GET, PUT, DELETE }
public WreqInfo WRequest(string URL, Method method, string POSTdata, string Referer = "", string UserAgent = "")
{
WreqInfo responseData = new WreqInfo();
try
{
HttpWebRequest hwrequest = (HttpWebRequest)WebRequest.Create(URL);
hwrequest.Accept = "*/*";
hwrequest.AllowAutoRedirect = true;
hwrequest.Timeout = 5000;
hwrequest.Method = method.ToString();
if (!isStrNull(UserAgent))
hwrequest.UserAgent = UserAgent;
else
hwrequest.UserAgent = "http_requester/0.1";
if (!isStrNull(Referer))
hwrequest.Referer = Referer;
if (URL.ToLower().IndexOf("https://") > -1)
{
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
hwrequest.ClientCertificates.Add(new System.Security.Cryptography.X509Certificates.X509Certificate());
}
if (hwrequest.Method == "POST")
{
hwrequest.ContentType = "application/x-www-form-urlencoded";
//ASCIIEncoding encoding = new ASCIIEncoding();
UTF8Encoding encoding = new UTF8Encoding();
byte[] postByteArray = encoding.GetBytes(POSTdata);
hwrequest.ContentLength = postByteArray.Length;
Stream postStream = hwrequest.GetRequestStream();
postStream.Write(postByteArray, 0, postByteArray.Length);
postStream.Close();
}
HttpWebResponse hwresponse = (HttpWebResponse)hwrequest.GetResponse();
if (hwresponse.StatusCode == HttpStatusCode.OK)
{
StreamReader responseStream = new StreamReader(hwresponse.GetResponseStream());
responseData.data = responseStream.ReadToEnd();
}
hwresponse.Close();
}
catch (Exception ex)
{
responseData.log = ex.Message;
}
return responseData;
}
#region
public static class ChineseConverter
{
internal const int LOCALE_SYSTEM_DEFAULT = 0x0800;
internal const int LCMAP_SIMPLIFIED_CHINESE = 0x02000000;
internal const int LCMAP_TRADITIONAL_CHINESE = 0x04000000;
[System.Runtime.InteropServices.DllImport("kernel32", CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)]
internal static extern int LCMapString(int Locale, int dwMapFlags, string lpSrcStr, int cchSrc, [System.Runtime.InteropServices.Out] string lpDestStr, int cchDest);
public static string ToSimplified(string pSource)
{
String tTarget = new String(' ', pSource.Length);
int tReturn = LCMapString(LOCALE_SYSTEM_DEFAULT, LCMAP_SIMPLIFIED_CHINESE, pSource, pSource.Length, tTarget, pSource.Length);
return tTarget;
}
public static string ToTraditional(string pSource)
{
String tTarget = new String(' ', pSource.Length);
int tReturn = LCMapString(LOCALE_SYSTEM_DEFAULT, LCMAP_TRADITIONAL_CHINESE, pSource, pSource.Length, tTarget, pSource.Length);
return tTarget;
}
}
#endregion
#region
public string ReadFileContent(string path)
{
string text = "";
try
{
if (path.IndexOf("~/") > -1) { path = Server.MapPath(path); }
Stream stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read);
StreamReader objReader = new StreamReader(stream);
text = objReader.ReadToEnd();
objReader.Close();
objReader.Dispose();
stream.Close();
stream.Dispose();
}
catch (Exception)
{
//throw;
}
return text;
}
#endregion
}
}

View File

@@ -0,0 +1,44 @@
~\17168erp\App_Code\encrypt.cs // 加密程式
~\17168erp\App_Code\function.cs // 輔助功能
// 有加密的欄位
phone 聯絡電話
id_code 身份證號
passport 護照號碼
cellphone 手機號碼
contactor_phone 緊急連絡人電話
// Page_Load
// ** 解密 DecryptAutoKey **
if (!isStrNull(prod.phone))
{
MyWeb.encrypt encrypt = new MyWeb.encrypt();
contactor_phone.Text = encrypt.DecryptAutoKey(prod.phone.ToString());
}
// edit_Click
// ** 加密 EncryptAutoKey **
encrypt.EncryptAutoKey(textBox.Text.Trim())
// 使用參考
foreach (Control obj in cardBodyPanel.Controls)
{
if (obj is TextBox)
{
var ObjValue = followers.GetType().GetProperty(obj.ID);
var textBox = (TextBox)obj;
if (!isStrNull(textBox.Text))
{
if (textBox.TextMode == TextBoxMode.Date)
ObjValue.SetValue(followers, selectDate(textBox));
else if (!isStrNull(((TextBox)obj).Attributes["data-encrypt"])
&& ValString(textBox.Attributes["data-encrypt"]).Equals("Y"))
ObjValue.SetValue(followers, encrypt.EncryptAutoKey(textBox.Text.Trim()));
else
ObjValue.SetValue(followers, ((TextBox)obj).Text.Trim());
}
else
ObjValue.SetValue(followers, null);
}
}