public void saveTotalTimeRecord(int accID, DateTime startDT, double totalTimeMinute, int totalOvertimeMinute)
        {
            var timeRecord = new workTimeTotal();

            timeRecord.accountID = accID;
            timeRecord.dateMonth = startDT;
            //timeRecord.dateMonth = definePara.dtNow().AddMonths(-1).AddDays(1 - definePara.dtNow().Day).Date;
            timeRecord.totalTime     = totalTimeMinute;
            timeRecord.totalOvertime = totalOvertimeMinute;
            timeRecord.createTime    = definePara.dtNow();
            Repository.SaveTotalTimeRecord(timeRecord);
        }
        public void SaveTotalTimeRecord(workTimeTotal data)
        {
            var context = _DbContext.worktimetotals.FirstOrDefault(
                b => b.accountID == data.accountID && b.dateMonth == data.dateMonth);

            if (context == null)
            {
                _DbContext.worktimetotals.Add(data);
                _DbContext.SaveChanges();
            }
            else
            {
                context.totalTime     = data.totalTime;
                context.totalOvertime = data.totalOvertime;
                context.updateTime    = definePara.dtNow();
                _DbContext.SaveChanges();
            }
        }
        public void refreshEmployeeOvertime(OvertimeApply context)
        {
            var accID      = context.accountID;
            var targetDate = context.workDate;
            var sDate      = targetDate.AddDays(1 - targetDate.Day).Date;
            var eDate      = sDate.AddMonths(1).AddDays(-1).Date;

            var otApplies = _DbContext.overtimeApply.Where(
                b => b.accountID == accID && b.applyStatus == 1 &&
                b.workDate >= sDate && b.workDate <= eDate)
                            .OrderBy(b => b.workDate).ToList();

            var totalOvertimeMinute = 0;

            foreach (var apply in otApplies)                //計算加班
            {
                totalOvertimeMinute += apply.timeLength;
            }
            var workTimeTotal = _DbContext.worktimetotals.FirstOrDefault(
                b => b.accountID == accID &&  b.dateMonth == sDate);

            if (workTimeTotal == null)
            {
                var timeRecord = new workTimeTotal();
                timeRecord.accountID     = accID;
                timeRecord.dateMonth     = sDate;
                timeRecord.totalOvertime = totalOvertimeMinute;
                timeRecord.createTime    = definePara.dtNow();
                _DbContext.worktimetotals.Add(timeRecord);
                _DbContext.SaveChanges();
            }
            else
            {
                workTimeTotal.totalOvertime = totalOvertimeMinute;
                workTimeTotal.updateTime    = definePara.dtNow();
                _DbContext.SaveChanges();
            }
        }