public User Get(int userId) { User user = null; var comm = GetCommand("SPUsersGet"); comm.AddParameter<int>(this.Factory, "UserId", userId); var dr = GetFirstRow(comm); if (dr != null) { user = ParseUserInfo(dr); user.ExternalProfileUrl = dr.GetString("UserExternalProfileUrl"); user.Email = dr.GetString("UserEmail"); user.EmailPolicy = (EmailPolicy)(dr.GetNullable<int?>("UserEmailPolicy") ?? (int)EmailPolicy.None); user.Photo = dr.GetString("UserPhoto"); user.Website = dr.GetString("UserWebsite"); user.BirthDate = dr.GetNullableStruct<DateTime>("UserBirthDate"); user.Warned = (!dr.IsNull("WarningStart")) && dr.GetNullableStruct<bool>("WarningRead") != true; user.Suspended = (!dr.IsNull("SuspendedStart")) && (dr.IsNull("SuspendedEnd") || dr.GetNullableStruct<DateTime>("SuspendedEnd") >= DateTime.UtcNow); user.Banned = !dr.IsNull("BannedStart"); user.SuspendedEnd = dr.GetNullableStruct<DateTime>("SuspendedEnd"); user.ModeratorReason = dr.GetNullableStruct<ModeratorReason>("ModeratorReason"); user.ModeratorReasonMessage = dr.GetString("ModeratorReasonFull"); } //se obtiene el perfil desde construnario UserProfileAcces profileaccess = new UserProfileAcces(MysqlconnectionString); user.Construnario_Profile = profileaccess.Get_UserProfile(dr.Get<string>("userproviderid")); return user; }
protected virtual User ParseUserInfo(DataRow dr) { User user = new User(); user.Id = dr.Get<int>("UserId"); user.UserName = dr.GetString("UserName"); user.Role = dr.Get<UserRole>("UserGroupId"); user.RoleName = dr.GetString("UserGroupName"); user.RegistrationDate = dr.GetDate("UserRegistrationDate"); decimal offSet = dr.Get<decimal>("UserTimeZone"); user.TimeZone = new TimeSpan((long)(offSet * (decimal)TimeSpan.TicksPerHour)); //se obtiene el perfil desde construnario UserProfileAcces profileaccess = new UserProfileAcces(MysqlconnectionString); user.Construnario_Profile = profileaccess.Get_UserProfilebyUserName(user.UserName ); return user; }
/// <summary> /// Converts a user data row into a app user entity /// </summary> /// <param name="dr"></param> /// <returns></returns> protected virtual User ParseUserLoginInfo(DataRow dr) { var user = new User(); user.Id = dr.Get<int>("UserId"); user.UserName = dr.GetString("UserName"); user.Role = dr.Get<UserRole>("UserGroupId"); user.Guid = dr.Get<Guid>("UserGuid"); user.ExternalProfileUrl = dr.GetString("UserExternalProfileUrl"); user.ProviderLastCall = dr.GetDate("UserProviderLastCall"); user.Email = dr.GetString("UserEmail"); decimal offSet = dr.Get<decimal>("UserTimeZone"); user.TimeZone = new TimeSpan((long)(offSet * (decimal)TimeSpan.TicksPerHour)); if (dr.Table.Columns.Contains("WarningStart")) { user.Warned = (!dr.IsNull("WarningStart")) && dr.GetNullableStruct<bool>("WarningRead") != true; user.Suspended = (!dr.IsNull("SuspendedStart")) && (dr.IsNull("SuspendedEnd") || dr.GetNullableStruct<DateTime>("SuspendedEnd") >= DateTime.UtcNow); user.Banned = !dr.IsNull("BannedStart"); user.SuspendedEnd = dr.GetNullableStruct<DateTime>("SuspendedEnd"); } //se obtiene el perfil desde construnario UserProfileAcces profileaccess = new UserProfileAcces(MysqlconnectionString); user.Construnario_Profile = profileaccess.Get_UserProfilebyUserName(user.UserName ); return user; }
protected virtual Forum ParseForumWithTopicDataRow(DataRow dr, UserRole? role) { Forum f = ParseForumDataRow(dr); //cambiando el codigo var comm = GetCommand("sptopicsgetbyforumlatest"); comm.AddParameter(Factory, "forumid", DbType.Int16, f.Id ); comm.AddParameter(Factory, "usergroupid", DbType.Int16, role); comm.AddParameter(Factory, "startindex", DbType.Int16, 0); comm.AddParameter(Factory, "length", DbType.Int16, 1); var dt = GetTable(comm); if (dt.Rows.Count > 0) { if (!dt.Rows[0].IsNull("TopicCreationDate")) { f.LastTopic = new Topic(); f.LastTopic.User = (new UsersDataAccess()).Get(dt.Rows[0].Get<int>("UserId")); //se obtiene el perfil desde construnario UserProfileAcces profileaccess = new UserProfileAcces(MysqlconnectionString); f.LastTopic.User.Construnario_Profile = profileaccess.Get_UserProfilebyUserName(f.LastTopic.User.UserName); f.LastTopic.Id = dt.Rows[0].Get<int>("TopicId"); f.LastTopic.Date = dt.Rows[0].GetDate("TopicCreationDate"); f.LastTopic.Title = dt.Rows[0].GetString("TopicTitle"); f.LastTopic.ShortName = dt.Rows[0].GetString("TopicShortName"); } } //cambiando end return f; }