Esempio n. 1
0
        public static List <WorkloadInfo> GetWorkloadListTotally(List <WorkloadInfo> workloadPerMonth)
        {
            Dictionary <string, List <WorkloadInfo> > workloadMap = new Dictionary <string, List <WorkloadInfo> >();

            // group by name
            foreach (var nextInfo in workloadPerMonth)
            {
                if (!workloadMap.ContainsKey(nextInfo.Name))
                {
                    workloadMap[nextInfo.Name] = new List <WorkloadInfo>();
                }
                workloadMap[nextInfo.Name].Add(nextInfo);
            }

            // summarize by name
            List <WorkloadInfo> totalInfo = new List <WorkloadInfo>();

            foreach (var nextPersonInfoList in workloadMap.Values)
            {
                WorkloadInfo firstInfo = nextPersonInfoList.First();

                // to advoid the precision difference after summaried, we round two decimal before sum
                firstInfo.PayStaffMonth = Math.Round(firstInfo.PayStaffMonth, 2);

                // deduce money by late days (per month)
                // we escape the latedays property for absent days in summarizatioin
                if (firstInfo.LateTimes >= 3)
                {
                    firstInfo.LateTimes = (firstInfo.LateTimes + 2) / 3;
                }
                else
                {
                    // reset the late days
                    firstInfo.LateTimes = 0;
                }

                foreach (var nextPersonInfo in nextPersonInfoList)
                {
                    if (nextPersonInfo == firstInfo)
                    {
                        continue;
                    }
                    firstInfo.ActualShowDays += nextPersonInfo.ActualShowDays;
                    firstInfo.DueShowDays    += nextPersonInfo.DueShowDays;
                    if (nextPersonInfo.LateTimes >= 3)
                    {
                        firstInfo.LateTimes += ((nextPersonInfo.LateTimes + 2) / 3);
                    }
                    firstInfo.OTHours       += nextPersonInfo.OTHours;
                    firstInfo.PayStaffMonth += Math.Round(nextPersonInfo.PayStaffMonth, 2);
                }
                totalInfo.Add(firstInfo);
            }

            return(totalInfo);
        }
Esempio n. 2
0
        static void SetWorkloadInfo(WorkloadInfo workloadInfo, List <AttendanceInfo> attendanceInfoList)
        {
            double actualDays            = 0;
            int    lateTimes             = 0;
            int    leaveTimes            = 0;
            int    additionalRecordTimes = 0;
            int    OTHours = 0;

            foreach (var nextInfo in attendanceInfoList)
            {
                // OT hours
                OTHours += nextInfo.OTHours;

                // actural show days
                actualDays += nextInfo.WorkDay;

                // late times
                if (nextInfo.State == AttendanceState.Late)
                {
                    lateTimes++;
                }

                // leave times
                if (nextInfo.State == AttendanceState.Leave)
                {
                    leaveTimes++;
                }

                // additional record times
                if ((nextInfo.State == AttendanceState.AdditionalRecord) ||
                    (nextInfo.State == AttendanceState.AdditionalRecord_Ticket))
                {
                    additionalRecordTimes++;
                }
            }

            workloadInfo.ActualShowDays        = actualDays;
            workloadInfo.LateTimes             = lateTimes;
            workloadInfo.LeaveTimes            = leaveTimes;
            workloadInfo.AdditionalRecordTimes = additionalRecordTimes;
            workloadInfo.OTHours = OTHours;

            // pay staff month
            workloadInfo.PayStaffMonth = workloadInfo.ActualShowDays / (double)workloadInfo.DueShowDays;
        }
Esempio n. 3
0
        public static List <WorkloadInfo> GetWorklaodListPerMonth(List <AttendanceInfo> attendanceInfoList)
        {
            Dictionary <string, List <AttendanceInfo> > attendanceNameMap = new Dictionary <string, List <AttendanceInfo> >();

            // group by name
            foreach (var nextInfo in attendanceInfoList)
            {
                if (!attendanceNameMap.ContainsKey(nextInfo.Name))
                {
                    attendanceNameMap.Add(nextInfo.Name, new List <AttendanceInfo>());
                }
                attendanceNameMap[nextInfo.Name].Add(nextInfo);
            }

            List <WorkloadInfo> workloadInfoList = new List <WorkloadInfo>();

            foreach (var nextName in attendanceNameMap.Keys)
            {
                // group by month
                Dictionary <DateTime, List <AttendanceInfo> > monthlyMap = GroupByMonth(attendanceNameMap[nextName]);

                foreach (var nextMonth in monthlyMap.Keys)
                {
                    WorkloadInfo workloadInfo = new WorkloadInfo();
                    workloadInfo.Name        = nextName;
                    workloadInfo.Month       = nextMonth.Month;
                    workloadInfo.DueShowDays = CalcDueShowDays(nextMonth);

                    SetWorkloadInfo(workloadInfo, monthlyMap[nextMonth]);

                    workloadInfoList.Add(workloadInfo);
                }
            } // foreach (var nextName in nameMap.Keys)

            return(workloadInfoList);
        }