Table of Contents

Class CPUtilsBaseClass

Namespace
Contensive.BaseClasses
Assembly
CPBase.dll

helper methods to support processes, properties and methods used throughout

public abstract class CPUtilsBaseClass
Inheritance
CPUtilsBaseClass
Inherited Members

Methods

AppendLog(string)

Create a log entry type "Log"

public abstract void AppendLog(string logText)

Parameters

logText string

AppendLog(string, string)

Deprecated, file logging is no longer supported. Use AppendLog(message) to log Info level messages

[Obsolete("Deprecated, file logging is no longer supported. Use AppendLog(message) to log Info level messages", false)]
public abstract void AppendLog(string pathFilename, string logText)

Parameters

pathFilename string
logText string

AppendLogFile(string)

Deprecated, use AppendLog

[Obsolete("Deprecated, use AppendLog", false)]
public abstract void AppendLogFile(string Text)

Parameters

Text string

ConvertHTML2Text(string)

Return a text approximation of html content

public abstract string ConvertHTML2Text(string Source)

Parameters

Source string

Returns

string

Deprecated

[Obsolete("Deprecated", false)]
public abstract string ConvertLinkToShortLink(string URL, string ServerHost, string ServerVirtualPath)

Parameters

URL string
ServerHost string
ServerVirtualPath string

Returns

string

Deprecated

[Obsolete("Deprecated", false)]
public abstract string ConvertShortLinkToLink(string URL, string PathPagePrefix)

Parameters

URL string
PathPagePrefix string

Returns

string

ConvertText2HTML(string)

Return an html approximation of text content

public abstract string ConvertText2HTML(string source)

Parameters

source string

Returns

string

CreateGuid()

Return a new guid in system's format {...}

public abstract string CreateGuid()

Returns

string

DecodeGMTDate(string)

Deprecated

[Obsolete("Deprecated. Use native methods to convert date formats.", false)]
public abstract DateTime DecodeGMTDate(string GMTDate)

Parameters

GMTDate string

Returns

DateTime

DecodeHTML(string)

wrapped dotnet namespace for use in scripting

public abstract string DecodeHTML(string source)

Parameters

source string

Returns

string

DecodeHtmlFromWysiwygEditor(string)

html content can be stored with embedded addons. Use this routine to prepare the content returnedfrom a wysiwyg editor. (addons converted to images)

public abstract string DecodeHtmlFromWysiwygEditor(string source)

Parameters

source string

Returns

string

DecodeResponseVariable(string)

Decodes a querystring response argument (key or value) you would expect to see within a querystring (key1=value1&key2=value2)

public abstract string DecodeResponseVariable(string source)

Parameters

source string

Returns

string

DecodeUrl(string)

wrapped dotnet WebUtility.UrlDecode(source) for use in scripting. Use to decode segments of a URL (key or value).

public abstract string DecodeUrl(string Url)

Parameters

Url string

Returns

string

EncodeAppRootPath(string)

convert a file link (like /ccLibraryFiles/imageFilename/000001/this.png) to a full URL

public abstract string EncodeAppRootPath(string link)

Parameters

link string

Returns

string

EncodeBoolean(object)

Convert to boolean. If no valid rendition exists, returns false. (accepts true, yes, on, any +number)

public abstract bool EncodeBoolean(object expression)

Parameters

expression object

Returns

bool

EncodeContentForWeb(string)

public abstract string EncodeContentForWeb(string source)

Parameters

source string

Returns

string

EncodeContentForWeb(string, string)

public abstract string EncodeContentForWeb(string source, string contextContentName)

Parameters

source string
contextContentName string

Returns

string

EncodeContentForWeb(string, string, int)

public abstract string EncodeContentForWeb(string source, string contextContentName, int contextRecordID)

Parameters

source string
contextContentName string
contextRecordID int

Returns

string

EncodeContentForWeb(string, string, int, int)

html content can be stored with embedded addons. This routine renders the content for display on a website.

