Exemplo n.º 1
0
        public void FillEmployeeWeeks(List <EmployeeWeek> weeks, DateTime beginDate, DateTime endDate,
                                      long[] emplIds, Dictionary <long, EmployeeWeek> dictWeek)
        {
            if (weeks != null && weeks.Count > 0)
            {
                List <EmployeeDayStatePlanning> daystates = GetEmployeesState(emplIds, beginDate, endDate);

                if (daystates != null)
                {
                    EmployeeWeek lastWeek = null;
                    EmployeeDay  day      = null;
                    foreach (EmployeeDayStatePlanning edsp in daystates)
                    {
                        if ((lastWeek == null) || (edsp.EmployeeID != lastWeek.EmployeeId))
                        {
                            lastWeek = null;
                            dictWeek.TryGetValue(edsp.EmployeeID, out lastWeek);
                        }

                        if (lastWeek != null)
                        {
                            day = lastWeek.GetDay(edsp.Date);
                            if (day != null)
                            {
                                EmployeeDayProcessor.AssignDay(edsp, day);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void FillEmployeeWeeks(List <EmployeeWeek> weeks, DateTime beginDate, DateTime endDate)
        {
            if (weeks != null && weeks.Count > 0)
            {
                Dictionary <long, EmployeeWeek> _diction = EmployeeWeekProcessor.GetDictionary(weeks);
                long[] ids = EmployeeWeekProcessor.GetEmployeeIds(weeks);

                List <EmployeeDayStateRecording> daystates = servicedao.GetEmployeesStates(ids, beginDate, endDate);

                if (daystates != null)
                {
                    EmployeeWeek lastWeek = null;
                    EmployeeDay  day      = null;
                    foreach (EmployeeDayStateRecording edsp in daystates)
                    {
                        if ((lastWeek == null) || (edsp.EmployeeID != lastWeek.EmployeeId))
                        {
                            lastWeek = null;
                            _diction.TryGetValue(edsp.EmployeeID, out lastWeek);
                        }

                        if (lastWeek != null)
                        {
                            day = lastWeek.GetDay(edsp.Date);
                            if (day != null)
                            {
                                EmployeeDayProcessor.AssignDay(edsp, day);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void BeforePrintRecordingTable(object sender, PrintEventArgs e)
        {
            _plannedDayView = _actualDayView = null;

            if (DataSource != null && ((IList)DataSource).Count > 0)
            {
                EmployeeWeek ew = GetCurrentEmployee();

                _plannedDayView = new RecordingDayView();
                _plannedDayView.RecordingDay = ew.GetDay(_recordingContext.ViewDate);

                _actualDayView = new RecordingDayView();
                EmployeeWeek emplWeek = _recordingContext.WorldActualState[ew.EmployeeId];
                if (emplWeek != null)
                {
                    _actualDayView.RecordingDay = emplWeek.GetDay(_recordingContext.ViewDate);
                }
            }
        }
Exemplo n.º 4
0
        private void CalculateWeeklyMessageOrSaldoWorkingModels(EmployeeWeek planningweek)
        {
            if (planningweek.IsValidWeek)
            {
                EmployeeDay          epday  = planningweek.GetDay(planningweek.EndDate);
                EmployeeWorkingModel entity = null;
                foreach (WorkingModelWrapperNew wrap in _weeklyMessagesModels)
                {
                    if (!planningweek.PlannedWeek)
                    {
                        if (!wrap.Model.UseInRecording)
                        {
                            continue;
                        }
                    }
                    if (!DateTimeHelper.IsIntersectInc(wrap.Model.BeginTime, wrap.Model.EndTime,
                                                       planningweek.BeginDate, planningweek.EndDate))
                    {
                        continue;
                    }

                    if (wrap.Validate(planningweek, planningweek.BeginDate))
                    {
                        if (wrap.IsMessageModel)
                        {
                            entity                = new EmployeeWorkingModel();
                            entity.EmployeeID     = epday.EmployeeId;
                            entity.Date           = epday.Date;
                            entity.WorkingModelID = wrap.Model.ID;


                            if (epday.WorkingModels == null)
                            {
                                epday.WorkingModels = new List <EmployeeWorkingModel>();
                            }
                            epday.WorkingModels.Add(entity);
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        public void FillEmployeeWeeks(List <EmployeeWeek> weeks, DateTime beginDate, DateTime endDate)
        {
            if (weeks != null && weeks.Count > 0)
            {
                List <long> lstIds = new List <long>(weeks.Count);
                Dictionary <long, EmployeeWeek> _diction = new Dictionary <long, EmployeeWeek>();
                foreach (EmployeeWeek epw in weeks)
                {
                    lstIds.Add(epw.EmployeeId);
                    _diction[epw.EmployeeId] = epw;
                }

                long[] ids = lstIds.ToArray();

                List <EmployeeDayStatePlanning> daystates = GetEmployeesState(ids, beginDate, endDate);

                if (daystates != null)
                {
                    EmployeeWeek lastWeek = null;
                    EmployeeDay  day      = null;
                    foreach (EmployeeDayStatePlanning edsp in daystates)
                    {
                        if ((lastWeek == null) || (edsp.EmployeeID != lastWeek.EmployeeId))
                        {
                            lastWeek = null;
                            _diction.TryGetValue(edsp.EmployeeID, out lastWeek);
                        }

                        if (lastWeek != null)
                        {
                            day = lastWeek.GetDay(edsp.Date);
                            if (day != null)
                            {
                                EmployeeDayProcessor.AssignDay(edsp, day);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
        private void CalculateWeeklyWorkingModels(EmployeeWeek planningweek)
        {
            Debug.Assert(planningweek != null);

            if (planningweek.IsValidWeek)
            {
                EmployeeDay          epday  = planningweek.GetDay(planningweek.EndDate);
                EmployeeWorkingModel entity = null;

                foreach (WorkingModelWrapperNew wrap in _weeklyModels)
                {
                    if (!planningweek.PlannedWeek)
                    {
                        if (!wrap.Model.UseInRecording)
                        {
                            continue;
                        }
                    }

                    if (!DateTimeHelper.IsIntersectInc(wrap.Model.BeginTime, wrap.Model.EndTime,
                                                       planningweek.BeginDate, planningweek.EndDate))
                    {
                        continue;
                    }

                    if (wrap.Validate(planningweek, planningweek.BeginDate))
                    {
                        entity                = new EmployeeWorkingModel();
                        entity.EmployeeID     = epday.EmployeeId;
                        entity.Date           = epday.Date;
                        entity.WorkingModelID = wrap.Model.ID;
                        if (!wrap.IsMessageModel)
                        {
                            entity.Hours            = wrap.GetModelValue;
                            entity.AdditionalCharge = wrap.Model.AddCharges;

                            if (wrap.Model.AddCharges)
                            {
                                epday.CountDailyAdditionalCharges += entity.Hours;
                            }
                            else
                            {
                                epday.CountDailyPlannedWorkingHours += entity.Hours;
                            }
                        }
                        //if (!wrap.IsMessageModel)
                        //{
                        //    int result = 0;
                        //    if (wrap.Model.AddValue != 0)
                        //    {
                        //        result += DateTimeHelper.RoundToQuoter((short)(60 * wrap.Model.AddValue));
                        //    }
                        //    if (wrap.Model.MultiplyValue != 0)
                        //    {
                        //        result += DateTimeHelper.RoundToQuoter((short)(wrap.Hours * wrap.Model.MultiplyValue - wrap.Hours));
                        //    }

                        //    if (wrap.Model.AddCharges)
                        //    {
                        //        entity.AdditionalCharge = true;
                        //        entity.Hours = result;
                        //        epday.CountDailyAdditionalCharges += result;

                        //    }
                        //    else
                        //    {
                        //        entity.AdditionalCharge = false;
                        //        entity.Hours = result;
                        //        epday.CountDailyPlannedWorkingHours += result;
                        //    }
                        //}
                        if (epday.WorkingModels == null)
                        {
                            epday.WorkingModels = new List <EmployeeWorkingModel>();
                        }
                        epday.WorkingModels.Add(entity);
                    }
                }
            }
        }
Exemplo n.º 7
0
        public void FillEmployeeWeeks(DateTime begin, DateTime end, bool bPlanning)
        {
            if (_listweeks == null || _listweeks.Count == 0)
            {
                return;
            }

            List <EmployeeTimeRange> lstRanges = new List <EmployeeTimeRange>();
            EmployeeTimeRange        range     = null;

            #region Load entities

            if (bPlanning)
            {
                List <WorkingTimePlanning> lstWorks =
                    EmployeeService.EmployeeTimeService.WorkingTimePlanningService.GetWorkingTimePlanningsByEmployeeIds(_employeeids, begin, end);
                List <AbsenceTimePlanning> lstAbsences =
                    EmployeeService.EmployeeTimeService.AbsenceTimePlanningService.GetAbsenceTimePlanningsByEmployeeIds(_employeeids, begin, end);

                if (lstWorks != null)
                {
                    foreach (WorkingTimePlanning entity in lstWorks)
                    {
                        lstRanges.Add(new EmployeeTimeRange(entity));
                    }
                }
                if (lstAbsences != null)
                {
                    foreach (AbsenceTimePlanning entity in lstAbsences)
                    {
                        lstRanges.Add(new EmployeeTimeRange(entity));
                    }
                }
            }
            else
            {
                List <WorkingTimeRecording> lstWorks =
                    EmployeeService.EmployeeTimeService.WorkingTimeRecordingService.GetWorkingTimeRecordingsByEmployeeIds(_employeeids, begin, end);
                List <AbsenceTimeRecording> lstAbsences =
                    EmployeeService.EmployeeTimeService.AbsenceTimeRecordingService.GetAbsenceTimeRecordingsByEmployeeIds(_employeeids, begin, end);
                if (lstWorks != null)
                {
                    foreach (WorkingTimeRecording entity in lstWorks)
                    {
                        lstRanges.Add(new EmployeeTimeRange(entity));
                    }
                }
                if (lstAbsences != null)
                {
                    foreach (AbsenceTimeRecording entity in lstAbsences)
                    {
                        lstRanges.Add(new EmployeeTimeRange(entity));
                    }
                }
            }

            #endregion

            lstRanges.Sort();

            if (lstRanges.Count > 0)
            {
                EmployeeWeek week    = null;
                EmployeeDay  emplday = null;
                for (int i = 0; i < lstRanges.Count; i++)
                {
                    range = lstRanges[i];
                    if (week == null || (week.EmployeeId != range.EmployeeID))
                    {
                        week = null;
                        _dictionWeek.TryGetValue(range.EmployeeID, out week);
                    }

                    if (week != null)
                    {
                        emplday = week.GetDay(range.Date);
                        if (emplday != null)
                        {
                            if (emplday.TimeList == null)
                            {
                                emplday.TimeList = new List <EmployeeTimeRange>();
                            }
                            emplday.TimeList.Add(range);
                        }
                    }
                }
            }
        }