Example #1
0
        public List <EmployeeWeek> FillPlanningEmployeeWeeks(long storeid, long worldid, DateTime aBegin, DateTime aEnd)
        {
            if (_listweeks != null && _listweeks.Count > 0)
            {
                FillEmployeeWeeks(aBegin, aEnd, true);
//                EmployeeTimeService timeService = EmployeeService.EmployeeTimeService as EmployeeTimeService;

//                timeService.FillEmployeeWeeks(_listweeks, _employeeids, _dictionWeek, aBegin, aEnd, true);

                if (LoadWeeks)
                {
                    EmployeeTimeService timeService = EmployeeService.EmployeeTimeService as EmployeeTimeService;

                    EmployeeWeekTimePlanningService weekService = timeService.EmployeeWeekTimePlanningService as EmployeeWeekTimePlanningService;

                    List <EmployeeWeekTimePlanning> planningweeks = weekService.GetEmployeesWeekState(_employeeids, aBegin, aEnd);

                    if (planningweeks != null && planningweeks.Count > 0)
                    {
                        EmployeeWeek emplweek = null;
                        foreach (EmployeeWeekTimePlanning week in planningweeks)
                        {
                            if (_dictionWeek.TryGetValue(week.EmployeeID, out emplweek))
                            {
                                emplweek.NewWeek = false;

                                EmployeeWeekProcessor.Assign(week, emplweek);
                            }
                        }
                    }
                }
            }
            return(_listweeks);
        }
Example #2
0
        public void SaveEmployeeWeek(EmployeeWeek week)
        {
            if (week != null)
            {
                DeleteAbsenceTimeRange(week.EmployeeId, week.BeginDate, week.EndDate);
                List <AbsenceTimeRecording> lst    = new List <AbsenceTimeRecording>();
                AbsenceTimeRecording        entity = null;
                foreach (EmployeeDay ed in week.DaysList)
                {
                    if (ed.TimeList != null)
                    {
                        foreach (EmployeeTimeRange range in ed.TimeList)
                        {
                            if (range.AbsenceID > 0)
                            {
                                entity = new AbsenceTimeRecording();
                                range.AssignTo(entity);
                                lst.Add(entity);
                            }
                        }
                    }
                }

                if (lst.Count > 0)
                {
                    foreach (AbsenceTimeRecording entity1 in lst)
                    {
                        SaveOrUpdate(entity1);
                    }
                }
            }
        }
Example #3
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);
                            }
                        }
                    }
                }
            }
        }
Example #4
0
 public void SaveEmployeeWeek(EmployeeWeek planningweek)
 {
     if (planningweek != null)
     {
         ServiceDao.SaveEmployeeWeek(planningweek);
     }
 }
Example #5
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);
                            }
                        }
                    }
                }
            }
        }
Example #6
0
        public RecordingDayRow(EmployeeWeek week, RecordingDayView dayview,
                               EmployeeWeek actualweek, RecordingDayView actualdayview, long orderHwgr)
        {
            _plannedWeek    = week;
            _plannedDayView = dayview;

            _actualWeek    = actualweek;
            _actualDayView = actualdayview;

            if (_plannedDayView != null)
            {
                _plannedDay = _plannedDayView.RecordingDay;
            }

            if (_actualDayView != null)
            {
                _actualDay = _actualDayView.RecordingDay;
            }

            if (_plannedWeek.FullName != null)
            {
                _fullname = _plannedWeek.FullName;
            }

            _OrderHWGR = orderHwgr;
        }
Example #7
0
 public void CalculateNew(EmployeeWeek planningweek, bool bPlanned)
 {
     //planningweek.CalculateBeforeWorkingModels ();
     //CalculateDailyWorkingModels(daysInfo, planningweek);
     //CalculateWeeklyWorkingModels(daysInfo, planningweek);
     //planningweek.CalculateAfterWorkingModels();
     //CalculateWeeklyMessageOrSaldoWorkingModels(daysInfo, planningweek);
 }