[Obsolete("Depreated. Use method without wrapper", false)]
public abstract string EncodeContentForWeb(string source, string contextContentName, int contextRecordID, int ignoreId)

Parameters

source string
contextContentName string
contextRecordID int
ignoreId int

Returns

string

EncodeDate(object)

Convert to DateTime. If no valid rendition exists, returns default( DateTime ) = 1/1/0001 12:00:00AM.

public abstract DateTime EncodeDate(object expression)

Parameters

expression object

Returns

DateTime

EncodeHTML(string)

wrapped dotnet namespace for use in scripting

public abstract string EncodeHTML(string source)

Parameters

source string

Returns

string

EncodeHtmlForWysiwygEditor(string)

html content can be stored with embedded addons. Use this routine to prepare the content for a wysiwyg editor. (addons converted to images)

public abstract string EncodeHtmlForWysiwygEditor(string source)

Parameters

source string

Returns

string

EncodeInteger(object)

Convert to integer. If no valid rendition exists, returns 0.

public abstract int EncodeInteger(object expression)

Parameters

expression object

Returns

int

EncodeJavascript(string)

Deprecated

[Obsolete("Use System.Web.HttpUtility.JavaScriptStringEncode()", false)]
public abstract string EncodeJavascript(string source)

Parameters

source string

Returns

string

EncodeNumber(object)

Convert to double. If no valid rendition exists, returns 0.

public abstract double EncodeNumber(object expression)

Parameters

expression object

Returns

double

EncodeQueryString(string)

Deprecated

[Obsolete("Encode each key value first with EncodeResponseVariable(), then assemble them into the querystring.", false)]
public abstract string EncodeQueryString(string Source)

Parameters

Source string

Returns

string

EncodeRequestVariable(string)

Encodes a querystring response argument (key or value) you would expect to see within a querystring (key1=value1&key2=value2)

public abstract string EncodeRequestVariable(string Source)

Parameters

Source string

Returns

string

EncodeText(object)

return an input argument as string, or empty string if it can not be converted.

public abstract string EncodeText(object expression)

Parameters

expression object

Returns

string

EncodeTextSafe(object)

Use only for text input that might contain XSS attacks, such as user input. return an input argument as string, or empty string if it can not be converted. Checks for XSS injection

public abstract string EncodeTextSafe(object expression)

Parameters

expression object

Returns

string

EncodeUrl(string)

wrapped dotnet WebUtility.UrlEncode(Source) for use in scripting. Use to encode segments of a URL (key or value).

public abstract string EncodeUrl(string source)

Parameters

source string

Returns

string

EncodeUrlForHrefSrc(string)

wrapped dotnet WebUtility.UrlEncode(Source) for use in scripting. Use to encode segments of a URL (key or value).

public abstract string EncodeUrlForHrefSrc(string source)

Parameters

source string

Returns

string

ExecuteAddon(string)

Deprecated. use cp.addon.execute()

[Obsolete("Deprecated. use cp.addon.execute()", false)]
public abstract string ExecuteAddon(string idGuidOrName)

Parameters

idGuidOrName string

Returns

string

ExecuteAddon(string, addonContext)

Deprecated. use cp.addon.execute()

[Obsolete("Deprecated. use cp.addon.execute()", false)]
public abstract string ExecuteAddon(string IdGuidOrName, CPUtilsBaseClass.addonContext context)

Parameters

IdGuidOrName string
context CPUtilsBaseClass.addonContext

Returns

string

ExecuteAddon(string, int)

Deprecated. use cp.addon.execute() and manage the wrapper manually.

[Obsolete("Deprecated. use cp.addon.execute() and manage the wrapper manually.", false)]
public abstract string ExecuteAddon(string IdGuidOrName, int ignoreId)

Parameters

IdGuidOrName string
ignoreId int

Returns

string

ExecuteAddonAsProcess(string)

Deprecated. use cp.addon.executeAsProcess()

[Obsolete("Deprecated. use cp.addon.executeAsProcess()", false)]
public abstract string ExecuteAddonAsProcess(string IdGuidOrName)

Parameters

