chore: 首次簽入 Thinkyu ASP.NET 專案
- 加入 Visual Studio / ASP.NET .gitignore - 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Text;
|
||||
|
||||
namespace 報到系統
|
||||
{
|
||||
public class EncDec
|
||||
{
|
||||
/// <summary>
|
||||
/// WLIB 新版密碼的加密函數
|
||||
/// </summary>
|
||||
/// <param name="S">欲加密之密碼字串,最大長度 8 位,僅可包含A-Z、a-z、0-9</param>
|
||||
/// <returns>加密後之密碼字串</returns>
|
||||
public static string KeyEnc(string S)
|
||||
{
|
||||
int k1 = 0;
|
||||
int k2 = 0;
|
||||
int i, j;
|
||||
Random rnd = new Random(DateTime.UtcNow.AddHours(8).Millisecond);
|
||||
byte[] inBuf = new byte[8];
|
||||
byte[] outBuf = new byte[10];
|
||||
string tmp;
|
||||
|
||||
while (true)
|
||||
{
|
||||
k1 = rnd.Next(31);
|
||||
k2 = rnd.Next(31);
|
||||
outBuf[0] = (byte)(k1 + 44);
|
||||
outBuf[9] = (byte)(k2 + 66);
|
||||
|
||||
if (S.Length < 8)
|
||||
inBuf = Encoding.ASCII.GetBytes(S.PadRight(8));
|
||||
else
|
||||
inBuf = Encoding.ASCII.GetBytes(S);
|
||||
|
||||
for (i = 1; i <= 8; i++)
|
||||
{
|
||||
j = (k1 % 31) + i;
|
||||
j = ((k2 + j) % 31) + 1;
|
||||
|
||||
outBuf[i] = (byte)(inBuf[i - 1] ^ j);
|
||||
}
|
||||
tmp = Encoding.ASCII.GetString(outBuf);
|
||||
if (tmp.IndexOf('\'') < 0 && tmp.IndexOf('"') < 0)
|
||||
break;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// WLIB 新版密碼的解密函數
|
||||
/// </summary>
|
||||
/// <param name="S">欲解密之密碼字串,固定 10 位</param>
|
||||
/// <returns>解密後之密碼字串。若參數 S 長度不是 10 位,則傳回".." + S + ".."</returns>
|
||||
public static string KeyDec(string S)
|
||||
{
|
||||
int i, j;
|
||||
int Key1, Key2;
|
||||
byte[] inBuf;
|
||||
byte[] outBuf = new byte[8];
|
||||
|
||||
if (S.Length != 10)
|
||||
return ".." + S + "..";
|
||||
|
||||
//解密
|
||||
inBuf = Encoding.ASCII.GetBytes(S);
|
||||
Key1 = inBuf[0] - 44;
|
||||
Key2 = inBuf[9] - 66;
|
||||
|
||||
for (i = 1; i <= 8; i++)
|
||||
{
|
||||
j = Key1 % 31 + i;
|
||||
j = (Key2 + j) % 31 + 1;
|
||||
outBuf[i - 1] = (byte)(inBuf[i] ^ j);
|
||||
}
|
||||
return Encoding.ASCII.GetString(outBuf).Trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Web;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace 報到系統
|
||||
{
|
||||
public class PublicVariable : WebLib.PublicVariable
|
||||
{
|
||||
private static Random r = new Random();
|
||||
|
||||
// 常用變數
|
||||
public static string[] 換行分隔 = { "\r\n" };
|
||||
|
||||
#region SESSION 變數名稱
|
||||
public const string CompanyId = "CompanyId";
|
||||
public const string EmployeeId = "EmployeeId";
|
||||
public const string EmployeeName = "EmployeeName";
|
||||
public const string EmployeeFunction = "EmployeeFunction";
|
||||
public const string CurrentPlace = "CurrentPlace";
|
||||
public const string CurrentPlaceName = "CurrentPlaceName";
|
||||
public const string UserGroups = "UserGroups";
|
||||
public const string IsSystemManager = "IsSystemManager";
|
||||
public const string IsCustomManager = "IsCustomManager";
|
||||
public const string IsFieldStaffWorker = "IsFieldStaffWorker";
|
||||
public const string IsQueryWorker = "IsQueryWorker";
|
||||
#endregion
|
||||
|
||||
#region 系統設定變數,由 Global.asax 讀取 web.config 中的設定
|
||||
|
||||
/// <summary>
|
||||
/// 未登入時開放某些功能
|
||||
/// </summary>
|
||||
public static bool NoLoginFunction = false;
|
||||
|
||||
/// <summary>
|
||||
/// 系統管理員群組
|
||||
/// </summary>
|
||||
public static string SystemManagerGroup = "SG01";
|
||||
|
||||
/// <summary>
|
||||
/// 客戶管理員群組
|
||||
/// </summary>
|
||||
public static string CustomManagerGroup = "SG02";
|
||||
|
||||
/// <summary>
|
||||
/// 現場工作人員群組
|
||||
/// </summary>
|
||||
|
||||
public static string FieldStaffGroup = "SG03";
|
||||
|
||||
/// <summary>
|
||||
/// 查詢人員群組
|
||||
/// </summary>
|
||||
public static string QueryGroup = "SG04";
|
||||
|
||||
/// <summary>
|
||||
/// 總管理處ID
|
||||
/// </summary>
|
||||
public static int 總管理處ID = 2;
|
||||
|
||||
/// <summary>
|
||||
/// 人資部ID
|
||||
/// </summary>
|
||||
public static int 人資部ID = 8;
|
||||
|
||||
/// <summary>
|
||||
/// 目前使用的簡訊平台代碼(由 BWEX.CurrentMMSPlatform 載入)
|
||||
/// </summary>
|
||||
public static string CurrentMMSPlatform = "EVERY8D";
|
||||
#endregion
|
||||
|
||||
public PublicVariable()
|
||||
{
|
||||
SystemName = "Education";
|
||||
}
|
||||
|
||||
public static string SystemVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
|
||||
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
|
||||
return fvi.FileVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace 報到系統
|
||||
{
|
||||
public class Utils
|
||||
{
|
||||
/// <summary>
|
||||
/// 依格式選項格式化簽到/簽退時間字串
|
||||
/// timeFormat: "datetime" => 年月日時分秒 (原始值),"time" => 只取 HH:mm
|
||||
/// </summary>
|
||||
public static string FormatTimeValue(string timeValue, string timeFormat)
|
||||
{
|
||||
if (string.IsNullOrEmpty(timeValue))
|
||||
return "";
|
||||
|
||||
if (timeFormat == "time")
|
||||
{
|
||||
// 取 HH:mm,格式為 "yyyy-MM-dd HH:mm:ss" 時從第11碼取5碼
|
||||
return timeValue.Length >= 16 ? timeValue.Substring(11, 5) : timeValue;
|
||||
}
|
||||
|
||||
// datetime 模式回傳原始值
|
||||
return timeValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user