Example #8
0
 public void FillEmployeeWeek(EmployeeWeek entity)
 {
     if (entity != null && entity.DaysList != null)
     {
         foreach (EmployeeDay day in entity.DaysList)
         {
             FillEmployeeDay(day);
         }
     }
 }
Example #9
0
        public EmployeeWeek GetEmployeeWeek(long emplid, DateTime beginDate, DateTime endDate)
        {
            EmployeeWeek week = null;
            EmployeeWeekTimeRecording entity = GetEmployeeWeekState(emplid, beginDate, endDate);

            if (entity != null)
            {
                week = new EmployeeWeek(entity);
            }
            return(week);
        }
Example #10
0
        public void CalculateNew(EmployeeWeek planningweek, bool bPlanned)
        {
            if (_lunchManager != null)
            {
                _lunchManager.Process(planningweek);
            }

            planningweek.CalculateBeforeWorkingModels();
            CalculateDailyWorkingModels(planningweek);
            CalculateWeeklyWorkingModels(planningweek);
            planningweek.CalculateAfterWorkingModels();
            CalculateWeeklyMessageOrSaldoWorkingModels(planningweek);
        }
        public void SaveEmployeeWorkingModel(EmployeeWeek week)
        {
            List<EmployeeWorkingModel> lst = EmployeeWeekProcessor.GetWorkingModels(week);

            List<EmployeeRecordingWorkingModel> lstEntities = new List<EmployeeRecordingWorkingModel>(lst.Count);
            EmployeeRecordingWorkingModel entity = null;
            foreach (EmployeeWorkingModel model in lst)
            {
                entity = new EmployeeRecordingWorkingModel();
                model.AssignTo(entity);
                lstEntities.Add(entity);
            }


            SaveEmployeeWorkingModel(week.EmployeeId, lstEntities, week.BeginDate, week.EndDate);
        }
Example #12
0
        public void Process(EmployeeWeek week)
        {
            foreach (EmployeeDay day in week.DaysList)
            {
                day.CountDailyWorkingHours        = 0;
                day.CountDailyPlannedWorkingHours = 0;
                day.CountDailyAdditionalCharges   = 0;
                //day.CountUnitsPerDay = 0;



                if (day.TimeList != null && day.TimeList.Count > 0)
                {
                    _ApplyLunchBrakeModels(day, true);

                    EmployeeTimeRange timerange;
                    for (int i = 0; i < day.TimeList.Count; i++)
                    {
                        timerange = day.TimeList[i];
                        if (timerange.IsWorkingRange)
                        {
                            day.CountDailyWorkingHours += timerange.Time;
                            //day.CountUnitsPerDay += timerange.GetUnits();
                        }
                    }

                    _ApplyLunchBrakeModels(day, false);

                    day.CountDailyPlannedWorkingHours = day.CountDailyWorkingHours;

                    for (int i = 0; i < day.TimeList.Count; i++)
                    {
                        timerange = day.TimeList[i];
                        if (!timerange.IsWorkingRange)
                        {
                            if (timerange.Absence != null && timerange.Absence.UseInCalck)
                            {
                                day.CountDailyPlannedWorkingHours += timerange.End - timerange.Begin;
                            }
                        }
                    }
                }
            }
        }
Example #13
0
        public List <EmployeeWeek> GetEmployeesWeekStates(long[] emplids, DateTime beginDate, DateTime endDate)
        {
            List <EmployeeWeek> weeks = null;
            EmployeeWeek        week  = null;

            List <EmployeeWeekTimeRecording> entities = GetEmployeesWeekState(emplids, beginDate, endDate);

            if (entities != null)
            {
                weeks = new List <EmployeeWeek>();
                foreach (EmployeeWeekTimeRecording entity in entities)
                {
                    week = new EmployeeWeek(entity);
                    weeks.Add(week);//EmployeeWeekProcessor.Assign(entity, week));
                }
            }

            return(weeks);
        }
        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);
                }
            }
        }
