public void Calculate(double avg_day_a_week, DictionListEmployeesContract contracts, List<AbsenceTimePlanning> absence_times)
        {
            foreach (AbsenceTimePlanning absence_time in absence_times)
            {
                if (absence_time.Absence == null)
                    throw new ArgumentNullException();

                if (absence_time.Absence.AbsenceTypeID == AbsenceType.Holiday)
                {
                    absence_time.ApplyTime(contracts.GetContractHours(absence_time.EmployeeID, absence_time.Date), avg_day_a_week);
                }
            }
        }
        public void Calculate(double avg_day_a_week, DictionListEmployeesContract contracts, List <AbsenceTimePlanning> absence_times)
        {
            foreach (AbsenceTimePlanning absence_time in absence_times)
            {
                if (absence_time.Absence == null)
                {
                    throw new ArgumentNullException();
                }

                if (absence_time.Absence.AbsenceTypeID == AbsenceType.Holiday)
                {
                    absence_time.ApplyTime(contracts.GetContractHours(absence_time.EmployeeID, absence_time.Date), avg_day_a_week);
                }
            }
        }
        public void Calculate(long storeid, DateTime aBegin, List<EmployeePlanningWeek> weeks)
        {
            if (weeks != null && weeks.Count > 0)
            {
                // build list of absences
                List<AbsenceTimePlanning> lst_Absences = new List<AbsenceTimePlanning>();
                foreach (EmployeePlanningWeek week in weeks)
                {
                    foreach (EmployeePlanningDay day in week.Days.Values)
                    {
                        if (day.AbsenceTimeList != null && day.AbsenceTimeList.Count > 0)
                        {
                            foreach (AbsenceTimePlanning absence_time in day.AbsenceTimeList)
                            {
                                lst_Absences.Add(absence_time);
                            }
                        }
                    }
                }
                // if exists absence times
                if (lst_Absences.Count > 0)
                {
                    AbsenceManager absencemanager = new AbsenceManager(ServerEnvironment.AbsenceService);
                    int year = DateTimeHelper.GetYearByDate(aBegin);
                    long countryid = ServerEnvironment.StoreService.GetCountryByStoreId(storeid);
                    absencemanager.CountryId = countryid;
                    // fill times by absence entity
                    absencemanager.FillAbsencePlanningTimes(lst_Absences);
                    double avg_day_a_week = ServerEnvironment.AvgWorkingDaysInWeekService.GetAvgWorkingDaysInWeekByStore(storeid, year);

                    long[] ids = new long[weeks.Count];
                    for (int i = 0; i < weeks.Count; i++)
                    {
                        ids[i] = weeks[i].EmployeeId;
                    }
                    List<EmployeeContract> lst =
                        ServerEnvironment.EmployeeContractService.GetEmployeeContracts(ids, aBegin, aBegin.AddDays(7));

                    DictionListEmployeesContract indexer = new DictionListEmployeesContract(lst);

                    Calculate(avg_day_a_week, indexer, lst_Absences);
                }

            }
        }
        public void Calculate(long storeid, DateTime aBegin, List <EmployeePlanningWeek> weeks)
        {
            if (weeks != null && weeks.Count > 0)
            {
                // build list of absences
                List <AbsenceTimePlanning> lst_Absences = new List <AbsenceTimePlanning>();
                foreach (EmployeePlanningWeek week in weeks)
                {
                    foreach (EmployeePlanningDay day in week.Days.Values)
                    {
                        if (day.AbsenceTimeList != null && day.AbsenceTimeList.Count > 0)
                        {
                            foreach (AbsenceTimePlanning absence_time in day.AbsenceTimeList)
                            {
                                lst_Absences.Add(absence_time);
                            }
                        }
                    }
                }
                // if exists absence times
                if (lst_Absences.Count > 0)
                {
                    AbsenceManager absencemanager = new AbsenceManager(ServerEnvironment.AbsenceService);
                    int            year           = DateTimeHelper.GetYearByDate(aBegin);
                    long           countryid      = ServerEnvironment.StoreService.GetCountryByStoreId(storeid);
                    absencemanager.CountryId = countryid;
                    // fill times by absence entity
                    absencemanager.FillAbsencePlanningTimes(lst_Absences);
                    double avg_day_a_week = ServerEnvironment.AvgWorkingDaysInWeekService.GetAvgWorkingDaysInWeekByStore(storeid, year);

                    long[] ids = new long[weeks.Count];
                    for (int i = 0; i < weeks.Count; i++)
                    {
                        ids[i] = weeks[i].EmployeeId;
                    }
                    List <EmployeeContract> lst =
                        ServerEnvironment.EmployeeContractService.GetEmployeeContracts(ids, aBegin, aBegin.AddDays(7));

                    DictionListEmployeesContract indexer = new DictionListEmployeesContract(lst);

                    Calculate(avg_day_a_week, indexer, lst_Absences);
                }
            }
        }
