public void AddToLists(ZTask task) { if (task.Assignment.AssigneeId != "user101010") { AssignedToOthers.Add(task); } DateTimeOffset?offset = task.TaskDetails.DueDate; DateTime? dateTime = offset.HasValue ? offset.Value.DateTime : (DateTime?)null; if (dateTime != null) { if (dateTime?.Date == DateTime.Today && task.TaskDetails.TaskStatus == 0) { Today.Add(task); } if (dateTime?.Date < DateTime.Today && task.TaskDetails.TaskStatus == 0) { Delayed.Add(task); } if (dateTime?.Date > DateTime.Today && task.TaskDetails.TaskStatus == 0) { Upcoming.Add(task); } } }
private void Appointments_SearchCompleted(object sender, AppointmentsSearchEventArgs e) { if (e.Results != null) { foreach (Appointment appt in e.Results) { string ConferenceId = Conference.GetId(appt); if (!string.IsNullOrEmpty(ConferenceId)) { if (appt.StartTime > DateTime.Now.Date.AddDays(1)) { Tomorrow.Add(appt); } else { Today.Add(appt); } } } } // update the Tile ShellTile PrimaryTile = ShellTile.ActiveTiles.First(); if (PrimaryTile != null) { IconicTileData tile = new IconicTileData(); tile.Count = Today.Count; tile.Title = "My Conference Calls"; tile.SmallIconImage = new Uri("/ApplicationIcon.png", UriKind.Relative); tile.IconImage = new Uri("/AppHub/icon200.png", UriKind.Relative); PrimaryTile.Update(tile); } }
public void Negative_Time_Comparisons() { DateTime nearbyPastTime = Today.Add(-Closeness.Default - 1.Milliseconds()); DateTime nearbyFutureTime = Today.Add(Closeness.Default + 1.Milliseconds()); Assert.That(Today, Must.Not.Be.CloseTo(nearbyPastTime)); Assert.That(Today, Must.Not.Be.CloseTo(nearbyFutureTime)); nearbyPastTime = Today.Add(-35.Milliseconds()); nearbyFutureTime = Today.Add(35.Milliseconds()); Assert.That(Today, Must.Not.Be.CloseTo(nearbyPastTime, ms: 30)); Assert.That(Today, Must.Not.Be.CloseTo(nearbyPastTime, within: 30.Milliseconds())); Assert.That(Today, Must.Not.Be.CloseTo(nearbyFutureTime, ms: 30)); Assert.That(Today, Must.Not.Be.CloseTo(nearbyFutureTime, within: 30.Milliseconds())); }
public JsonResult groupbyAttendanceList(DateTime date, string param) { var employees = db.Employee.GetAllWithRelatedData(x => x.IsActive == true && x.IsDeleted == false).ToList(); var vm = new List <vmGroupbyAttendance>(); switch (param) { case "department": foreach (var item in employees.GroupBy(g => g.DepartmentId)) { var name = ""; var total = 0; var absent = 0; var present = 0; var late = 0; var business = 0; var leave = 0; name = item.Select(x => x.Department.Name).FirstOrDefault(); total = item.Select(x => x.Id).Count(); foreach (var employee in item) { //check leave var isLeaveExists = db.LeaveApplication.GetFirstOrDefault(x => x.EmployeeId == employee.Id && x.FromDate.Date == Today && x.Status == ApplicationStatus.Pending || x.Status == ApplicationStatus.Approved); if (isLeaveExists != null) { leave += 1; continue; } //check business var isBusinessExists = db.BusinessApplication.GetFirstOrDefault(x => x.EmployeeId == employee.Id && x.FromDate.Date == Today && x.Status == ApplicationStatus.Pending || x.Status == ApplicationStatus.Approved); if (isBusinessExists != null) { business += 1; continue; } //check late var lateCount = db.SystemPreference.GetFirstOrDefault().LateCount; var shift = employee.Shift.ShiftDetailsList.Where(x => x.DayName == Today.ToString("dddd")).FirstOrDefault(); var officeStart = Today.Add(DateTime.Parse(shift.OfficeStartTime).TimeOfDay); var officeStart_with_lateAllow = officeStart.AddMinutes(lateCount); var punch = db.AttendanceMachineDataFiltered.GetAllAsQueryable().Where(x => x.EmployeeId == employee.Id && x.TransactionTime.Date == Today).OrderBy(o => o.TransactionTime).ToList().Take(1); if (punch.Count() == 0) { absent += 1; continue; } else if (punch.FirstOrDefault().TransactionTime > officeStart_with_lateAllow) { late += 1; present += 1; continue; } else { present += 1; continue; } } vm.Add(new vmGroupbyAttendance { Absent = absent, Business = business, Late = late, Leave = leave, Present = present, Name = name, Total = total }); } break; case "designation": foreach (var item in employees.GroupBy(g => g.DesignationId)) { var name = ""; var total = 0; var absent = 0; var present = 0; var late = 0; var business = 0; var leave = 0; name = item.Select(x => x.Designation.Name).FirstOrDefault(); total = item.Select(x => x.Id).Count(); foreach (var employee in item) { //check leave var isLeaveExists = db.LeaveApplication.GetFirstOrDefault(x => x.EmployeeId == employee.Id && x.FromDate.Date == Today && x.Status == ApplicationStatus.Pending || x.Status == ApplicationStatus.Approved); if (isLeaveExists != null) { leave += 1; continue; } //check business var isBusinessExists = db.BusinessApplication.GetFirstOrDefault(x => x.EmployeeId == employee.Id && x.FromDate.Date == Today && x.Status == ApplicationStatus.Pending || x.Status == ApplicationStatus.Approved); if (isBusinessExists != null) { business += 1; continue; } //check late var lateCount = db.SystemPreference.GetFirstOrDefault().LateCount; var shift = employee.Shift.ShiftDetailsList.Where(x => x.DayName == Today.ToString("dddd")).FirstOrDefault(); var officeStart = Today.Add(DateTime.Parse(shift.OfficeStartTime).TimeOfDay); var officeStart_with_lateAllow = officeStart.AddMinutes(lateCount); var punch = db.AttendanceMachineDataFiltered.GetAllAsQueryable().Where(x => x.EmployeeId == employee.Id && x.TransactionTime.Date == Today).OrderBy(o => o.TransactionTime).ToList().Take(1); if (punch.Count() == 0) { absent += 1; continue; } else if (punch.FirstOrDefault().TransactionTime > officeStart_with_lateAllow) { late += 1; present += 1; continue; } else { present += 1; continue; } } vm.Add(new vmGroupbyAttendance { Absent = absent, Business = business, Late = late, Leave = leave, Present = present, Name = name, Total = total }); } break; case "shift": foreach (var item in employees.GroupBy(g => g.ShiftId)) { var name = ""; var total = 0; var absent = 0; var present = 0; var late = 0; var business = 0; var leave = 0; name = item.Select(x => x.Shift.Name).FirstOrDefault(); total = item.Select(x => x.Id).Count(); foreach (var employee in item) { //check leave var isLeaveExists = db.LeaveApplication.GetFirstOrDefault(x => x.EmployeeId == employee.Id && x.FromDate.Date == Today && x.Status == ApplicationStatus.Pending || x.Status == ApplicationStatus.Approved); if (isLeaveExists != null) { leave += 1; continue; } //check business var isBusinessExists = db.BusinessApplication.GetFirstOrDefault(x => x.EmployeeId == employee.Id && x.FromDate.Date == Today && x.Status == ApplicationStatus.Pending || x.Status == ApplicationStatus.Approved); if (isBusinessExists != null) { business += 1; continue; } //check late var lateCount = db.SystemPreference.GetFirstOrDefault().LateCount; var shift = employee.Shift.ShiftDetailsList.Where(x => x.DayName == Today.ToString("dddd")).FirstOrDefault(); var officeStart = Today.Add(DateTime.Parse(shift.OfficeStartTime).TimeOfDay); var officeStart_with_lateAllow = officeStart.AddMinutes(lateCount); var punch = db.AttendanceMachineDataFiltered.GetAllAsQueryable().Where(x => x.EmployeeId == employee.Id && x.TransactionTime.Date == Today).OrderBy(o => o.TransactionTime).ToList().Take(1); if (punch.Count() == 0) { absent += 1; continue; } else if (punch.FirstOrDefault().TransactionTime > officeStart_with_lateAllow) { late += 1; present += 1; continue; } else { present += 1; continue; } } vm.Add(new vmGroupbyAttendance { Absent = absent, Business = business, Late = late, Leave = leave, Present = present, Name = name, Total = total }); } break; } return(Json(vm)); }