Example #15
0
        public void SaveEmployeeWeek(EmployeeWeek planningweek)
        {
            if (planningweek == null)
            {
                throw new ArgumentNullException();
            }

            EmployeeWeekTimeRecording entity = GetEmployeeWeekState(planningweek.EmployeeId, planningweek.BeginDate, planningweek.EndDate);

            if (entity == null)
            {
                entity = new EmployeeWeekTimeRecording();
            }

            EmployeeWeekProcessor.AssignTo(entity, planningweek);

            SaveOrUpdate(entity);

            //planningweek.ID = entity.ID;
        }
Example #16
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);
                        }
                    }
                }
            }
        }
Example #17
0
        public void UpdateSaldoAfterPlanning(EmployeeWeek week)
        {
            EmployeeWeekTimePlanning entity = GetByDate(week.EmployeeId, week.BeginDate);

            if (entity == null)
            {
                entity = new EmployeeWeekTimePlanning();
                EmployeeWeekProcessor.AssignTo(entity, week);
                UpdateEntity(entity);
            }
            else
            {
                if (EmployeeWeekProcessor.IsModified(entity, week))
                {
                    EmployeeWeekProcessor.AssignTo(entity, week);
                    UpdateEntity(entity);
                }
            }

            UpdateSaldoFrom(week.EmployeeId, DateTimeHelper.GetNextMonday(week.BeginDate), week.Saldo);
        }
Example #18
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);
                            }
                        }
                    }
                }
            }
        }
Example #19
0
 private void FillEmployeeDayByStoreDay(EmployeeWeek emplweek)
 {
     if (emplweek != null)
     {
         StoreDaysList dayslist = null;
         foreach (EmployeeDay day in emplweek.DaysList)
         {
             if (day.HasRelation)
             {
                 if (!m_dictionDays.TryGetValue(day.StoreId, out dayslist))
                 {
                     dayslist = EmployeeService.StoreService.GetStoreDays(day.StoreId, emplweek.BeginDate, emplweek.EndDate.AddDays(356));
                     m_dictionDays[day.StoreId] = dayslist;
                 }
                 if (m_dictionDays.TryGetValue(day.StoreId, out dayslist))
                 {
                     day.StoreDay = dayslist[day.Date];
                 }
             }
         }
     }
 }
Example #20
0
        public virtual void FillLastSaldo(Dictionary <long, EmployeeWeek> dict, long[] ids, DateTime aBeginWeek, bool bPlanning)
        {
            if (ids == null || ids.Length == 0)
            {
                return;
            }

            long[][] result = Service.EmployeeTimeSaldoGet(ids, (bPlanning) ? EmployeeTimeSaldoType.Planning : EmployeeTimeSaldoType.Recording, aBeginWeek);

            long         id     = 0;
            long         value  = 0;
            EmployeeWeek entity = null;

            foreach (long[] data in result)
            {
                id    = (long)data[0];
                value = (long)data[1];
                if (dict.TryGetValue(id, out entity))
                {
                    entity.LastSaldo = (int)value;
                }
            }
        }
