Пример #1
0
        public static List <UserMovementLogModel> ToMovementLog(DbDataReader readers)
        {
            if (readers == null)
            {
                return(null);
            }
            var models = new List <UserMovementLogModel>();

            while (readers.Read())
            {
                var model = new UserMovementLogModel
                {
                    Id              = Convert.IsDBNull(readers["Id"]) ? string.Empty : Convert.ToString(readers["Id"]),
                    UserId          = Convert.IsDBNull(readers["UserId"]) ? string.Empty : Convert.ToString(readers["UserId"]),
                    LogDateTime     = Convert.IsDBNull(readers["LogDateTime"]) ? (DateTime?)null : Convert.ToDateTime(readers["LogDateTime"]),
                    Latitude        = Convert.IsDBNull(readers["Latitude"]) ? (decimal?)null : Convert.ToDecimal(readers["Latitude"]),
                    Longitude       = Convert.IsDBNull(readers["Longitude"]) ? (decimal?)null : Convert.ToDecimal(readers["Longitude"]),
                    CompanyId       = Convert.ToInt32(readers["CompanyId"]),
                    LogLocation     = Convert.IsDBNull(readers["LogLocation"]) ? string.Empty : Convert.ToString(readers["LogLocation"]),
                    DeviceName      = Convert.IsDBNull(readers["DeviceName"]) ? string.Empty : Convert.ToString(readers["DeviceName"]),
                    DeviceOSVersion = Convert.IsDBNull(readers["DeviceOSVersion"]) ? string.Empty : Convert.ToString(readers["DeviceOSVersion"]),
                    IsCheckInPoint  = Convert.IsDBNull(readers["IsCheckInPoint"]) ? (bool?)null : Convert.ToBoolean(readers["IsCheckInPoint"]),
                    IsCheckOutPoint = Convert.IsDBNull(readers["IsCheckOutPoint"]) ? (bool?)null : Convert.ToBoolean(readers["IsCheckOutPoint"]),
                };

                models.Add(model);
            }

            return(models);
        }
Пример #2
0
        public ResponseModel SaveCheckPoint(UserMovementLogModel model)
        {
            var errMessage     = string.Empty;
            var queryParamList = new QueryParamList
            {
                new QueryParamObj {
                    ParamDirection = ParameterDirection.Input, ParamName = "@Id", ParamValue = Guid.NewGuid().ToString()
                },
                new QueryParamObj {
                    ParamDirection = ParameterDirection.Input, ParamName = "@UserId", ParamValue = model.UserId
                },
                new QueryParamObj {
                    ParamDirection = ParameterDirection.Input, ParamName = "@LogDateTime", ParamValue = DateTime.UtcNow, DBType = DbType.DateTime
                },
                new QueryParamObj {
                    ParamDirection = ParameterDirection.Input, ParamName = "@Latitude", ParamValue = model.Latitude
                },
                new QueryParamObj {
                    ParamDirection = ParameterDirection.Input, ParamName = "@Longitude", ParamValue = model.Longitude
                },
                new QueryParamObj {
                    ParamDirection = ParameterDirection.Input, ParamName = "@LogLocation", ParamValue = model.LogLocation
                },
                new QueryParamObj {
                    ParamDirection = ParameterDirection.Input, ParamName = "@IsCheckInPoint", ParamValue = model.IsCheckInPoint
                },
                new QueryParamObj {
                    ParamDirection = ParameterDirection.Input, ParamName = "@IsCheckOutPoint", ParamValue = model.IsCheckOutPoint
                },
                new QueryParamObj {
                    ParamDirection = ParameterDirection.Input, ParamName = "@DeviceName", ParamValue = model.DeviceName
                },
                new QueryParamObj {
                    ParamDirection = ParameterDirection.Input, ParamName = "@DeviceOSVersion", ParamValue = model.DeviceOSVersion
                },
                new QueryParamObj {
                    ParamDirection = ParameterDirection.Input, ParamName = "@CompanyId", ParamValue = model.CompanyId
                }
            };

            const string sql = @"INSERT INTO ResourceTracker_UserMovementLog(Id,UserId,LogDateTime,Latitude,Longitude,LogLocation,IsCheckInPoint,
                                    IsCheckOutPoint,DeviceName,DeviceOSVersion,CompanyId)
				                 VALUES(@Id,@UserId,@LogDateTime,@Latitude,@Longitude,@LogLocation,@IsCheckInPoint,
                                    @IsCheckOutPoint,@DeviceName,@DeviceOSVersion,@CompanyId)";

            DBExecCommandEx(sql, queryParamList, ref errMessage);

            return(new ResponseModel {
                Success = string.IsNullOrEmpty(errMessage)
            });
        }