예제 #1
0
        public static void CalculateTimeINOUTOpenShift(AttData attendanceRecord, PollData up)
        {
            try
            {
                TAS2013Entities context = new TAS2013Entities();
                switch (up.RdrDuty)
                {
                    case 1: //IN
                        if (attendanceRecord.Tin0 == null)
                        {
                            if (up.EntTime.TimeOfDay < OpenShiftThresholdEnd)
                            {
                                DateTime dt = new DateTime();
                                dt = up.EntDate.Date.AddDays(-1);
                                var _attData = context.AttDatas.FirstOrDefault(aa => aa.AttDate == dt && aa.EmpID == up.EmpID);
                                if (_attData != null)
                                {

                                    if (_attData.TimeIn != null)
                                    {
                                        if (_attData.TimeIn.Value.TimeOfDay > OpenShiftThresholdStart)
                                        {
                                            //attdata - 1 . multipleTimeIn =  up.EntTime

                                        }
                                        else
                                        {
                                            attendanceRecord.Tin0 = up.EntTime;
                                            attendanceRecord.TimeIn = up.EntTime;
                                            attendanceRecord.StatusAB = false;
                                            attendanceRecord.StatusP = true;
                                            attendanceRecord.Remarks = null;
                                            attendanceRecord.StatusIN = true;
                                        }
                                    }
                                    else
                                    {
                                        attendanceRecord.Tin0 = up.EntTime;
                                        attendanceRecord.TimeIn = up.EntTime;
                                        attendanceRecord.StatusAB = false;
                                        attendanceRecord.StatusP = true;
                                        attendanceRecord.Remarks = null;
                                        attendanceRecord.StatusIN = true;
                                    }
                                }
                                else
                                {
                                    attendanceRecord.Tin0 = up.EntTime;
                                    attendanceRecord.TimeIn = up.EntTime;
                                    attendanceRecord.StatusAB = false;
                                    attendanceRecord.StatusP = true;
                                    attendanceRecord.Remarks = null;
                                    attendanceRecord.StatusIN = true;
                                }
                            }
                            else
                            {
                                attendanceRecord.Tin0 = up.EntTime;
                                attendanceRecord.TimeIn = up.EntTime;
                                attendanceRecord.StatusAB = false;
                                attendanceRecord.StatusP = true;
                                attendanceRecord.Remarks = null;
                                attendanceRecord.StatusIN = true;
                            }

                        }
                        else if (attendanceRecord.Tin1 == null)
                        {
                            attendanceRecord.Tin1 = up.EntTime;
                            SortingInTime(attendanceRecord);
                        }
                        else if (attendanceRecord.Tin2 == null)
                        {
                            attendanceRecord.Tin2 = up.EntTime;
                            SortingInTime(attendanceRecord);
                        }
                        else if (attendanceRecord.Tin3 == null)
                        {
                            attendanceRecord.Tin3 = up.EntTime;
                            SortingInTime(attendanceRecord);
                        }
                        else if (attendanceRecord.Tin4 == null)
                        {
                            attendanceRecord.Tin4 = up.EntTime;
                            SortingInTime(attendanceRecord);
                        }
                        else if (attendanceRecord.Tin5 == null)
                        {
                            attendanceRecord.Tin5 = up.EntTime;
                            SortingInTime(attendanceRecord);
                        }
                        else if (attendanceRecord.Tin6 == null)
                        {
                            attendanceRecord.Tin6 = up.EntTime;
                            SortingInTime(attendanceRecord);
                        }
                        else if (attendanceRecord.Tin7 == null)
                        {
                            attendanceRecord.Tin7 = up.EntTime;
                            SortingInTime(attendanceRecord);
                        }
                        else if (attendanceRecord.Tin8 == null)
                        {
                            attendanceRecord.Tin8 = up.EntTime;
                            SortingInTime(attendanceRecord);
                        }
                        else if (attendanceRecord.Tin9 == null)
                        {
                            attendanceRecord.Tin9 = up.EntTime;
                            SortingInTime(attendanceRecord);
                        }
                        else if (attendanceRecord.Tin10 == null)
                        {
                            attendanceRecord.Tin10 = up.EntTime;
                            SortingInTime(attendanceRecord);
                        }
                        else
                        {
                            attendanceRecord.Tin11 = up.EntTime;
                            SortingInTime(attendanceRecord);
                        }
                        break;
                    case 5: //OUT
                        if (up.EntTime.TimeOfDay < OpenShiftThresholdEnd)
                        {
                            DateTime dt = up.EntDate.AddDays(-1);
                            if (context.AttDatas.Where(aa => aa.AttDate == dt && aa.EmpID == up.EmpID).Count() > 0)
                            {
                                AttData AttDataOfPreviousDay = context.AttDatas.FirstOrDefault(aa => aa.AttDate == dt && aa.EmpID == up.EmpID);
                                if (AttDataOfPreviousDay.TimeIn != null)
                                {
                                    if (AttDataOfPreviousDay.TimeIn.Value.TimeOfDay > OpenShiftThresholdStart)
                                    {
                                        //AttDate -1, Possible TimeOut = up.entryTime
                                        MarkOUTForOpenShift(up.EntTime, AttDataOfPreviousDay);
                                    }
                                    else
                                    {
                                        // Mark as out of that day
                                        MarkOUTForOpenShift(up.EntTime, attendanceRecord);
                                    }
                                }
                                else
                                    MarkOUTForOpenShift(up.EntTime, attendanceRecord);
                            }
                            else
                            {
                                // Mark as out of that day
                                MarkOUTForOpenShift(up.EntTime, attendanceRecord);
                            }

                        }
                        else
                        {
                            //Mark as out of that day
                            MarkOUTForOpenShift(up.EntTime, attendanceRecord);
                        }
                        //-------------------------------------------------------
                        context.SaveChanges();
                        break;
                }
            }
            catch (Exception ex)
            {
            }
        }