Example #21
0
        public List <EmployeeWeek> FillActualEmployeeWeeks(long storeid, long worldid, DateTime aBegin, DateTime aEnd)
        {
            if (_listweeks != null && _listweeks.Count > 0)
            {
                //EmployeeTimeService timeService = EmployeeService.EmployeeTimeService as EmployeeTimeService;
                //timeService.FillEmployeeWeeks(_listweeks, aBegin, aEnd, false);

                FillEmployeeWeeks(aBegin, aEnd, false);

                if (LoadWeeks)
                {
                    EmployeeTimeService timeService = EmployeeService.EmployeeTimeService as EmployeeTimeService;

                    EmployeeWeekTimeRecordingService weekService = timeService.EmployeeWeekTimeRecordingService as EmployeeWeekTimeRecordingService;

                    List <EmployeeWeekTimeRecording> weeks = weekService.GetEmployeesWeekState(_employeeids, aBegin, aEnd);

                    if (weeks != null && weeks.Count > 0)
                    {
                        EmployeeWeek emplweek = null;
                        foreach (EmployeeWeekTimeRecording week in weeks)
                        {
                            if (_dictionWeek.TryGetValue(week.EmployeeID, out emplweek))
                            {
                                emplweek.NewWeek = false;
                                //emplweek.CustomEdit = week.CustomEdit;
                                //if (week.CustomEdit)
                                //    emplweek.Saldo = week.Saldo;

                                EmployeeWeekProcessor.Assign(week, emplweek);
                            }
                        }
                    }
                }
            }
            return(_listweeks);
        }
Example #22
0
        public void FillEmployeeWeeks(List <EmployeeWeek> planningweeks, long[] emplIds, Dictionary <long, EmployeeWeek> dictWeek)
        {
            if (planningweeks == null || planningweeks.Count == 0)
            {
                return;
            }

            List <EmployeeWeekTimePlanning> lst = GetEmployeesWeekState(emplIds, planningweeks[0].BeginDate, planningweeks[0].EndDate);

            if (lst == null || lst.Count == 0)
            {
                return;
            }

            EmployeeWeek ew = null;

            foreach (EmployeeWeekTimePlanning ewtp in lst)
            {
                if (dictWeek.TryGetValue(ewtp.EmployeeID, out ew))
                {
                    EmployeeWeekProcessor.Assign(ewtp, ew);
                }
            }
        }
Example #23
0
        public void SaveEmployeeWeek(EmployeeWeek planningweek)
        {
            if (planningweek == null)
            {
                throw new ArgumentNullException();
            }

            EmployeeWeekTimePlanning entity = GetEmployeeWeekState(planningweek.EmployeeId, planningweek.BeginDate, planningweek.EndDate);

            if (entity == null)
            {
                entity = new EmployeeWeekTimePlanning();
            }

            EmployeeWeekProcessor.AssignTo(entity, planningweek);

            SaveOrUpdate(entity);

            //planningweek.ID = entity.ID;
            if (DateTimeHelper.Between(DateTime.Today, planningweek.BeginDate, planningweek.EndDate))
            {
                UpdatePlanningSaldo(entity);
            }
        }
Example #24
0
 public void SaveEmployeeWeek(EmployeeWeek week)
 {
     workingTimeRecordingDao.SaveEmployeeWeek(week);
 }
Example #25
0
 public void SaveEmployeeWeek(EmployeeWeek week)
 {
     workingTimePlanningDao.SaveEmployeeWeek(week);
 }
Example #26
0
 public void SaveEmployeeWeek(EmployeeWeek week)
 {
     absenceTimeRecordingDao.SaveEmployeeWeek(week);
 }
 public void SaveEmployeeWeek(EmployeeWeek week)
 {
 }
Example #28
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);
                    }
                }
            }
        }
