本文整理汇总了C#中DotNetNuke.Entities.Users.UserInfo类的典型用法代码示例。如果您正苦于以下问题:C# UserInfo类的具体用法?C# UserInfo怎么用?C# UserInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UserInfo类属于DotNetNuke.Entities.Users命名空间,在下文中一共展示了UserInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetProperty
public string GetProperty(string propertyName, string format, CultureInfo formatProvider, UserInfo AccessingUser, Scope AccessLevel, ref bool PropertyNotFound)
{
TimeZoneInfo userTimeZone = AccessingUser.Profile.PreferredTimeZone;
switch (propertyName.ToLower())
{
case "current":
if (format == string.Empty)
{
format = "D";
}
return TimeZoneInfo.ConvertTime(DateTime.Now, userTimeZone).ToString(format, formatProvider);
case "now":
if (format == string.Empty)
{
format = "g";
}
return TimeZoneInfo.ConvertTime(DateTime.Now, userTimeZone).ToString(format, formatProvider);
case "system":
if (format == String.Empty)
{
format = "g";
}
return DateTime.Now.ToString(format, formatProvider);
case "utc":
if (format == String.Empty)
{
format = "g";
}
return DateTime.Now.ToUniversalTime().ToString(format, formatProvider);
default:
PropertyNotFound = true;
return string.Empty;
}
}
示例2: AddGroupNotification
internal virtual Notification AddGroupNotification(string notificationTypeName, int tabId, int moduleId, RoleInfo group, UserInfo initiatingUser, IList<RoleInfo> moderators, IList<UserInfo> recipients) {
var notificationType = NotificationsController.Instance.GetNotificationType(notificationTypeName);
var tokenReplace = new GroupItemTokenReplace(group);
var subject = Localization.GetString(notificationTypeName + ".Subject", Constants.SharedResourcesPath);
subject = tokenReplace.ReplaceGroupItemTokens(subject);
var body = Localization.GetString(notificationTypeName + ".Body", Constants.SharedResourcesPath);
body = tokenReplace.ReplaceGroupItemTokens(body);
body = body.Replace("Public.Text", Localization.GetString("Public.Text", Constants.SharedResourcesPath));
body = body.Replace("Private.Text", Localization.GetString("Private.Text", Constants.SharedResourcesPath));
bool dismiss = notificationTypeName != Constants.GroupPendingNotification;
var notification = new Notification
{
NotificationTypeID = notificationType.NotificationTypeId,
Subject = subject,
Body = body,
IncludeDismissAction = dismiss,
SenderUserID = initiatingUser.UserID,
Context = String.Format("{0}:{1}:{2}", tabId, moduleId, group.RoleID)
};
NotificationsController.Instance.SendNotification(notification, initiatingUser.PortalID, moderators, recipients);
return notification;
}
示例3: ValueProviderWrapperForPropertyAccess
public ValueProviderWrapperForPropertyAccess(string name, IPropertyAccess source, UserInfo user, CultureInfo localization)
{
Name = name;
_source = source;
_user = user;
_loc = localization;
}
示例4: UpdateTimeZoneInfo
private void UpdateTimeZoneInfo(UserInfo user, ProfilePropertyDefinitionCollection properties)
{
ProfilePropertyDefinition newTimeZone = properties["PreferredTimeZone"];
ProfilePropertyDefinition oldTimeZone = properties["TimeZone"];
if (newTimeZone != null && oldTimeZone != null)
{
//Old timezone is present but new is not...we will set that up.
if (!string.IsNullOrEmpty(oldTimeZone.PropertyValue) && string.IsNullOrEmpty(newTimeZone.PropertyValue))
{
int oldOffset;
int.TryParse(oldTimeZone.PropertyValue, out oldOffset);
TimeZoneInfo timeZoneInfo = Localization.ConvertLegacyTimeZoneOffsetToTimeZoneInfo(oldOffset);
newTimeZone.PropertyValue = timeZoneInfo.Id;
UpdateUserProfile(user);
}
//It's also possible that the new value is set but not the old value. We need to make them backwards compatible
else if (!string.IsNullOrEmpty(newTimeZone.PropertyValue) && string.IsNullOrEmpty(oldTimeZone.PropertyValue))
{
TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(newTimeZone.PropertyValue);
if (timeZoneInfo != null)
{
oldTimeZone.PropertyValue = timeZoneInfo.BaseUtcOffset.TotalMinutes.ToString(CultureInfo.InvariantCulture);
}
}
}
}
示例5: PortalSecurity_IsInRoles_NonAdmin_In_Deny_Role_Is_False
public void PortalSecurity_IsInRoles_NonAdmin_In_Deny_Role_Is_False()
{
var user = new UserInfo { IsSuperUser = false, UserID = UserId };
const string roles = "!SomeRoleName";
var portalSettings = SetupPortalSettings();
Assert.IsFalse(PortalSecurity.IsInRoles(user, portalSettings, roles));
}
示例6: FloodControl
/// <summary>
/// cstor
/// </summary>
/// <param name="moduleId"></param>
/// <param name="tabId"></param>
/// <param name="ipAddress"></param>
/// <param name="user"></param>
public FloodControl(int moduleId, int tabId, string ipAddress, UserInfo user)
{
this.moduleId = moduleId;
this.tabId = tabId;
this.ipAddress = ipAddress;
this.user = user;
if (user != null)
{
//work out if the userinfo
//object has edit permission on this module
var moduleInfo = ModuleController.Instance.GetModule(moduleId, tabId, false);
hasEditAccess = ModulePermissionController
.HasModuleAccess(SecurityAccessLevel.Edit,
null,
moduleInfo);
//load the flood control settings
var settings = new ShoutBoxModuleSettings(moduleId, tabId);
floodTimePost = settings.FloodNewPost;
floodTimeReply = settings.FloodReply;
floodTimeVote = settings.FloodVoting;
}
}
示例7: CreateJournalEntry
public static void CreateJournalEntry(RoleInfo roleInfo, UserInfo createdBy)
{
var journalController = JournalController.Instance;
var journalItem = new JournalItem();
string url = "";
if (roleInfo.Settings.ContainsKey("URL"))
{
url = roleInfo.Settings["URL"];
}
journalItem.PortalId = roleInfo.PortalID;
journalItem.ProfileId = createdBy.UserID;
journalItem.UserId = createdBy.UserID;
journalItem.Title = roleInfo.RoleName;
journalItem.ItemData = new ItemData {Url = url};
journalItem.SocialGroupId = roleInfo.RoleID;
journalItem.Summary = roleInfo.Description;
journalItem.Body = null;
journalItem.JournalTypeId = journalController.GetJournalType("groupcreate").JournalTypeId;
journalItem.ObjectKey = string.Format("groupcreate:{0}:{1}", roleInfo.RoleID.ToString(CultureInfo.InvariantCulture), createdBy.UserID.ToString(CultureInfo.InvariantCulture));
if (journalController.GetJournalItemByKey(roleInfo.PortalID, journalItem.ObjectKey) != null)
journalController.DeleteJournalItemByKey(roleInfo.PortalID, journalItem.ObjectKey);
journalItem.SecuritySet = string.Empty;
if (roleInfo.IsPublic)
journalItem.SecuritySet += "E,";
journalController.SaveJournalItem(journalItem, -1);
}
示例8: TicksPropertyAcccess_GetProperty_Returns_Correct_String
public void TicksPropertyAcccess_GetProperty_Returns_Correct_String(string propertyName)
{
//Arrange
var ticksPropertyAccess = new TicksPropertyAccess();
var accessingUser = new UserInfo();
long expected = DateTime.MinValue.Ticks;
switch (propertyName)
{
case "now":
expected = DateTime.Now.Ticks;
break;
case "today":
expected = DateTime.Today.Ticks;
break;
case "ticksperday":
expected = TimeSpan.TicksPerDay;
break;
}
//Act
bool propertyNotFound = false;
string propertyValue = ticksPropertyAccess.GetProperty(propertyName, "", CultureInfo.InvariantCulture,
accessingUser, Scope.DefaultSettings, ref propertyNotFound);
//Assert
Assert.AreEqual(expected.ToString(CultureInfo.InvariantCulture), propertyValue);
}
示例9: IsAuthorized
public override bool IsAuthorized(AuthFilterContext context)
{
if (SecurityLevel == SecurityAccessLevel.Anonymous)
{
return true;
}
User = HttpContextSource.Current.Request.IsAuthenticated ? UserController.Instance.GetCurrentUserInfo() : new UserInfo();
ContextSecurity security = new ContextSecurity(context.ActionContext.Request.FindModuleInfo());
switch (SecurityLevel)
{
case SecurityAccessLevel.Authenticated:
return User.UserID != -1;
case SecurityAccessLevel.Host:
return User.IsSuperUser;
case SecurityAccessLevel.Admin:
return security.IsAdmin;
case SecurityAccessLevel.Edit:
return security.CanEdit;
case SecurityAccessLevel.View:
return security.CanView;
case SecurityAccessLevel.Pilot:
return security.IsPilot;
case SecurityAccessLevel.Verifier:
return security.IsVerifier;
}
return false;
}
示例10: AddSpeaker
public static int AddSpeaker(int portalId, int conferenceId, int userId, string email, string firstName, string lastName, string displayName, string company, int updatingUserId)
{
var user = UserController.Instance.GetUserById(portalId, userId);
if (user == null)
{
user = UserController.GetUserByEmail(portalId, email);
if (user == null)
{
user = new UserInfo() { PortalID = portalId, Username = email, Email = email, FirstName = firstName, LastName = lastName, DisplayName = displayName };
user.Membership.Password = UserController.GeneratePassword();
user.Membership.Approved = true;
user.Membership.UpdatePassword = true;
var res = UserController.CreateUser(ref user);
if (res != DotNetNuke.Security.Membership.UserCreateStatus.Success)
{
throw new System.Exception(res.ToString());
}
}
}
var speaker = SpeakerRepository.Instance.GetSpeaker(conferenceId, user.UserID);
if (speaker == null)
{
var s = new Models.Speakers.SpeakerBase() { ConferenceId = conferenceId, UserId = user.UserID, Company = company };
SpeakerRepository.Instance.AddSpeaker(s, updatingUserId);
}
DnnRoleController.CheckSpeaker(portalId, conferenceId, user.UserID);
return user.UserID;
}
示例11: GetProperty
public string GetProperty(string propertyName, string format, CultureInfo formatProvider, UserInfo AccessingUser, Scope CurrentScope, ref bool PropertyNotFound)
{
switch (propertyName.ToLowerInvariant())
{
case "url":
return NewUrl(objParent.Language);
case "flagsrc":
return "/" + objParent.Language + ".gif";
case "selected":
return (objParent.Language == CultureInfo.CurrentCulture.Name).ToString();
case "label":
return Localization.GetString("Label", objParent.resourceFile);
case "i":
return Globals.ResolveUrl("~/images/Flags");
case "p":
return Globals.ResolveUrl(PathUtils.Instance.RemoveTrailingSlash(objPortal.HomeDirectory));
case "s":
return Globals.ResolveUrl(PathUtils.Instance.RemoveTrailingSlash(objPortal.ActiveTab.SkinPath));
case "g":
return Globals.ResolveUrl("~/portals/" + Globals.glbHostSkinFolder);
default:
PropertyNotFound = true;
return string.Empty;
}
}
示例12: CreateNewUser
public UserCreateStatus CreateNewUser(string firstName, string lastName, string emailAddress, int portalId)
{
var ctlPortal = new PortalController();
var portalSettings = ctlPortal.GetPortals().Cast<PortalInfo>().FirstOrDefault(p => p.PortalID == portalId);
var user = new UserInfo()
{
FirstName = firstName,
LastName = lastName,
Email = emailAddress,
Username = emailAddress,
DisplayName = string.Concat(firstName, " ", lastName),
PortalID = portalId
};
user.Profile.PreferredLocale = portalSettings.DefaultLanguage;
user.Profile.FirstName = firstName;
user.Profile.LastName = lastName;
user.Membership.Approved = true;
user.Membership.Password = PasswordGenerator.GeneratePassword();
user.Membership.UpdatePassword = true;
var status = UserController.CreateUser(ref user);
User = user;
return status;
}
示例13: canUserAccessModule
/// <param name="moduleId"></param>
/// <param name="tabId"></param>
/// <param name="permissionKey">You can use the constants, but for modules there are only
/// those two</param>
/// <returns></returns>
public static bool canUserAccessModule(UserInfo user, int portalId, int tabId, ModuleInfo moduleInfo, string permissionKey)
{
var retVal = false;
string permissionsString = null;
if (moduleInfo.InheritViewPermissions)
{
var tabPermissionController = new TabPermissionController();
var tabPermissionCollection =
tabPermissionController.GetTabPermissionsCollectionByTabID(tabId, portalId);
permissionsString = tabPermissionController.GetTabPermissions(tabPermissionCollection, permissionKey);
}
else
{
var modulePermissionController = new ModulePermissionController();
var permissionCollection =
modulePermissionController.GetModulePermissionsCollectionByModuleID(moduleInfo.ModuleID, tabId);
permissionsString = modulePermissionController.GetModulePermissions(permissionCollection, permissionKey);
}
char[] splitter = { ';' };
var roles = permissionsString.Split(splitter);
foreach (var role in roles)
{
if (role.Length > 0)
{
if (user != null && user.IsInRole(role))
retVal = true;
else if (user == null && role.ToLower().Equals("all users"))
retVal = true;
}
}
return retVal;
}
示例14: GetProperty
public string GetProperty(string propertyName, string format, CultureInfo formatProvider, UserInfo AccessingUser, Scope AccessLevel, ref bool PropertyNotFound)
{
if (obj == null)
{
return string.Empty;
}
return GetObjectProperty(obj, propertyName, format, formatProvider, ref PropertyNotFound);
}
示例15: GetProperty
/// <summary>
/// Get Preloaded Data Property.
/// </summary>
/// <param name="propertyName">property name.</param>
/// <param name="format">format.</param>
/// <param name="formatProvider">format provider.</param>
/// <param name="accessingUser">accessing user.</param>
/// <param name="accessLevel">access level.</param>
/// <param name="propertyNotFound">Whether found the property value.</param>
/// <returns></returns>
public string GetProperty(string propertyName, string format, CultureInfo formatProvider, UserInfo accessingUser, Scope accessLevel, ref bool propertyNotFound)
{
var contactList = _service.GetContacts(searchTerm, _portalId, pageIndex, pageSize);
var contacts = contactList
.Select(contact => new ContactViewModel(contact))
.ToList();
return "{ results: " + JsonConvert.SerializeObject(contacts) + ", pageCount: " + contactList.TotalCount + "}";
}