protected static FR_L5EM_GEAAWCFTAE_1403 Execute(DbConnection Connection, DbTransaction Transaction, P_L5EM_GEAAWCFTAE_1403 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5EM_GEAAWCFTAE_1403(); returnValue.Result = new L5EM_GEAAWCFTAE_1403(); //Put your code here L5EM_GEAAWCFT_1210[] employees = cls_Get_Employees_And_ActiveWorkingContracts_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result; if (employees == null) { employees = new L5EM_GEAAWCFT_1210[0]; returnValue.Result.Employees = employees; return(returnValue); } L5EM_GEAAWCFT_1210 loggedEmployee = employees.Where(i => i.CMN_BPT_EMP_EmployeeID == Parameter.EmployeeID).FirstOrDefault(); L5CM_GCSFT_1157 company = cls_Get_Company_Structure_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result; EmployeeUtils employeeUtils = new EmployeeUtils(); employeeUtils.ComapnyStructure = company; List <Guid> employeesUnderManager = employeeUtils.getEmployeesForManager(Parameter.appStartDate, employees, company, Parameter.EmployeeID, securityTicket.SessionTicket); if (loggedEmployee == null) { employees = employees.Where(i => employeesUnderManager.Contains(i.CMN_BPT_EMP_EmployeeID)).ToArray(); } employees = employees.Where(i => employeesUnderManager.Contains(i.CMN_BPT_EMP_EmployeeID) || EmployeeUtils.getEmployeeWorkplaceHistoriesFromAppStartDate(i.EmployeeWorkplaceHistory, Parameter.appStartDate).Intersect(EmployeeUtils.getEmployeeWorkplaceHistoriesFromAppStartDate(loggedEmployee.EmployeeWorkplaceHistory, Parameter.appStartDate)).Any()).ToArray(); if (employees.Where(i => i.CMN_BPT_EMP_EmployeeID == Parameter.EmployeeID).ToArray().Length == 0) { if (loggedEmployee != null) { if (employees.Length == 0) { employees = new L5EM_GEAAWCFT_1210[1]; employees[0] = loggedEmployee; } else { L5EM_GEAAWCFT_1210[] employeeList = new L5EM_GEAAWCFT_1210[employees.Length + 1]; for (int i = 0; i < employees.Length; i++) { employeeList[i] = employees[i]; } employeeList[employees.Length] = loggedEmployee; employees = employeeList; } } } returnValue.Result.Employees = employees; if (employees.Length == 0) { returnValue.Result = null; } return(returnValue); #endregion UserCode }
protected static FR_L5EM_GEALRDFIDL_1138_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L5EM_GEALRDFIDL_1138 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5EM_GEALRDFIDL_1138_Array(); List <L5EM_GEALRDFIDL_1138> resultList = new List <L5EM_GEALRDFIDL_1138>(); //Put your code here L5EM_GEAAWCFT_1210[] allEmployees = cls_Get_Employees_And_ActiveWorkingContracts_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result; L5AR_GART_1118[] allReasons = cls_Get_AbsenceReasons_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result; foreach (var employeeID in Parameter.EmployeeIDList) { L5EM_GEALRDFIDL_1138 result = new L5EM_GEALRDFIDL_1138(); L5EM_GEAAWCFT_1210 employee = allEmployees.Where(x => x.CMN_BPT_EMP_EmployeeID == employeeID).FirstOrDefault(); if (employee == null) { continue; } result.FirstName = employee.FirstName; result.LastName = employee.LastName; result.CMN_BPT_BusinessParticipantID = employee.CMN_BPT_BusinessParticipantID; result.CMN_BPT_EMP_EmployeeID = employee.CMN_BPT_EMP_EmployeeID; result.CMN_BPT_EMP_EmploymentRelationshipID = employee.CMN_BPT_EMP_EmploymentRelationshipID; result.Work_StartDate = employee.Work_StartDate; result.Work_EndDate = employee.Work_EndDate; result.CMN_BPT_EMP_WorkingContractID = employee.ActiveWorkingContract.CMN_BPT_EMP_WorkingContractID; result.IsContractEndDateDefined = employee.ActiveWorkingContract.IsContractEndDateDefined; result.IsWorkTimeCalculated_InDays = employee.ActiveWorkingContract.IsWorkTimeCalculated_InDays; result.IsWorkTimeCalculated_InHours = employee.ActiveWorkingContract.IsWorkTimeCalculated_InHours; result.Contract_StartDate = employee.ActiveWorkingContract.Contract_StartDate; result.Contract_EndDate = employee.ActiveWorkingContract.Contract_EndDate; result.R_WorkTime_DaysPerWeek = employee.ActiveWorkingContract.R_WorkTime_DaysPerWeek; result.R_WorkTime_HoursPerWeek = employee.ActiveWorkingContract.R_WorkTime_HoursPerWeek; List <L5EM_GEALRDFIDL_1138_WeeklyOfficeHour> weeklyOfficeHoursResult = new List <L5EM_GEALRDFIDL_1138_WeeklyOfficeHour>(); foreach (var weeklyOfficeHours in employee.ActiveWorkingContract.WeeklyOfficeHours) { L5EM_GEALRDFIDL_1138_WeeklyOfficeHour weeklyOfficeHourInterval = new L5EM_GEALRDFIDL_1138_WeeklyOfficeHour(); weeklyOfficeHourInterval.CMN_CAL_WeeklyOfficeHours_IntervalID = weeklyOfficeHours.CMN_CAL_WeeklyOfficeHours_IntervalID; weeklyOfficeHourInterval.IsWholeDay = weeklyOfficeHours.IsWholeDay; weeklyOfficeHourInterval.TimeFrom_InMinutes = weeklyOfficeHours.TimeFrom_InMinutes; weeklyOfficeHourInterval.TimeTo_InMinutes = weeklyOfficeHours.TimeTo_InMinutes; weeklyOfficeHourInterval.IsMonday = weeklyOfficeHours.IsMonday; weeklyOfficeHourInterval.IsTuesday = weeklyOfficeHours.IsTuesday; weeklyOfficeHourInterval.IsWednesday = weeklyOfficeHours.IsWednesday; weeklyOfficeHourInterval.IsThursday = weeklyOfficeHours.IsThursday; weeklyOfficeHourInterval.IsFriday = weeklyOfficeHours.IsFriday; weeklyOfficeHourInterval.IsSaturday = weeklyOfficeHours.IsSaturday; weeklyOfficeHourInterval.IsSunday = weeklyOfficeHours.IsSunday; weeklyOfficeHoursResult.Add(weeklyOfficeHourInterval); } result.WeeklyOfficeHours = weeklyOfficeHoursResult.ToArray(); P_L5EM_GAFE_1216 adjustmentsParam = new P_L5EM_GAFE_1216(); adjustmentsParam.EmployeeID = employeeID; L5EM_GAFE_1216[] adjustmentsForEmployee = cls_get_Adjustments_For_Employee.Invoke(Connection, Transaction, adjustmentsParam, securityTicket).Result; List <L5EM_GEALRDFIDL_1138_WorkingContract2LeaveRequest> workingContract2LeaveRequestResult = new List <L5EM_GEALRDFIDL_1138_WorkingContract2LeaveRequest>(); List <L5EM_GEALRDFIDL_1138_EmployeeWorkplaceHistory> employeeWorkplaceAssignments = new List <L5EM_GEALRDFIDL_1138_EmployeeWorkplaceHistory>(); foreach (var workplaceAssignemns in employee.EmployeeWorkplaceHistory) { L5EM_GEALRDFIDL_1138_EmployeeWorkplaceHistory item = new L5EM_GEALRDFIDL_1138_EmployeeWorkplaceHistory(); item.BoundTo_Workplace_RefID = workplaceAssignemns.BoundTo_Workplace_RefID; item.CMN_BPT_EMP_Employee_PlanGroup_RefID = workplaceAssignemns.CMN_BPT_EMP_Employee_PlanGroup_RefID; item.CMN_BPT_EMP_Employee_WorkplaceAssignmentID = workplaceAssignemns.CMN_BPT_EMP_Employee_WorkplaceAssignmentID; item.Default_BreakTime_Template_RefID = workplaceAssignemns.Default_BreakTime_Template_RefID; item.IsBreakTimeCalculated_Actual = workplaceAssignemns.IsBreakTimeCalculated_Actual; item.IsBreakTimeCalculated_Planning = workplaceAssignemns.IsBreakTimeCalculated_Planning; item.SequenceNumber = workplaceAssignemns.SequenceNumber; item.WorkplaceAssignment_StartDate = workplaceAssignemns.WorkplaceAssignment_StartDate; employeeWorkplaceAssignments.Add(item); } result.EmployeeWorkplaceHistory = employeeWorkplaceAssignments.ToArray(); foreach (var absence in employee.ActiveWorkingContract.WorkingContract2LeaveRequest) { L5EM_GEALRDFIDL_1138_WorkingContract2LeaveRequest workingContract2LeaveRequest = new L5EM_GEALRDFIDL_1138_WorkingContract2LeaveRequest(); L5AR_GART_1118 reason = allReasons.Where(x => x.CMN_BPT_STA_AbsenceReasonID == absence.STA_AbsenceReason_RefID).FirstOrDefault(); if (reason == null) { continue; } workingContract2LeaveRequest.CMN_BPT_EMP_Employee_WorkingContract_AllowedAbsenceReasonID = absence.CMN_BPT_EMP_Employee_WorkingContract_AllowedAbsenceReasonID; workingContract2LeaveRequest.IsAbsenceCalculated_InDays = absence.IsAbsenceCalculated_InDays; workingContract2LeaveRequest.IsAbsenceCalculated_InHours = absence.IsAbsenceCalculated_InHours; workingContract2LeaveRequest.ContractAllowedAbsence_per_Month = absence.ContractAllowedAbsence_per_Month; workingContract2LeaveRequest.AbsenceReasonName = reason.ReasonName; workingContract2LeaveRequest.CMN_BPT_STA_AbsenceReasonID = reason.CMN_BPT_STA_AbsenceReasonID; workingContract2LeaveRequest.AbsenceReason_ParentID = reason.Parent_RefID; workingContract2LeaveRequest.IsAuthorizationRequired = reason.IsAuthorizationRequired; workingContract2LeaveRequest.IsIncludedInCapacityCalculation = reason.IsIncludedInCapacityCalculation; workingContract2LeaveRequest.IsAllowedAbsence = reason.IsAllowedAbsence; workingContract2LeaveRequest.IsDeactivated = reason.IsDeactivated; workingContract2LeaveRequest.IsCarryOverEnabled = reason.IsCarryOverEnabled; L5EM_GAFE_1216[] adjustmentsForAbsenceReason = adjustmentsForEmployee.Where(x => x.CMN_BPT_STA_AbsenceReasonID == workingContract2LeaveRequest.CMN_BPT_STA_AbsenceReasonID).ToArray(); List <L5EM_GEALRDFIDL_1138_adjustments> adjustmentsResult = new List <L5EM_GEALRDFIDL_1138_adjustments>(); foreach (var adjustment in adjustmentsForAbsenceReason) { L5EM_GEALRDFIDL_1138_adjustments adjustmentResult = new L5EM_GEALRDFIDL_1138_adjustments(); adjustmentResult.CMN_BPT_EMP_ContractAbsenceAdjustmentID = adjustment.CMN_BPT_EMP_ContractAbsenceAdjustmentID; adjustmentResult.AbsenceTime_InMinutes = adjustment.AbsenceTime_InMinutes; adjustmentResult.ContractAbsenceAdjustment_Group_RefID = adjustment.CMN_BPT_EMP_ContractAbsenceAdjustment_GroupID; adjustmentResult.IsManual = adjustment.IsManual; adjustmentResult.TriggeringAccount_RefID = adjustment.TriggeringAccount_RefID; adjustmentResult.AdjustmentComment = adjustment.AdjustmentComment; adjustmentResult.AdjustmentDate = adjustment.AdjustmentDate; adjustmentsResult.Add(adjustmentResult); } workingContract2LeaveRequest.Adjustments = adjustmentsResult.ToArray(); workingContract2LeaveRequestResult.Add(workingContract2LeaveRequest); } result.WorkingContract2LeaveRequest = workingContract2LeaveRequestResult.ToArray(); resultList.Add(result); } returnValue.Result = resultList.ToArray(); return(returnValue); #endregion UserCode }
protected static FR_L5EM_GEAAWCFT_1210_Array Execute(DbConnection Connection, DbTransaction Transaction, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5EM_GEAAWCFT_1210_Array(); List <L5EM_GEAAWCFT_1210> resultList = new List <L5EM_GEAAWCFT_1210>(); List <Guid> employeeIDs = new List <Guid>(); ORM_CMN_BPT_EMP_Employee.Query employeeQuery = new ORM_CMN_BPT_EMP_Employee.Query(); employeeQuery.IsDeleted = false; employeeQuery.Tenant_RefID = securityTicket.TenantID; List <ORM_CMN_BPT_EMP_Employee> employeeList = ORM_CMN_BPT_EMP_Employee.Query.Search(Connection, Transaction, employeeQuery); foreach (var employeeItem in employeeList) { L5EM_GEAAWCFT_1210 result = new L5EM_GEAAWCFT_1210(); ORM_CMN_BPT_EMP_Employee employee = new ORM_CMN_BPT_EMP_Employee(); employee.Load(Connection, Transaction, employeeItem.CMN_BPT_EMP_EmployeeID); result.CMN_BPT_EMP_EmployeeID = employee.CMN_BPT_EMP_EmployeeID; result.Staff_Number = employee.Staff_Number; result.StandardFunction = employee.StandardFunction; ORM_CMN_BPT_EMP_EmploymentRelationship.Query employmentRelationshipQuery = new ORM_CMN_BPT_EMP_EmploymentRelationship.Query(); employmentRelationshipQuery.Employee_RefID = employee.CMN_BPT_EMP_EmployeeID; employmentRelationshipQuery.IsDeleted = false; employmentRelationshipQuery.Tenant_RefID = securityTicket.TenantID; ORM_CMN_BPT_EMP_EmploymentRelationship employmentRelationship = ORM_CMN_BPT_EMP_EmploymentRelationship.Query.Search(Connection, Transaction, employmentRelationshipQuery).FirstOrDefault(); if (employmentRelationship == null) { continue; } ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract.Query employmentRelationship_2_WorkingContractQuery = new ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract.Query(); employmentRelationship_2_WorkingContractQuery.EmploymentRelationship_RefID = employmentRelationship.CMN_BPT_EMP_EmploymentRelationshipID; employmentRelationship_2_WorkingContractQuery.IsDeleted = false; employmentRelationship_2_WorkingContractQuery.Tenant_RefID = securityTicket.TenantID; employmentRelationship_2_WorkingContractQuery.IsContract_Active = true; List <ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract> employmentRelationship_2_WorkingContractList = ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract.Query.Search(Connection, Transaction, employmentRelationship_2_WorkingContractQuery); if (employmentRelationship_2_WorkingContractList.Count == 0) { continue; } ORM_CMN_BPT_BusinessParticipant businessParticipant = new ORM_CMN_BPT_BusinessParticipant(); businessParticipant.Load(Connection, Transaction, employee.BusinessParticipant_RefID); result.CMN_BPT_BusinessParticipantID = businessParticipant.CMN_BPT_BusinessParticipantID; result.DisplayName = businessParticipant.DisplayName; ORM_CMN_PER_PersonInfo personInfo = new ORM_CMN_PER_PersonInfo(); personInfo.Load(Connection, Transaction, businessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID); result.CMN_PER_PersonInfoID = personInfo.CMN_PER_PersonInfoID; result.FirstName = personInfo.FirstName; result.LastName = personInfo.LastName; result.PrimaryEmail = personInfo.PrimaryEmail; result.Title = personInfo.Title; result.ProfileImage_Document_RefID = personInfo.ProfileImage_Document_RefID; result.BirthDate = personInfo.BirthDate; result.CMN_BPT_EMP_EmploymentRelationshipID = employmentRelationship.CMN_BPT_EMP_EmploymentRelationshipID; result.Work_StartDate = employmentRelationship.Work_StartDate; result.Work_EndDate = employmentRelationship.Work_EndDate; //Address if (personInfo.Address_RefID != Guid.Empty) { ORM_CMN_Address address = new ORM_CMN_Address(); address.Load(Connection, Transaction, personInfo.Address_RefID); result.CMN_AddressID = address.CMN_AddressID; result.Street_Name = address.Street_Name; result.Street_Number = address.Street_Number; result.City_AdministrativeDistrict = address.City_AdministrativeDistrict; result.City_Region = address.City_Region; result.City_Name = address.City_Name; result.City_PostalCode = address.City_PostalCode; result.Province_Name = address.Province_Name; result.Country_Name = address.Country_Name; result.Country_ISOCode = address.Country_ISOCode; } //Contacts ORM_CMN_PER_CommunicationContact comunicationContactQuery = new ORM_CMN_PER_CommunicationContact(); comunicationContactQuery.PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; comunicationContactQuery.Tenant_RefID = securityTicket.TenantID; comunicationContactQuery.IsDeleted = false; List <ORM_CMN_PER_CommunicationContact> comunicationContacts = new List <ORM_CMN_PER_CommunicationContact>(); List <L5EM_GEAAWCFT_1210_Contacts> resultComunicationContacts = new List <L5EM_GEAAWCFT_1210_Contacts>(); foreach (var comunicationContact in comunicationContacts) { ORM_CMN_PER_CommunicationContact_Type contactType = new ORM_CMN_PER_CommunicationContact_Type(); contactType.Load(Connection, Transaction, comunicationContact.CMN_PER_CommunicationContactID); L5EM_GEAAWCFT_1210_Contacts resultComunicationContact = new L5EM_GEAAWCFT_1210_Contacts(); resultComunicationContact.CMN_PER_CommunicationContact_TypeID = contactType.CMN_PER_CommunicationContact_TypeID; resultComunicationContact.CMN_PER_CommunicationContactID = comunicationContact.CMN_PER_CommunicationContactID; resultComunicationContact.Content = comunicationContact.Content; resultComunicationContact.Type = contactType.Type; resultComunicationContacts.Add(resultComunicationContact); } result.Contacts = resultComunicationContacts.ToArray(); //Employee workplace history ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment.Query employeeWorkplaceAssignmentsQuery = new ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment.Query(); employeeWorkplaceAssignmentsQuery.CMN_BPT_EMP_Employee_RefID = employee.CMN_BPT_EMP_EmployeeID; employeeWorkplaceAssignmentsQuery.Tenant_RefID = securityTicket.TenantID; employeeWorkplaceAssignmentsQuery.IsDeleted = false; List <ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment> employeeWorkplaceAssignemntsList = ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment.Query.Search(Connection, Transaction, employeeWorkplaceAssignmentsQuery); List <L5EM_GEAAWCFT_1210_EmployeeWorkplaceHistory> employeeWorkplaceAssignments = new List <L5EM_GEAAWCFT_1210_EmployeeWorkplaceHistory>(); foreach (var workplaceAssignemns in employeeWorkplaceAssignemntsList) { L5EM_GEAAWCFT_1210_EmployeeWorkplaceHistory item = new L5EM_GEAAWCFT_1210_EmployeeWorkplaceHistory(); item.BoundTo_Workplace_RefID = workplaceAssignemns.BoundTo_Workplace_RefID; item.CMN_BPT_EMP_Employee_PlanGroup_RefID = workplaceAssignemns.CMN_BPT_EMP_Employee_PlanGroup_RefID; item.CMN_BPT_EMP_Employee_WorkplaceAssignmentID = workplaceAssignemns.CMN_BPT_EMP_Employee_WorkplaceAssignment; item.Default_BreakTime_Template_RefID = workplaceAssignemns.Default_BreakTime_Template_RefID; item.IsBreakTimeCalculated_Actual = workplaceAssignemns.IsBreakTimeCalculated_Actual; item.IsBreakTimeCalculated_Planning = workplaceAssignemns.IsBreakTimeCalculated_Planning; item.SequenceNumber = workplaceAssignemns.SequenceNumber; item.WorkplaceAssignment_StartDate = workplaceAssignemns.WorkplaceAssignment_StartDate; employeeWorkplaceAssignments.Add(item); } result.EmployeeWorkplaceHistory = employeeWorkplaceAssignments.ToArray(); L5EM_GEAAWCFT_1210_WorkingContract resultWorkingContract = new L5EM_GEAAWCFT_1210_WorkingContract(); ORM_CMN_BPT_EMP_WorkingContract workingContract = new ORM_CMN_BPT_EMP_WorkingContract(); workingContract.Load(Connection, Transaction, employmentRelationship_2_WorkingContractList[0].WorkingContract_RefID); resultWorkingContract.CMN_BPT_EMP_WorkingContractID = workingContract.CMN_BPT_EMP_WorkingContractID; resultWorkingContract.EmploymentRelationship_2_WorkingContractAssigmentID = employmentRelationship_2_WorkingContractList[0].AssignmentID; resultWorkingContract.IsContract_Active = employmentRelationship_2_WorkingContractList[0].IsContract_Active; resultWorkingContract.Contract_StartDate = workingContract.Contract_StartDate; resultWorkingContract.Contract_EndDate = workingContract.Contract_EndDate; resultWorkingContract.IsContractEndDateDefined = workingContract.IsContractEndDateDefined; resultWorkingContract.IsWorkTimeCalculated_InDays = workingContract.IsWorkTimeCalculated_InDays; resultWorkingContract.IsWorkTimeCalculated_InHours = workingContract.IsWorkTimeCalculated_InHours; resultWorkingContract.R_WorkTime_DaysPerWeek = workingContract.R_WorkTime_DaysPerWeek; resultWorkingContract.R_WorkTime_HoursPerWeek = workingContract.R_WorkTime_HoursPerWeek; //Office hours ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay.Query workingContractToWorkingDayQuery = new ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay.Query(); workingContractToWorkingDayQuery.CMN_BPT_EMP_WorkingContract_RefID = workingContract.CMN_BPT_EMP_WorkingContractID; //workingContractToWorkingDayQuery.Tenant_RefID = securityTicket.TenantID; workingContractToWorkingDayQuery.IsDeleted = false; List <ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay> workingDayAssigments = ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay.Query.Search(Connection, Transaction, workingContractToWorkingDayQuery); List <L5EM_GEAAWCFT_1210_WeeklyOfficeHour> resultWeeklyOfficeHours = new List <L5EM_GEAAWCFT_1210_WeeklyOfficeHour>(); foreach (var workingDayAssigment in workingDayAssigments) { ORM_CMN_CAL_WeeklyOfficeHours_Interval interval = new ORM_CMN_CAL_WeeklyOfficeHours_Interval(); interval.Load(Connection, Transaction, workingDayAssigment.CMN_CAL_WeeklyOfficeHours_Interval_RefID); L5EM_GEAAWCFT_1210_WeeklyOfficeHour resultOfficeHour = new L5EM_GEAAWCFT_1210_WeeklyOfficeHour(); resultOfficeHour.CMN_CAL_WeeklyOfficeHours_IntervalID = interval.CMN_CAL_WeeklyOfficeHours_IntervalID; resultOfficeHour.IsFriday = interval.IsFriday; resultOfficeHour.IsMonday = interval.IsMonday; resultOfficeHour.IsSaturday = interval.IsSaturday; resultOfficeHour.IsSunday = interval.IsSunday; resultOfficeHour.IsThursday = interval.IsThursday; resultOfficeHour.IsTuesday = interval.IsTuesday; resultOfficeHour.IsWednesday = interval.IsWednesday; resultOfficeHour.IsWholeDay = interval.IsWholeDay; resultOfficeHour.TimeFrom_InMinutes = interval.TimeFrom_InMinutes; resultOfficeHour.TimeTo_InMinutes = interval.TimeTo_InMinutes; resultWeeklyOfficeHours.Add(resultOfficeHour); } resultWorkingContract.WeeklyOfficeHours = resultWeeklyOfficeHours.ToArray(); //Allowed absence reasons ORM_CMN_BPT_EMP_WorkingContract_AllowedAbsenceReason.Query AllowedAbsenceReasonQuery = new ORM_CMN_BPT_EMP_WorkingContract_AllowedAbsenceReason.Query(); AllowedAbsenceReasonQuery.WorkingContract_RefID = workingContract.CMN_BPT_EMP_WorkingContractID; AllowedAbsenceReasonQuery.Tenant_RefID = securityTicket.TenantID; AllowedAbsenceReasonQuery.IsDeleted = false; List <ORM_CMN_BPT_EMP_WorkingContract_AllowedAbsenceReason> allowedAbsenceReasons = ORM_CMN_BPT_EMP_WorkingContract_AllowedAbsenceReason.Query.Search(Connection, Transaction, AllowedAbsenceReasonQuery); List <L5EM_GEAAWCFT_1210_WorkingContract2LeaveRequest> resultAllowedAbsenceReasons = new List <L5EM_GEAAWCFT_1210_WorkingContract2LeaveRequest>(); foreach (var allowedAbsenceReason in allowedAbsenceReasons) { ORM_CMN_BPT_STA_AbsenceReason absenceReason = new ORM_CMN_BPT_STA_AbsenceReason(); absenceReason.Load(Connection, Transaction, allowedAbsenceReason.STA_AbsenceReason_RefID); L5EM_GEAAWCFT_1210_WorkingContract2LeaveRequest resultReasonresultReason = new L5EM_GEAAWCFT_1210_WorkingContract2LeaveRequest(); resultReasonresultReason.IsAbsenceCalculated_InDays = allowedAbsenceReason.IsAbsenceCalculated_InDays; resultReasonresultReason.IsAbsenceCalculated_InHours = allowedAbsenceReason.IsAbsenceCalculated_InHours; resultReasonresultReason.ContractAllowedAbsence_per_Month = allowedAbsenceReason.ContractAllowedAbsence_per_Month; resultReasonresultReason.STA_AbsenceReason_RefID = allowedAbsenceReason.STA_AbsenceReason_RefID; resultAllowedAbsenceReasons.Add(resultReasonresultReason); } resultWorkingContract.WorkingContract2LeaveRequest = resultAllowedAbsenceReasons.ToArray(); result.ActiveWorkingContract = resultWorkingContract; resultList.Add(result); } returnValue.Result = resultList.ToArray(); return(returnValue); #endregion UserCode }
protected static FR_L5EM_GEFTAE_1517 Execute(DbConnection Connection, DbTransaction Transaction, P_L5EM_GEFTAE_1517 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5EM_GEFTAE_1517(); returnValue.Result = new L5EM_GEFTAE_1517(); //Put your code here L5EM_GEAAWCFT_1210[] employees = cls_Get_Employees_And_ActiveWorkingContracts_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result; L5EM_GEAAWCFT_1210 loggedEmployee = employees.Where(i => i.CMN_BPT_EMP_EmployeeID == Parameter.EmployeeID).FirstOrDefault(); L5CM_GCSFT_1157 company = cls_Get_Company_Structure_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result; Dictionary <Guid, List <Guid> > managesPerLocation = new Dictionary <Guid, List <Guid> >(); var oldEmpls = CLE_L5_CMN_Employees.Complex.Retrieval.cls_Get_Employees_For_Tenant_And_ManagerEmployeeID.Invoke(Connection, Transaction, new PlannicoModel.Models.P_L5EM_GEFTAE_1517 { EmployeeID = Parameter.EmployeeID }, securityTicket).Result; foreach (var office in company.Offices) { List <Guid> managerIDList = new List <Guid>(); foreach (var manager in office.Managers) { if (!managerIDList.Contains(manager.CMN_BPT_EMP_EmployeeID)) { managerIDList.Add(manager.CMN_BPT_EMP_EmployeeID); } } if (managerIDList.Count() > 0) { managesPerLocation.Add(office.CMN_STR_OfficeID, managerIDList); } } foreach (var workarea in company.WorkAreas) { List <Guid> managerIDList = new List <Guid>(); foreach (var manager in workarea.ResponsiblePersons) { if (!managerIDList.Contains(manager.CMN_BPT_EMP_EmployeeID)) { managerIDList.Add(manager.CMN_BPT_EMP_EmployeeID); } } if (managerIDList.Count() > 0) { managesPerLocation.Add(workarea.CMN_STR_PPS_WorkAreaID, managerIDList); } } foreach (var workplace in company.WorkPlaces) { List <Guid> managerIDList = new List <Guid>(); foreach (var manager in workplace.ResponsiblePersons) { if (!managerIDList.Contains(manager.CMN_BPT_EMP_EmployeeID)) { managerIDList.Add(manager.CMN_BPT_EMP_EmployeeID); } } if (managerIDList.Count() > 0) { managesPerLocation.Add(workplace.CMN_STR_PPS_WorkplaceID, managerIDList); } } var employeeList = new List <L5EM_GEAAWCFT_1210>(); foreach (var e in employees) { foreach (var wh in e.EmployeeWorkplaceHistory) { if (managesPerLocation.ContainsKey(wh.BoundTo_Workplace_RefID) && managesPerLocation[wh.BoundTo_Workplace_RefID].Contains(loggedEmployee.CMN_BPT_EMP_EmployeeID)) { var loggedEmployeeValidWorkplaces = loggedEmployee.EmployeeWorkplaceHistory.Where(w => w.WorkplaceAssignment_StartDate >= Parameter.appStartDate).Select(w => w.BoundTo_Workplace_RefID); if (loggedEmployeeValidWorkplaces != null) { if (loggedEmployeeValidWorkplaces.Contains(wh.BoundTo_Workplace_RefID) && !employeeList.Contains(e)) { employeeList.Add(e); } } } } } if (!employeeList.Contains(loggedEmployee)) { employeeList.Add(loggedEmployee); } returnValue.Result.Employees = employeeList.ToArray(); if (employees.Length == 0) { returnValue.Result = null; } return(returnValue); #endregion UserCode }