Example #29
0
        private void CalculateDailyWorkingModels(EmployeeWeek planningweek)
        {
            #region daily calculation

            Debug.Assert(planningweek != null);

            if (planningweek.IsValidWeek)
            {
                EmployeeWorkingModel entity = null;
                foreach (EmployeeDay epd in planningweek.DaysList)
                {
                    epd.CountDailyAdditionalCharges = 0;
                    epd.WorkingModels = null;

                    if (!epd.IsValidDay)
                    {
                        continue;
                    }

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

                        if (!DateTimeHelper.Between(epd.Date, wrap.Model.BeginTime, wrap.Model.EndTime))
                        {
                            continue;
                        }

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

                                if (wrap.Model.AddCharges)
                                {
                                    epd.CountDailyAdditionalCharges += entity.Hours;
                                }
                                else
                                {
                                    epd.CountDailyPlannedWorkingHours += entity.Hours;
                                }
                                //if (wrap.Model.AddCharges)
                                //{
                                //    entity.AdditionalCharge = true;
                                //    if (wrap.Model.AddValue != 0)
                                //    {
                                //        entity.Hours += DateTimeHelper.RoundToQuoter((short)(60 * wrap.Model.AddValue));
                                //        epd.CountDailyAdditionalCharges += DateTimeHelper.RoundToQuoter((short)(60 * wrap.Model.AddValue));
                                //    }
                                //    if (wrap.Model.MultiplyValue != 0)
                                //    {
                                //        entity.Hours = DateTimeHelper.RoundToQuoter((short)(wrap.Hours * wrap.Model.MultiplyValue - wrap.Hours));
                                //        epd.CountDailyAdditionalCharges += DateTimeHelper.RoundToQuoter((short)(wrap.Hours * wrap.Model.MultiplyValue - wrap.Hours));
                                //    }
                                //}
                                //else
                                //{
                                //    entity.AdditionalCharge = false;
                                //    if (wrap.Model.AddValue != 0)
                                //    {
                                //        entity.Hours += DateTimeHelper.RoundToQuoter((short)(60 * wrap.Model.AddValue));
                                //        epd.CountDailyPlannedWorkingHours += DateTimeHelper.RoundToQuoter((short)(60 * wrap.Model.AddValue));
                                //    }
                                //    if (wrap.Model.MultiplyValue != 0)
                                //    {
                                //        entity.Hours += DateTimeHelper.RoundToQuoter((short)(wrap.Hours * wrap.Model.MultiplyValue - wrap.Hours));
                                //        epd.CountDailyPlannedWorkingHours += DateTimeHelper.RoundToQuoter((short)(wrap.Hours * wrap.Model.MultiplyValue - wrap.Hours));
                                //    }

                                //}
                            }

                            if (epd.WorkingModels == null)
                            {
                                epd.WorkingModels = new List <EmployeeWorkingModel>();
                            }
                            epd.WorkingModels.Add(entity);
                        }
                    }
                }
            }
            #endregion
        }
