Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public static void Recalculate(long[] ids)
        {
            EmployeeService empl_service = ServerEnvironment.EmployeeService as EmployeeService;

            List <Employee> lst = empl_service.EmployeeDao.GetEmployeeByIds(ids);

            IList list = empl_service.EmployeeDao.GetDifferenceContractsAndRelations();

            if (lst == null)
            {
                return;
            }
            int i = 0;

            DictionListEmployeeRelations rels = new DictionListEmployeeRelations(ServerEnvironment.EmployeeRelationService.LoadAllSorted());



            CacheListEmployeeContracts contracts = (new CacheListEmployeeContracts()).LoadAll();

            CacheEmployeesAllIn all = (new CacheEmployeesAllIn()).LoadAll();

            DateTime beginDate = DateTime.Today.AddDays(-7);

            beginDate = DateTimeHelper.GetMonday(beginDate);


            SrvEmployeeWeekPlanningList PlanningWeeks = new SrvEmployeeWeekPlanningList();

            PlanningWeeks.InitList(null, beginDate);

            SrvEmployeeWeekRecordingList RecordingWeeks = new SrvEmployeeWeekRecordingList();

            RecordingWeeks.InitList(null, beginDate);

            List <Store>             stores         = ServerEnvironment.StoreService.FindAll();
            Dictionary <long, Store> diction_stores = new Dictionary <long, Store>();

            foreach (Store s in stores)
            {
                diction_stores[s.ID] = s;
            }

            long austriaid = ServerEnvironment.CountryService.AustriaCountryID;
            //rels.LoadRelations(ServerEnvironment.EmployeeRelationService);
            EmployeeBusinessObject bz = null;

            foreach (Employee e in lst)
            {
                i++;

                if (bz == null)
                {
                    bz = new EmployeeBusinessObject(e, DateTime.Today);
                }
                else
                {
                    bz.Employee = e;
                }

                bz.AustriaEmployee = diction_stores[e.MainStoreID].CountryID == austriaid;

                bz.Relations     = rels;
                bz.Contracts     = contracts;
                bz.AllInManagers = all;

                bz.PlanningWeeks  = PlanningWeeks;
                bz.RecordingWeeks = RecordingWeeks;
                bz.RecalculateFrom();
            }
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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;

            }



        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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;
        }
Exemplo n.º 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;
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
        public static void Recalculate(long[] ids)
        {
            EmployeeService empl_service = ServerEnvironment.EmployeeService as EmployeeService;

            List<Employee> lst = empl_service.EmployeeDao.GetEmployeeByIds(ids);

            IList list = empl_service.EmployeeDao.GetDifferenceContractsAndRelations();

            if (lst == null) return;
            int i = 0;

            DictionListEmployeeRelations rels = new DictionListEmployeeRelations(ServerEnvironment.EmployeeRelationService.LoadAllSorted());

            CacheListEmployeeContracts contracts = (new CacheListEmployeeContracts()).LoadAll();

            CacheEmployeesAllIn all = (new CacheEmployeesAllIn()).LoadAll();

            DateTime beginDate = DateTime.Today.AddDays(-7);
            beginDate = DateTimeHelper.GetMonday(beginDate);

            SrvEmployeeWeekPlanningList PlanningWeeks = new SrvEmployeeWeekPlanningList();
            PlanningWeeks.InitList(null, beginDate);

            SrvEmployeeWeekRecordingList RecordingWeeks = new SrvEmployeeWeekRecordingList();
            RecordingWeeks.InitList(null, beginDate);

            List<Store> stores = ServerEnvironment.StoreService.FindAll();
            Dictionary<long, Store> diction_stores = new Dictionary<long, Store>();
            foreach (Store s in stores)
                diction_stores[s.ID] = s;

            long austriaid = ServerEnvironment.CountryService.AustriaCountryID;
            //rels.LoadRelations(ServerEnvironment.EmployeeRelationService);
            EmployeeBusinessObject bz = null;

            foreach (Employee e in lst)
            {
                i++;

                if (bz == null)
                    bz = new EmployeeBusinessObject(e, DateTime.Today);
                else
                    bz.Employee = e;

                bz.AustriaEmployee = diction_stores[e.MainStoreID].CountryID == austriaid;

                bz.Relations = rels;
                bz.Contracts = contracts;
                bz.AllInManagers = all;

                bz.PlanningWeeks = PlanningWeeks;
                bz.RecordingWeeks = RecordingWeeks;
                bz.RecalculateFrom();

            }
        }