예제 #2
0
 public static void CalculateTimeINOUT(AttData attendanceRecord, PollData up)
 {
     try
     {
         switch (up.RdrDuty)
         {
             case 1: //IN
                 if (attendanceRecord.Tin0 == null)
                 {
                     attendanceRecord.Tin0 = up.EntTime;
                     attendanceRecord.TimeIn = up.EntTime;
                     attendanceRecord.StatusAB = false;
                     attendanceRecord.StatusP = true;
                     attendanceRecord.Remarks = null;
                 }
                 else if (attendanceRecord.Tin1 == null)
                 {
                     attendanceRecord.Tin1 = up.EntTime;
                     SortingInTime(attendanceRecord);
                 }
                 else if (attendanceRecord.Tin2 == null)
                 {
                     attendanceRecord.Tin2 = up.EntTime;
                     SortingInTime(attendanceRecord);
                 }
                 else if (attendanceRecord.Tin3 == null)
                 {
                     attendanceRecord.Tin3 = up.EntTime;
                     SortingInTime(attendanceRecord);
                 }
                 else if (attendanceRecord.Tin4 == null)
                 {
                     attendanceRecord.Tin4 = up.EntTime;
                     SortingInTime(attendanceRecord);
                 }
                 else if (attendanceRecord.Tin5 == null)
                 {
                     attendanceRecord.Tin5 = up.EntTime;
                     SortingInTime(attendanceRecord);
                 }
                 else if (attendanceRecord.Tin6 == null)
                 {
                     attendanceRecord.Tin6 = up.EntTime;
                     SortingInTime(attendanceRecord);
                 }
                 else if (attendanceRecord.Tin7 == null)
                 {
                     attendanceRecord.Tin7 = up.EntTime;
                     SortingInTime(attendanceRecord);
                 }
                 else if (attendanceRecord.Tin8 == null)
                 {
                     attendanceRecord.Tin8 = up.EntTime;
                     SortingInTime(attendanceRecord);
                 }
                 else if (attendanceRecord.Tin9 == null)
                 {
                     attendanceRecord.Tin9 = up.EntTime;
                     SortingInTime(attendanceRecord);
                 }
                 else if (attendanceRecord.Tin10 == null)
                 {
                     attendanceRecord.Tin10 = up.EntTime;
                     SortingInTime(attendanceRecord);
                 }
                 else
                 {
                     attendanceRecord.Tin11 = up.EntTime;
                     SortingInTime(attendanceRecord);
                 }
                 break;
             case 5: //OUT
                 if (attendanceRecord.Tout0 == null)
                 {
                     attendanceRecord.Tout0 = up.EntTime;
                     attendanceRecord.TimeOut = up.EntTime;
                     SortingOutTime(attendanceRecord);
                 }
                 else if (attendanceRecord.Tout1 == null)
                 {
                     attendanceRecord.Tout1 = up.EntTime;
                     attendanceRecord.TimeOut = up.EntTime;
                     SortingOutTime(attendanceRecord);
                 }
                 else if (attendanceRecord.Tout2 == null)
                 {
                     attendanceRecord.Tout2 = up.EntTime;
                     attendanceRecord.TimeOut = up.EntTime;
                     SortingOutTime(attendanceRecord);
                 }
                 else if (attendanceRecord.Tout3 == null)
                 {
                     attendanceRecord.Tout3 = up.EntTime;
                     attendanceRecord.TimeOut = up.EntTime;
                     SortingOutTime(attendanceRecord);
                 }
                 else if (attendanceRecord.Tout4 == null)
                 {
                     attendanceRecord.Tout4 = up.EntTime;
                     attendanceRecord.TimeOut = up.EntTime;
                     SortingOutTime(attendanceRecord);
                 }
                 else if (attendanceRecord.Tout5 == null)
                 {
                     attendanceRecord.Tout5 = up.EntTime;
                     attendanceRecord.TimeOut = up.EntTime;
                     SortingOutTime(attendanceRecord);
                 }
                 else if (attendanceRecord.Tout6 == null)
                 {
                     attendanceRecord.Tout6 = up.EntTime;
                     attendanceRecord.TimeOut = up.EntTime;
                     SortingOutTime(attendanceRecord);
                 }
                 else if (attendanceRecord.Tout7 == null)
                 {
                     attendanceRecord.Tout7 = up.EntTime;
                     attendanceRecord.TimeOut = up.EntTime;
                     SortingOutTime(attendanceRecord);
                 }
                 else if (attendanceRecord.Tout8 == null)
                 {
                     attendanceRecord.Tout8 = up.EntTime;
                     attendanceRecord.TimeOut = up.EntTime;
                     SortingOutTime(attendanceRecord);
                 }
                 else if (attendanceRecord.Tout9 == null)
                 {
                     attendanceRecord.Tout9 = up.EntTime;
                     attendanceRecord.TimeOut = up.EntTime;
                     SortingOutTime(attendanceRecord);
                 }
                 else if (attendanceRecord.Tout10 == null)
                 {
                     attendanceRecord.Tout10 = up.EntTime;
                     attendanceRecord.TimeOut = up.EntTime;
                     SortingOutTime(attendanceRecord);
                 }
                 else
                 {
                     attendanceRecord.Tout11 = up.EntTime;
                     attendanceRecord.TimeOut = up.EntTime;
                     SortingOutTime(attendanceRecord);
                 }
                 break;
             case 8: //DUTY
                 if (attendanceRecord.Tin0 != null)
                 {
                     if (attendanceRecord.Tout0 == null)
                     {
                         attendanceRecord.Tout0 = up.EntTime;
                         attendanceRecord.TimeOut = up.EntTime;
                     }
                     else if (attendanceRecord.Tin1 == null)
                     {
                         attendanceRecord.Tin1 = up.EntTime;
                         attendanceRecord.TimeOut = up.EntTime;
                     }
                     else if (attendanceRecord.Tout1 == null)
                     {
                         attendanceRecord.Tout1 = up.EntTime;
                         attendanceRecord.TimeOut = up.EntTime;
                     }
                     else if (attendanceRecord.Tin2 == null)
                     {
                         attendanceRecord.Tin2 = up.EntTime;
                         attendanceRecord.TimeOut = up.EntTime;
                     }
                     else if (attendanceRecord.Tout2 == null)
                     {
                         attendanceRecord.Tout2 = up.EntTime;
                         attendanceRecord.TimeOut = up.EntTime;
                     }
                     else if (attendanceRecord.Tin3 == null)
                     {
                         attendanceRecord.Tin3 = up.EntTime;
                         attendanceRecord.TimeOut = up.EntTime;
                     }
                     else if (attendanceRecord.Tout3 == null)
                     {
                         attendanceRecord.Tout3 = up.EntTime;
                         attendanceRecord.TimeOut = up.EntTime;
                     }
                     else if (attendanceRecord.Tin4 == null)
                     {
                         attendanceRecord.Tin4 = up.EntTime;
                         attendanceRecord.TimeOut = up.EntTime;
                     }
                     else if (attendanceRecord.Tout4 == null)
                     {
                         attendanceRecord.Tout4 = up.EntTime;
                         attendanceRecord.TimeOut = up.EntTime;
                     }
                     else if (attendanceRecord.Tin5 == null)
                     {
                         attendanceRecord.Tin5 = up.EntTime;
                         attendanceRecord.TimeOut = up.EntTime;
                     }
                     else if (attendanceRecord.Tout5 == null)
                     {
                         attendanceRecord.Tout5 = up.EntTime;
                         attendanceRecord.TimeOut = up.EntTime;
                     }
                     else if (attendanceRecord.Tin6 == null)
                     {
                         attendanceRecord.Tin6 = up.EntTime;
                         attendanceRecord.TimeOut = up.EntTime;
                     }
                     else if (attendanceRecord.Tout6 == null)
                     {
                         attendanceRecord.Tout6 = up.EntTime;
                         attendanceRecord.TimeOut = up.EntTime;
                     }
                     //
                     else if (attendanceRecord.Tin7 == null)
                     {
                         attendanceRecord.Tin7 = up.EntTime;
                         attendanceRecord.TimeOut = up.EntTime;
                     }
                     else if (attendanceRecord.Tout7 == null)
                     {
                         attendanceRecord.Tout7 = up.EntTime;
                         attendanceRecord.TimeOut = up.EntTime;
                     }
                     else if (attendanceRecord.Tin8 == null)
                     {
                         attendanceRecord.Tin8 = up.EntTime;
                         attendanceRecord.TimeOut = up.EntTime;
                     }
                     else if (attendanceRecord.Tout8 == null)
                     {
                         attendanceRecord.Tout8 = up.EntTime;
                         attendanceRecord.TimeOut = up.EntTime;
                     }
                     else if (attendanceRecord.Tin9 == null)
                     {
                         attendanceRecord.Tin9 = up.EntTime;
                         attendanceRecord.TimeOut = up.EntTime;
                     }
                     else if (attendanceRecord.Tout9 == null)
                     {
                         attendanceRecord.Tout9 = up.EntTime;
                         attendanceRecord.TimeOut = up.EntTime;
                     }
                     else if (attendanceRecord.Tin10 == null)
                     {
                         attendanceRecord.Tin10 = up.EntTime;
                         attendanceRecord.TimeOut = up.EntTime;
                     }
                     else if (attendanceRecord.Tout10 == null)
                     {
                         attendanceRecord.Tout10 = up.EntTime;
                         attendanceRecord.TimeOut = up.EntTime;
                     }
                     else if (attendanceRecord.Tin11 == null)
                     {
                         attendanceRecord.Tin11 = up.EntTime;
                         attendanceRecord.TimeOut = up.EntTime;
                     }
                     else if (attendanceRecord.Tout11 == null)
                     {
                         attendanceRecord.Tout11 = up.EntTime;
                         attendanceRecord.TimeOut = up.EntTime;
                     }
                     else if (attendanceRecord.Tin12 == null)
                     {
                         attendanceRecord.Tin12 = up.EntTime;
                         attendanceRecord.TimeOut = up.EntTime;
                     }
                     else if (attendanceRecord.Tout12 == null)
                     {
                         attendanceRecord.Tout12 = up.EntTime;
                         attendanceRecord.TimeOut = up.EntTime;
                     }
                     else if (attendanceRecord.Tin13 == null)
                     {
                         attendanceRecord.Tin13 = up.EntTime;
                         attendanceRecord.TimeOut = up.EntTime;
                     }
                     else
                     {
                         attendanceRecord.Tout13 = up.EntTime;
                         attendanceRecord.TimeOut = up.EntTime;
                     }
                 }
                 else
                 {
                     attendanceRecord.Tin0 = up.EntTime;
                     attendanceRecord.TimeIn = up.EntTime;
                     attendanceRecord.StatusAB = false;
                     attendanceRecord.StatusP = true;
                     attendanceRecord.Remarks = null;
                 }
                 break;
         }
     }
     catch (Exception ex)
     {
     }
 }