Example #30
0
        public List <EmployeeWeek> BuildEmployeeWeeks(long storeid, long worldid, DateTime aBegin, DateTime aEnd, bool bPlanning)
        {
            Store store = ServerEnvironment.StoreService.FindById(storeid);

            if (store == null)
            {
                return(null);
            }
            long countryid = store.CountryID;
            bool IsAustria = store.CountryID == ServerEnvironment.CountryService.AustriaCountryID;


            // list of all employee for storeid and world
            IList employees = EmployeeService.EmployeeDao.GetPlanningEmployeesByWorld(storeid, worldid, aBegin, aEnd);

            if (employees == null && employees.Count == 0)
            {
                return(null);
            }

            long[] ids = new long[employees.Count];
            for (int i = 0; i < employees.Count; i++)
            {
                ids[i] = (employees[i] as Employee).ID;
            }

            EmployeeRelationService relationService = EmployeeService.EmployeeRelationService as EmployeeRelationService;

            List <EmployeeRelation> emplRelations = relationService.GetEmployeeRelationsByEmployeeIds(ids, aBegin, aEnd);

            //CountryStoreWorldManager swmanager = new CountryStoreWorldManager(EmployeeService.StoreWorldService);
            //swmanager.StoreId = storeid;
            if (swCountryManager == null)
            {
                //long countryid = EmployeeService.StoreService.GetCountryByStoreId(storeid);
                swCountryManager           = new CountryStoreWorldManager(EmployeeService.StoreWorldService);
                swCountryManager.CountryId = countryid;
            }

            List <EmployeeLongTimeAbsence> emplLongTimeAbsences =
                EmployeeService.EmployeeLongTimeAbsenceService.GetEmployeesHasLongTimeAbsence(ids, aBegin, aEnd);

            EmployeeLongTimeAbsenceIndexer absenceIndexer = new EmployeeLongTimeAbsenceIndexer(emplLongTimeAbsences);

            DictionListEmployeeRelations relationIndexer = new DictionListEmployeeRelations(emplRelations);

            List <EmployeeContract> contracts = EmployeeService.EmployeeContractService.GetEmployeeContracts(ids, aBegin, aEnd);

            ContractIndexer = new DictionListEmployeesContract(contracts);


            // applly relations
            EmployeeRelation relationWorld     = null;
            bool             bExistsRelation   = false;
            bool             bExistsContract   = false;
            bool             bNotExistsAbsence = true;

            _listweeks = new List <EmployeeWeek>();
            EmployeeWeek emplWeek = null;


            foreach (Employee empl in employees)
            {
                emplWeek           = new EmployeeWeek(empl.ID, empl.FullName, aBegin, aEnd, empl.OrderHwgrID.HasValue ? empl.OrderHwgrID.Value : 0);
                emplWeek.LastSaldo = (int)Math.Round(empl.BalanceHours);
                bExistsRelation    = false;

                foreach (EmployeeDay d in emplWeek.DaysList)
                {
                    relationWorld = relationIndexer.GetRelationEntity(empl.ID, d.Date);
                    if (relationWorld != null)
                    {
                        d.StoreWorldId = swCountryManager.GetStoreWorldIdByStoreAndWorldId(relationWorld.StoreID, relationWorld.WorldID.Value);
                        d.StoreId      = relationWorld.StoreID;
                    }

                    bExistsRelation |= d.HasRelation;
                }
                if (bExistsRelation)
                {
                    bExistsContract = ContractIndexer.FillEmployeeWeek(emplWeek);
                    if (bExistsContract)
                    {
                        bNotExistsAbsence = absenceIndexer.FillEmployeeWeek(emplWeek);

                        if (bNotExistsAbsence)
                        {
                            _listweeks.Add(emplWeek);
                        }
                    }
                }
            }

            FillEmployeeDayByStoreDay(storeid, aBegin, aEnd);

            _dictionWeek = EmployeeWeekProcessor.GetDictionary(_listweeks);
            _employeeids = EmployeeWeekProcessor.GetEmployeeIds(_listweeks);


            if (bPlanning)
            {
                FillPlanningEmployeeWeeks(storeid, worldid, aBegin, aEnd);
            }
            else
            {
                FillActualEmployeeWeeks(storeid, worldid, aBegin, aEnd);
            }

            //LastSaldoBuilder saldoBuilder = new LastSaldoBuilder();
            LastSaldoBuilder saldoBuilder = (IsAustria) ? new LastSaldoBuilderAustria() : new LastSaldoBuilder();



            saldoBuilder.FillLastSaldo(_dictionWeek, _employeeids, aBegin, bPlanning);

            EmployeeMonthWorkingTime monthData = new EmployeeMonthWorkingTime(EmployeeService.EmployeeTimeService as EmployeeTimeService);

            monthData.IsPlanning    = bPlanning;
            monthData.CurrentMonday = aBegin;
            CacheEmployeesAllIn managerAllIn = new CacheEmployeesAllIn();

            managerAllIn.LoadByStoreRelation(storeid);

            foreach (EmployeeWeek ew in _listweeks)
            {
                ew.WorkingTimeByMonth = monthData.GetMonthWorkingTime(ew.EmployeeId);
                ew.CountSaturday      = (byte)monthData.CountSaturday;
                ew.CountSunday        = (byte)monthData.CountSunday;

                ew.WorkingDaysBefore = (byte)monthData.WorkingDaysBefore;
                ew.WorkingDaysAfter  = (byte)monthData.WorkingDaysAfter;
                ew.AllIn             = managerAllIn.GetAllIn(ew.EmployeeId, aBegin, aEnd);
            }

            return(_listweeks);
        }