private static void TestServices() { RoleService.Init(); UserService.Init(); CountryService.Init(); LanguageService.Init(); AvgAmountService.Init(); CountryAdditionalHourService.Init(); ColouringService.Init(); FeastService.Init(); AbsenceService.Init(); WorkingModelService.Init(); YearlyWorkingDayService.Init(); EmployeeService.Init(); EmployeeRelationService.Init(); EmployeeContractService.Init(); LongTimeAbsenceService.Init(); EmployeeLongTimeAbsenceService.Init(); StoreService.Init(); WGRService.Init(); HWGRService.Init(); WorldService.Init(); StoreToWorldService.Init(); WorldToHWGRService.Init(); HwgrToWgrService.Init(); StoreWorkingTimeService.Init(); StoreAdditionalHourService.Init(); BufferHoursService.Init(); BenchmarkService.Init(); TrendCorrectionService.Init(); PersonMinMaxService.Init(); RegionService.Init(); AbsenceTimePlanningService.Init(); AbsenceTimeRecordingService.Init(); WorkingTimePlanningService.Init(); WorkingTimeRecordingService.Init(); EmployeeTimeService.Init(); AvgWorkingDaysInWeekService.Init(); EmployeeDayStatePlanningService.Init(); EmployeeDayStateRecordingService.Init(); EmployeeWeekTimePlanningService.Init(); EmployeeWeekTimeRecordingService.Init(); EmployeePlanningWorkingModelService.Init(); EmployeeRecordingWorkingModelService.Init(); }
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 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); }
public static void InitServices() { // when connection is lost, it seems old references are no longer valid _ImportParam.CountryService = null; _ImportParam.EmployeeService = null; _ImportParam.RegionService = null; _ImportParam.StoreService = null; _UserService = null; _CountryService = null; _LanguageService = null; _EmployeeService = null; _StoreService = null; _RegionService = null; _AuthService = null; _RoleService = null; RoleService.Init(); UserService.Init(); CountryService.Init(); LanguageService.Init(); AvgAmountService.Init(); CountryAdditionalHourService.Init(); ColouringService.Init(); FeastService.Init(); AbsenceService.Init(); WorkingModelService.Init(); YearlyWorkingDayService.Init(); EmployeeService.Init(); EmployeeRelationService.Init(); EmployeeAllInService.Init(); EmployeeContractService.Init(); LongTimeAbsenceService.Init(); EmployeeLongTimeAbsenceService.Init(); StoreService.Init(); WGRService.Init(); HWGRService.Init(); WorldService.Init(); StoreToWorldService.Init(); WorldToHWGRService.Init(); HwgrToWgrService.Init(); StoreWorkingTimeService.Init(); StoreAdditionalHourService.Init(); BufferHoursService.Init(); BufferHourAvailableService.Init(); BenchmarkService.Init(); TrendCorrectionService.Init(); PersonMinMaxService.Init(); RegionService.Init(); AbsenceTimePlanningService.Init(); AbsenceTimeRecordingService.Init(); WorkingTimePlanningService.Init(); WorkingTimeRecordingService.Init(); EmployeeTimeService.Init(); AvgWorkingDaysInWeekService.Init(); EmployeeDayStatePlanningService.Init(); EmployeeDayStateRecordingService.Init(); EmployeeWeekTimePlanningService.Init(); EmployeeWeekTimeRecordingService.Init(); EmployeePlanningWorkingModelService.Init(); EmployeeRecordingWorkingModelService.Init(); EmployeeHolidaysInfoService.Init(); _ImportParam.CountryService = CountryService; _ImportParam.EmployeeService = EmployeeService; _ImportParam.RegionService = RegionService; _ImportParam.StoreService = StoreService; }