private static void AddWorkSheetColumn(StringBuilder builder, DailyTimeTrack dtt, Dictionary <string, string> columnsToDisplay) { // FOR USER NAME builder.Append(Environment.NewLine + "<Column ss:Width='100'/>"); foreach (var property in dtt.GetType().GetProperties()) { if (columnsToDisplay.ContainsKey(property.Name)) { builder.Append(Environment.NewLine + "<Column ss:Width='100'/>"); } } builder.Append(Environment.NewLine + "<Row>"); builder.Append(Environment.NewLine + "\t" + "<Cell ss:StyleID='Header'><Data ss:Type='String' > Employee </Data></Cell>"); foreach (var property in dtt.GetType().GetProperties()) { if (columnsToDisplay.ContainsKey(property.Name)) { builder.Append(Environment.NewLine + "\t" + "<Cell ss:StyleID='Header'><Data ss:Type='String' >" + columnsToDisplay[property.Name] + "</Data></Cell>"); } } builder.Append(Environment.NewLine + "</Row>"); }
public static DailyTimeTrack GetCurrentDayClockInOutTime(string userName) { var startDate = WebHelpers.GetCurrentDateTimeByTimeZoneId(WebConfigurationManager.AppSettings["UserTimeZoneId"]).Date; var endDate = startDate.AddDays(1); using (var dbContext = new TimeTrackingEntities()) { var currentUser = dbContext.ExtendedUserProfiles.FirstOrDefault(c => c.UserName.ToLower().Equals(userName)); var userClockInOutTimeList = (from utsh in dbContext.UserTimeTrackHistories where utsh.IsDeleted==false && utsh.UserName.ToLower().Equals(userName.ToLower()) && (utsh.StampDate >= startDate && utsh.StampDate < endDate) && utsh.ClockInTime.Length > 0 select utsh).ToList(); if (userClockInOutTimeList.Any()) { var userTimeStampHistory = userClockInOutTimeList.FirstOrDefault(); if (userTimeStampHistory != null) { var dailyTimeTrack = new DailyTimeTrack(userTimeStampHistory.StampDate, currentUser.HourlyRate.HasValue ? currentUser.HourlyRate.Value : 0) { TimeTrackList = GetTimeTrackList(userClockInOutTimeList, userTimeStampHistory.StampDate). OrderByDescending(c => c.ClockInTime).ThenByDescending( d => d.ClockOutTime).ToList() }; dailyTimeTrack.SubmitButtonText = dailyTimeTrack.TimeTrackList.Any(c => c.ClockOutTime == null) ? WebConfigurationManager.AppSettings["ClockOutText"] : WebConfigurationManager.AppSettings["ClockInText"]; return dailyTimeTrack; } } return new DailyTimeTrack(); } }
public DailyTimeTrackViewModel() { DailyTimeTrack = new DailyTimeTrack(); UserFullName = string.Empty; }
public DailyTimeTrackViewModel(DailyTimeTrack dailyTimeTrack, string userFullName, string userName) { DailyTimeTrack = dailyTimeTrack; UserFullName = userFullName; UserName = userName; }
private static void AddWorkSheetColumn(StringBuilder builder, DailyTimeTrack dtt, Dictionary<string, string> columnsToDisplay) { // FOR USER NAME builder.Append(Environment.NewLine + "<Column ss:Width='100'/>"); foreach (var property in dtt.GetType().GetProperties()) { if (columnsToDisplay.ContainsKey(property.Name)) builder.Append(Environment.NewLine + "<Column ss:Width='100'/>"); } builder.Append(Environment.NewLine + "<Row>"); builder.Append(Environment.NewLine + "\t" + "<Cell ss:StyleID='Header'><Data ss:Type='String' > Employee </Data></Cell>"); foreach (var property in dtt.GetType().GetProperties()) { if (columnsToDisplay.ContainsKey(property.Name)) builder.Append(Environment.NewLine + "\t" + "<Cell ss:StyleID='Header'><Data ss:Type='String' >" + columnsToDisplay[property.Name] + "</Data></Cell>"); } builder.Append(Environment.NewLine + "</Row>"); }
public static DailyTimeTrack GetDailyClockInOutTimeByDate(string userName, DateTime startDate, DateTime endDate) { var weekEndDateToSearchInDatabase = endDate.AddDays(1); using (var dbContext = new TimeTrackingEntities()) { var currentUser = dbContext.ExtendedUserProfiles.FirstOrDefault(c => c.UserName.ToLower().Equals(userName)); var userTimeTrackHistoryForRequestedDay = (from utsh in dbContext.UserTimeTrackHistories where utsh.IsDeleted == false && utsh.UserName.ToLower().Equals(userName.ToLower()) && (utsh.StampDate >= startDate && utsh.StampDate < weekEndDateToSearchInDatabase) && utsh.ClockInTime.Length > 0 select utsh).ToList(); if (userTimeTrackHistoryForRequestedDay.Any()) { var dailyTimeTrack = new DailyTimeTrack(startDate, currentUser.HourlyRate.HasValue ? currentUser.HourlyRate.Value : 0) { StampDate = startDate, TimeTrackList = GetTimeTrackList(userTimeTrackHistoryForRequestedDay, startDate). OrderByDescending(c => c.TimeTrackId).ThenByDescending( d => d.ClockInTime).ToList() }; return dailyTimeTrack; } } return new DailyTimeTrack(); }
public static WeeklyTimeTrack GetWeeklyClockInOutTimeByDate(string userName, DateTime startDate, DateTime endDate) { var weekEndDateToSearchInDatabase = endDate.AddDays(1); var weeklyTimeTrack = new WeeklyTimeTrack { WeekStartDate = startDate.Date, WeekEndDate = endDate.Date, DailyTimeTracks = new List<DailyTimeTrack>() }; using (var dbContext = new TimeTrackingEntities()) { var currentUser = dbContext.ExtendedUserProfiles.FirstOrDefault(c => c.UserName.ToLower().Equals(userName)); var userWeeklyClockInOutTimings = (from utsh in dbContext.UserTimeTrackHistories where utsh.IsDeleted == false && utsh.UserName.ToLower().Equals(userName.ToLower()) && (utsh.StampDate >= startDate && utsh.StampDate < weekEndDateToSearchInDatabase) && utsh.ClockInTime.Length > 0 select utsh).ToList(); if (userWeeklyClockInOutTimings.Any()) { var weekDay = startDate.Date; while (weekDay.Date <= endDate.Date) { var dailyUserStampList = userWeeklyClockInOutTimings.Where( daily => daily.StampDate >= weekDay && daily.StampDate < weekDay.AddDays(1)).ToList(); var dailyTimeTrack = new DailyTimeTrack(startDate, currentUser.HourlyRate.HasValue ? currentUser.HourlyRate.Value : 0) { StampDate = weekDay, TimeTrackList = GetTimeTrackList(dailyUserStampList, weekDay). OrderByDescending(c => c.ClockInTime).ThenByDescending( d => d.ClockOutTime).ToList() }; weeklyTimeTrack.DailyTimeTracks.Add(dailyTimeTrack); weeklyTimeTrack.DailyTimeTracks = weeklyTimeTrack.DailyTimeTracks.OrderByDescending(c => c.StampDate).ToList(); weekDay = weekDay.AddDays(1); } } } return weeklyTimeTrack; }
public static CustomTimeTrack GetUserTimeTrackHistoryForSpecifiedPeriod(string userName, DateTime startDate, DateTime endDate) { var weekEndDateToSearchInDatabase = endDate.AddDays(1); var customTimeTrack = new CustomTimeTrack { CustomStartDate = startDate.Date, CustomEndDate = endDate.Date, UserName=userName, DailyTimeTracks = new List<DailyTimeTrack>() }; using (var dbContext = new TimeTrackingEntities()) { var currentUser = dbContext.ExtendedUserProfiles.FirstOrDefault(c => c.UserName.ToLower().Equals(userName)); customTimeTrack.EmployeeName = currentUser.FirstName + " " + currentUser.LastName; var userClockInOutTimings = (from utsh in dbContext.UserTimeTrackHistories where utsh.IsDeleted == false && utsh.UserName.ToLower().Equals(userName.ToLower()) && (utsh.StampDate >= startDate && utsh.StampDate < weekEndDateToSearchInDatabase) && utsh.ClockInTime.Length > 0 select utsh).ToList(); if (userClockInOutTimings.Any()) { var currentDay = startDate.Date; while (currentDay <= endDate.Date) { var dailyUserStampList = userClockInOutTimings.Where( daily => daily.StampDate >= currentDay && daily.StampDate < currentDay.AddDays(1)).ToList(); var dailyTimeTrack = new DailyTimeTrack(startDate, currentUser.HourlyRate.HasValue ? currentUser.HourlyRate.Value : 0) { StampDate = currentDay, TimeTrackList = GetTimeTrackList(dailyUserStampList, currentDay). OrderByDescending(c => c.ClockInTime).ThenByDescending( d => d.ClockOutTime).ToList() }; customTimeTrack.DailyTimeTracks.Add(dailyTimeTrack); customTimeTrack.DailyTimeTracks = customTimeTrack.DailyTimeTracks.OrderByDescending(c => c.StampDate).ToList(); currentDay = currentDay.AddDays(1); } } } return customTimeTrack; }
public DailyTimeTrackViewModel() { DailyTimeTrack= new DailyTimeTrack(); UserFullName = string.Empty; }
public DailyTimeTrackViewModel(DailyTimeTrack dailyTimeTrack, string userFullName,string userName) { DailyTimeTrack = dailyTimeTrack; UserFullName = userFullName; UserName = userName; }