IdGuidOrName string

Returns

string

ExportCsv(string, string, string)

Run an SQL query on the default datasource and save the data in a CSV file in the filename provided to a record in the downloads table.

public abstract void ExportCsv(string SQL, string exportName, string filename)

Parameters

SQL string

The query to run, selecting the data to be exported.

exportName string

The name of the export data, used in the downloads table

filename string

The filename for the export, saved in the downloads table

GetArgument(string, string)

get a value from a key=value delimited string. ex keyValueDelimitedString (a=b&c=4), keys ( a and c ), delimiter ( & ), values ( b and 4 )

public abstract string GetArgument(string key, string keyValueDelimitedString)

Parameters

key string
keyValueDelimitedString string

Returns

string

GetArgument(string, string, string)

get a value from a key=value delimited string. ex keyValueDelimitedString (a=b&c=4), keys ( a and c ), delimiter ( & ), values ( b and 4 )

public abstract string GetArgument(string key, string keyValueDelimitedString, string defaultValue)

Parameters

key string
keyValueDelimitedString string
defaultValue string

Returns

string

GetArgument(string, string, string, string)

get a value from a key=value delimited string. ex keyValueDelimitedString (a=b&c=4), keys ( a and c ), delimiter ( & ), values ( b and 4 )

public abstract string GetArgument(string key, string keyValueDelimitedString, string defaultValue, string delimiter)

Parameters

key string
keyValueDelimitedString string
defaultValue string
delimiter string

Returns

string

GetAuthenticationToken(int)

Authentication token can be used to authenticate the user with the request "eid=token". The default expiration is 24 hours.

public abstract string GetAuthenticationToken(int UserId)

Parameters

UserId int

Returns

string

GetAuthenticationToken(int, DateTime)

Authentication token can be used to authenticate the user with the request "eid=token".

public abstract string GetAuthenticationToken(int UserId, DateTime Expiration)

Parameters

UserId int
Expiration DateTime

Returns

string

GetDateTimeMockable()

Returns current DateTime.Now if cp.Mock.DateTime is not set, else returns Mock.DateTime

public abstract DateTime GetDateTimeMockable()

Returns

DateTime

GetFilename(string)

Return the filename part of a path (after the left-most slash), either Unix or Dos

public abstract string GetFilename(string pathFilename)

Parameters

pathFilename string

Returns

string

GetFirstNonZeroDate(DateTime, DateTime)

Deprecated

[Obsolete("Deprecated", false)]
public abstract DateTime GetFirstNonZeroDate(DateTime Date0, DateTime Date1)

Parameters

Date0 DateTime
Date1 DateTime

Returns

DateTime

GetFirstNonZeroInteger(int, int)

Deprecated

[Obsolete("Deprecated", false)]
public abstract int GetFirstNonZeroInteger(int Integer0, int Integer1)

Parameters

Integer0 int
Integer1 int

Returns

int

GetIntegerString(int, int)

Deprecated

[Obsolete("Use string.PadRight() and string.PadLeft()", false)]
public abstract string GetIntegerString(int Value, int DigitCount)

Parameters

Value int
DigitCount int

Returns

string

GetLine(string)

Deprecated

[Obsolete("Use new StringReader(str).ReadLine()", false)]
public abstract string GetLine(string Body)

Parameters

Body string

Returns

string

GetListIndex(string, string)

returns a 1-based index into the comma delimited ListOfItems where Item is found.

public abstract int GetListIndex(string itemToFind, string commaDelimitedListOfItems)

Parameters

itemToFind string
commaDelimitedListOfItems string

Returns

int

GetPleaseWaitEnd()

Deprecated

[Obsolete("Deprecated", false)]
public abstract string GetPleaseWaitEnd()

Returns

string

GetPleaseWaitStart()

Deprecated

[Obsolete("Deprecated", false)]
public abstract string GetPleaseWaitStart()

Returns

string

GetProcessID()

Deprecated

[Obsolete("Use Process.GetCurrentProcess().Id", false)]
public abstract int GetProcessID()

