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
+149
View File
@@ -0,0 +1,149 @@
<%@ Application Language="C#" %>
<%@ Import Namespace="Wellan.Service" %>
<script RunAt="server">
private static bool debug = true;
void Application_Start(object sender, EventArgs e)
{
// 啟動檔案定時清除
// 要停止檔案定時清除,必須停止網站應用程式,或是設定 Enabled = false
WDeleteFileService dfs = WDeleteFileService.GetInstance();
if (!dfs.Enabled)
{
dfs.DeletePatterns.Clear();
dfs.DeletePatterns.Add(Server.MapPath(@"~\reportData\") + "*.mdb");
dfs.DeletePatterns.Add(Server.MapPath(@"~\reportData\") + "*.rpp");
dfs.Interval = 600; // 每幾秒清除一次檔案
dfs.FileAgeToDelete = 600; // 要清除最後寫入時間是幾秒之前的檔案
dfs.Enabled = true;
}
// 初始化 TimeCalc 資料
// TimeCalc.Init();
if (ConfigurationManager.AppSettings["DEBUG"] != null)
debug = ConfigurationManager.AppSettings["DEBUG"].ToUpper() == "Y";
else
debug = true;
// 讀取公用變數的值
if (ConfigurationManager.AppSettings["InnerDepartment"] != null)
PublicVariable.InnerDepartment = ConfigurationManager.AppSettings["InnerDepartment"];
#region 發郵件設定
if (ConfigurationManager.AppSettings["SendMailBySSL"] != null)
PublicVariable.SendMailBySSL = Convert.ToBoolean(ConfigurationManager.AppSettings["SendMailBySSL"].ToLower());
if (ConfigurationManager.AppSettings["SendMailHost"] != null)
PublicVariable.SendMailHost = ConfigurationManager.AppSettings["SendMailHost"];
if (ConfigurationManager.AppSettings["SendMailPort"] != null)
PublicVariable.SendMailPort = Convert.ToInt32(ConfigurationManager.AppSettings["SendMailPort"]);
if (ConfigurationManager.AppSettings["SendMailUserName"] != null)
PublicVariable.SendMailUserName = ConfigurationManager.AppSettings["SendMailUserName"];
if (ConfigurationManager.AppSettings["SendMailPassword"] != null)
PublicVariable.SendMailPassword = ConfigurationManager.AppSettings["SendMailPassword"];
#endregion
// 啟動郵件傳送服務
// 郵件伺服器相關設定,在 Web.Config 中的 System.Net 節
WMailSender mailSender = WMailSender.GetInstance();
if (!mailSender.Enabled)
{
mailSender.Host = PublicVariable.SendMailHost;
mailSender.Port = PublicVariable.SendMailPort;
mailSender.UserName = PublicVariable.SendMailUserName;
mailSender.Password = PublicVariable.SendMailPassword;
mailSender.UseSSL = PublicVariable.SendMailBySSL;
mailSender.CheckInterval = 10;
mailSender.SendCountPerInterval = 10;
mailSender.LogPath = Server.MapPath("~/Log/");
mailSender.Enabled = true;
}
// 啟動定時發郵件
MailTask.Enabled = true;
PublicVariable.RPARAttachPath = Server.MapPath("~/UploadedPicture/RPAR_ATTACHMENT");
}
void Application_End(object sender, EventArgs e)
{
// 應用程式關閉時執行的程式碼
}
private string Message1 = @"錯誤網頁:{0}
錯誤類別:{1}
錯誤來源:{2}
錯誤訊息:{3}
堆疊內容:
{4}
";
private string Message2 = @"以上的錯誤發生的原因是:
錯誤類別:{0}
錯誤來源:{1}
錯誤訊息:{2}
堆疊內容:
{3}
";
void Application_Error(object sender, EventArgs e)
{
// 發生未處理錯誤時執行的程式碼
string Message = "";
Exception ex = Server.GetLastError();
Message += String.Format(Message1,
Request.Path,
ex.GetType().FullName,
ex.Source,
ex.Message,
ex.StackTrace);
ex = ex.InnerException;
while (ex != null)
{
Message += String.Format(Message2,
ex.GetType().FullName,
ex.Source,
ex.Message,
ex.StackTrace);
ex = ex.InnerException;
}
//寫入文字檔
string fileName = DateTime.UtcNow.AddHours(8).ToString("yyyyMMdd_HHmmss");
System.IO.File.AppendAllText(Server.MapPath(string.Format(@"~/Log/{0}.txt", fileName)), Message);
//清除Error
Server.ClearError();
if (debug)
Response.Write("系統錯誤,請聯絡系統管理員!<br><pre>" + Message + "</pre>");
else
Response.Write(String.Format("系統執行時發生錯誤,請聯絡系統管理員,並告知錯誤代碼:{0}", fileName));
}
void Session_Start(object sender, EventArgs e)
{
// 啟動新工作階段時執行的程式碼
}
void Session_End(object sender, EventArgs e)
{
// 工作階段結束時執行的程式碼。
// 注意: 只有在 Web.config 檔將 sessionstate 模式設定為 InProc 時,
// 才會引發 Session_End 事件。如果將工作階段模式設定為 StateServer
// 或 SQLServer,就不會引發這個事件。
}
</script>