• Share
    • Twitter
    • LinkedIn
    • Facebook
    • Email
  • Feedback
  • Improve this Doc

Class Util

A collection of utilities for import/export.

Inheritance
System.Object
Util
Namespace: Dnn.ExportImport.Components.Common
Assembly: DotNetNuke.SiteExportImport.dll
Syntax
public static class Util : object

Methods

| Improve this Doc View Source

CalculateTotalPages(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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

  • View Source
Back to top by the community, for the community... #DNNCMS