public DailyTimeTrackViewModel(DailyTimeTrack dailyTimeTrack, int userId)
 {
     using (var dbContext = new SchTimeTrackingEntities())
     {
         var currentUser =
                     dbContext.UserProfiles.FirstOrDefault(c => c.UserId.Equals(userId));
         DailyTimeTrack = dailyTimeTrack;
         UserFullName = currentUser.FirstName + " " + currentUser.LastName;
         UserName = currentUser.UserName;
     }
 }
コード例 #2
0
        public static DailyTimeTrack GetCurrentDayClockInOutTime(string userName)
        {
            var startDate = WebHelpers.GetCurrentDateTimeByTimeZoneId(ConfigurationManager.AppSettings["UserTimeZoneId"]).Date;
            var endDate = startDate.AddDays(1);
            using (var dbContext = new SchTimeTrackingEntities())
            {
                var currentUser =
                       dbContext.UserProfiles.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) ? ConfigurationManager.AppSettings["ClockOutText"] : ConfigurationManager.AppSettings["ClockInText"];
                        return dailyTimeTrack;
                    }
                }
                return new DailyTimeTrack();
            }
        }
コード例 #3
0
        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>");
        }
コード例 #4
0
        public static DailyTimeTrack GetDailyClockInOutTimeByDate(int userId, DateTime startDate, DateTime endDate)
        {
            var weekEndDateToSearchInDatabase = endDate.AddDays(1);

            using (var dbContext = new SchTimeTrackingEntities())
            {
                var currentUser =
                    dbContext.UserProfiles.FirstOrDefault(c => c.UserId.Equals(userId));
                var userTimeTrackHistoryForRequestedDay = (from utsh in dbContext.UserTimeTrackHistories
                                                           where utsh.IsDeleted == false &&
                                                            utsh.UserName.ToLower().Equals(currentUser.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()
                    };
                    dailyTimeTrack.RoleName = currentUser.RoleId == 3 ? "User" : "Admin";
                    return dailyTimeTrack;
                }
            }
            return new DailyTimeTrack();
        }
コード例 #5
0
        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 SchTimeTrackingEntities())
            {
                var currentUser =
                    dbContext.UserProfiles.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();
                weeklyTimeTrack.RoleName = (currentUser.RoleId == 3? "User": "******");
                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;
        }
コード例 #6
0
        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 SchTimeTrackingEntities())
            {
                var currentUser = dbContext.UserProfiles.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;
 }