Esempio n. 1
0
 private void CalLeaveEarly()
 {
     if (this.OffDutyTime != null && this.NewEndTime != null && this.OffDutyTime.Value < this.NewEndTime)
     {
         TimeSpan ts  = new TimeSpan(this.NewEndTime.Ticks - this.OffDutyTime.Value.Ticks);
         int      min = (int)Math.Floor(ts.TotalMinutes);
         this.LeaveEarly = min > this.AllowLeaveEarlyTime ? min : 0; //大于允许早退时间才算早退
         if (this.LeaveEarly > 0 && AttendanceRules.Current != null)
         {
             if (AttendanceRules.Current.MinLeaveEarly != null && AttendanceRules.Current.MinLeaveEarlyAsAbsentMinute > 0 && AttendanceRules.Current.MinLeaveEarly >= this.LeaveEarly)
             {
                 if (Present > 0)
                 {
                     AbsentItem ai = new AbsentItem()
                     {
                         ID       = Guid.NewGuid(),
                         Category = AttendanceResultDescription.GetDescription(AttendanceResultCode.LeaveEarly) + "计缺勤",
                         Duration = Present > AttendanceRules.Current.MinLeaveEarlyAsAbsentMinute ? AttendanceRules.Current.MinLeaveEarlyAsAbsentMinute : Present,
                     };
                     this.AbsentItems.Add(ai);
                     Present -= AttendanceRules.Current.MinLeaveEarlyAsAbsentMinute;
                     if (Present < 0)
                     {
                         Present = 0;
                     }
                 }
             }
             if (AttendanceRules.Current.LeaveEarlyAsAbsent != null && this.LeaveEarly > AttendanceRules.Current.LeaveEarlyAsAbsent)
             {
                 if (Present > 0)
                 {
                     AbsentItem ai = new AbsentItem()
                     {
                         ID       = Guid.NewGuid(),
                         Category = AttendanceResultDescription.GetDescription(AttendanceResultCode.LeaveEarly) + "计缺勤",
                         Duration = this.Present,
                     };
                     this.AbsentItems.Add(ai);
                     this.Present = 0;
                 }
             }
         }
     }
 }
Esempio n. 2
0
 private void CalLate()
 {
     if (this.OnDutyTime != null && this.NewStartTime != null && this.OnDutyTime.Value > this.NewStartTime)
     {
         TimeSpan ts  = new TimeSpan(this.OnDutyTime.Value.Ticks - this.NewStartTime.Ticks);
         int      min = (int)Math.Floor(ts.TotalMinutes);
         this.Belate = min > this.AllowLateTime ? min : 0; //大于允许迟到时间才算迟到
         if (this.Belate > 0 && AttendanceRules.Current != null)
         {
             if (AttendanceRules.Current.MinLate != null && AttendanceRules.Current.MinLateAsAbsentMinute > 0 && AttendanceRules.Current.MinLate >= this.Belate)
             {
                 if (Present > 0)
                 {
                     AbsentItem ai = new AbsentItem()
                     {
                         ID       = Guid.NewGuid(),
                         Category = AttendanceResultDescription.GetDescription(AttendanceResultCode.Late) + "计缺勤",
                         Duration = Present > AttendanceRules.Current.MinLateAsAbsentMinute ? AttendanceRules.Current.MinLateAsAbsentMinute : Present,
                     };
                     this.AbsentItems.Add(ai);
                     Present -= AttendanceRules.Current.MinLateAsAbsentMinute;
                     if (Present < 0)
                     {
                         Present = 0;
                     }
                 }
             }
             if (AttendanceRules.Current.LateAsAbsent != null && this.Belate > AttendanceRules.Current.LateAsAbsent)
             {
                 if (Present > 0)
                 {
                     AbsentItem ai = new AbsentItem()
                     {
                         ID       = Guid.NewGuid(),
                         Category = AttendanceResultDescription.GetDescription(AttendanceResultCode.Late) + "计缺勤",
                         Duration = this.Present,
                     };
                     this.AbsentItems.Add(ai);
                     this.Present = 0;
                 }
             }
         }
     }
 }