chore: 首次簽入 Thinkyu ASP.NET 專案

- 加入 Visual Studio / ASP.NET .gitignore
- 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
This commit is contained in:
2026-09-10 09:42:37 +08:00
commit 577060bc78
2496 changed files with 501389 additions and 0 deletions
@@ -0,0 +1,211 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Timers;
using System.IO;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using WebLib;
namespace Education
{
public class FollowService
{
private static FollowService _instance = null;
private Timer _timer = null;
private static int _interval = 30;
private static string _doWorkTime = "00:00";
private static bool _enabled = false;
private static bool _busy = false;
private static = new ();
private DAC_BPSN Dao員工;
private DbConnection conn;
/// <summary>
/// 發動時間,預設值為 00:00
/// </summary>
public static string DoWorkTime
{
get
{
return _doWorkTime;
}
set
{
_doWorkTime = value;
}
}
/// <summary>
/// 郵件模版路徑
/// </summary>
public static string TemplatePath { get; set; }
/// <summary>
/// 設定或取得簽核跟催服務是否啟動
/// </summary>
public static bool Enabled
{
get
{
return _enabled;
}
set
{
if (value)
{
if (_enabled)
return;
Instance._timer.Interval = _interval * 1000;
Instance._timer.AutoReset = true;
Instance._timer.Enabled = true;
_enabled = true;
}
else
{
if (!_enabled)
return;
_enabled = false;
Instance._timer.Enabled = false;
}
}
}
private FollowService()
{
_timer = new Timer();
_timer.Enabled = false;
_timer.Elapsed += new ElapsedEventHandler(DoFollowWork);
conn = DAC.NewConnection();
Dao員工 = new DAC_BPSN(conn);
}
public static FollowService Instance
{
get
{
if (_instance == null)
_instance = new FollowService();
return _instance;
}
}
private void DoFollowWork(object sender, ElapsedEventArgs e)
{
string nowTime = DateTime.UtcNow.AddHours(8).ToString("HH:mm");
if (nowTime.CompareTo(_doWorkTime) == 0 && !_busy)
{
_busy = true;
try
{
DAC_表單簽核明細 dao表單簽核明細 = new DAC_表單簽核明細(conn);
List first = dao表單簽核明細.Select第一次稽催();
List second = dao表單簽核明細.Select第二次稽催();
List third = dao表單簽核明細.Select第三次稽催();
foreach ( item in first)
{
SendFollowMail(item, 3);
item. = 1;
dao表單簽核明細.UpdateOne(item);
}
foreach ( item in second)
{
SendFollowMail(item, 7);
item. = 2;
dao表單簽核明細.UpdateOne(item);
}
foreach ( item in third)
{
SendFollowMail(item, 14);
item. = 3;
dao表單簽核明細.UpdateOne(item);
}
DoSurveyReminderWork();
}
finally
{
_busy = false;
}
}
}
private void SendFollowMail( item, int )
{
string = Dao員工.Get電子郵件(item.);
string = Dao員工.Get員工姓名(item.);
= new ();
.(item.ID, , , , TemplatePath);
}
private void DoSurveyReminderWork()
{
if (string.IsNullOrEmpty(PublicVariable.SiteBaseUrl))
return;
string = PublicVariable.SiteBaseUrl + "/MobileSurvey/Login.aspx";
int deadlineDays = PublicVariable.SurveyReminderDeadlineDays;
DateTime minDate = PublicVariable.SurveyReminderMinCourseDate;
string[] excludeEmps = PublicVariable.SurveyReminderExcludeEmployees
.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
DbCommand cmd = conn.CreateCommand();
cmd.CommandText =
@"select A.學員編號, A.訓練課程編號, C.BPNME as 學員姓名, C.BPEML as 電子郵件,
B.顯示編號, B.訓練名稱, B.訓練日期, B.訓練日期迄
from 課程報名 A
inner join 訓練課程企劃 B on A.訓練課程編號 = B.編號
inner join BPSNView C on A.學員編號 = C.BPENO
where (A.報名狀態 = 'Y' or A.報名狀態 = 'R')
and B.訓練日期 >= @MinCourseDate
and (A.滿意度催填狀態 is null or A.滿意度催填狀態 = '')
and not exists (
select 1 from 滿意度調查 D
where D.訓練課程企劃編號 = A.訓練課程編號 and D.學員編號 = A.學員編號
)
and dateadd(day, @DeadlineDays, B.訓練日期迄) < getdate()
order by A.學員編號";
cmd.Parameters.Add(new SqlParameter("@MinCourseDate", minDate));
cmd.Parameters.Add(new SqlParameter("@DeadlineDays", deadlineDays));
DataTable dt = new DataTable();
using (var reader = cmd.ExecuteReader())
{
dt.Load(reader);
}
foreach (DataRow row in dt.Rows)
{
string = DAC.GetString(row["學員編號"]);
if (excludeEmps.Contains())
continue;
string = DAC.GetString(row["學員姓名"]);
string = DAC.GetString(row["電子郵件"]);
string = DAC.GetString(row["訓練名稱"]);
DateTime = DAC.GetDateTime(row["訓練日期"]);
DateTime = DAC.GetDateTime(row["訓練日期迄"]);
int = DAC.GetInt32(row["訓練課程編號"]);
= new ();
.滿(, , , , , );
DbCommand cmdUpd = conn.CreateCommand();
cmdUpd.CommandText =
"update 課程報名 set 滿意度催填狀態 = 'Y'" +
" where 訓練課程編號 = @訓練課程編號 and 學員編號 = @學員編號";
cmdUpd.Parameters.Add(new SqlParameter("@訓練課程編號", ));
cmdUpd.Parameters.Add(new SqlParameter("@學員編號", ));
cmdUpd.ExecuteNonQuery();
}
}
}
}