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
+555
View File
@@ -0,0 +1,555 @@
using System;
using System.Linq;
using System.Xml.Linq;
using Wellan.Common;
/// <summary>
/// 計算時數的類別
/// </summary>
public class TimeCalc
{
public string ;
public string ;
public string ;
public string ;
public int ;
public int ;
public bool ;
private BhrdDAC bhrdDao = new BhrdDAC(WGuard1.Query);
private RtmeDAC rtmeDao = new RtmeDAC(WGuard1.Query);
private BpsnDAC bpsnDao = new BpsnDAC(WGuard1.Query);
private BpaaDAC bpaaDao = new BpaaDAC(WGuard1.Query);
private BtmeDAC btmeDao = new BtmeDAC(WGuard1.Query);
public TimeCalc()
{
}
/// <summary>
/// 計算時數之前取得各個時間點
/// </summary>
/// <param name="員工編號"></param>
/// <param name="日期"></param>
public void Init(string , DateTime )
{
= WGuard1.WSetR("UNRPARTIME", 1);
= WGuard1.WSetR("UNRPARTIME", 2);
= WGuard1.WSetR("UNRPARTIME", 3);
= WGuard1.WSetR("UNRPARTIME", 4);
= WGuard1.WSetR("彈性上班時間", 1) == "Y";
// 取員工班表
var btmeItem = rtmeDao.SelectBtmeDay(, );
if (btmeItem != null && !String.IsNullOrEmpty(btmeItem.BTSTM) && !String.IsNullOrEmpty(btmeItem.BTETM)
&& !String.IsNullOrEmpty(btmeItem.BTRST) && !String.IsNullOrEmpty(btmeItem.BTRED))
{
= btmeItem.BTSTM;
= btmeItem.BTETM;
= btmeItem.BTRST;
= btmeItem.BTRED;
}
// 若員工班表沒有設定,則取專案預設班表
else
{
// 取員工專案年度接單編號
var rapyn = bpsnDao.GetProjectByDate(, );
if (!String.IsNullOrEmpty(rapyn))
{
// 取專案預設班表編號
var bptme = bpaaDao.GetTimeTableNo(rapyn);
if (!String.IsNullOrEmpty(bptme))
{
// 取班表
btmeItem = btmeDao.SelectOne(bptme).FirstOrDefault();
if (btmeItem != null && !String.IsNullOrEmpty(btmeItem.BTSTM) && !String.IsNullOrEmpty(btmeItem.BTETM)
&& !String.IsNullOrEmpty(btmeItem.BTRST) && !String.IsNullOrEmpty(btmeItem.BTRED))
{
= btmeItem.BTSTM;
= btmeItem.BTETM;
= btmeItem.BTRST;
= btmeItem.BTRED;
}
}
}
}
= (, ) - (, );
= (, );
}
public static int (int )
{
double = ((double) / 30d) % 1d;
if ( > 0.5d)
return ( / 60 + 1) * 60;
else
return ( / 60) * 60;
}
public static int (int )
{
double = ((double) / 15d) % 1d;
if ( > 0.5d)
return ( / 30 + 1) * 30;
else
return ( / 30) * 30;
}
public static int (string tm1, string tm2)
{
DateTime dt1 = new DateTime();
DateTime dt2 = new DateTime();
dt1 = dt1.AddHours(Convert.ToInt32((tm1 + "00:00").Substring(0, 2))).AddMinutes(Convert.ToInt32((tm1 + "00:00").Substring(3, 2)));
dt2 = dt2.AddHours(Convert.ToInt32((tm2 + "00:00").Substring(0, 2))).AddMinutes(Convert.ToInt32((tm2 + "00:00").Substring(3, 2)));
return Convert.ToInt32((dt2 - dt1).TotalMinutes);
}
public static string (string tm1, int minutes)
{
DateTime dt1 = new DateTime();
dt1 = dt1.AddHours(Convert.ToInt32((tm1 + "00:00").Substring(0, 2))).AddMinutes(Convert.ToInt32((tm1 + "00:00").Substring(3, 2)));
dt1 = dt1.AddMinutes(minutes);
return dt1.ToString("HH:mm");
}
public int (string , string )
{
if (.CompareTo() <= 0 && .CompareTo() >= 0)
return ;
else if (.CompareTo() >= 0 && .CompareTo() <= 0 && .CompareTo() >= 0)
return (, );
else if (.CompareTo() <= 0 && .CompareTo() >= 0 && .CompareTo() <= 0)
return (, );
else if (.CompareTo() >= 0 && .CompareTo() <= 0 && .CompareTo() >= 0 && .CompareTo() <= 0)
return (, );
else
return 0;
}
public int (string , DateTime , DateTime , string , string , string , bool is進整小時)
{
Init(, );
if (String.IsNullOrEmpty())
= ;
if (String.IsNullOrEmpty())
= ;
int ;
// 起始與結束同一天
if ( == )
{
= (, ) - (, );
}
// 起始與結束不同天
else
{
DateTime std = ;
= 0;
while (std <= )
{
Init(, std);
// 不是假日,或是產假,要列入時數計算
if (!bhrdDao.IsHoliday(, std) || == RPAR_TYPE.T05_產假)
{
// 第一天
if (std == )
{
+= (, ) - (, );
}
// 最後一天
else if (std == )
{
+= (, ) - (, );
}
// 中間其他天
else
{
+= ;
}
}
std = std.AddDays(1);
}
}
if (is進整小時)
= ();
return ;
}
public int (string , DateTime , DateTime , string )
{
// 起始與結束同一天
if ( == )
{
return 1;
}
// 起始與結束不同天
else
{
DateTime std = ;
int = 0;
while (std <= )
{
// 不是假日,或是產假,要列入時數計算
if (!bhrdDao.IsHoliday(, std) || == RPAR_TYPE.T05_產假)
{
++;
}
std = std.AddDays(1);
}
return ;
}
}
public int (string , DateTime , DateTime , DateTime , string , string , string , bool is進整小時)
{
int = 0;
// 起始與結束同一天
if ( == )
{
Init(, );
if (String.IsNullOrEmpty())
= ;
if (String.IsNullOrEmpty())
= ;
= (, ) - (, );
if (is進整小時)
return ();
else
return ;
}
// 起始與結束不同天
else
{
DateTime std = ;
while (std <= )
{
Init(, std);
// 不是假日,或是產假,要列入時數計算
if (!bhrdDao.IsHoliday(, std) || == RPAR_TYPE.T05_產假)
{
// 第一天
if (std == )
{
= (, ) - (, );
}
// 最後一天
else if (std == )
{
= (, ) - (, );
}
// 中間其他天
else
{
= ;
}
// 只計算一天,就返回
if ( == std)
{
if (is進整小時)
return ();
else
return ;
}
}
else
= 0;
std = std.AddDays(1);
}
return 0;
}
}
public int (string , DateTime , string , string , bool )
{
Init(, );
int = (, ) - (, );
// 2018/3/1 之後休息日加班不進整 4 小時
if ( && .CompareTo(new DateTime(2018, 3, 1)) < 0)
= (int)(Math.Ceiling((decimal) / 240m) * 240m);
return ;
}
//public static void 拆分加班時數(int 分鐘數, bool 是假日, out int 前二, out int 後二, out int 假日)
//{
// 前二 = 0;
// 後二 = 0;
// 假日 = 0;
// if (是假日)
// 假日 = 分鐘數;
// else
// {
// if (分鐘數 < 120)
// 前二 = 分鐘數;
// else
// {
// 前二 = 120;
// 後二 = 分鐘數 - 120;
// }
// }
//}
public int (string , DateTime , DateTime , string , string )
{
Init(, );
if (String.IsNullOrEmpty())
= ;
if (String.IsNullOrEmpty())
= ;
int ;
// 起始與結束同一天
if ( == )
{
= (, ) - (, );
}
// 起始與結束不同天
else
{
DateTime std = ;
= 0;
while (std <= )
{
Init(, std);
// 第一天
if (std == )
{
+= (, ) - (, );
}
// 最後一天
else if (std == )
{
+= (, ) - (, );
}
// 中間其他天
else
{
+= ;
}
std = std.AddDays(1);
}
}
return ;
}
public int (string , DateTime , DateTime , DateTime , string , string )
{
Init(, );
if (String.IsNullOrEmpty())
= ;
if (String.IsNullOrEmpty())
= ;
int ;
// 起始與結束同一天
if ( == )
{
= (, ) - (, );
if ( == )
return ;
else
return 0;
}
// 起始與結束不同天
else
{
DateTime std = ;
while (std <= )
{
Init(, std);
= 0;
// 第一天
if (std == )
{
= (, ) - (, );
}
// 最後一天
else if (std == )
{
= (, ) - (, );
}
// 中間其他天
else
{
= ;
}
if ( == std)
return ;
std = std.AddDays(1);
}
}
return 0;
}
public static DateTime (string , DateTime , string )
{
// 解析30小時制(小時可能 >= 24,表示跨入隔日凌晨)
var parts = .Split(':');
var timeSpan = new TimeSpan(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]));
var sourceTime = .Date.Add(timeSpan);
if (string.IsNullOrEmpty() || string.Compare(, "Taipei Standard Time") == 0)
{
return sourceTime;
}
// 重要:將 Kind 設為 Unspecified
sourceTime = DateTime.SpecifyKind(sourceTime, DateTimeKind.Unspecified);
// 轉換到目標時區
var sourceZone = TimeZoneInfo.FindSystemTimeZoneById("Taipei Standard Time");
var targetZone = TimeZoneInfo.FindSystemTimeZoneById();
var utcTime = TimeZoneInfo.ConvertTimeToUtc(sourceTime, sourceZone);
var targetTime = TimeZoneInfo.ConvertTimeFromUtc(utcTime, targetZone);
return targetTime;
}
public static string (string , DateTime , string )
{
var targetTime = (, , );
// 輸出 30 小時制時分秒
// 06:00 之前算前一天,小時數加 24
int outputHours = targetTime.Hour;
if (targetTime.TimeOfDay < new TimeSpan(6, 0, 0))
outputHours += 24;
return string.Format("{0:00}:{1:00}:{2:00}", outputHours, targetTime.Minute, targetTime.Second);
}
}
/// <summary>
/// 30 小時制的日期類別
/// </summary>
public class DateAndTime
{
/// <summary>
/// 台灣工作日期
/// </summary>
public DateTime TwWorkDate;
/// <summary>
/// 台灣日曆日期
/// </summary>
public DateTime TwCalendarDate;
/// <summary>
/// 台灣時間
/// </summary>
public string TwTime;
/// <summary>
/// 當地日期
/// </summary>
public DateTime LocalDate;
/// <summary>
/// 當地時間
/// </summary>
public string LocalTime;
/// <summary>
/// 時區名稱
/// </summary>
public string TimezoneName;
/// <summary>
/// 時區ID
/// </summary>
public string TimeZoneID;
/// <summary>
/// 打卡的日期
/// </summary>
public DateTime CardDate;
public DateAndTime(DateTime twWorkDate, DateTime twCalendarDate, string twTime, DateTime localDate, string localTime, string timezoneName, string timezoneID) : base()
{
TwWorkDate = twWorkDate;
TwCalendarDate = twCalendarDate;
TwTime = twTime;
LocalDate = localDate;
LocalTime = localTime;
TimezoneName = timezoneName;
TimeZoneID = timezoneID;
CardDate = string.IsNullOrEmpty(TimeZoneID) || string.Compare(TimeZoneID, "Taipei Standard Time") == 0
? TwWorkDate
: TwCalendarDate;
}
public static DateAndTime GetNow(string bpeno)
{
var twNow = DateTime.UtcNow.AddHours(8);
var rasnDao = new RasnDAC(WGuard1.Query);
string timezoneID;
string timezoneName;
rasnDao.GetTimeZone(bpeno, twNow, out timezoneID, out timezoneName);
var twCalendarDate = twNow.Date;
var twWorkDate = twNow.Date;
var localNow = TimeCalc.(timezoneID, twNow.Date, twNow.ToString("HH:mm:ss"));
var localDate = localNow.Date;
var twHourOffset = 0;
var localHourOffset = 0;
// 06:00 之前算前一天
if (twNow.TimeOfDay < new TimeSpan(6, 0, 0))
{
twWorkDate = twWorkDate.AddDays(-1);
twHourOffset = 24;
}
if (localNow.TimeOfDay < new TimeSpan(6, 0, 0))
{
localDate = localDate.AddDays(-1);
localHourOffset = 24;
}
return new DateAndTime(
twWorkDate,
twCalendarDate,
string.Format("{0:00}:{1:00}:{2:00}", twNow.TimeOfDay.Hours + twHourOffset, twNow.TimeOfDay.Minutes, twNow.Second),
localDate,
string.Format("{0:00}:{1:00}:{2:00}", localNow.TimeOfDay.Hours + localHourOffset, localNow.TimeOfDay.Minutes, localNow.Second),
timezoneName,
timezoneID
);
}
}