public void LoadByEmployee(IEmployeeLongTimeAbsenceService service, long emplid) { if (service == null) { return; } List <EmployeeLongTimeAbsence> list = service.GetEmployeesHasLongTimeAbsence(new long[] { emplid }, DateTimeSql.SmallDatetimeMin, DateTimeSql.SmallDatetimeMax); BuildDiction(list); }
public AbsencePlanningQuery GetAllAbsencePlanning(long storeID, long countryID, int year, DateTime today) { int TodayYear = DateTimeHelper.GetYearByDate(DateTime.Today); bool isAustria = countryID == _countryService.AustriaCountryID; DateTime begin, end; begin = DateTimeHelper.GetBeginYearDate(year); end = DateTimeHelper.GetEndYearDate(year); DateTime dateToday = DateTime.Today; AbsencePlanningQuery result = new AbsencePlanningQuery(); List <long> employee_ids = new List <long>(); result.Year = year; result.StoreID = storeID; // need remove - once per country need load result.Absences = _absenceService.GetCountryAbsences(countryID); result.AvgDaysPerWeek = _countryService.AvgWorkingDaysInWeekService .GetAvgWorkingDaysInWeek(countryID, year); result.StoreDays = _storeService.GetStoreDays(storeID, begin, end); result.LongabsencesEntities = _employeeService.LongTimeAbsenceService.FindAllByCountry(countryID); EmployeeService service = _employeeService as EmployeeService; List <Employee> employees = service.EmployeeDao.GetStoreEmployeesHaveContracts(storeID, begin, end); long[] ids_employee = null; if (employees != null && employees.Count > 0) { foreach (Employee empl in employees) { employee_ids.Add(empl.ID); } ids_employee = employee_ids.ToArray(); EmployeeContractService contract_service = ServerEnvironment.EmployeeContractService as EmployeeContractService; result.Contracts = contract_service.GetEmployeeContractsByStore(storeID, begin, end); EmployeeRelationService relation_service = _employeeService.EmployeeRelationService as EmployeeRelationService; result.Relations = relation_service.GetEmployeeRelationByMainStore(storeID, begin, end); result.Longabsences = _employeeLongTimeAbsenceService.GetEmployeesHasLongTimeAbsence(storeID, begin, end); //Debug.Assert(result.Contracts != null && result.Contracts.Count >= employees.Count); //Debug.Assert(result.Relations != null && result.Relations.Count >= employees.Count); if (dateToday < begin) { result.Plannings = _absenceTimePlanningService .GetAbsenceTimePlanningsByEmployeeIds(ids_employee, begin, end); } else if (dateToday > end) { result.Recordings = _absenceTimeRecordingService .GetAbsenceTimeRecordingsByEmployeeIds(ids_employee, begin, end); } else { result.Plannings = _absenceTimePlanningService .GetAbsenceTimePlanningsByEmployeeIds(ids_employee, dateToday, end); result.Recordings = _absenceTimeRecordingService .GetAbsenceTimeRecordingsByEmployeeIds(ids_employee, begin, dateToday.AddDays(-1)); } List <EmployeeHolidaysInfo> holidays = ExEmployeeHolidays.GetAllByStore(storeID, year); Dictionary <long, EmployeeHolidaysInfo> hash = new Dictionary <long, EmployeeHolidaysInfo>(); hash = EmployeeHolidaysInfo.BuildDiction(holidays); BzEmployeeHoliday bz_entity = null; EmployeeHolidaysInfo entity = null; foreach (Employee empl in employees) { if (result._holidays == null) { result._holidays = new List <BzEmployeeHoliday>(); } if (!hash.TryGetValue(empl.ID, out entity)) { entity = new EmployeeHolidaysInfo((short)year, 0, 0, 0, empl.ID); } bz_entity = new BzEmployeeHoliday(entity, empl.FullName, empl.MainStoreID, empl.OrderHwgrID); bz_entity.IsAustria = isAustria; if (isAustria && year == TodayYear) { bz_entity.AvailableHolidays = Convert.ToDouble(empl.AvailableHolidays); } result._holidays.Add(bz_entity); } } return(result); }
public void LoadByEmployee(IEmployeeLongTimeAbsenceService service, long emplid) { if (service == null) return; List<EmployeeLongTimeAbsence> list = service.GetEmployeesHasLongTimeAbsence(new long[] { emplid }, DateTimeSql.SmallDatetimeMin, DateTimeSql.SmallDatetimeMax); BuildDiction(list); }