Beispiel #5
0
        public void RecalculateFrom(DateTime date)
        {
            DateTime monday     = DateTimeHelper.GetMonday(date);
            DateTime PrevMonday = monday.AddDays(-7);

            if (Relations == null)
            {
                Relations = new DictionListEmployeeRelations(ServerEnvironment.EmployeeRelationService.GetEmployeeRelations(Employee.ID));
            }
            if (Contracts == null)
            {
                Contracts = new DictionListEmployeesContract(ServerEnvironment.EmployeeContractService.GetEmployeeContracts(Employee.ID));
            }

            //LongAbsences = new EmployeeLongTimeAbsenceIndexer(ServerEnvironment.EmployeeLongTimeAbsenceService, Employee.ID);
            if (AllInManagers == null)
            {
                AllInManagers = new CacheEmployeesAllIn(Employee.ID);
            }
            if (RecordingWeeks == null)
            {
                RecordingWeeks = new SrvEmployeeWeekRecordingList();

                RecordingWeeks.InitList(Employee.ID, PrevMonday);
            }


            if (PlanningWeeks == null)
            {
                PlanningWeeks = new SrvEmployeeWeekPlanningList(Employee.ID, PrevMonday);
            }
            PlanningWeeks.BzEmployee     = this;
            PlanningWeeks.AllInManager   = AllInManagers;
            PlanningWeeks.Contracts      = Contracts;
            PlanningWeeks.RecordingWeeks = RecordingWeeks;

            PlanningWeeks.RecalculateAfterImport(monday);
        }
Beispiel #6
0
        private void ProcessQuery(AbsencePlanningQuery query)
        {
            gcAbsencePlanning.DataSource = null;
            if (query == null) return;

            if (_absencemanager == null) return;

            if (query.Plannings != null && query.Plannings.Count > 0)
                _absencemanager.FillAbsencePlanningTimes(query.Plannings);

            if (query.Recordings != null && query.Recordings.Count > 0)
                _absencemanager.FillAbsenceRecordingTimes(query.Recordings);

            if (query.Longabsences != null && query.Longabsences.Count > 0)
                _longabsencesmanager.FillEmployeelongAbsences(query.Longabsences);

            

            ShowHideColumnForAustria();
            DictionListEmployeesContract c_indexer = null;
            if (query.Contracts != null)
            {
                c_indexer = new DictionListEmployeesContract(query.Contracts);
            }
            DictionListEmployeeRelations r_indexer = null;
            if (query.Relations != null)
            {
                r_indexer = new DictionListEmployeeRelations(query.Relations);
            }

            List<long> ids = new List<long>();

            if (query.Plannings != null)
            {
                foreach (AbsenceTimePlanning a in query.Plannings)
                    ids.Add(a.ID);
            }

            ids.Sort();
            _ids_absences_from_server = ids.ToArray();

            Dictionary<long, BzEmployeeHoliday> _index = new Dictionary<long, BzEmployeeHoliday>();
            if (query._holidays != null)
            {
                foreach (BzEmployeeHoliday e in query._holidays)
                    _index[e.EmployeeId] = e;

                List<EmployeeRelation> relations = null;
                List<EmployeeContract> contracts = null;
                foreach (BzEmployeeHoliday e in query._holidays)
                {
                    e.AvgDayInWeek = query.AvgDaysPerWeek;
                    e.IsAustria = IsAustria;
                    e.HwgrName = GetHwgrName(e.HwgrId);
                    if (r_indexer != null)
                        relations = r_indexer[e.EmployeeId];
                    if (c_indexer != null)
                        contracts = c_indexer[e.EmployeeId];
                    if (relations != null)
                        e.AddRelation(relations);
                    if (contracts != null)
                        e.AddContract(contracts);

                    if (query.Plannings != null)
                    {
                        foreach (AbsenceTimePlanning a in query.Plannings)
                        {
                            if (a.EmployeeID == e.EmployeeId)
                                e.AddAbsences(a);
                        }
                    }
                    if (query.Recordings != null)
                    {
                        foreach (AbsenceTimeRecording a in query.Recordings)
                        {
                            if (a.EmployeeID == e.EmployeeId)
                                e.AddAbsences(a);
                        }
                    }

                    if (query.Longabsences != null)
                    {
                        foreach (EmployeeLongTimeAbsence a in query.Longabsences)
                        {
                            if (a.EmployeeID == e.EmployeeId)
                            {
                                e.AddLongAbsence(a);
                            }
                        }
                    }
                    e.BuildWeeks();

                    if (_ListStoreToWorld != null)
                    {
                        foreach (StoreToWorld sw in _ListStoreToWorld)
                        {
                            if (sw == _emptyworld)// all worlds
                            {
                                continue;
                            }
                            if (e.Relations != null && e.Relations.IsExistsWorldAssignment(sw))
                            {
                                if (!_indexEmployeeByWorld.ContainsKey(sw.ID))
                                {
                                    _indexEmployeeByWorld[sw.ID] = new BindingList<BzEmployeeHoliday>();
                                }
                                _indexEmployeeByWorld[sw.ID].Add(e);
                            }
                        }

                        
                    }
                }
                _EmployeesList = null;
                _EmployeesList = new BindingList<BzEmployeeHoliday>(query._holidays);

                _indexEmployeeByWorld[_emptyworld.ID] = _EmployeesList;

            }



        }
