예제 #1
0
        public ResponseModel CheckOut(AttendanceEntryModel model)
        {
            var errMessage     = string.Empty;
            var queryParamList = new QueryParamList
            {
                new QueryParamObj {
                    ParamDirection = ParameterDirection.Input, ParamName = "@UserId", ParamValue = model.UserId
                },
                new QueryParamObj {
                    ParamDirection = ParameterDirection.Input, ParamName = "@LessTimeReason", ParamValue = model.Reason
                },
                new QueryParamObj {
                    ParamDirection = ParameterDirection.Input, ParamName = "@CheckOutTime", ParamValue = DateTime.UtcNow, DBType = DbType.DateTime
                }
            };

            const string sql = @"DECLARE @id bigint
                                SELECT TOP 1 @id=Id FROM ResourceTracker_Attendance WHERE UserId=@UserId AND CheckOutTime IS NULL ORDER BY Id DESC
                                UPDATE ResourceTracker_Attendance SET CheckOutTime=@CheckOutTime,LessTimeReason=@LessTimeReason WHERE Id=@id";

            DBExecCommandEx(sql, queryParamList, ref errMessage);

            return(new ResponseModel {
                Success = string.IsNullOrEmpty(errMessage)
            });
        }
예제 #2
0
        public ResponseModel AddAttendanceAsLeave(AttendanceEntryModel model)
        {
            var errMessage     = string.Empty;
            var queryParamList = new QueryParamList
            {
                new QueryParamObj {
                    ParamDirection = ParameterDirection.Input, ParamName = "@UserId", ParamValue = model.UserId
                },
                new QueryParamObj {
                    ParamDirection = ParameterDirection.Input, ParamName = "@CompanyId", ParamValue = model.CompanyId
                },
                new QueryParamObj {
                    ParamDirection = ParameterDirection.Input, ParamName = "@AttendanceDate", ParamValue = DateTime.UtcNow, DBType = DbType.DateTime
                },
                new QueryParamObj {
                    ParamDirection = ParameterDirection.Input, ParamName = "@IsLeave", ParamValue = true, DBType = DbType.Boolean
                }
            };

            const string sql = @"IF NOT EXISTS(SELECT * FROM ResourceTracker_Attendance A WHERE A.UserId=@UserId AND CONVERT(DATE,AttendanceDate)=CONVERT(DATE,@AttendanceDate))
                                BEGIN
                                INSERT INTO ResourceTracker_Attendance(UserId,CompanyId,AttendanceDate,IsLeave)
				                    VALUES(@UserId,@CompanyId,@AttendanceDate,@IsLeave)
                                END";

            DBExecCommandEx(sql, queryParamList, ref errMessage);

            return(new ResponseModel {
                Success = string.IsNullOrEmpty(errMessage)
            });
        }
