public StudentAttendanceSummary GetAttendanceSummary(int studentNo) { var query = new StringBuilder(); query.AppendFormat("SELECT StudentNo, Student, Course, CourseDescription, TermBeginDate, ScheduledTotal, ScheduledToDate, AttendedToDate") .AppendFormat(" FROM vWebAttendanceSummary") .AppendFormat(" WHERE StudentNo = {0} ORDER BY TermBeginDate ASC", studentNo); var attendanceSummaries = new List <AttendanceSummary>(); using (var reader = this.ExecuteReader(CommandType.Text, query.ToString())) { while (reader.Read()) { int colIndex = -1; var attendanceSummary = new AttendanceSummary(); attendanceSummary.StudentNo = reader[++colIndex] as int?; attendanceSummary.Student = reader[++colIndex] as string; attendanceSummary.Course = reader[++colIndex] as string; attendanceSummary.CourseDescription = reader[++colIndex] as string; attendanceSummary.TermBeginDate = reader[++colIndex] as DateTime?; attendanceSummary.ScheduledTotal = reader[++colIndex] as double?; attendanceSummary.ScheduledToDate = reader[++colIndex] as double?; attendanceSummary.AttendedToDate = reader[++colIndex] as double?; attendanceSummary.AttendedPercentage = ((attendanceSummary.AttendedToDate * 100) / attendanceSummary.ScheduledToDate); attendanceSummaries.Add(attendanceSummary); } } return(new StudentAttendanceSummary(attendanceSummaries)); }
public async Task <StudentStatsModel> GetStatsById(Guid studentId, Guid academicYearId) { using (var unitOfWork = await DataConnectionFactory.CreateUnitOfWork()) { var stats = new StudentStatsModel(); var achievements = await unitOfWork.Achievements.GetPointsByStudent(studentId, academicYearId); var incidents = await unitOfWork.Incidents.GetPointsByStudent(studentId, academicYearId); var attendanceMarks = await unitOfWork.AttendanceMarks.GetByStudent(studentId, academicYearId); var exclusions = await unitOfWork.Exclusions.GetCountByStudent(studentId); var attendanceCodes = await unitOfWork.AttendanceCodes.GetAll(); var attendanceSummary = new AttendanceSummary(attendanceCodes.Select(c => new AttendanceCodeModel(c)).ToList(), attendanceMarks.Select(m => new AttendanceMarkModel(m)).ToList()); stats.StudentId = studentId; stats.AchievementPoints = achievements; stats.BehaviourPoints = incidents; stats.PercentageAttendance = attendanceSummary.GetPresentAndAea(true); stats.Exclusions = exclusions; return(stats); } }
public async Task <AttendanceSummary> SaveAttendance(AttendanceSummary attendance) { BaseAPI <AttendanceSummary> api = new BaseAPI <AttendanceSummary>(); api.RelativeUrl = "attendance/saveattendance"; return(await api.PostAsync(attendance)); }
public AttendanceEditorModel(IContentPage ui, AttendanceSummary attendance) : base(ui) { // EO TODO Testing //this.Attendance = new AttendanceSummary(); this.Attendance = attendance == null ? new AttendanceSummary() : attendance; this.LoadAttendances(); }
public async Task <AttendanceSummary> GetSummaryByStudent(Guid studentId, Guid academicYearId) { var codes = (await _attendanceCodeRepository.GetAll()).Select(BusinessMapper.Map <AttendanceCodeModel>) .ToList(); var marks = (await _attendanceMarkRepository.GetByStudent(studentId, academicYearId)).Select(BusinessMapper .Map <AttendanceMarkModel>).ToList(); var summary = new AttendanceSummary(codes, marks); return(summary); }
public static AttendanceSummary ToEntity(this AttendanceSummaryModel model) { var entity = new AttendanceSummary() { Id = model.Id, UserId = model.UserId, Year = model.Year, Type = (int)model.Type, LastValue = model.LastValue, BaseValue = model.BaseValue, RemainValue = model.RemainValue }; return(entity); }
public async Task <AttendanceSummary> GetAttendanceSummaryByStudent(Guid studentId, Guid academicYearId) { using (var unitOfWork = await DataConnectionFactory.CreateUnitOfWork()) { var codes = (await unitOfWork.AttendanceCodes.GetAll()).Select(c => new AttendanceCodeModel(c)) .ToList(); var marks = (await unitOfWork.AttendanceMarks.GetByStudent(studentId, academicYearId)).Select(m => new AttendanceMarkModel(m)).ToList(); var summary = new AttendanceSummary(codes, marks); return(summary); } }
public async Task <AttendanceSummary> GetAttendanceSummary(int teacherId, GradingPeriod gradingPeriod) { var classes = ServiceLocator.ClassService.GetTeacherClasses(gradingPeriod.SchoolYearRef, teacherId, gradingPeriod.MarkingPeriodRef); if (classes.Count == 0) { return(new AttendanceSummary { ClassesDaysStat = new List <ClassDailyAttendanceSummary>(), Students = new List <StudentAttendanceSummary>() }); } var classesIds = classes.Select(x => x.Id).ToList(); var attSummarytask = ConnectorLocator.AttendanceConnector.GetSectionAttendanceSummary(classesIds, gradingPeriod.StartDate, gradingPeriod.EndDate); var students = ServiceLocator.StudentService.GetTeacherStudents(teacherId, gradingPeriod.SchoolYearRef); var sectionsAttendanceSummary = await attSummarytask; var res = new AttendanceSummary(); var dailySectionAttendances = new List <DailySectionAbsenceSummary>(); var studentAtts = new List <StudentSectionAbsenceSummary>(); var sectionStSet = new HashSet <Pair <int, int> >(); var sectionDaySet = new HashSet <Pair <int, DateTime> >(); foreach (var sectionAttendanceSummary in sectionsAttendanceSummary) { foreach (var dailySectionAtt in sectionAttendanceSummary.Days) { var pair = new Pair <int, DateTime>(dailySectionAtt.SectionId, dailySectionAtt.Date); if (!sectionDaySet.Contains(pair)) { sectionDaySet.Add(pair); dailySectionAttendances.Add(dailySectionAtt); } } foreach (var student in sectionAttendanceSummary.Students) { var pair = new Pair <int, int>(student.SectionId, student.StudentId); if (!sectionStSet.Contains(pair)) { sectionStSet.Add(pair); studentAtts.Add(student); } } } studentAtts = studentAtts.Where(x => classesIds.Contains(x.SectionId)).ToList(); res.ClassesDaysStat = ClassDailyAttendanceSummary.Create(dailySectionAttendances, classes); res.Students = StudentAttendanceSummary.Create(studentAtts, students, classes); return(res); }
public ResponseMessage GetAttendanceSummary() { ResponseMessage result = new ResponseMessage(); //List<TblAttendance> attendanceList = new List<TblAttendance>(); //List<TblEmployeeInformation> employeeList = new List<TblEmployeeInformation>(); AttendanceSummary summary = new AttendanceSummary(); try { using (_connection = new OracleConnection(_dbConnectionString)) { using (_command = new OracleCommand()) { _command.BindByName = true; _connection.Open(); _command.Connection = _connection; _command.CommandText = "spAttendanceSummary"; //_command.Parameters.Add(); _command.Parameters.Add("EMP_ATTEN_CURSOR", OracleDbType.RefCursor).Direction = ParameterDirection.Output; _command.CommandType = CommandType.StoredProcedure; _reader = _command.ExecuteReader(); while (_reader.Read()) { summary.totalEmployee = Convert.ToInt32(_reader["TOTAL_EMPLOYEE"]); summary.totalPresent = Convert.ToInt32(_reader["TOTAL_PRESENT"]); summary.totalAbsent = Convert.ToInt32(_reader["TOTAL_ABSENT"]); //attendanceList.Add(attendance); } _connection.Close(); } } return(result = ResponseMapping.GetResponseMessage(summary, (int)StatusCode.Success, ConstantMessage.RetriveSuccess)); } catch (Exception ex) { return(result = ResponseMapping.GetResponseMessage(null, (int)StatusCode.Faild, ex.Message.ToString())); } }
public static TeacherAttendanceSummaryViewData Create(AttendanceSummary attendanceSummary, DateTime currentDate) { var res = new TeacherAttendanceSummaryViewData(); var alerts = new List <string>(); res.Absent = new ShortAttendanceSummaryViewData { ClassesStats = ClassAttendanceStatViewData.Create(attendanceSummary.ClassesDaysStat, AttendanceTypeEnum.Absent, currentDate), Students = ShortStudentAttendanceViewData.Create(attendanceSummary.Students, alerts, AttendanceTypeEnum.Absent) }; res.Late = new ShortAttendanceSummaryViewData { ClassesStats = ClassAttendanceStatViewData.Create(attendanceSummary.ClassesDaysStat, AttendanceTypeEnum.Tardies, currentDate), Students = ShortStudentAttendanceViewData.Create(attendanceSummary.Students, alerts, AttendanceTypeEnum.Tardies) }; return(res); }
/// <summary> /// Sends the digest emails for each regional group within the attendance summary. /// </summary> /// <param name="systemCommunication">The system communication.</param> /// <param name="attendanceSummary">The attendance summary.</param> private void SendDigestEmails(SystemCommunication systemCommunication, AttendanceSummary attendanceSummary) { foreach (var regionalGroupAttendance in attendanceSummary.RegionalGroupAttendances) { // Add the merge objects to support this email. var mergeObjects = Rock.Lava.LavaHelper.GetCommonMergeFields(null); mergeObjects.Add("StartDate", attendanceSummary.StartDate); mergeObjects.Add("EndDate", attendanceSummary.EndDate); mergeObjects.Add("GroupAttendances", regionalGroupAttendance.GroupAttendances); // Send a separate email to each leader within this regional group. foreach (Person leader in regionalGroupAttendance.Leaders) { SendDigestEmail(systemCommunication, mergeObjects, leader, regionalGroupAttendance.Group); } } }
public async Task <AttendanceEditorModelResult> GetAttendanceEditorModel(AttendanceSummary attendance) { BaseAPI <AttendanceEditorModelResult> api = new BaseAPI <AttendanceEditorModelResult>(); api.RelativeUrl = "attendance/attendanceeditor"; api.ParameterDictionary.Add("AttendanceID", attendance.AttendanceID.ToString()); // EO TODO Need to get the active term api.ParameterDictionary.Add("TermID", "1"); try { var result = await api.GetAsync(); return(result); } catch (Exception ex) { } return(null); }
// GET: Attendance public ActionResult Index() { var model = new AttendanceSummary(); model.TotalWorkDays = 22; model.TotalLeaves = 3.5; model.TotalAbsences = 1; model.TotalActualWorkHours = new TimeSpan(195, 23, 10); model.TotalEditedWorkHours = new TimeSpan(12, 00, 00); model.TotalExtraOrDeficitWorkHours = new TimeSpan(1, 29, 34); model.DayWiseAttendanceSummary = new List <DayWiseAttendanceSummary>(); model.DayWiseAttendanceSummary.Add(new DayWiseAttendanceSummary() { AttendanceStatus = AttendanceStatus.Present.DescriptionAttr(), Date = DateTime.Now.Day.ToString(), ExtraDeficitHours = new TimeSpan(0, 16, 10), InTime = DateTime.Now.ToShortTimeString(), OutTime = DateTime.Now.ToShortTimeString(), Shift = Shift.Flexible.DescriptionAttr(), WorkHours = new TimeSpan(9, 12, 00) }); model.DayWiseAttendanceSummary.Add(new DayWiseAttendanceSummary() { AttendanceStatus = AttendanceStatus.HalfDay.DescriptionAttr(), Date = DateTime.Now.AddDays(1).Day.ToString(), ExtraDeficitHours = new TimeSpan(0, 0, 0), InTime = DateTime.Now.ToShortTimeString(), OutTime = DateTime.Now.ToShortTimeString(), Shift = Shift.Flexible.DescriptionAttr(), WorkHours = new TimeSpan(5, 12, 00) }); model.DayWiseAttendanceSummary.Add(new DayWiseAttendanceSummary() { AttendanceStatus = AttendanceStatus.Absent.DescriptionAttr(), Date = DateTime.Now.AddDays(2).Day.ToString(), ExtraDeficitHours = new TimeSpan(0, 0, 0), InTime = "00:00", OutTime = "00:00", Shift = Shift.Flexible.DescriptionAttr(), WorkHours = new TimeSpan(9, 12, 00) }); return(View(model)); }
public static AttendanceSummaryModel ToModel(this AttendanceSummary entity) { // 将entity 转为 Model var model = new AttendanceSummaryModel() { Id = entity.Id, UserId = entity.UserId, Year = entity.Year, Type = (OrderType)entity.Type, LastValue = entity.LastValue, BaseValue = entity.BaseValue, RemainValue = entity.RemainValue }; //考勤(申请单)类型名称 model.TypeName = EnumExtensions.GetDescriptionList(typeof(OrderType))[model.Type.ToString()]; return(model); }
public async Task <AttendanceSummary> GetAttendanceSummary(int teacherId, GradingPeriod gradingPeriod) { Trace.Assert(Context.SchoolYearId.HasValue); var classes = ServiceLocator.ClassService.GetTeacherClasses(gradingPeriod.SchoolYearRef, teacherId, gradingPeriod.MarkingPeriodRef); var classesIds = classes.Select(x => x.Id).ToList(); var students = ServiceLocator.StudentService.GetTeacherStudents(teacherId, Context.SchoolYearId.Value); var sectionsAttendanceSummary = GetSectionAttendanceSummary(classesIds, gradingPeriod.StartDate, gradingPeriod.EndDate); var res = new AttendanceSummary(); var dailySectionAttendances = new List <DailySectionAbsenceSummary>(); var studentAtts = new List <StudentSectionAbsenceSummary>(); foreach (var sectionAttendanceSummary in sectionsAttendanceSummary) { dailySectionAttendances.AddRange(sectionAttendanceSummary.Days); studentAtts.AddRange(sectionAttendanceSummary.Students); } res.ClassesDaysStat = ClassDailyAttendanceSummary.Create(dailySectionAttendances, classes); studentAtts = studentAtts.Where(x => classesIds.Contains(x.SectionId)).ToList(); res.Students = StudentAttendanceSummary.Create(studentAtts, students, classes); return(res); }
/// <summary> /// init AttendanceSummaryModel /// </summary> /// <param name="entity"></param> /// <param name="type"></param> /// <param name="userid"></param> /// <returns></returns> private AttendanceSummaryModel ToModel(AttendanceSummary entity, OrderType type, int userid) { if (entity == null) { entity = new AttendanceSummary() { Type = (int)type, BaseValue = 0, LastValue = 0, RemainValue = 0, Year = DateTime.Now.Year, UserId = userid }; } var model = entity.ToModel(); model.UsedValue = CountUsedVacation(userid, type); return(model); }
private void Init() { #region Filling AttendanceData Test Data AttendanceData = new Dictionary <int, StudentAttendance>(); var attendanceEntries = new List <AttendanceEntry>(); var attendanceEntry1 = new AttendanceEntry { StudentNo = 1, Student = "Alex", Course = "Test001 (T-1)", TermBeginDate = new DateTime(2011, 2, 16), ClassDate = new DateTime(2011, 2, 16), ClassStartTime = new DateTime(1899, 12, 30, 5, 30, 0), ClassEndTime = new DateTime(1899, 12, 30, 9, 30, 0), ClassHours = "4", Complete = "Y", AttendanceHours = 4, CourseDescription = "This is test 1 course.", AttendanceCode = "P", AttendedAdj = 4, ScheduledAdj = 4 }; var attendanceEntry2 = new AttendanceEntry { StudentNo = 1, Student = "Alex", Course = "Test001 (T-1)", TermBeginDate = new DateTime(2011, 2, 16), ClassDate = new DateTime(2011, 2, 17), ClassStartTime = new DateTime(1899, 12, 30, 5, 30, 0), ClassEndTime = new DateTime(1899, 12, 30, 9, 30, 0), ClassHours = "4", Complete = "Y", AttendanceHours = 4, CourseDescription = "This is test 1 course.", AttendanceCode = "P", AttendedAdj = 4, ScheduledAdj = 4 }; var attendanceEntry3 = new AttendanceEntry { StudentNo = 1, Student = "Alex", Course = "Test002 (T-2)", TermBeginDate = new DateTime(2011, 2, 16), ClassDate = new DateTime(2011, 3, 10), ClassStartTime = null, ClassEndTime = null, ClassHours = "0", Complete = "Y", AttendanceHours = 3, CourseDescription = "This is test 3 course.", AttendanceCode = "P", AttendedAdj = 3, ScheduledAdj = 3 }; attendanceEntries.Add(attendanceEntry1); attendanceEntries.Add(attendanceEntry2); attendanceEntries.Add(attendanceEntry3); var studentAttendance = new StudentAttendance(attendanceEntries); AttendanceData.Add(1, studentAttendance); attendanceEntry1 = new AttendanceEntry { StudentNo = 2, Student = "Ben", Course = "Test011 (T-11)", TermBeginDate = new DateTime(2011, 3, 8), ClassDate = new DateTime(2011, 3, 8), ClassStartTime = new DateTime(1899, 12, 30, 5, 30, 0), ClassEndTime = new DateTime(1899, 12, 30, 9, 30, 0), ClassHours = "4", Complete = "Y", AttendanceHours = 4, CourseDescription = "This is a test 11 course.", AttendanceCode = "P", AttendedAdj = 4, ScheduledAdj = 4 }; attendanceEntry2 = new AttendanceEntry { StudentNo = 2, Student = "Ben", Course = "Test012 (T-12)", TermBeginDate = new DateTime(2011, 3, 8), ClassDate = new DateTime(2011, 3, 9), ClassStartTime = new DateTime(1899, 12, 30, 5, 30, 0), ClassEndTime = new DateTime(1899, 12, 30, 9, 30, 0), ClassHours = "4", Complete = "Y", AttendanceHours = 4, CourseDescription = "This is a test 2 course.", AttendanceCode = "P", AttendedAdj = 4, ScheduledAdj = 4 }; attendanceEntry3 = new AttendanceEntry { StudentNo = 2, Student = "Ben", Course = "Test013 (T-13)", TermBeginDate = new DateTime(2011, 3, 8), ClassDate = new DateTime(2011, 3, 22), ClassStartTime = null, ClassEndTime = null, ClassHours = "4", Complete = "Y", AttendanceHours = 4, CourseDescription = "This is a test 13 course.", AttendanceCode = "P", AttendedAdj = 4, ScheduledAdj = 4 }; attendanceEntries = new List <AttendanceEntry> { attendanceEntry1, attendanceEntry2, attendanceEntry3 }; studentAttendance = new StudentAttendance(attendanceEntries); AttendanceData.Add(2, studentAttendance); #endregion SummaryData = new Dictionary <int, StudentAttendanceSummary>(); var attendanceSummary1 = new AttendanceSummary(); attendanceSummary1.StudentNo = 1; attendanceSummary1.Student = "Alex"; attendanceSummary1.Course = "Test001 (T-1)"; attendanceSummary1.CourseDescription = "This is Test 1 Course"; attendanceSummary1.TermBeginDate = new DateTime(2011, 2, 16); attendanceSummary1.ScheduledTotal = 8; attendanceSummary1.ScheduledToDate = 8; attendanceSummary1.AttendedToDate = 8; attendanceSummary1.AttendedPercentage = ((attendanceSummary1.AttendedToDate * 100) / attendanceSummary1.ScheduledToDate); var attendanceSummary2 = new AttendanceSummary(); attendanceSummary2.StudentNo = 1; attendanceSummary2.Student = "Alex"; attendanceSummary2.Course = "Test002 (T-2)"; attendanceSummary2.CourseDescription = "This is Test 2 Course"; attendanceSummary2.TermBeginDate = new DateTime(2011, 2, 16); attendanceSummary2.ScheduledTotal = 3; attendanceSummary2.ScheduledToDate = 3; attendanceSummary2.AttendedToDate = 3; attendanceSummary2.AttendedPercentage = ((attendanceSummary2.AttendedToDate * 100) / attendanceSummary2.ScheduledToDate); var summary = new StudentAttendanceSummary(new[] { attendanceSummary1, attendanceSummary2 }); SummaryData.Add(1, summary); attendanceSummary1 = new AttendanceSummary(); attendanceSummary1.StudentNo = 2; attendanceSummary1.Student = "Ben"; attendanceSummary1.Course = "Test011 (T-11)"; attendanceSummary1.CourseDescription = "This is Test 11 Course"; attendanceSummary1.TermBeginDate = new DateTime(2011, 2, 16); attendanceSummary1.ScheduledTotal = 8; attendanceSummary1.ScheduledToDate = 8; attendanceSummary1.AttendedToDate = 8; attendanceSummary1.AttendedPercentage = ((attendanceSummary1.AttendedToDate * 100) / attendanceSummary1.ScheduledToDate); attendanceSummary2 = new AttendanceSummary(); attendanceSummary2.StudentNo = 2; attendanceSummary2.Student = "Ben"; attendanceSummary2.Course = "Test012 (T-12)"; attendanceSummary2.CourseDescription = "This is Test 12 Course"; attendanceSummary2.TermBeginDate = new DateTime(2011, 2, 16); attendanceSummary2.ScheduledTotal = 12; attendanceSummary2.ScheduledToDate = 12; attendanceSummary2.AttendedToDate = 12; attendanceSummary2.AttendedPercentage = ((attendanceSummary2.AttendedToDate * 100) / attendanceSummary2.ScheduledToDate); summary = new StudentAttendanceSummary(new[] { attendanceSummary1, attendanceSummary2 }); SummaryData.Add(2, summary); }
public bool AddUser(UserModel model) { using (var dbContext = new MissionskyOAEntities()) { //设置初始密码 model.Password = (new MD5Cryptology()).Encrypt("123456"); model.CreatedTime = DateTime.Now; // 判断输入的工龄,如果输入为负数,直接赋值为0 if (model.ServerYear < 0) { model.ServerYear = Math.Abs(model.ServerYear); } // 根据ServerYear处理ServerYearType //model.ServerYearType = GetServerYearType(model); //int year = model.ServerYear; if (model.ServerYear >= 0 && model.ServerYear < 10) { model.ServerYearType = UserServiceYearType.TenYears; } else if (model.ServerYear >= 10 && model.ServerYear < 20) { model.ServerYearType = UserServiceYearType.TwentyYears; } else if (model.ServerYear >= 20) { model.ServerYearType = UserServiceYearType.ThirtyYears; } var UserEntity = model.ToEntity(); dbContext.Users.Add(model.ToEntity()); //初始化角色 UserRole userRole = new UserRole() { UserId = UserEntity.Id, RoleId = model.Role, }; dbContext.UserRoles.Add(userRole); //初始化所有假期 for (int i = 1; i < 7; i++) { AttendanceSummary attendance = new AttendanceSummary() { UserId = UserEntity.Id, Year = DateTime.Now.Year, Type = i, LastValue = 0, BaseValue = 0, RemainValue = 0 }; dbContext.AttendanceSummaries.Add(attendance); } dbContext.SaveChanges(); return(true); } }
/// <summary> /// 初使化用户考勤汇总信息 /// </summary> /// <param name="dbContext">数据库上下文</param> /// <param name="userId">用户Id</param> /// <returns></returns> public void InitAttendanceSummary(MissionskyOAEntities dbContext, int userId) { if (dbContext == null) { throw new NullReferenceException("Invalid db context when init user attendance summary."); } var user = dbContext.Users.FirstOrDefault(it => it.Id == userId); if (user == null || !user.Available) { Log.Error(string.Format("用户不存在或已离职。Id: {0}", userId)); return; } // var baseVacations = _userService.ImportUserBaseVacation(userId); if (baseVacations == null) { baseVacations = new NameValueCollection(); } Type type = typeof(OrderType); ArrayList vacations = EnumExtensions.GetEmnuValueList(type); foreach (string item in vacations) { var orderType = (OrderType)Enum.Parse(type, item); if (orderType == OrderType.None || orderType == OrderType.DaysOff) //不汇总此类假期 { continue; } //本年度汇总信息 var thisSummary = dbContext.AttendanceSummaries.FirstOrDefault(it => it.UserId == userId && it.Year == DateTime.Now.Year && it.Type == (int)orderType); //获取用户入职时间和工龄类型 DateTime joinTime = (DateTime)user.JoinDate; int serverYearType = user.ServerYearType.HasValue ? user.ServerYearType.Value : (int)UserServiceYearType.TenYears; if (thisSummary == null) { thisSummary = new AttendanceSummary() //初使化数据本年度 { UserId = userId, Year = DateTime.Now.Year, Type = (int)orderType, BaseValue = 0.0, LastValue = 0.0, RemainValue = 0.0 }; //上一年的汇总信息 var lastSummary = dbContext.AttendanceSummaries.FirstOrDefault( it => it.UserId == userId && it.Year == DateTime.Now.Year - 1 && it.Type == (int)orderType); switch (orderType) { case OrderType.AnnualLeave: //年假 thisSummary.LastValue = lastSummary == null ? 0.0 : lastSummary.RemainValue; //thisSummary.BaseValue = baseVacations.AllKeys.Contains(OrderType.AnnualLeave.ToString()) // ? Double.Parse(baseVacations[OrderType.AnnualLeave.ToString()]) // : 75.0; thisSummary.BaseValue = CaculateBaseValueForTotalServiceYear(joinTime, serverYearType, DateTime.Now) + CaculateBaseValueForCompanyServiceYear(joinTime, DateTime.Now); thisSummary.RemainValue = thisSummary.LastValue + thisSummary.BaseValue; //基准 + 上一年剩余 break; case OrderType.Overtime: //加班 thisSummary.LastValue = lastSummary == null ? 0.0 : lastSummary.RemainValue; thisSummary.RemainValue = thisSummary.LastValue; //无基准 break; case OrderType.SickLeave: //病假 thisSummary.BaseValue = baseVacations.AllKeys.Contains(OrderType.SickLeave.ToString()) ? Double.Parse(baseVacations[OrderType.SickLeave.ToString()]) : 0.0; thisSummary.RemainValue = thisSummary.BaseValue; //无剩余 break; case OrderType.FuneralLeave: //丧假 thisSummary.BaseValue = baseVacations.AllKeys.Contains(OrderType.FuneralLeave.ToString()) ? Double.Parse(baseVacations[OrderType.FuneralLeave.ToString()]) : 0.0; thisSummary.RemainValue = thisSummary.BaseValue; //无剩余 break; case OrderType.MaternityLeave: //产假 if (lastSummary == null) //未汇总过产假 { thisSummary.BaseValue = baseVacations.AllKeys.Contains(OrderType.MaternityLeave.ToString()) ? Double.Parse(baseVacations[OrderType.MaternityLeave.ToString()]) : 0.0; } else if (lastSummary.RemainValue == lastSummary.BaseValue) //未使用过产假 { thisSummary.BaseValue = lastSummary.RemainValue; } thisSummary.RemainValue = thisSummary.BaseValue; break; case OrderType.MarriageLeave: //婚假 if (lastSummary == null) //未汇总过婚假 { thisSummary.BaseValue = baseVacations.AllKeys.Contains(OrderType.MarriageLeave.ToString()) ? Double.Parse(baseVacations[OrderType.MarriageLeave.ToString()]) : 0.0; } else if (lastSummary.RemainValue == lastSummary.BaseValue) //未使用过婚假 { thisSummary.BaseValue = lastSummary.RemainValue; } thisSummary.RemainValue = thisSummary.BaseValue; break; case OrderType.AskLeave: //事假 break; } dbContext.AttendanceSummaries.Add(thisSummary); } else { switch (orderType) { case OrderType.AnnualLeave: //年假 double baseValueIncrementThisMouth = 0.0; // 在每月的1号重新计算这个月的baseValue double baseValueTotalThisMouth = CaculateBaseValueForTotalServiceYear(joinTime, serverYearType, DateTime.Now) + CaculateBaseValueForCompanyServiceYear(joinTime, DateTime.Now); if ("01".Equals(DateTime.Now.Day.ToString("00")) && baseValueTotalThisMouth != thisSummary.BaseValue) { if (thisSummary.BaseValue == 0 || thisSummary.BaseValue == 0.0) { // 获取上个月一号的时间 DateTime lastMouthFirstDay = AttendanceSummaryExtentions.GetLastMouthFirstDay(DateTime.Now.Year, DateTime.Now.Month); // 当baseValue为0时,计算上月的baseValue double baseValueTotalLastMouth = CaculateBaseValueForTotalServiceYear(joinTime, serverYearType, lastMouthFirstDay) + CaculateBaseValueForCompanyServiceYear(joinTime, lastMouthFirstDay); baseValueIncrementThisMouth = Math.Round((double)(baseValueTotalThisMouth - baseValueTotalLastMouth), 1); thisSummary.BaseValue = baseValueTotalThisMouth; //thisSummary.RemainValue += baseValueIncrementThisMouth; } else { // 计算上月新增的baseValue baseValueIncrementThisMouth = Math.Round((double)(baseValueTotalThisMouth - thisSummary.BaseValue), 1); // 更新baseValue 和 RemainValue thisSummary.BaseValue = baseValueTotalThisMouth; //thisSummary.RemainValue += baseValueIncrementThisMouth; } thisSummary.RemainValue += baseValueIncrementThisMouth; } break; case OrderType.Overtime: //加班 break; case OrderType.SickLeave: //病假 break; case OrderType.FuneralLeave: //丧假 break; case OrderType.MaternityLeave: //产假 break; case OrderType.MarriageLeave: //婚假 break; case OrderType.AskLeave: //事假 break; } //dbContext.AttendanceSummaries.Add(thisSummary); } } dbContext.SaveChanges(); //保存到数据库 }
public AttendanceDetail(AttendanceSummary attendance) { InitializeComponent(); this.BindingContext = new AttendanceEditorModel(this, attendance); }
public AttendanceSummary SavePlayerAttendance([FromBody] AttendanceSummary attendance) { return(Dependency.Resolve <IAttendanceManager>().SaveAttendance(attendance.SessionID, attendance.PlayerID, attendance.AmountPaid)); }
/// <summary> /// Processes the job. /// </summary> /// <param name="context">The context.</param> private void ProcessJob(IJobExecutionContext context) { JobDataMap dataMap = context.JobDetail.JobDataMap; // Make sure we have valid entity Guids. var parentGroupGuid = dataMap.Get(AttributeKey.ParentGroup).ToString().AsGuidOrNull(); if (parentGroupGuid == null) { _errors.Add("The selected parent group is not valid."); return; } var systemCommunicationGuid = dataMap.Get(AttributeKey.SystemCommunication).ToString().AsGuidOrNull(); if (systemCommunicationGuid == null) { _errors.Add("The selected system communication is not valid."); return; } // Make sure we have a valid date range. int.TryParse(dataMap.Get(AttributeKey.DateRange).ToString(), out int dateRangeInt); if (dateRangeInt <= 0 || dateRangeInt > 2) { dateRangeInt = 1; } DateRange dateRange = ( DateRange )dateRangeInt; GetStartAndEndDates(dateRange, out DateTime startDate, out DateTime endDate); // Create an object to hold all of the attendance data. var attendanceSummary = new AttendanceSummary { StartDate = startDate, EndDate = endDate }; SystemCommunication systemCommunication; // Retrieve all of the needed data from the database. using (var rockContext = new RockContext()) { InitializeServices(rockContext); // Make sure the selected system communication exists. systemCommunication = _systemCommunicationService.GetNoTracking(systemCommunicationGuid.Value); if (systemCommunication == null) { _errors.Add("Unable to retrieve the selected system communication."); return; } attendanceSummary.RegionalGroupAttendances = GetRegionalGroupAttendances(parentGroupGuid.Value, startDate, endDate); } if (attendanceSummary.RegionalGroupAttendances?.Any() != true) { // Warnings/errors will have been added explaining what failed. return; } // Send the emails. SendDigestEmails(systemCommunication, attendanceSummary); }