Beispiel #7
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);
        }
Beispiel #8
0
        //////////////////////////////////////////////////////////////////////////////////////

        public EmployeeWeek BuildEmployeeWeek(long emplid, DateTime aBeginWeek)
        {
            if (aBeginWeek.DayOfWeek != DayOfWeek.Monday)
            {
                throw new ArgumentException();
            }

            if (emplid <= 0)
            {
                throw new ArgumentException();
            }


            Employee empl = EmployeeService.FindById(emplid);

            if (empl == null)
            {
                throw new ArgumentNullException();
            }

            long[]   ids      = new long[] { emplid };
            DateTime aEndWeek = DateTimeHelper.GetSunday(aBeginWeek);
            EmployeeRelationService        relationService      = EmployeeService.EmployeeRelationService as EmployeeRelationService;
            List <EmployeeLongTimeAbsence> emplLongTimeAbsences =
                EmployeeService.EmployeeLongTimeAbsenceService.GetEmployeesHasLongTimeAbsence(ids, aBeginWeek, aEndWeek);
            EmployeeLongTimeAbsenceIndexer absenceIndexer = new EmployeeLongTimeAbsenceIndexer(emplLongTimeAbsences);

            List <EmployeeRelation>      emplRelations   = relationService.GetEmployeeRelationsByEmployeeIds(ids, aBeginWeek, aEndWeek);
            DictionListEmployeeRelations relationIndexer = new DictionListEmployeeRelations(emplRelations);

            List <EmployeeContract>      contracts       = EmployeeService.EmployeeContractService.GetEmployeeContracts(ids, aBeginWeek, aEndWeek);
            DictionListEmployeesContract contractIndexer = new DictionListEmployeesContract(contracts);

            EmployeeWeek emplWeek = new EmployeeWeek(emplid, "", aBeginWeek, aEndWeek, empl.OrderHwgrID.HasValue ? empl.OrderHwgrID.Value : 0);


            EmployeeRelation relationWorld     = null;
            bool             bExistsRelation   = false;
            bool             bExistsContract   = false;
            bool             bNotExistsAbsence = true;

            if (swCountryManager == null)
            {
                long countryid = EmployeeService.StoreService.GetCountryByStoreId(empl.MainStoreID);
                swCountryManager           = new CountryStoreWorldManager(EmployeeService.StoreWorldService);
                swCountryManager.CountryId = countryid;
            }

            bExistsContract = contractIndexer.FillEmployeeWeek(emplWeek);
            if (bExistsContract)
            {
                bNotExistsAbsence = absenceIndexer.FillEmployeeWeek(emplWeek);
                if (bNotExistsAbsence)
                {
                    foreach (EmployeeDay d in emplWeek.DaysList)
                    {
                        relationWorld = relationIndexer.GetRelationEntity(emplid, d.Date);
                        if (relationWorld != null)
                        {
                            d.StoreWorldId = swCountryManager.GetStoreWorldIdByStoreAndWorldId(relationWorld.StoreID, relationWorld.WorldID.Value);
                            d.StoreId      = relationWorld.StoreID;
                        }

                        bExistsRelation |= d.HasRelation;
                    }
                }
            }
            if (!bExistsContract || !bExistsRelation || !bNotExistsAbsence)
            {
                emplWeek = null;
            }

            return(emplWeek);
        }
