本文整理汇总了C#中DotNetNuke.Entities.Users.UserInfo.GetSafeUsername方法的典型用法代码示例。如果您正苦于以下问题:C# UserInfo.GetSafeUsername方法的具体用法?C# UserInfo.GetSafeUsername怎么用?C# UserInfo.GetSafeUsername使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DotNetNuke.Entities.Users.UserInfo
的用法示例。
在下文中一共展示了UserInfo.GetSafeUsername方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Context
/// -----------------------------------------------------------------------------
/// <summary>
/// Provides a list of context variables for XML output
/// </summary>
/// <returns>DataTable with all context variables</returns>
/// -----------------------------------------------------------------------------
public DataTable Context(ModuleInfo moduleInfo, UserInfo userInfo, string searchInput, string orderBy,
string orderDirection, string paging)
{
var request = HttpContext.Current.Request;
orderBy = orderBy.AsString("UserDefinedRowId");
orderDirection = orderDirection.AsString("ascending");
var contextTable = new DataTable("Context");
contextTable.Columns.Add("ModuleId", typeof (int));
contextTable.Columns.Add("TabId", typeof (int));
contextTable.Columns.Add("TabName", typeof(string));
contextTable.Columns.Add("PortalId", typeof (int));
contextTable.Columns.Add("UserName", typeof (string));
contextTable.Columns.Add("BestUserName", typeof (string));
//obsolete, please use DisplayName
contextTable.Columns.Add("DisplayName", typeof (string));
contextTable.Columns.Add("ApplicationPath", typeof (string));
contextTable.Columns.Add("HomePath", typeof (string));
contextTable.Columns.Add("UserRoles", typeof (string));
contextTable.Columns.Add("IsAdministratorRole", typeof (bool));
contextTable.Columns.Add("Parameter", typeof (string));
contextTable.Columns.Add("OrderBy", typeof (string));
contextTable.Columns.Add("OrderDirection", typeof (string));
contextTable.Columns.Add("CurrentCulture", typeof (string));
contextTable.Columns.Add("LocalizedString_Search", typeof (string));
contextTable.Columns.Add("LocalizedString_Page", typeof (string));
contextTable.Columns.Add("LocalizedString_Of", typeof (string));
contextTable.Columns.Add("LocalizedString_First", typeof (string));
contextTable.Columns.Add("LocalizedString_Previous", typeof (string));
contextTable.Columns.Add("LocalizedString_Next", typeof (string));
contextTable.Columns.Add("LocalizedString_Last", typeof (string));
contextTable.Columns.Add("NowInTicks", typeof (long));
contextTable.Columns.Add("TodayInTicks", typeof (long));
contextTable.Columns.Add("TicksPerDay", typeof (long));
contextTable.Columns.Add("LocalizedDate", typeof (string));
contextTable.Columns.Add("Now", typeof (DateTime));
if (paging != string.Empty)
{
contextTable.Columns.Add("Paging", typeof (int));
}
var row = contextTable.NewRow();
row["ModuleId"] = moduleInfo.ModuleID;
row["TabId"] = moduleInfo.TabID;
row["TabName"] = moduleInfo.ParentTab.TabName;
row["PortalId"] = moduleInfo.PortalID;
// null username handled by extension method
row["DisplayName"] = userInfo.GetSafeDisplayname();
row["UserName"] = userInfo.GetSafeUsername();
row["BestUserName"] = row["DisplayName"];
var portalSettings = Globals.GetPortalSettings();
row["HomePath"] = portalSettings.HomeDirectory;
row["ApplicationPath"] = request.ApplicationPath == "/" ? "" : request.ApplicationPath;
row["UserRoles"] = ModuleSecurity.RoleNames(userInfo);
if (ModuleSecurity.IsAdministrator())
{
row["IsAdministratorRole"] = true;
}
row["Parameter"] = searchInput;
row["OrderBy"] = orderBy;
row["OrderDirection"] = orderDirection == "DESC" ? "descending" : "ascending";
row["CurrentCulture"] = new Localization().CurrentCulture;
if (paging != string.Empty)
{
row["Paging"] = int.Parse(paging);
}
row["LocalizedString_Search"] = Localization.GetString("Search.Text", Definition.SharedRessources);
row["LocalizedString_Page"] = Localization.GetString("PagingPage.Text", Definition.SharedRessources);
row["LocalizedString_of"] = Localization.GetString("PagingOf.Text", Definition.SharedRessources);
row["LocalizedString_First"] = Localization.GetString("PagingFirst.Text", Definition.SharedRessources);
row["LocalizedString_Previous"] = Localization.GetString("PagingPrevious.Text", Definition.SharedRessources);
row["LocalizedString_Next"] = Localization.GetString("PagingNext.Text", Definition.SharedRessources);
row["LocalizedString_Last"] = Localization.GetString("PagingLast.Text", Definition.SharedRessources);
var d = SystemDateTime.GetCurrentTimeUtc();
var timeZone = userInfo.Username != null
? userInfo.Profile.PreferredTimeZone
: portalSettings.TimeZone;
d = TimeZoneInfo.ConvertTimeFromUtc( d, timeZone);
row["Now"] = d;
row["LocalizedDate"] = d.ToString("g", Thread.CurrentThread.CurrentCulture);
row["NowInTicks"] = d.Ticks;
row["TodayInTicks"] = d.Date.Ticks ;
row["TicksPerDay"] = TimeSpan.TicksPerDay;
contextTable.Rows.Add(row);
return contextTable;
}