public void NUnit_WorkDay_Domain_Add() { Att_WorkDayServices service = new Att_WorkDayServices(); string result = string.Empty; int countSC = 0; for (int i = 1; i <= 10; i++) { var model = new Att_WorkDay { ProfileID = 1, WorkDate = DateTime.Parse("10-05-14"), FirstInTime = DateTime.Parse("10-05-14 08:00:00"), LastOutTime = DateTime.Parse("10-05-14 23:00:00"), WorkDuration = 15 }; result = service.Add(model); if (result != string.Empty) { countSC += 1; Console.WriteLine("Process Success >>> Create >>> " + model.Id ); } } Console.WriteLine("Total success record: " + countSC); }
public void NUnit_WorkDay_Domain_Get() { Att_WorkDayServices service = new Att_WorkDayServices(); string status = string.Empty; var repo = service.GetAllUseEntity<Att_WorkDayEntity>(ref status); Console.Write("Total Record: " + repo.Count()); }
/// <summary> /// [Son.Vo] - Xóa hoặc chuyển đổi trạng thái của Lịch Sử Thẻ(Att_WorkDay) sang IsDelete /// </summary> /// <param name="id"></param> /// <returns></returns> public Att_WorkdayModel DeleteOrRemove(Guid id) { //ActionService service = new ActionService(UserLogin); //var result = service.DeleteOrRemove<Att_WorkdayEntity, Att_WorkdayModel>(id); //return result; Att_WorkDayServices service = new Att_WorkDayServices(); var result = service.Remove<Att_WorkdayEntity>(id); //return result; return new Att_WorkdayModel(); }
//SonVo - 20140617 - chuyển thành trạng thái Sumit public ActionResult SubmitWorkDay(string selectedIds) { List<Guid> ids = new List<Guid>(); if (selectedIds != null) { ids = selectedIds .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Select(x => new Guid(x)) .ToList(); } Att_WorkDayServices service = new Att_WorkDayServices(); service.SubmitWorkDay(ids); return Json(""); }
public void NUnit_WorkDay_Domain_GetById() { string status = string.Empty; Att_WorkDayServices service = new Att_WorkDayServices(); var model = new Att_WorkDay { Id = 3 }; var result = service.GetById<Att_WorkDayEntity>(model.Id, ref status) as Att_WorkDayEntity; NUnit.Framework.Assert.IsNotNull(result); Console.Write("SearchResult: " + result.Id + " | " + result.ProfileID + " | " + result.WorkDate + " | " + result.FirstInTime //+ " | " + result.FirstOutTime //+ " | " + result.LastInTime + " | " + result.LastOutTime + " | " + result.WorkDuration + " | " + result.EarlyDuration1 + " | " + result.LateDuration1 + " | " + result.LateEarlyDuration ); }
public IEnumerable<Att_OvertimeModel> Post(Att_ComputeOvertimeModel model) { Att_WorkDayServices serviceWorkDay = new Att_WorkDayServices(); var status = string.Empty; var lstWorkDay = serviceWorkDay.GetWorkDaysByInOut(model.DateFrom, model.DateTo); Cat_ShiftServices serviceShift = new Cat_ShiftServices(); var lstShift = serviceShift.GetDataNotParam<Cat_ShiftEntity>(ConstantSql.hrm_cat_sp_get_Shift, UserLogin, ref status); //Cat_ShiftItemServices serviceShiftItem = new Cat_ShiftItemServices(); //var lstShiftItem = serviceShiftItem.GetCatShiftItem(); var lstShiftItem = new List<Cat_ShiftItemEntity>(); Cat_DayOffServices servicesDayOff = new Cat_DayOffServices(); var lstDayOff = servicesDayOff.GetAllUseEntity<Cat_DayOffEntity>(ref status).ToList(); Cat_OvertimeTypeServices servicesOvertimeType = new Cat_OvertimeTypeServices(); var lstOvertimeType = servicesOvertimeType.GetDataNotParam<Cat_OvertimeTypeEntity>(ConstantSql.hrm_cat_sp_get_OvertimeType, UserLogin, ref status); var Att_OvertimeInfoFillterAnalyze = new Att_OvertimeInfoFillterAnalyze() { isAllowGetAfterShift = model.isAllowGetAfterShift, isAllowGetBeforeShift = model.isAllowGetBeforeShift, isAllowGetInShift = model.isAllowGetInShift, isAllowGetOTOutterShift = model.isAllowGetOTOutterShift, isAllowGetTypeBaseOnActualDate = model.isAllowGetTypeBaseOnActualDate, isAllowGetTypeBaseOnBeginShift = model.isAllowGetTypeBaseOnBeginShift, isAllowGetTypeBaseOnEndShift = model.isAllowGetTypeBaseOnEndShift, MininumOvertimeHour = model.MininumOvertimeHour }; var service = new Att_OvertimeServices(); var result = service.AnalyzeOvertime(lstWorkDay, lstShift, lstShiftItem, lstDayOff, lstOvertimeType, Att_OvertimeInfoFillterAnalyze, UserLogin).ToList().Translate<Att_OvertimeModel>(); return result; }
public void NUnit_WorkDay_Domain_Edit() { Att_WorkDayServices service = new Att_WorkDayServices(); var model = new Att_WorkDay { Id = 5, ProfileID = 1 }; string result = service.Edit(model); if (result != string.Empty) { Console.WriteLine("Process Success >>> Update >>> " + model.Id + " | " + model.ProfileID + " | " + model.WorkDate ); } }
public void NUnit_WorkDay_Domain_SummaryInOut() { #region listShift using (var contextCategory = new VnrHrmDataContext()) { List<Cat_Shift> listShift = new List<Cat_Shift>(); Cat_Shift _shift = new Cat_Shift() { Id = 1, ShiftName = "Ca Test", InTime = DateTime.Parse("01-09-14 08:00:00"), CoOut = 9, CoBreakIn = 4, CoBreakOut = 5, }; listShift.Add(_shift); contextCategory.Cat_Shift.Add(_shift); contextCategory.SaveChanges(); } #endregion #region listRoster using (var contextAtt = new VnrHrmDataContext()) { List<Att_Roster> listRoster = new List<Att_Roster>(); Att_Roster _roster = new Att_Roster() { ProfileID = 1, RosterGroupName = "Nhom 1", Type = "E_DEFAULT", Status = "", DateEnd = DateTime.Parse("01-03-2014"), DateStart = DateTime.Parse("01-02-2014"), MonShiftID = 1, TueShiftID = 1, WedShiftID = 1, ThuShiftID = 1, FriShiftID = 1, SatShiftID = 1, SunShiftID = 1 }; listRoster.Add(_roster); contextAtt.Att_Roster.Add(_roster); contextAtt.SaveChanges(); #endregion #region listTamScanLog List<Att_TAMScanLog> listTamScanLog = new List<Att_TAMScanLog>(); Att_TAMScanLog _tamScanLog1 = new Att_TAMScanLog() { CardCode = "123", TimeLog = DateTime.Parse("01-02-2014 08:00:00"), SrcType = "E_IN", Type = "" }; Att_TAMScanLog _tamScanLog2 = new Att_TAMScanLog() { CardCode = "123", TimeLog = DateTime.Parse("01-02-2014 17:00:00"), SrcType = "E_OUT", Type = "" }; Att_TAMScanLog _tamScanLog3 = new Att_TAMScanLog() { CardCode = "123", TimeLog = DateTime.Parse("02-02-2014 08:00:00"), SrcType = "E_IN", Type = "" }; Att_TAMScanLog _tamScanLog4 = new Att_TAMScanLog() { CardCode = "123", TimeLog = DateTime.Parse("02-02-2014 17:00:00"), SrcType = "E_OUT", Type = "" }; listTamScanLog.Add(_tamScanLog1); listTamScanLog.Add(_tamScanLog2); listTamScanLog.Add(_tamScanLog3); listTamScanLog.Add(_tamScanLog4); contextAtt.Att_TAMScanLog.Add(_tamScanLog1); contextAtt.Att_TAMScanLog.Add(_tamScanLog2); contextAtt.Att_TAMScanLog.Add(_tamScanLog3); contextAtt.Att_TAMScanLog.Add(_tamScanLog4); contextAtt.SaveChanges(); } #endregion # region CardHistory using (var contextHr = new VnrHrmDataContext()) { List<Hre_CardHistory> listcardhistory = new List<Hre_CardHistory>(); Hre_CardHistory cardhistory = new Hre_CardHistory() { ProfileID = 1, CardCode = "123", DateEffect = DateTime.Parse("01-01-2014") }; listcardhistory.Add(cardhistory); contextHr.Hre_CardHistory.Add(cardhistory); contextHr.SaveChanges(); } #endregion DateTime dateFrom = DateTime.Parse("01-02-2014"); DateTime dateTo = DateTime.Parse("01-03-2014"); List<int> listSelectedProfileID = new List<int>(){1,2}; Att_WorkDayServices service = new Att_WorkDayServices(); //List<Att_WorkDayEntity> ListInOut = service.SummaryInOut(dateFrom, dateTo, listSelectedProfileID); }
public void NUnit_WorkDay_Domain_Delete() { Att_WorkDayServices service = new Att_WorkDayServices(); int rs = 0; var model = new Att_WorkDay { Id = 3 }; string result = service.Delete<Att_WorkDayEntity>(model.Id); if (result != string.Empty) { rs += 1; Console.WriteLine("Process Success >>> Delete >>> " + model.Id); } }
public void SaveLeaveData(List<Att_WorkdayEntity> lstWorkDate, Guid LeaveDayCode, Guid? UserApproved,string userLogin, string Comment) { string status = string.Empty; List<Att_LeaveDayEntity> lstLeaveDaySave = new List<Att_LeaveDayEntity>(); var workDate = new Att_WorkDayServices(); var hre_Profile = new Hre_ProfileServices(); #region getData List<object> lstobject = new List<object>(); lstobject.AddRange(new object[18]); lstobject[16] = 1; lstobject[17] = int.MaxValue - 1; List<Guid> lstProfileId = lstWorkDate.Select(m => m.ProfileID).ToList(); var lstProfile = hre_Profile.GetData<Hre_ProfileEntity>(lstobject, ConstantSql.hrm_hr_sp_get_Profile, userLogin, ref status).Where(m => lstProfileId.Contains(m.ID)).Select(m => new { m.ID, m.CodeEmp, m.ProfileName }).ToList(); #endregion string Duplicate = string.Empty; foreach (var item in lstWorkDate) { if (!string.IsNullOrEmpty(item.udLeavedayCode1)) { var profile = lstProfile.Where(m => m.ID == item.ProfileID).FirstOrDefault(); if (profile != null) { bool isHaveValue = false; if (profile.ProfileName != string.Empty) { Duplicate += profile.ProfileName; isHaveValue = true; } if (profile.CodeEmp != string.Empty) { Duplicate += "[" + profile.CodeEmp + "]"; isHaveValue = true; } if (isHaveValue) { Duplicate += "; "; } } continue; } //Att_WorkdayEntity WorkdayModify = SaveLeaveDataItem(item.ID, LeaveDayCode, UserApproved, Comment, false); var message = SaveLeaveDataItem(item.ID, LeaveDayCode, UserApproved, Comment, false); } //DataErrorCode ErrorCode = EntityService.SubmitChanges(GuidContext, LoginUserID); return; }
public DataTable GetReportMonthlyTimeSheet(DateTime? dateStart, DateTime DateTo, string strOrgStructure, List<Hre_ProfileEntity> profiles, Guid[] shiftIDs, Guid[] payrollIDs, bool isIncludeQuitEmp, bool isNotAllowZero, Guid exportid, string UserLogin) { using (var context = new VnrHrmDataContext()) { DataTable table = CreateReportMonthlyTimeSheetSchema(UserLogin); dateStart = new DateTime(dateStart.Value.Year, dateStart.Value.Month, 1); DateTime monthEnd = new DateTime(dateStart.Value.Year, dateStart.Value.Month, DateTime.DaysInMonth(dateStart.Value.Year, dateStart.Value.Month)); monthEnd = monthEnd.AddDays(1).AddMilliseconds(-1); var unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); var repoProfile = new Hre_ProfileRepository(unitOfWork); var repoCat_OrgStructure = new Cat_OrgStructureRepository(unitOfWork); var orgs = repoCat_OrgStructure.FindBy(s => s.Code != null).ToList(); var repoCat_OrgStructureType = new Cat_OrgStructureTypeRepository(unitOfWork); var orgTypes = repoCat_OrgStructureType.FindBy(s => s.IsDelete == null).ToList(); var repoCat_Position = new Cat_PositionRepository(unitOfWork); var positions = repoCat_Position.FindBy(s => s.Code != null).Select(s => new { s.ID, s.Code, s.PositionName }).ToList(); var repoCat_JobTitle = new Cat_JobTitleRepository(unitOfWork); var jobtitles = repoCat_JobTitle.FindBy(s => s.Code != null).Select(s => new { s.ID, s.Code, s.JobTitleName }).ToList(); var repoCat_LeaveDayType = new Cat_LeaveDayTypeRepository(unitOfWork); var leavedayTypes = repoCat_LeaveDayType.FindBy(s => s.Code != null && s.IsDelete == null).Select(s => new { s.Code, s.ID, s.PaidRate, s.LeaveDayTypeName }).ToList(); var repoCat_OvertimeType = new Cat_OvertimeTypeRepository(unitOfWork); var overtimTypes = repoCat_OvertimeType.FindBy(s => s.Code != null && s.IsDelete == null).Select(s => new { s.ID, s.Code, s.OvertimeTypeName }).ToList(); var codeCenters = unitOfWork.CreateQueryable<Cat_CostCentre>(Guid.Empty, s => s.Code != null).Select(s => new { s.ID, s.Code }).ToList(); List<Guid> profileIds = profiles.Select(s => s.ID).ToList(); string status = string.Empty; List<object> para_reportWorDay = new List<object>(); para_reportWorDay.AddRange(new object[2]); para_reportWorDay[0] = dateStart; para_reportWorDay[0] = monthEnd; var repoWorkDay = new Att_WorkDayServices(); List<Att_WorkdayEntity> workDays = repoWorkDay.GetData<Att_WorkdayEntity>(para_reportWorDay, ConstantSql.hrm_att_sp_getdata_reportWorDay, UserLogin, ref status).ToList(); workDays = workDays.Where(s => profileIds.Contains(s.ProfileID)).ToList(); if (payrollIDs != null) { profiles = profiles.Where(s => s.PayrollGroupID != null && payrollIDs.Contains(s.PayrollGroupID.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 repoAtt_AttendencaTable = new Att_AttendanceTableRepository(unitOfWork); List<object> para = new List<object>(); para.AddRange(new object[7]); para[3] = dateStart; para[4] = monthEnd; para[5] = 1; para[6] = int.MaxValue; var attService = new Att_AttendanceServices(); List<Att_AttendanceTableEntity> lstAttendanceTable = attService.GetData<Att_AttendanceTableEntity>(para, ConstantSql.hrm_att_sp_get_attdancetable, UserLogin, ref status).ToList(); var attendanceTables = lstAttendanceTable.Where(s => profileIds.Contains(s.ProfileID)).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); if (attendanceTableProfile == null) { continue; } 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 cost = codeCenters.FirstOrDefault(s => s.ID == profile.CostCentreID); var positon = positions.FirstOrDefault(s => s.ID == profile.PositionID); var jobtitle = jobtitles.FirstOrDefault(s => s.ID == profile.JobTitleID); row[Att_ReportMonthlyTimeSheetEntity.FieldNames.ProfileName] = profile.ProfileName; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.CodeEmp] = profile.CodeEmp; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.DepartmentCode] = orgOrg != null ? orgOrg.Code : string.Empty; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.BranchCode] = orgBranch != null ? orgBranch.Code : string.Empty; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.TeamCode] = orgTeam != null ? orgTeam.Code : string.Empty; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.SectionCode] = orgSection != null ? orgSection.Code : string.Empty; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.CodeOrg] = orgOrg != null ? orgOrg.Code : string.Empty; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.BranchName] = orgBranch != null ? orgBranch.OrgStructureName : string.Empty; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.TeamName] = orgTeam != null ? orgTeam.OrgStructureName : string.Empty; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.SectionName] = orgSection != null ? orgSection.OrgStructureName : string.Empty; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.PositionName] = positon != null ? positon.PositionName : string.Empty; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.JobTitleName] = jobtitle != null ? jobtitle.JobTitleName : string.Empty; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.CodeCenter] = cost != null ? cost.Code : string.Empty; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.StdWorkDayCount] = attendanceTableProfile.StdWorkDayCount > 0 ? (object)attendanceTableProfile.StdWorkDayCount : DBNull.Value; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.RealWorkDayCount] = attendanceTableProfile.RealWorkDayCount > 0 ? (object)attendanceTableProfile.RealWorkDayCount : DBNull.Value; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.PaidWorkDayCount] = attendanceTableProfile.PaidWorkDayCount > 0 ? (object)attendanceTableProfile.PaidWorkDayCount : DBNull.Value; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.AnlDayAvailable] = attendanceTableProfile.AnlDayAvailable > 0 ? (object)attendanceTableProfile.AnlDayAvailable : DBNull.Value; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.NightShiftHours] = attendanceTableProfile.NightShiftHours > 0 ? (object)attendanceTableProfile.NightShiftHours : DBNull.Value; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.LateEarlyDeductionHours] = attendanceTableProfile.LateEarlyDeductionHours > 0 ? (object)attendanceTableProfile.LateEarlyDeductionHours : DBNull.Value; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.AnlDayTaken] = attendanceTableProfile.AnlDayTaken > 0 ? (object)attendanceTableProfile.AnlDayTaken : DBNull.Value; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.Note] = attendanceTableProfile.Note != null ? attendanceTableProfile.Note : string.Empty; #region Export theo cot dong if (exportid != Guid.Empty) { var leaday = leavedayTypes.FirstOrDefault(s => s.ID == attendanceTableProfile.LeaveDay1Type); if (leaday != null && !string.IsNullOrEmpty(leaday.Code) && table.Columns.Contains(leaday.Code)) { row[leaday.Code] = attendanceTableProfile.LeaveDay1Hours > 0 ? (object)attendanceTableProfile.LeaveDay1Hours : DBNull.Value; } leaday = leavedayTypes.FirstOrDefault(s => s.ID == attendanceTableProfile.LeaveDay2Type); if (leaday != null) { row[leaday.Code] = attendanceTableProfile.LeaveDay2Hours > 0 ? (object)attendanceTableProfile.LeaveDay2Hours : DBNull.Value; } leaday = leavedayTypes.FirstOrDefault(s => s.ID == attendanceTableProfile.LeaveDay3Type); if (leaday != null) { row[leaday.Code] = attendanceTableProfile.LeaveDay3Hours > 0 ? (object)attendanceTableProfile.LeaveDay3Hours : DBNull.Value; } leaday = leavedayTypes.FirstOrDefault(s => s.ID == attendanceTableProfile.LeaveDay4Type); if (leaday != null) { row[leaday.Code] = attendanceTableProfile.LeaveDay4Hours > 0 ? (object)attendanceTableProfile.LeaveDay4Hours : DBNull.Value; } var overtimeType = overtimTypes.FirstOrDefault(s => s.ID == attendanceTableProfile.Overtime1Type); if (overtimeType != null) { // row[overtimeType.Code] = attendanceTableProfile.Overtime1Hours > 0 ? (object)attendanceTableProfile.Overtime1Hours : DBNull.Value; row[overtimeType.OvertimeTypeName] = attendanceTableProfile.Overtime1Hours > 0 ? (object)attendanceTableProfile.Overtime1Hours : DBNull.Value; } overtimeType = overtimTypes.FirstOrDefault(s => s.ID == attendanceTableProfile.Overtime2Type); if (overtimeType != null) { // row[overtimeType.Code] = attendanceTableProfile.Overtime2Hours > 0 ? (object)attendanceTableProfile.Overtime2Hours : DBNull.Value; row[overtimeType.OvertimeTypeName] = attendanceTableProfile.Overtime2Hours > 0 ? (object)attendanceTableProfile.Overtime2Hours : DBNull.Value; } overtimeType = overtimTypes.FirstOrDefault(s => s.ID == attendanceTableProfile.Overtime3Type); if (overtimeType != null) { //row[overtimeType.Code] = attendanceTableProfile.Overtime3Hours > 0 ? (object)attendanceTableProfile.Overtime3Hours : DBNull.Value; row[overtimeType.OvertimeTypeName] = attendanceTableProfile.Overtime3Hours > 0 ? (object)attendanceTableProfile.Overtime3Hours : DBNull.Value; } overtimeType = overtimTypes.FirstOrDefault(s => s.ID == attendanceTableProfile.Overtime4Type); if (overtimeType != null) { //row[overtimeType.Code] = attendanceTableProfile.Overtime4Hours > 0 ? (object)attendanceTableProfile.Overtime4Hours : DBNull.Value; row[overtimeType.OvertimeTypeName] = attendanceTableProfile.Overtime4Hours > 0 ? (object)attendanceTableProfile.Overtime4Hours : DBNull.Value; } overtimeType = overtimTypes.FirstOrDefault(s => s.ID == attendanceTableProfile.Overtime5Type); if (overtimeType != null) { //row[overtimeType.Code] = attendanceTableProfile.Overtime5Hours > 0 ? (object)attendanceTableProfile.Overtime5Hours : DBNull.Value; row[overtimeType.OvertimeTypeName] = attendanceTableProfile.Overtime5Hours > 0 ? (object)attendanceTableProfile.Overtime5Hours : DBNull.Value; } overtimeType = overtimTypes.FirstOrDefault(s => s.ID == attendanceTableProfile.Overtime6Type); if (overtimeType != null) { //row[overtimeType.Code] = attendanceTableProfile.Overtime6Hours > 0 ? (object)attendanceTableProfile.Overtime6Hours : DBNull.Value; row[overtimeType.OvertimeTypeName] = attendanceTableProfile.Overtime6Hours > 0 ? (object)attendanceTableProfile.Overtime6Hours : DBNull.Value; } row[Att_ReportMonthlyTimeSheetEntity.FieldNames.CountLateEarly] = (object)attendanceTableProfile.CardMissingCount ?? DBNull.Value; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.CountLateLess2H] = (object)attendanceTableProfile.LateEarlyLeastCount ?? DBNull.Value; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.CountLateMore2H] = (object)attendanceTableProfile.LateEarlyGreaterCount ?? DBNull.Value; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.UsableLeave] = attendanceTableProfile.TotalAnlDayAvailable > 0 ? (object)attendanceTableProfile.TotalAnlDayAvailable : DBNull.Value; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.SickLeave] = attendanceTableProfile.TotalSickDayAvailable > 0 ? (object)attendanceTableProfile.TotalSickDayAvailable : DBNull.Value; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.CurrentMonth] = attendanceTableProfile.AnlDayTaken > 0 ? (object)attendanceTableProfile.AnlDayTaken : DBNull.Value; //row["SickCurrentMonth"] = attendanceTableProfile.SickDayTaken > 0 ? (object)attendanceTableProfile.SickDayTaken : DBNull.Value; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.SickCurrentMonth] = attendanceTableProfile.SickDayTaken > 0 ? (object)attendanceTableProfile.SickDayTaken : DBNull.Value; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.YearToDate] = attendanceTableProfile.AnlDayAdjacent > 0 ? (object)attendanceTableProfile.AnlDayAdjacent : DBNull.Value; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.SickYearToDate] = attendanceTableProfile.SickDayAdjacent > 0 ? (object)attendanceTableProfile.SickDayAdjacent : DBNull.Value; row[Att_ReportMonthlyTimeSheetEntity.FieldNames.SumMuteLateEarly] = (object)attendanceTableProfile.LateEarlyTotal ?? DBNull.Value; } #endregion table.Rows.Add(row); } if (exportid != Guid.Empty) { return table.ConfigDatatable(); } return table; } }
public DataTable GetReportDailyAttendance(DateTime dateStart, DateTime dateEnd, string userExport, List<Hre_ProfileEntity> lstProfileAll, Guid[] payrollIDs, bool excludeNotInOut, bool isCreateTemplate, string UserLogin) { using (var context = new VnrHrmDataContext()) { DataTable table = CreateReportDailyAttendanceSchema(); if (isCreateTemplate) { return table.ConfigDatatable(); } List<Guid> lstProfileIDs = lstProfileAll.Select(s => s.ID).ToList(); var unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); var repoAtt_Workday = new Att_WorkDayRepository(unitOfWork); 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_Shift = new Cat_ShiftRepository(unitOfWork); var repoWorkDay = new Att_WorkDayServices(); var repoCat_Shift = new Cat_ShiftServices(); var profiles = lstProfileAll.Select(s => new { s.ID, s.DateQuit, s.OrgStructureID, s.ProfileName, s.CodeEmp, s.PositionID, s.JobTitleID, s.PayrollGroupID }).ToList(); if (payrollIDs != null) { profiles = profiles.Where(m => m.PayrollGroupID != null && payrollIDs.Contains(m.PayrollGroupID.Value)).ToList(); } var profileIds = profiles.Select(s => s.ID).Distinct().ToList(); string status = string.Empty; string E_APPROVED = WorkdayStatus.E_APPROVED.ToString(); List<object> para_reportWorDay = new List<object>(); para_reportWorDay.AddRange(new object[3]); para_reportWorDay[1] = dateStart; para_reportWorDay[2] = dateEnd; List<Att_WorkdayEntity> workDays = repoWorkDay.GetData<Att_WorkdayEntity>(para_reportWorDay, ConstantSql.hrm_att_sp_getdata_reportWorDay, UserLogin, ref status).ToList(); workDays = workDays.Where(m => profileIds.Contains(m.ProfileID) && m.Status == E_APPROVED).ToList(); var orgs = repoCat_OrgStructure.FindBy(s => s.IsDelete == null && s.Code != null).ToList(); #region var orgTypes = repoCat_OrgStructureType.FindBy(s => s.IsDelete == null).ToList(); var positions = repoCat_Position.FindBy(s => s.IsDelete == null && s.Code != null).Select(s => new { s.ID, s.Code, s.PositionName }).ToList(); var jobtitles = repoCat_JobTitle.FindBy(s => s.IsDelete == null && s.Code != null).Select(s => new { s.ID, s.Code, s.JobTitleName }).ToList(); #endregion if (workDays == null || workDays.Count == 0) { return table; } profileIds = workDays.Select(m => m.ProfileID).Distinct().ToList(); profiles = profiles.Where(m => profileIds.Contains(m.ID)).ToList(); List<object> para_repoCatShift = new List<object>(); //para_repoCatShift.AddRange(new object[4]); //para_repoCatShift[0] = null; //para_repoCatShift[1] = null; //para_repoCatShift[2] = null; //para_repoCatShift[3] = null; List<Cat_ShiftEntity> lstShift = repoCat_Shift.GetData<Cat_ShiftEntity>(para_repoCatShift, ConstantSql.hrm_cat_sp_get_Shift, UserLogin, ref status).ToList(); foreach (var item in workDays) { DataRow row = table.NewRow(); row[Att_ReportDailyAttendanceEntity.FieldNames.DateFrom] = dateStart; row[Att_ReportDailyAttendanceEntity.FieldNames.DateTo] = dateEnd; var Profile = profiles.Where(m => m.ID == item.ProfileID).FirstOrDefault(); if (Profile != null) { row[Att_ReportDailyAttendanceEntity.FieldNames.CodeEmp] = Profile.CodeEmp != null ? Profile.CodeEmp : string.Empty; row[Att_ReportDailyAttendanceEntity.FieldNames.ProfileName] = Profile.ProfileName != null ? Profile.ProfileName : string.Empty; Guid? orgId = Profile.OrgStructureID; if (orgId != null) { 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); row[Att_ReportDailyAttendanceEntity.FieldNames.ProfileOrgCode] = orgOrg != null ? orgOrg.Code : string.Empty; row[Att_ReportDailyAttendanceEntity.FieldNames.DepartmentCode] = orgOrg != null ? orgOrg.Code : string.Empty; row[Att_ReportDailyAttendanceEntity.FieldNames.BranchCode] = orgBranch != null ? orgBranch.Code : string.Empty; row[Att_ReportDailyAttendanceEntity.FieldNames.TeamCode] = orgTeam != null ? orgTeam.Code : string.Empty; row[Att_ReportDailyAttendanceEntity.FieldNames.SectionCode] = orgSection != null ? orgSection.Code : string.Empty; row[Att_ReportDailyAttendanceEntity.FieldNames.BranchName] = orgBranch != null ? orgBranch.OrgStructureName : string.Empty; row[Att_ReportDailyAttendanceEntity.FieldNames.TeamName] = orgTeam != null ? orgTeam.OrgStructureName : string.Empty; row[Att_ReportDailyAttendanceEntity.FieldNames.SectionName] = orgSection != null ? orgSection.OrgStructureName : string.Empty; } var positon = positions.FirstOrDefault(s => s.ID == Profile.PositionID); var jobtitle = jobtitles.FirstOrDefault(s => s.ID == Profile.JobTitleID); row[Att_ReportDailyAttendanceEntity.FieldNames.PositionName] = positon != null ? positon.PositionName : string.Empty; row[Att_ReportDailyAttendanceEntity.FieldNames.JobTitleName] = jobtitle != null ? jobtitle.JobTitleName : string.Empty; } var shift = lstShift.Where(m => m.ID == item.ShiftID).FirstOrDefault(); if (shift != null) { row[Att_ReportDailyAttendanceEntity.FieldNames.ShiftName] = shift.ShiftName; } var shiftActual = lstShift.Where(m => m.ID == item.ShiftActual).FirstOrDefault(); if (shiftActual != null) { row[Att_ReportDailyAttendanceEntity.FieldNames.ActualShift] = shiftActual.ShiftName; } if (item.WorkDate != null) { row[Att_ReportDailyAttendanceEntity.FieldNames.WorkDate] = item.WorkDate; } var shiftApprove = lstShift.Where(m => m.ID == item.ShiftApprove).FirstOrDefault(); if (shiftApprove != null) { row[Att_ReportDailyAttendanceEntity.FieldNames.ApprovedShift] = shiftApprove.ShiftName; } if (item.InTime1 != null) { row[Att_ReportDailyAttendanceEntity.FieldNames.TimeIn] = item.InTime1; } if (item.OutTime1 != null) { row[Att_ReportDailyAttendanceEntity.FieldNames.TimeOut] = item.OutTime1; } row[Att_ReportDailyAttendanceEntity.FieldNames.Type] = item.Type; row[Att_ReportDailyAttendanceEntity.FieldNames.SrcType] = item.SrcType; row[Att_ReportDailyAttendanceEntity.FieldNames.Status] = item.Status; row[Att_ReportDailyAttendanceEntity.FieldNames.Note] = item.Note; if (item.LateDuration1 != null) { row[Att_ReportDailyAttendanceEntity.FieldNames.LateDuration1] = item.LateDuration1; } if (item.EarlyDuration1 != null) { row[Att_ReportDailyAttendanceEntity.FieldNames.EarlyDuration1] = item.EarlyDuration1; } if (item.LateEarlyDuration != null) { row[Att_ReportDailyAttendanceEntity.FieldNames.LateEarlyDuration] = item.LateEarlyDuration; } if (item.LateEarlyRoot != null) { row[Att_ReportDailyAttendanceEntity.FieldNames.LateEarlyRoot] = item.LateEarlyRoot; } row[Att_ReportDailyAttendanceEntity.FieldNames.LateEarlyReason] = item.LateEarlyReason; row[Att_ReportDailyAttendanceEntity.FieldNames.UserExport] = userExport; row[Att_ReportDailyAttendanceEntity.FieldNames.DateExport] = DateTime.Today; if (item.InTimeRoot != null) row[Att_ReportDailyAttendanceEntity.FieldNames.InTimeRoot] = item.InTimeRoot.Value; if (item.OutTimeRoot != null) row[Att_ReportDailyAttendanceEntity.FieldNames.OutTimeRoot] = item.OutTimeRoot.Value; if (item.LateEarlyDuration != null) { if (item.LateEarlyDuration.Value < 120) { row[Att_ReportDailyAttendanceEntity.FieldNames.EarlyLateLess2h] = "X"; } else { row[Att_ReportDailyAttendanceEntity.FieldNames.EarlyLateOver2h] = "X"; } } else { row[Att_ReportDailyAttendanceEntity.FieldNames.EarlyLateLess2h] = "X"; } table.Rows.Add(row); } return table; } }