Beispiel #9
0
        //////////////////////////////////////////////////////////////////////////////////////
        public EmployeeWeek BuildEmployeeWeek(long emplid, DateTime aBeginWeek)
        {
            if (aBeginWeek.DayOfWeek != DayOfWeek.Monday)
                throw new ArgumentException();

            if (emplid <= 0)
                throw new ArgumentException();

            Employee empl = EmployeeService.FindById(emplid);

            if (empl == null)
                throw new ArgumentNullException();

            long[] ids = new long[] { emplid };
            DateTime aEndWeek = DateTimeHelper.GetSunday(aBeginWeek);
            EmployeeRelationService relationService = EmployeeService.EmployeeRelationService as EmployeeRelationService;
            List<EmployeeLongTimeAbsence> emplLongTimeAbsences =
                EmployeeService.EmployeeLongTimeAbsenceService.GetEmployeesHasLongTimeAbsence(ids, aBeginWeek, aEndWeek);
            EmployeeLongTimeAbsenceIndexer absenceIndexer = new EmployeeLongTimeAbsenceIndexer(emplLongTimeAbsences);

            List<EmployeeRelation> emplRelations = relationService.GetEmployeeRelationsByEmployeeIds(ids, aBeginWeek, aEndWeek);
            DictionListEmployeeRelations relationIndexer = new DictionListEmployeeRelations(emplRelations);

            List<EmployeeContract> contracts = EmployeeService.EmployeeContractService.GetEmployeeContracts(ids, aBeginWeek, aEndWeek);
            DictionListEmployeesContract contractIndexer = new DictionListEmployeesContract(contracts);

            EmployeeWeek emplWeek = new EmployeeWeek(emplid, "", aBeginWeek,aEndWeek, empl.OrderHwgrID.HasValue ? empl.OrderHwgrID.Value : 0);

            EmployeeRelation relationWorld = null;
            bool bExistsRelation = false;
            bool bExistsContract = false;
            bool bNotExistsAbsence = true;

            if (swCountryManager == null)
            {
                long countryid = EmployeeService.StoreService.GetCountryByStoreId(empl.MainStoreID);
                swCountryManager = new CountryStoreWorldManager(EmployeeService.StoreWorldService);
                swCountryManager.CountryId = countryid;
            }

            bExistsContract = contractIndexer.FillEmployeeWeek(emplWeek);
            if (bExistsContract)
            {
                bNotExistsAbsence = absenceIndexer.FillEmployeeWeek(emplWeek);
                if (bNotExistsAbsence)
                {
                    foreach (EmployeeDay d in emplWeek.DaysList)
                    {
                        relationWorld = relationIndexer.GetRelationEntity(emplid, d.Date);
                        if (relationWorld != null)
                        {
                            d.StoreWorldId = swCountryManager.GetStoreWorldIdByStoreAndWorldId(relationWorld.StoreID, relationWorld.WorldID.Value);
                            d.StoreId = relationWorld.StoreID;
                        }

                        bExistsRelation |= d.HasRelation;
                    }
                }
            }
            if (!bExistsContract || !bExistsRelation || !bNotExistsAbsence)
                emplWeek = null;

            return emplWeek;
        }
Beispiel #10
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;
        }
        public void RecalculateFrom(DateTime date)
        {
            DateTime monday = DateTimeHelper.GetMonday(date);
            DateTime PrevMonday = monday.AddDays(-7);
            if (Relations == null)
            {
                Relations = new DictionListEmployeeRelations(ServerEnvironment.EmployeeRelationService.GetEmployeeRelations (Employee.ID));
            }
            if (Contracts == null)
            {
                Contracts = new DictionListEmployeesContract(ServerEnvironment.EmployeeContractService.GetEmployeeContracts (Employee.ID));
            }

            //LongAbsences = new EmployeeLongTimeAbsenceIndexer(ServerEnvironment.EmployeeLongTimeAbsenceService, Employee.ID);
            if (AllInManagers == null)
            {
                AllInManagers = new CacheEmployeesAllIn(Employee.ID);
            }
            if (RecordingWeeks == null)
            {
                RecordingWeeks = new SrvEmployeeWeekRecordingList();

                RecordingWeeks.InitList(Employee.ID, PrevMonday);
            }

            if (PlanningWeeks == null)
            {
                PlanningWeeks = new SrvEmployeeWeekPlanningList(Employee.ID, PrevMonday);

            }
            PlanningWeeks.BzEmployee = this;
            PlanningWeeks.AllInManager = AllInManagers;
            PlanningWeeks.Contracts = Contracts;
            PlanningWeeks.RecordingWeeks = RecordingWeeks;

            PlanningWeeks.RecalculateAfterImport(monday);
        }