Returns

int

GetRandomDouble()

Return a random double between 0.0 and 1.0

public abstract double GetRandomDouble()

Returns

double

GetRandomInteger()

Return a random integer

public abstract int GetRandomInteger()

Returns

int

GetRandomInteger(int)

Return a random integer between 0 and maxValue

public abstract int GetRandomInteger(int maxValue)

Parameters

maxValue int

Returns

int

GetRandomString(int)

generate a random alphanumeric string, upper and lower case text and numerics (0...9, a...z, A...Z, no special characters)

public abstract string GetRandomString(int length)

Parameters

length int

Returns

string

IISReset()

For websites, run an iisreset. Call from a remote method that detects the server restoration and recovers

public abstract void IISReset()

IsInDelimitedString(string, string, string)

return true if the itemToFind is in the delimitedString

public abstract bool IsInDelimitedString(string delimitedString, string itemToFind, string delimiter)

Parameters

delimitedString string
itemToFind string
delimiter string

Returns

bool

ModifyLinkQueryString(string, string, bool)

Update or add a key=value pair within a url like "/path/page?key=value&key=value"

public abstract string ModifyLinkQueryString(string url, string key, bool value)

Parameters

url string
key string
value bool

Returns

string

ModifyLinkQueryString(string, string, bool, bool)

Update or add a key=value pair within a url, like "/path/page?key=value&key=value"

public abstract string ModifyLinkQueryString(string url, string key, bool value, bool addIfMissing)

Parameters

url string
key string
value bool
addIfMissing bool

Returns

string

ModifyLinkQueryString(string, string, DateTime)

Update or add a key=value pair within a url, like "/path/page?key=value&key=value"

public abstract string ModifyLinkQueryString(string url, string key, DateTime value)

Parameters

url string
key string
value DateTime

Returns

string

ModifyLinkQueryString(string, string, DateTime, bool)

Update or add a key=value pair within a url, like "/path/page?key=value&key=value"

public abstract string ModifyLinkQueryString(string url, string key, DateTime value, bool addIfMissing)

Parameters

url string
key string
value DateTime
addIfMissing bool

Returns

string

ModifyLinkQueryString(string, string, double)

Update or add a key=value pair within a url like "/path/page?key=value&key=value"

public abstract string ModifyLinkQueryString(string url, string key, double value)

Parameters

url string
key string
value double

Returns

string

ModifyLinkQueryString(string, string, double, bool)

Update or add a key=value pair within a url like "/path/page?key=value&key=value"

public abstract string ModifyLinkQueryString(string url, string key, double value, bool addIfMissing)

Parameters

url string
key string
value double
addIfMissing bool

Returns

string

ModifyLinkQueryString(string, string, int)

Update or add a key=value pair within a url like "/path/page?key=value&key=value"

public abstract string ModifyLinkQueryString(string url, string key, int value)

Parameters

url string
key string
value int

Returns

string

ModifyLinkQueryString(string, string, int, bool)

Update or add a key=value pair within a url like "/path/page?key=value&key=value"

public abstract string ModifyLinkQueryString(string url, string key, int value, bool addIfMissing)

Parameters

url string
key string
value int
addIfMissing bool

Returns

string

ModifyLinkQueryString(string, string, string)

Update or add a key=value pair within a url like "/path/page?key=value&key=value"

public abstract string ModifyLinkQueryString(string url, string key, string value)

Parameters

url string
key string
value string

Returns

string

ModifyLinkQueryString(string, string, string, bool)

Update or add a key=value pair within a url like "/path/page?key=value&key=value"

public abstract string ModifyLinkQueryString(string url, string key, string value, bool addIfMissing)

Parameters

url string
key string
value string
addIfMissing bool

Returns

string

ModifyQueryString(string, string, bool)

Update or add a key=value pair within key value pair string like "key=value&key=value"

public abstract string ModifyQueryString(string sourceQueryString, string key, bool value)

Parameters

sourceQueryString string
key string
value bool

Returns

string

