public DataTable GetReportMonthlyHourFlightLocal(Guid CutOffDurationID, string strOrgStructure, Guid[] shiftIDs, Guid[] payrollIDs, Guid[] workPlaceIDs, string codeEmp, bool isIncludeQuitEmp, bool isNotAllowZero, bool isCreateTemplate, string userExport, string UserLogin) { using (var context = new VnrHrmDataContext()) { DataTable table = CreateReportMonthlyHourFlightLocalchema(UserLogin); if (isCreateTemplate) { return table.ConfigDatatable(); } string status = string.Empty; var unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); var repoCat_OrgStructure = new Cat_OrgStructureRepository(unitOfWork); var repoCat_OrgStructureType = new Cat_OrgStructureTypeRepository(unitOfWork); var repoCat_Position = new Cat_PositionRepository(unitOfWork); var repoCat_JobTitle = new Cat_JobTitleRepository(unitOfWork); var repoCat_LeaveDayType = new Cat_LeaveDayTypeRepository(unitOfWork); var repoWorkDay = new Att_WorkDayRepository(unitOfWork); var repoTimeSheet = new Att_TimeSheetRepository(unitOfWork); var repoJobtype = new Cat_JobTypeRepository(unitOfWork); var repoAtt_AttendencaTable = new CustomBaseRepository<Att_AttendanceTable>(unitOfWork); var repoAtt_AttendanceTableItem = new CustomBaseRepository<Att_AttendanceTableItem>(unitOfWork); var repoAtt_CutOffDuration = new CustomBaseRepository<Att_CutOffDuration>(unitOfWork); var roleServices = new Cat_RoleServices(); var lstRole = new List<object>(); lstRole.Add(null); lstRole.Add(null); lstRole.Add(1); lstRole.Add(100000000); var listRole = roleServices.GetData<Cat_RoleEntity>(lstRole, ConstantSql.hrm_cat_sp_get_Role, UserLogin, ref status).Where(s => s.Code != null).Select(m => new { m.ID, m.Code }).ToList(); var jobTypeServices = new Cat_JobTypeServices(); var lstjobType = new List<object>(); lstjobType.Add(null); lstjobType.Add(null); lstjobType.Add(1); lstjobType.Add(100000000); var listjobType = jobTypeServices.GetData<Cat_JobTypeEntity>(lstjobType, ConstantSql.hrm_cat_sp_get_JobType, UserLogin, ref status).Where(s => s.Code != null).Select(m => m.Code).ToList(); List<object> lstOrgIDs = new List<object>(); lstOrgIDs.AddRange(new object[3]); lstOrgIDs[0] = (object)strOrgStructure; lstOrgIDs[1] = null; lstOrgIDs[2] = codeEmp; List<Hre_ProfileEntity> profiles = GetData<Hre_ProfileEntity>(lstOrgIDs, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, UserLogin, ref status).ToList(); var cutoffInfo = repoAtt_CutOffDuration.FindBy(s => s.ID == CutOffDurationID).FirstOrDefault(); var leavedayTypes = repoCat_LeaveDayType.FindBy(s => s.Code != null && s.IsDelete == null).Select(s => new { s.Code, s.ID, s.PaidRate, s.LeaveDayTypeName }).ToList(); DateTime dateStart = cutoffInfo.DateStart; DateTime dateEnd = cutoffInfo.DateEnd; var orgs = repoCat_OrgStructure.FindBy(s => s.Code != null).ToList(); var orgTypes = repoCat_OrgStructureType.FindBy(s => s.IsDelete == null).ToList(); var positions = repoCat_Position.FindBy(s => s.Code != null).Select(s => new { s.ID, s.Code, s.PositionName }).ToList(); var jobtitles = repoCat_JobTitle.FindBy(s => s.Code != null).Select(s => new { s.ID, s.Code, s.JobTitleName }).ToList(); List<Guid> profileIds = profiles.Select(s => s.ID).ToList(); var timesheets = repoTimeSheet.FindBy(s => s.ProfileID != null && profileIds.Contains(s.ProfileID.Value) && s.Date != null && dateStart <= s.Date && s.Date <= dateEnd && s.IsDelete == null).Select(s => new { s.ProfileID, s.JobTypeID, s.RoleID, s.Date, s.NoHour, s.ID, s.Note }).ToList(); var jobtypes = repoJobtype.FindBy(s => s.IsDelete == null).Select(s => new { s.ID, s.Code, s.RoleID }).ToList(); var workDays = repoWorkDay.FindBy(s => profileIds.Contains(s.ProfileID) && dateStart <= s.WorkDate && s.WorkDate <= dateEnd && s.IsDelete == null).Select(s => new { s.ProfileID, s.ShiftID, s.Status }).ToList(); if (payrollIDs != null) { profiles = profiles.Where(s => s.PayrollGroupID != null && payrollIDs.Contains(s.PayrollGroupID.Value)).ToList(); } if (workPlaceIDs != null) { profiles = profiles.Where(s => s.WorkPlaceID != null && workPlaceIDs.Contains(s.WorkPlaceID.Value)).ToList(); } if (shiftIDs != null) { workDays = workDays.Where(s => s.ShiftID.HasValue && shiftIDs.Contains(s.ShiftID.Value)).ToList(); profileIds = workDays.Select(s => s.ProfileID).ToList(); profiles = profiles.Where(s => profileIds.Contains(s.ID)).ToList(); } if (!isIncludeQuitEmp) { profiles = profiles.Where(s => s.DateQuit == null || s.DateQuit > dateStart).ToList(); } profileIds = profiles.Select(s => s.ID).ToList(); var attendanceTables = repoAtt_AttendencaTable .FindBy(s => s.IsDelete == null && s.CutOffDurationID == CutOffDurationID && profileIds.Contains(s.ProfileID)) .ToList(); List<Guid> attendanceTablesID = attendanceTables.Select(s => s.ID).ToList(); var attendanceTableItem = repoAtt_AttendanceTableItem .FindBy(s => s.IsDelete == null && attendanceTablesID.Contains(s.AttendanceTableID)) .ToList(); if (isNotAllowZero) { profileIds = attendanceTables.Select(s => s.ProfileID).ToList(); profiles = profiles.Where(s => profileIds.Contains(s.ID)).ToList(); } profileIds = attendanceTables.Select(s => s.ProfileID).ToList(); profiles = profiles.Where(s => profileIds.Contains(s.ID)).ToList(); foreach (var profile in profiles) { var attendanceTableProfile = attendanceTables.FirstOrDefault(s => s.ProfileID == profile.ID); var timeSheetByProfile = timesheets.Where(s => s.ProfileID == profile.ID).ToList(); if (timeSheetByProfile == null) { continue; } var lstjobtypebytimesheetpro = timeSheetByProfile.Select(s => s.JobTypeID).ToList(); var lstJobTypeCodeByTimeSheet = jobtypes.Where(s => lstjobtypebytimesheetpro.Contains(s.ID)).Select(s => new { s.ID, s.Code, s.RoleID }).ToList(); if (attendanceTableProfile == null) { continue; } var attendanceTableItemProfile = attendanceTableItem.Where(s => s.AttendanceTableID == attendanceTableProfile.ID).ToList(); DataRow row = table.NewRow(); Guid? orgId = profile.OrgStructureID; var org = orgs.FirstOrDefault(s => s.ID == profile.OrgStructureID); var orgBranch = LibraryService.GetNearestParent(orgId, OrgUnit.E_BRANCH, orgs, orgTypes); var orgOrg = LibraryService.GetNearestParent(orgId, OrgUnit.E_DEPARTMENT, orgs, orgTypes); var orgTeam = LibraryService.GetNearestParent(orgId, OrgUnit.E_TEAM, orgs, orgTypes); var orgSection = LibraryService.GetNearestParent(orgId, OrgUnit.E_SECTION, orgs, orgTypes); var positon = positions.FirstOrDefault(s => s.ID == profile.PositionID); var jobtitle = jobtitles.FirstOrDefault(s => s.ID == profile.JobTitleID); row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.ProfileName] = profile.ProfileName; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.CodeEmp] = profile.CodeEmp; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DepartmentCode] = orgOrg != null ? orgOrg.Code : string.Empty; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.BranchCode] = orgBranch != null ? orgBranch.Code : string.Empty; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.TeamCode] = orgTeam != null ? orgTeam.Code : string.Empty; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.SectionCode] = orgSection != null ? orgSection.Code : string.Empty; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.BranchName] = orgBranch != null ? orgBranch.OrgStructureName : string.Empty; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.TeamName] = orgTeam != null ? orgTeam.OrgStructureName : string.Empty; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.SectionName] = orgSection != null ? orgSection.OrgStructureName : string.Empty; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.PositionName] = positon != null ? positon.PositionName : string.Empty; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.JobTitleName] = jobtitle != null ? jobtitle.JobTitleName : string.Empty; if (profile.DateHire != null) row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.StartingDate] = profile.DateHire.Value; if (profile.DateQuit != null) row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.ResignedDate] = profile.DateQuit.Value; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DateFrom] = dateStart; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DateTo] = dateEnd; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.UserExport] = userExport; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DateExport] = DateTime.Today; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.StdWorkDayCount] = attendanceTableProfile.StdWorkDayCount > 0 ? attendanceTableProfile.StdWorkDayCount : 0.0; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.RealWorkDayCount] = attendanceTableProfile.RealWorkDayCount > 0 ? attendanceTableProfile.RealWorkDayCount : 0.0; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.PaidWorkDayCount] = attendanceTableProfile.PaidWorkDayCount > 0 ? attendanceTableProfile.PaidWorkDayCount : 0.0; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.AnlDayAvailable] = attendanceTableProfile.AnlDayAvailable > 0 ? attendanceTableProfile.AnlDayAvailable : 0.0; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.NightShiftHours] = attendanceTableProfile.NightShiftHours > 0 ? attendanceTableProfile.NightShiftHours : 0.0; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.LateEarlyDeductionHours] = attendanceTableProfile.LateEarlyDeductionHours > 0 ? attendanceTableProfile.LateEarlyDeductionHours : 0.0; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.AnlDayTaken] = attendanceTableProfile.AnlDayTaken > 0 ? attendanceTableProfile.AnlDayTaken : 0.0; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Note] = attendanceTableProfile.Note != null ? attendanceTableProfile.Note : string.Empty; foreach (var item in attendanceTableItemProfile) { if (item.LeaveTypeID != null) { row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Data + item.WorkDate.Day.ToString()] = leavedayTypes.Where(s => s.ID == item.LeaveTypeID).FirstOrDefault().Code; } } foreach (var roleEntity in listRole) { var lstJobTypeByRoleID = lstJobTypeCodeByTimeSheet.Where(s => s.RoleID == roleEntity.ID).ToList(); foreach (var jobcode in lstJobTypeByRoleID) { var CodeRoleAndJobType = roleEntity.Code + "_" + jobcode.Code; if (table.Columns.Contains(CodeRoleAndJobType)) { double? nohourByPro = timeSheetByProfile.Where(s => s.JobTypeID == jobcode.ID && s.RoleID == roleEntity.ID).Sum(s => s.NoHour); row[CodeRoleAndJobType] = nohourByPro; } } } table.Rows.Add(row); } return table.ConfigTable(); } }
public DataTable GetReportMonthlyTimeSheetV2(string WorkHourType, Guid? GradeAttendanceID, Guid CutOffDurationID, string strProfile, string strOrgStructure, string codeEmp, bool isIncludeQuitEmp, bool isNotAllowZero, bool isCreateTemplate, string userExport, string UserLogin, Guid? jobtitleID, Guid? positionID) { bool IsPaidHour = WorkHourType == EnumDropDown.WorkHourType.E_PAIDHOUR.ToString() ? true : false; using (var context = new VnrHrmDataContext()) { DataTable table = CreateReportMonthlyTimeSheetV2Schema(UserLogin); if (isCreateTemplate) { return table.ConfigDatatable(); } string status = string.Empty; var unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); var repoCat_OrgStructure = new Cat_OrgStructureRepository(unitOfWork); var repoCat_OrgStructureType = new Cat_OrgStructureTypeRepository(unitOfWork); var repoCat_Position = new Cat_PositionRepository(unitOfWork); var repoCat_JobTitle = new Cat_JobTitleRepository(unitOfWork); var repoWorkDay = new Att_WorkDayRepository(unitOfWork); var repoTimeSheet = new Att_TimeSheetRepository(unitOfWork); var repoJobtype = new Cat_JobTypeRepository(unitOfWork); var repoAtt_AttendencaTable = new CustomBaseRepository<Att_AttendanceTable>(unitOfWork); var repoAtt_AttendanceTableItem = new CustomBaseRepository<Att_AttendanceTableItem>(unitOfWork); var repoAtt_CutOffDuration = new CustomBaseRepository<Att_CutOffDuration>(unitOfWork); var orgsService = new Cat_OrgStructureServices(); List<object> objorgs = new List<object>(); var lstallorgs = orgsService.GetDataNotParam<Cat_OrgStructure>(ConstantSql.hrm_cat_sp_get_AllOrg, UserLogin, ref status).ToList(); var orgTypeService = new Cat_OrgStructureTypeServices(); var lstObjOrgType = new List<object>(); lstObjOrgType.Add(null); lstObjOrgType.Add(null); lstObjOrgType.Add(1); lstObjOrgType.Add(int.MaxValue - 1); var lstOrgType = orgTypeService.GetData<Cat_OrgStructureType>(lstObjOrgType, ConstantSql.hrm_cat_sp_get_OrgStructureType, UserLogin, ref status); var jobTypeServices = new Cat_JobTypeServices(); var lstjobType = new List<object>(); lstjobType.Add(null); lstjobType.Add(null); lstjobType.Add(1); lstjobType.Add(Int32.MaxValue - 1); var listjobType = jobTypeServices.GetData<Cat_JobTypeEntity>(lstjobType, ConstantSql.hrm_cat_sp_get_JobType, UserLogin, ref status).Where(s => s.Code != null).Select(m => new { m.ID, m.Code }).ToList(); var lstObjOrgByOrderNumberCount = new List<object>(); lstObjOrgByOrderNumberCount.Add(strOrgStructure); var lstOrgByOrderNumberCount = orgsService.GetData<Cat_OrgStructure>(lstObjOrgByOrderNumberCount, ConstantSql.hrm_cat_sp_get_OrgStructureByOrderNumber, UserLogin, ref status).ToList(); List<Hre_ProfileEntity> profiles = new List<Hre_ProfileEntity>(); List<object> lstParamHR = new List<object>(); lstParamHR.Add(strOrgStructure); lstParamHR.Add(null); lstParamHR.Add(null); if (strProfile != null) { List<Hre_ProfileEntity> _profileIDs = new List<Hre_ProfileEntity>(); var lst = strProfile.Split(',').Select(s => Guid.Parse(s)).ToList(); if (strOrgStructure != null) { profiles = GetData<Hre_ProfileEntity>(strOrgStructure, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, UserLogin, ref status).ToList(); _profileIDs = profiles.Where(m => !lst.Contains(m.ID)).ToList(); profiles.AddRange(_profileIDs); } else { string selectedIds = Common.DotNetToOracle(strProfile); profiles = GetData<Hre_ProfileEntity>(selectedIds, ConstantSql.hrm_hr_sp_get_ProfileByIds, UserLogin, ref status).ToList(); } } else { profiles = GetData<Hre_ProfileEntity>(lstParamHR, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, UserLogin, ref status).ToList(); } if (GradeAttendanceID != null && GradeAttendanceID != Guid.Empty) { var lstObjAttGrade = new List<object>(); lstObjAttGrade.AddRange(new object[6]); lstObjAttGrade[1] = Common.DotNetToOracle(GradeAttendanceID.Value.ToString()); lstObjAttGrade[4] = 1; lstObjAttGrade[5] = int.MaxValue - 1; var lstAttGrade = GetData<Att_GradeEntity>(lstObjAttGrade, ConstantSql.hrm_att_sp_get_Att_Grade, UserLogin, ref status).ToList(); List<Guid> lstProOfGrade = lstAttGrade.Select(s => s.ProfileID.Value).Distinct().ToList(); profiles = profiles.Where(s => lstProOfGrade.Contains(s.ID)).ToList(); } var cutoffInfo = repoAtt_CutOffDuration.FindBy(s => s.ID == CutOffDurationID).FirstOrDefault(); var leavedayTypes = unitOfWork.CreateQueryable<Cat_LeaveDayType>(Guid.Empty, s => s.CodeStatistic != null).Select(s => new { s.Code, s.CodeStatistic, s.ID, s.PaidRate, s.LeaveDayTypeName }).ToList(); var overtimeTypes = unitOfWork.CreateQueryable<Cat_OvertimeType>(Guid.Empty, s => s.CodeStatistic != null).ToList(); DateTime dateStart = cutoffInfo.DateStart; DateTime dateEnd = cutoffInfo.DateEnd; if (!isIncludeQuitEmp) { profiles = profiles.Where(s => s.DateQuit == null || s.DateQuit > dateStart).ToList(); } if(jobtitleID != null) { profiles = profiles.Where(s => s.JobTitleID == jobtitleID).ToList(); } if (positionID != null) { profiles = profiles.Where(s => s.PositionID == positionID).ToList(); } List<Guid> profileIds = profiles.Select(s => s.ID).ToList(); var timesheets = new List<Att_TimeSheet>().Select(s => new { s.ProfileID, s.JobTypeID, s.RoleID, s.Date, s.NoHour, s.ID, s.Note, s.Sector }).ToList(); var workDays = new List<Att_Workday>().Select(s => new { s.ProfileID, s.ShiftID, s.Status }).ToList(); var attendanceTables = new List<Att_AttendanceTable>(); var attendanceTableItems = new List<Att_AttendanceTableItem>(); foreach (var item in profileIds.Chunk(1000)) { timesheets.AddRange(repoTimeSheet.FindBy(s => s.ProfileID != null && item.Contains(s.ProfileID.Value) && s.Date != null && dateStart <= s.Date && s.Date <= dateEnd && s.IsDelete == null).Select(s => new { s.ProfileID, s.JobTypeID, s.RoleID, s.Date, s.NoHour, s.ID, s.Note, s.Sector }).ToList()); workDays.AddRange(repoWorkDay.FindBy(s => item.Contains(s.ProfileID) && dateStart <= s.WorkDate && s.WorkDate <= dateEnd && s.IsDelete == null).Select(s => new { s.ProfileID, s.ShiftID, s.Status }).ToList()); attendanceTables.AddRange(repoAtt_AttendencaTable.FindBy(s => s.IsDelete == null && s.CutOffDurationID == CutOffDurationID && item.Contains(s.ProfileID)).ToList()); } var jobtypes = repoJobtype.FindBy(s => s.IsDelete == null).Select(s => new { s.ID, s.Code }).ToList(); List<Guid> attendanceTablesID = attendanceTables.Select(s => s.ID).ToList(); foreach (var item in attendanceTablesID.Chunk(1000)) { attendanceTableItems.AddRange(unitOfWork.CreateQueryable<Att_AttendanceTableItem>(s => s.IsDelete == null && item.Contains(s.AttendanceTableID)).ToList()); } if (isNotAllowZero) { profileIds = attendanceTables.Where(x => x.StdWorkDayCount > 0).Select(s => s.ProfileID).ToList(); profiles = profiles.Where(s => profileIds.Contains(s.ID)).ToList(); } profileIds = attendanceTables.Select(s => s.ProfileID).ToList(); profiles = profiles.Where(s => profileIds.Contains(s.ID)).ToList(); int p = 0; foreach (var profile in profiles) { p += 1; var attendanceTableProfile = attendanceTables.FirstOrDefault(s => s.ProfileID == profile.ID); var timeSheetByProfile = timesheets.Where(s => s.ProfileID == profile.ID).ToList(); //if (timeSheetByProfile == null) //{ // continue; //} var lstjobtypebytimesheetpro = timeSheetByProfile.Select(s => s.JobTypeID).ToList(); var lstJobTypeCodeByTimeSheet = jobtypes.Where(s => lstjobtypebytimesheetpro.Contains(s.ID)).Select(s => new { s.ID, s.Code }).ToList(); if (attendanceTableProfile == null) { continue; } var attendanceTableItemProfile = attendanceTableItems.Where(s => s.AttendanceTableID == attendanceTableProfile.ID).ToList(); DataRow row = table.NewRow(); //Guid? orgId = profile.OrgStructureID; //var org = orgs.FirstOrDefault(s => s.ID == profile.OrgStructureID); //var orgBranch = LibraryService.GetNearestParent(orgId, OrgUnit.E_BRANCH, orgs, orgTypes); //var orgOrg = LibraryService.GetNearestParent(orgId, OrgUnit.E_DEPARTMENT, orgs, orgTypes); //var orgTeam = LibraryService.GetNearestParent(orgId, OrgUnit.E_TEAM, orgs, orgTypes); //var orgSection = LibraryService.GetNearestParent(orgId, OrgUnit.E_SECTION, orgs, orgTypes); //var positon = positions.FirstOrDefault(s => s.ID == profile.PositionID); //var jobtitle = jobtitles.FirstOrDefault(s => s.ID == profile.JobTitleID); row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.ProfileName] = profile.ProfileName; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.CodeEmp] = profile.CodeEmp; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DepartmentName] = profile.OrgStructureName; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DepartmentCode] = profile.OrgStructureCode; if (profile.DateHire.HasValue) row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DateHire] = profile.DateHire.Value; if (profile.DateEndProbation.HasValue) row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DateEndProbation] = profile.DateEndProbation.Value; if (profile.E_COMPANY != null) row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_COMPANY] = profile.E_COMPANY; if (profile.E_BRANCH != null) row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_BRANCH] = profile.E_BRANCH; if (profile.E_UNIT != null) row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_UNIT] = profile.E_UNIT; if (profile.E_DIVISION != null) row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_DIVISION] = profile.E_DIVISION; if (profile.E_DEPARTMENT != null) row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_DEPARTMENT] = profile.E_DEPARTMENT; if (profile.E_TEAM != null) row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_TEAM] = profile.E_TEAM; if (profile.E_SECTION != null) row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_SECTION] = profile.E_SECTION; //row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DepartmentCode] = orgOrg != null ? orgOrg.Code : string.Empty; //row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.BranchCode] = orgBranch != null ? orgBranch.Code : string.Empty; //row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.TeamCode] = orgTeam != null ? orgTeam.Code : string.Empty; //row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.SectionCode] = orgSection != null ? orgSection.Code : string.Empty; //row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.BranchName] = orgBranch != null ? orgBranch.OrgStructureName : string.Empty; //row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.TeamName] = orgTeam != null ? orgTeam.OrgStructureName : string.Empty; //row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.SectionName] = orgSection != null ? orgSection.OrgStructureName : string.Empty; #region Lấy Tên Phòng ban cho BDF var orgName = GetParentOrg(lstallorgs, lstOrgType, profile.OrgStructureID); if (orgName.Count != 0) { if (orgName.Count < 3) { orgName.Insert(0, string.Empty); if (orgName.Count < 3) { orgName.Insert(0, string.Empty); } } row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Channel] = orgName[2]; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Region] = orgName[1]; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Area] = orgName[0]; } #endregion #region Lấy phòng ban cho VietNam EASport row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_COMPANY] = profile.E_COMPANY; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_BRANCH] = profile.E_BRANCH; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_UNIT] = profile.E_UNIT; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_DIVISION] = profile.E_DIVISION; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_DEPARTMENT] = profile.E_DEPARTMENT; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_TEAM] = profile.E_TEAM; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_SECTION] = profile.E_SECTION; #endregion //row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.PositionName] = positon != null ? positon.PositionName : string.Empty; //row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.JobTitleName] = jobtitle != null ? jobtitle.JobTitleName : string.Empty; if (profile.DateHire != null) row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.StartingDate] = profile.DateHire.Value; if (profile.DateQuit != null) row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.ResignedDate] = profile.DateQuit.Value; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DateFrom] = dateStart; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DateTo] = dateEnd; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DateExport] = DateTime.Today; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.UserExport] = userExport; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.StdWorkDayCount] = attendanceTableProfile.StdWorkDayCount > 0 ? attendanceTableProfile.StdWorkDayCount : 0.0; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.RealWorkDayCount] = attendanceTableProfile.RealWorkDayCount > 0 ? attendanceTableProfile.RealWorkDayCount : 0.0; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.PaidWorkDayCount] = attendanceTableProfile.PaidWorkDayCount > 0 ? attendanceTableProfile.PaidWorkDayCount : 0.0; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.HourPerDay] = attendanceTableProfile.HourPerDay > 0 ? attendanceTableProfile.HourPerDay : 0.0; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.AnlDayAvailable] = attendanceTableProfile.AnlDayAvailable > 0 ? attendanceTableProfile.AnlDayAvailable : 0.0; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.NightShiftHours] = attendanceTableProfile.NightShiftHours > 0 ? attendanceTableProfile.NightShiftHours : 0.0; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.LateEarlyDeductionHours] = attendanceTableProfile.LateEarlyDeductionHours > 0 ? attendanceTableProfile.LateEarlyDeductionHours : 0.0; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Note] = attendanceTableProfile.Note != null ? attendanceTableProfile.Note : string.Empty; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.UnPaidLeave] = attendanceTableProfile.UnPaidLeave > 0 ? attendanceTableProfile.UnPaidLeave : 0.0; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.AnlDayTaken] = attendanceTableProfile.AnlDayTaken > 0 ? attendanceTableProfile.AnlDayTaken : 0.0; row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.SickDayTaken] = attendanceTableProfile.SickDayTaken > 0 ? attendanceTableProfile.SickDayTaken : 0.0; double preg = 0.0; #region code cũ xử lý đổ (Data + Day) //foreach (var item in attendanceTableItemProfile) //{ // if (item.IsHavingPregTreatment) // { // preg += 1; // } // if (item.LeaveTypeID != null) // { // row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Data + item.WorkDate.Day.ToString()] = leavedayTypes.Where(s => s.ID == item.LeaveTypeID).FirstOrDefault().Code; // } // else // { // if (IsPaidHour) // { // row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Data + item.WorkDate.Day.ToString()] = item.WorkPaidHours; // } // else // { // row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Data + item.WorkDate.Day.ToString()] = item.WorkHours; // } // } //} #endregion attendanceTableItemProfile = attendanceTableItemProfile.OrderBy(s => s.WorkDate).ToList(); Dictionary<string, double> leave_Hour = new Dictionary<string, double>(); for (int i = 0; i < attendanceTableItemProfile.Count; i++) { int stt = i + 1; if (attendanceTableItemProfile[i].IsHavingPregTreatment) { preg += 1; } if (attendanceTableItemProfile[i].LeaveTypeID != null) { var leave = leavedayTypes.Where(s => s.ID == attendanceTableItemProfile[i].LeaveTypeID).FirstOrDefault(); if (attendanceTableItemProfile[i].LeaveDays == 0.5) { row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Data + stt] = leave.CodeStatistic + "/2"; } else { row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Data + stt] = leave.CodeStatistic; } if (leave.CodeStatistic == null) continue; if (leave_Hour.ContainsKey(leave.CodeStatistic)) leave_Hour[leave.CodeStatistic] += attendanceTableItemProfile[i].LeaveHours; else leave_Hour[leave.CodeStatistic] = attendanceTableItemProfile[i].LeaveHours; } else { if (IsPaidHour) { row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Data + stt] = attendanceTableItemProfile[i].WorkPaidHours; } else { row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Data + stt] = attendanceTableItemProfile[i].WorkHours; } } } foreach (var leave in leavedayTypes) { if (leave.CodeStatistic == null) continue; if (leave_Hour.ContainsKey(leave.CodeStatistic)) { row[leave.CodeStatistic] = leave_Hour[leave.CodeStatistic]; } } #region Tăng Ca if (attendanceTableProfile.Overtime1Type != null) { var overtime = overtimeTypes.Where(s => s.ID == attendanceTableProfile.Overtime1Type).FirstOrDefault(); if (overtime != null) row[overtime.CodeStatistic] = attendanceTableProfile.Overtime1Hours; } if (attendanceTableProfile.Overtime2Type != null) { var overtime = overtimeTypes.Where(s => s.ID == attendanceTableProfile.Overtime2Type).FirstOrDefault(); if (overtime != null) row[overtime.CodeStatistic] = attendanceTableProfile.Overtime2Hours; } if (attendanceTableProfile.Overtime3Type != null) { var overtime = overtimeTypes.Where(s => s.ID == attendanceTableProfile.Overtime3Type).FirstOrDefault(); if (overtime != null) row[overtime.CodeStatistic] = attendanceTableProfile.Overtime3Hours; } if (attendanceTableProfile.Overtime4Type != null) { var overtime = overtimeTypes.Where(s => s.ID == attendanceTableProfile.Overtime4Type).FirstOrDefault(); if (overtime != null) row[overtime.CodeStatistic] = attendanceTableProfile.Overtime4Hours; } if (attendanceTableProfile.Overtime5Type != null) { var overtime = overtimeTypes.Where(s => s.ID == attendanceTableProfile.Overtime5Type).FirstOrDefault(); if (overtime != null) row[overtime.CodeStatistic] = attendanceTableProfile.Overtime5Hours; } if (attendanceTableProfile.Overtime6Type != null) { var overtime = overtimeTypes.Where(s => s.ID == attendanceTableProfile.Overtime6Type).FirstOrDefault(); if (overtime != null) row[overtime.CodeStatistic] = attendanceTableProfile.Overtime6Hours; } #endregion row[Att_ReportMonthlyTimeSheetV2Entity.FieldNames.TotalPregnancy] = preg; foreach (var jobcode in listjobType) { if (table.Columns.Contains(jobcode.Code)) { double? nohourByPro = timeSheetByProfile.Where(s => s.JobTypeID == jobcode.ID).Sum(s => s.NoHour); double? sectorByPro = timeSheetByProfile.Where(s => s.JobTypeID == jobcode.ID).Sum(s => s.Sector); row[jobcode.Code] = nohourByPro == null ? 0 : nohourByPro.Value; row[jobcode.Code + "_Sector"] = sectorByPro == null ? 0 : sectorByPro.Value; } } table.Rows.Add(row); } var configs = new Dictionary<string, Dictionary<string, object>>(); var config = new Dictionary<string, object>(); config.Add("format", "{0:dd/mm/yyyy}"); configs.Add("DateFrom", config); return table.ConfigTable(); } }
DataTable CreateReportMonthlyHourFlightLocalchema(string UserLogin) { using (var context = new VnrHrmDataContext()) { string status = string.Empty; DataTable tb = new DataTable("ReportMonthlyHourFlightLocal"); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.CodeEmp); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.ProfileName); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DepartmentCode); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.PositionName); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.JobTitleName); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.StdWorkDayCount, typeof(Double)); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.RealWorkDayCount, typeof(Double)); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.PaidWorkDayCount, typeof(Double)); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.AnlDayAvailable, typeof(Double)); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.NightShiftHours, typeof(Double)); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.LateEarlyDeductionHours, typeof(Double)); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.AnlDayTaken, typeof(Double)); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Note); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.ResignedDate, typeof(DateTime)); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.StartingDate, typeof(DateTime)); //tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Note); for (int i = 1; i <= 31; i++) { DataColumn column = new DataColumn(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Data + i); column.Caption = i.ToString(); tb.Columns.Add(column); } #region MyRegion var leavedayTypeServices = new Cat_LeaveDayTypeServices(); var lstObjLeavedayType = new List<object>(); lstObjLeavedayType.Add(null); lstObjLeavedayType.Add(null); lstObjLeavedayType.Add(1); lstObjLeavedayType.Add(100000000); var lstLeavedayType = leavedayTypeServices.GetData<Cat_LeaveDayTypeEntity>(lstObjLeavedayType, ConstantSql.hrm_cat_sp_get_LeaveDayType, UserLogin, ref status).Where(s => s.Code != null).Select(m => m.Code).ToList(); foreach (var item in lstLeavedayType) { if (!tb.Columns.Contains(item)) { tb.Columns.Add(item); } } #endregion tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.BranchCode); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.TeamCode); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.SectionCode); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DepartmentName); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.BranchName); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.TeamName); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.SectionName); var jobTypeServices = new Cat_JobTypeServices(); var lstjobType = new List<object>(); lstjobType.Add(null); lstjobType.Add(null); lstjobType.Add(1); lstjobType.Add(100000000); var listjobType = jobTypeServices.GetData<Cat_JobTypeEntity>(lstjobType, ConstantSql.hrm_cat_sp_get_JobType, UserLogin, ref status).Where(s => s.Code != null).Select(m => new { m.RoleID, m.Code }).ToList(); var roleServices = new Cat_RoleServices(); var lstRole = new List<object>(); lstRole.Add(null); lstRole.Add(null); lstRole.Add(1); lstRole.Add(100000000); var listRole = roleServices.GetData<Cat_RoleEntity>(lstRole, ConstantSql.hrm_cat_sp_get_Role, UserLogin, ref status).Where(s => s.Code != null).Select(m => new { m.Code, m.ID }).ToList(); foreach (var roleEntity in listRole) { var lstJobTypeByRole = listjobType.Where(s => s.RoleID == roleEntity.ID).ToList(); foreach (var item in lstJobTypeByRole) { var CodeRoleAndJobType = roleEntity.Code + "_" + item.Code; if (!tb.Columns.Contains(CodeRoleAndJobType)) { tb.Columns.Add(CodeRoleAndJobType); } } } tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DateFrom, typeof(DateTime)); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DateTo, typeof(DateTime)); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.UserExport); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DateExport, typeof(DateTime)); return tb; } }
DataTable CreateReportMonthlyTimeSheetV2Schema(string UserLogin) { using (var context = new VnrHrmDataContext()) { var unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); string status = string.Empty; DataTable tb = new DataTable("ReportMonthlyTimeSheetV2"); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DateHire, typeof(DateTime)); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DateEndProbation, typeof(DateTime)); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.CodeEmp); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.ProfileName); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DepartmentCode); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.PositionName); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.JobTitleName); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.StdWorkDayCount, typeof(Double)); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.RealWorkDayCount, typeof(Double)); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.PaidWorkDayCount, typeof(Double)); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.HourPerDay, typeof(Double)); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.AnlDayAvailable, typeof(Double)); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.NightShiftHours, typeof(Double)); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.LateEarlyDeductionHours, typeof(Double)); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.AnlDayTaken, typeof(Double)); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Note); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.ResignedDate, typeof(DateTime)); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.StartingDate, typeof(DateTime)); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DateFrom, typeof(DateTime)); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DateTo, typeof(DateTime)); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.UnPaidLeave, typeof(Double)); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.SickDayTaken, typeof(Double)); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.TotalPregnancy, typeof(Double)); //tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Note); for (int i = 1; i <= 45; i++) { DataColumn column = new DataColumn(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Data + i); column.Caption = i.ToString(); tb.Columns.Add(column); } #region MyRegion var leavedayTypeServices = new Cat_LeaveDayTypeServices(); //var lstObjLeavedayType = new List<object>(); //lstObjLeavedayType.Add(null); //lstObjLeavedayType.Add(null); //lstObjLeavedayType.Add(1); //lstObjLeavedayType.Add(100000000); //var lstLeavedayType = leavedayTypeServices.GetData<Cat_LeaveDayTypeEntity>(lstObjLeavedayType, ConstantSql.hrm_cat_sp_get_LeaveDayType, ref status).Where(s => s.CodeStatistic != null).Select(m => m.CodeStatistic).ToList(); var lstLeavedayType = unitOfWork.CreateQueryable<Cat_LeaveDayType>(Guid.Empty, s => s.CodeStatistic != null).Select(m => m.CodeStatistic).ToList(); foreach (var item in lstLeavedayType) { if (!tb.Columns.Contains(item)) { tb.Columns.Add(item, typeof(double)); } } var lstOvertimeType = unitOfWork.CreateQueryable<Cat_OvertimeType>(Guid.Empty, s => s.CodeStatistic != null).Select(m => m.CodeStatistic).ToList(); foreach (var item in lstOvertimeType) { if (!tb.Columns.Contains(item)) { tb.Columns.Add(item, typeof(double)); } } #endregion tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.BranchCode); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.TeamCode); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.SectionCode); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DepartmentName); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.BranchName); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.TeamName); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.SectionName); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Channel); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Region); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.Area); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_COMPANY); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_BRANCH); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_UNIT); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_DIVISION); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_DEPARTMENT); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_TEAM); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.E_SECTION); var jobTypeServices = new Cat_JobTypeServices(); var lstjobType = new List<object>(); lstjobType.Add(null); lstjobType.Add(null); lstjobType.Add(1); lstjobType.Add(100000000); var listjobType = jobTypeServices.GetData<Cat_JobTypeEntity>(lstjobType, ConstantSql.hrm_cat_sp_get_JobType, UserLogin, ref status).Where(s => s.Code != null).Select(m => m.Code).ToList(); foreach (var item in listjobType) { if (!tb.Columns.Contains(item)) { tb.Columns.Add(item, typeof(double)); tb.Columns.Add(item + "_Sector", typeof(double)); } } tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.UserExport); tb.Columns.Add(Att_ReportMonthlyTimeSheetV2Entity.FieldNames.DateExport, typeof(DateTime)); return tb; } }