Class Util
A collection of utilities for import/export.
Inheritance
Namespace: Dnn.ExportImport.Components.Common
Assembly: DotNetNuke.SiteExportImport.dll
Syntax
public static class Util : object
Methods
| Improve this Doc View SourceCalculateTotalPages(Int32, Int32)
Calculates the total number of pages.
Declaration
public static int CalculateTotalPages(int totalRecords, int pageSize)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | totalRecords | The total amount of records. |
System.Int32 | pageSize | The number of items on a page. |
Returns
Type | Description |
---|---|
System.Int32 | A value indicating the total amount of pages required to containe the amount of items. |
ConvertToDbLocalTime(Nullable<DateTime>)
Convert the UTC time to Database local time.
Declaration
public static DateTime? ConvertToDbLocalTime(DateTime? dateTime)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<DateTime> | dateTime | The date and time to convert. |
Returns
Type | Description |
---|---|
System.Nullable<DateTime> | The converted date and time. |
ConvertToDbUtcTime(Nullable<DateTime>)
Convert the Local time to Database Utc time.
Declaration
public static DateTime? ConvertToDbUtcTime(DateTime? dateTime)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<DateTime> | dateTime | the date and time to convert. |
Returns
Type | Description |
---|---|
System.Nullable<DateTime> | The converted date and time. |
FixDateTime<T>(T)
Replaces missing DateTime values to give them Dnn.ExportImport.Components.Common.Constants.MinDbTime value.
Declaration
public static void FixDateTime<T>(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to fix. |
Type Parameters
Name | Description |
---|---|
T | The type of the item. |
FormatNumber(Nullable<Int32>)
Gets a string representation of a number formatted for the current thread culture.
Declaration
public static string FormatNumber(int? number)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.Int32> | number | The number to format. |
Returns
Type | Description |
---|---|
System.String | A string representing a number in the current thread culture format. |
FormatSize(Int64, Byte)
Formats a size to a human readable format.
Declaration
public static string FormatSize(long bytes, byte decimals = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | bytes | The amount of bytes to represent. |
System.Byte | decimals | How many decimal places to use in the resulting string. |
Returns
Type | Description |
---|---|
System.String | A human readable size format, for instance 1024 would return 1 KB. |
GeModuleDefIdByFriendltName(String)
Gets a module definition id by it's friendly name.
Declaration
public static int? GeModuleDefIdByFriendltName(string friendlyName)
Parameters
Type | Name | Description |
---|---|---|
System.String | friendlyName | The module definition frienly name. |
Returns
Type | Description |
---|---|
System.Nullable<System.Int32> | The found module definition id or null. |
GePermissionIdByName(String, String, String)
Gets the id of a permission by it's permission name.
Declaration
public static int? GePermissionIdByName(string permissionCode, string permissionKey, string permissionName)
Parameters
Type | Name | Description |
---|---|---|
System.String | permissionCode | The code of the permission. |
System.String | permissionKey | The key of the permission. |
System.String | permissionName | The name of the permission. |
Returns
Type | Description |
---|---|
System.Nullable<System.Int32> | The id of the permission if found, null if not found. |
GetDateTimeString(Nullable<DateTime>)
Gets a string representation of a date and time formatted for the current thread culture.
Declaration
public static string GetDateTimeString(DateTime? dateTime)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<DateTime> | dateTime | The date and time to convert. |
Returns
Type | Description |
---|---|
System.String | A human readable representation of the date and time. |
GetExpImpJobCacheKey(ExportImportJob)
Gets the export/import job cache key.
Declaration
public static string GetExpImpJobCacheKey(ExportImportJob job)
Parameters
Type | Name | Description |
---|---|---|
ExportImportJob | job | The job to generate the key for. |
Returns
Type | Description |
---|---|
System.String | A string representing the cacke key. |
GetPortableImplementors()
Gets the types that implement BasePortableService.
Declaration
public static IEnumerable<BasePortableService> GetPortableImplementors()
Returns
Type | Description |
---|---|
IEnumerable<BasePortableService> | An enumeration of the types that implement BasePortableService. |
GetProfilePropertyId(Int32, Nullable<Int32>, String)
Gets the id of a profile property from an export.
Declaration
public static int? GetProfilePropertyId(int portalId, int? exportedProfilePropertyId, string exportProfilePropertyname)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | portalId | The id of the portal (site). |
System.Nullable<System.Int32> | exportedProfilePropertyId | The exported profile property. |
System.String | exportProfilePropertyname | The name of the exported profile property. |
Returns
Type | Description |
---|---|
System.Nullable<System.Int32> | The id of the profile property or null if not found. |
GetRoleIdByName(Int32, Int32, String)
Get the new id of a role in an export.
Declaration
public static int? GetRoleIdByName(int portalId, int exportRoleId, string exportRolename)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | portalId | The id of the portal (site). |
System.Int32 | exportRoleId | The id of the role in the export. |
System.String | exportRolename | The name of the role in the export. |
Returns
Type | Description |
---|---|
System.Nullable<System.Int32> | The found role id or null. |
GetUserIdByName(ExportImportJob, Nullable<Int32>, String)
Get the id of a user for populating audit control values.
Declaration
public static int GetUserIdByName(ExportImportJob importJob, int? exportedUserId, string exportUsername)
Parameters
Type | Name | Description |
---|---|---|
ExportImportJob | importJob | A reference to the import job. |
System.Nullable<System.Int32> | exportedUserId | The user id for the user that created the export. |
System.String | exportUsername | The user name for the user that creted the export. |
Returns
Type | Description |
---|---|
System.Int32 | -1 if not found, 1 if the user is HOST, the user id if found on the imported site. |
HasValue(String)
Check if a given string is not null or empty (contains any value).
Declaration
public static bool HasValue(this string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The string to check. |
Returns
Type | Description |
---|---|
System.Boolean | A value indicating whether the string contains any value. |
IsNullOrEmpty(String)
Checks if a string is either null or empty ("").
Declaration
public static bool IsNullOrEmpty(this string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The string to check. |
Returns
Type | Description |
---|---|
System.Boolean | A value indicating whether the string is null or empty. |
IsNullOrWhiteSpace(String)
Checks if a string is either null or contains only whitespace (" ").
Declaration
public static bool IsNullOrWhiteSpace(this string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The string to check. |
Returns
Type | Description |
---|---|
System.Boolean | A value indicating whether the string is null or contains only whtespace. |
ReadJson<T>(String, ref T)
Reads an item from a json file.
Declaration
public static void ReadJson<T>(string filePath, ref T item)
Parameters
Type | Name | Description |
---|---|---|
System.String | filePath | The file to read from. |
T | item | The item to extract. |
Type Parameters
Name | Description |
---|---|
T | The type of the item. |
ToLocalDateTime(DateTime, UserInfo)
Converts non local dates and times to the provided user local time.
Declaration
public static DateTime ToLocalDateTime(DateTime dateTime, UserInfo userInfo)
Parameters
Type | Name | Description |
---|---|---|
DateTime | dateTime | The date to convert from. |
UserInfo | userInfo | The user for whitch to adjust the provided date and item. |
Returns
Type | Description |
---|---|
DateTime | The adjusted date and time. |
ToLocalDateTime(Nullable<DateTime>, UserInfo)
Converts a date and time to the user local time.
Declaration
public static DateTime? ToLocalDateTime(DateTime? dateTime, UserInfo userInfo)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<DateTime> | dateTime | The date and time to convert. |
UserInfo | userInfo | The user for which to adjust the date and time for. |
Returns
Type | Description |
---|---|
System.Nullable<DateTime> | The provided date time adjusted for the user local time. |
WriteJson<T>(String, T)
Writes an item to a file as json.
Declaration
public static void WriteJson<T>(string filePath, T item)
Parameters
Type | Name | Description |
---|---|---|
System.String | filePath | The file to save to. |
T | item | The item to write. |
Type Parameters
Name | Description |
---|---|
T | The type of the item to write. |