ModifyQueryString(string, string, bool, bool)

Update or add a key=value pair within key value pair string like "key=value&key=value"

public abstract string ModifyQueryString(string sourceQueryString, string key, bool value, bool addIfMissing)

Parameters

sourceQueryString string
key string
value bool
addIfMissing bool

Returns

string

ModifyQueryString(string, string, DateTime)

Update or add a key=value pair within key value pair string like "key=value&key=value"

public abstract string ModifyQueryString(string sourceQueryString, string key, DateTime value)

Parameters

sourceQueryString string
key string
value DateTime

Returns

string

ModifyQueryString(string, string, DateTime, bool)

Update or add a key=value pair within key value pair string like "key=value&key=value"

public abstract string ModifyQueryString(string sourceQueryString, string key, DateTime value, bool addIfMissing)

Parameters

sourceQueryString string
key string
value DateTime
addIfMissing bool

Returns

string

ModifyQueryString(string, string, double)

Update or add a key=value pair within key value pair string like "key=value&key=value"

public abstract string ModifyQueryString(string sourceQueryString, string key, double value)

Parameters

sourceQueryString string
key string
value double

Returns

string

ModifyQueryString(string, string, double, bool)

Update or add a key=value pair within key value pair string like "key=value&key=value"

public abstract string ModifyQueryString(string sourceQueryString, string key, double value, bool aAddIfMissing)

Parameters

sourceQueryString string
key string
value double
aAddIfMissing bool

Returns

string

ModifyQueryString(string, string, int)

Update or add a key=value pair within key value pair string like "key=value&key=value"

public abstract string ModifyQueryString(string sourceQueryString, string key, int value)

Parameters

sourceQueryString string
key string
value int

Returns

string

ModifyQueryString(string, string, int, bool)

Update or add a key=value pair within key value pair string like "key=value&key=value"

public abstract string ModifyQueryString(string sourceQueryString, string key, int value, bool addIfMissing)

Parameters

sourceQueryString string
key string
value int
addIfMissing bool

Returns

string

ModifyQueryString(string, string, string)

Update or add a key=value pair within key value pair string like "key=value&key=value"

public abstract string ModifyQueryString(string sourceQueryString, string key, string value)

Parameters

sourceQueryString string
key string
value string

Returns

string

ModifyQueryString(string, string, string, bool)

Update or add a key=value pair within key value pair string like "key=value&key=value"

public abstract string ModifyQueryString(string sourceQueryString, string key, string value, bool addIfMissing)

Parameters

sourceQueryString string
key string
value string
addIfMissing bool

Returns

string

ParseURL(string, ref string, ref string, ref string, ref string, ref string, ref string)

Deprecated

[Obsolete("Use SeparateUrl", false)]
public abstract void ParseURL(string SourceURL, ref string Protocol, ref string Host, ref string Port, ref string Path, ref string Page, ref string QueryString)

Parameters

SourceURL string
Protocol string
Host string
Port string
Path string
Page string
QueryString string

SeparateURL(string, ref string, ref string, ref string, ref string, ref string)

return the components of a url

public abstract void SeparateURL(string sourceUrl, ref string return_protocol, ref string return_domain, ref string return_path, ref string return_page, ref string return_queryString)

Parameters

sourceUrl string
return_protocol string
return_domain string
return_path string
return_page string
return_queryString string

SeparateURL(string, ref string, ref string, ref string, ref string, ref string, ref string)

return the components of a url

public abstract void SeparateURL(string sourceUrl, ref string return_protocol, ref string return_domain, ref string return_port, ref string return_path, ref string return_page, ref string return_queryString)

Parameters

sourceUrl string
return_protocol string
return_domain string
return_port string
return_path string
return_page string
return_queryString string

Sleep(int)

Deprecated

[Obsolete("Use System.Threading.Thread.Sleep()", false)]
public abstract void Sleep(int timeMSec)

Parameters

timeMSec int

SplitDelimited(string, string)

returns the result of a Split, except it honors quoted text, if a quote is found, it is assumed to also be a delimiter ( 'this"that"theother' = 'this "that" theother' )