예제 #3
0
        /// <summary>
        /// Update all attributes to be what is passed in
        /// </summary>
        /// <param name="data"></param>
        /// <returns>Null or updated data</returns>
        public AttendanceEntryModel Update(AttendanceEntryModel data)
        {
            if (data == null)
            {
                return(null);
            }
            var myReturn = attendanceList.Find(n => n.Id == data.Id);

            myReturn.Update(data);

            return(myReturn);
        }
        public IHttpActionResult CheckIn(AttendanceEntryModel model)
        {
            var attendanceFeed = _attendance.GetAttendanceFeed(model.CompanyId.Value, DateTime.UtcNow).ToList();

            if (attendanceFeed.Any(x => x.UserId == model.UserId && x.IsCheckedIn))
            {
                return(Ok(new ResponseModel {
                    Message = "Already checked-in."
                }));
            }

            var companyModel = _company.GetCompanyById(model.CompanyId.Value);

            if (companyModel != null && !string.IsNullOrEmpty(companyModel.MaximumOfficeHours))
            {
                var maxOfficeHourList = companyModel.MaximumOfficeHours.Split(':');
                model.OfficeHour = (Convert.ToInt32(maxOfficeHourList[0]) * 60) + Convert.ToInt32(maxOfficeHourList[1]);
            }

            if (companyModel != null && !string.IsNullOrEmpty(companyModel.OfficeOutTime))
            {
                var outTimeList = companyModel.OfficeOutTime.Split(':');
                model.AllowOfficeLessTime = (Convert.ToInt32(outTimeList[0]) * 60) + Convert.ToInt32(outTimeList[1]);
            }

            var response = _attendance.CheckIn(model);

            if (response.Success)
            {
                _attendance.SaveCheckPoint(new UserMovementLogModel {
                    UserId          = model.UserId,
                    CompanyId       = model.CompanyId,
                    Latitude        = model.Latitude,
                    Longitude       = model.Longitude,
                    LogLocation     = model.LogLocation,
                    DeviceName      = model.DeviceName,
                    DeviceOSVersion = model.DeviceOSVersion,
                    IsCheckInPoint  = true
                });
            }
            return(Ok(response));
        }
        public IHttpActionResult CheckOut(AttendanceEntryModel model)
        {
            var response = _attendance.CheckOut(model);

            if (response.Success)
            {
                _attendance.SaveCheckPoint(new UserMovementLogModel
                {
                    UserId          = model.UserId,
                    CompanyId       = model.CompanyId,
                    Latitude        = model.Latitude,
                    Longitude       = model.Longitude,
                    LogLocation     = model.LogLocation,
                    DeviceName      = model.DeviceName,
                    DeviceOSVersion = model.DeviceOSVersion,
                    IsCheckOutPoint = true
                });
            }
            return(Ok(response));
        }
        public IHttpActionResult CheckPoint(AttendanceEntryModel model)
        {
            if (string.IsNullOrEmpty(model.LogLocation))
            {
                return(Ok(new ResponseModel {
                    Message = "LogLocation is required."
                }));
            }

            var response = _attendance.SaveCheckPoint(new UserMovementLogModel
            {
                UserId          = model.UserId,
                CompanyId       = model.CompanyId,
                Latitude        = model.Latitude,
                Longitude       = model.Longitude,
                LogLocation     = model.LogLocation,
                DeviceName      = model.DeviceName,
                DeviceOSVersion = model.DeviceOSVersion
            });

            return(Ok(response));
        }
예제 #7
0
        public ResponseModel CheckIn(AttendanceEntryModel model)
        {
            var errMessage     = string.Empty;
            var queryParamList = new QueryParamList
            {
                new QueryParamObj {
                    ParamDirection = ParameterDirection.Input, ParamName = "@UserId", ParamValue = model.UserId
                },
                new QueryParamObj {
                    ParamDirection = ParameterDirection.Input, ParamName = "@CompanyId", ParamValue = model.CompanyId
                },
                new QueryParamObj {
                    ParamDirection = ParameterDirection.Input, ParamName = "@AttendanceDate", ParamValue = DateTime.UtcNow, DBType = DbType.DateTime
                },
                new QueryParamObj {
                    ParamDirection = ParameterDirection.Input, ParamName = "@CheckInTime", ParamValue = DateTime.UtcNow, DBType = DbType.DateTime
                },
                new QueryParamObj {
                    ParamDirection = ParameterDirection.Input, ParamName = "@DailyWorkingTimeInMin", ParamValue = model.OfficeHour, DBType = DbType.Int32
                },
                new QueryParamObj {
                    ParamDirection = ParameterDirection.Input, ParamName = "@AllowOfficeLessTime", ParamValue = model.AllowOfficeLessTime, DBType = DbType.Int32
                },
            };

            const string sql = @"IF NOT EXISTS(SELECT * FROM ResourceTracker_Attendance A WHERE A.UserId=@UserId AND CONVERT(DATE,AttendanceDate)=CONVERT(DATE,@AttendanceDate))
                                BEGIN
                                INSERT INTO ResourceTracker_Attendance(UserId,CompanyId,AttendanceDate,CheckInTime,DailyWorkingTimeInMin,AllowOfficeLessTime)
				                                            VALUES(@UserId,@CompanyId,@AttendanceDate,@CheckInTime,@DailyWorkingTimeInMin,@AllowOfficeLessTime)
                                END";

            DBExecCommandEx(sql, queryParamList, ref errMessage);

            return(new ResponseModel {
                Success = string.IsNullOrEmpty(errMessage)
            });
        }
예제 #8
0
 /// <summary>
 /// Makes a new Avatar
 /// </summary>
 /// <param name="data"></param>
 /// <returns>Avatar Passed In</returns>
 public AttendanceEntryModel Create(AttendanceEntryModel data)
 {
     attendanceList.Add(data);
     return(data);
 }