public abstract object SplitDelimited(string wordList, string delimiter)

Parameters

wordList string
delimiter string

Returns

object

Upgrade(bool)

Deprecated

[Obsolete("Installation upgrade through the cp interface is deprecated. Please use the command line tool.", false)]
public abstract void Upgrade(bool isNewApp)

Parameters

isNewApp bool

Upgrade51ConvertDirectoryInfoArrayToParseString(List<FolderDetail>)

Method used to convert application data from DotNet DirectoryInfo object to internal legacy 4.1 Parse string.

public abstract string Upgrade51ConvertDirectoryInfoArrayToParseString(List<CPFileSystemBaseClass.FolderDetail> DirectoryInfo)

Parameters

DirectoryInfo List<CPFileSystemBaseClass.FolderDetail>

Returns

string

Upgrade51ConvertFileInfoArrayToParseString(List<FileDetail>)

Method used to convert application data from DotNet DirectoryInfo object to internal legacy 4.1 Parse string.

public abstract string Upgrade51ConvertFileInfoArrayToParseString(List<CPFileSystemBaseClass.FileDetail> DirectoryInfo)

Parameters

DirectoryInfo List<CPFileSystemBaseClass.FileDetail>

Returns

string

hashMd5(string)

Deprecated

[Obsolete("Deprecated, some server audits fail if Md5 use detected.")]
public abstract string hashMd5(string source)

Parameters

source string

Returns

string

installCollectionFromFile(string)

Install an addon collection file asynchonously. The task is queued and the taskId is returned. Use cp.tasks.getTaskStatus to determine status

[Obsolete("Deprecated, use CP.Addon.InstallCollectionFile().", false)]
public abstract int installCollectionFromFile(string privateFile)

Parameters

privateFile string

Returns

int

installCollectionFromLibrary(string)

Install an addon collections from the collection library asynchonously. The task is queued and the taskId is returned. Use cp.tasks.getTaskStatus to determine status

[Obsolete("Deprecated, use CP.Addon.InstallCollectionFromLibrary().", false)]
public abstract int installCollectionFromLibrary(string collectionGuid)

Parameters

collectionGuid string

Returns

int

Install an addon collections from an endpoint asynchonously. The task is queued and the taskId is returned. Use cp.tasks.getTaskStatus to determine status

[Obsolete("Deprecated, use CP.Addon.InstallCollectionFromLink().", false)]
public abstract int installCollectionFromLink(string link)

Parameters

link string

Returns

int

installCollectionsFromFolder(string)

Install all addon collections in a folder asynchonously. The task is queued and the taskId is returned. Use cp.tasks.getTaskStatus to determine status

[Obsolete("Deprecated, use CP.Addon.InstallCollectionFile().", false)]
public abstract int installCollectionsFromFolder(string privateFolder)

Parameters

privateFolder string

Returns

int

installCollectionsFromFolder(string, bool)

Install all addon collections in a folder asynchonously. Optionally delete the folder. The task is queued and the taskId is returned. Use cp.tasks.getTaskStatus to determine status

[Obsolete("Deprecated, use CP.Addon.InstallCollectionFile().", false)]
public abstract int installCollectionsFromFolder(string privateFolder, bool deleteFolderWhenDone)

Parameters

privateFolder string
deleteFolderWhenDone bool

Returns

int

isGuid(string)

returns true if the string is a guid (start/end with brace, char count, check dashes

public abstract bool isGuid(string guid)

Parameters

guid string

Returns

bool

versionIsOlder(string, string)

return true the versionStringToTest is older than the versionStringToTestAgainst. For example, to test if the installed version stored in a site property "installedVersion" is older than version 25.1.1.1, versionIsOlder( cp.Site.GetText( "installedVersion" ), "25.1.1.1")

public abstract bool versionIsOlder(string versionStringToTest, string versionStringToTestAgainst)

Parameters

versionStringToTest string
versionStringToTestAgainst string

Returns

bool