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
logTextstring
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
AppendLogFile(string)
Deprecated, use AppendLog
[Obsolete("Deprecated, use AppendLog", false)]
public abstract void AppendLogFile(string Text)
Parameters
Textstring
ConvertHTML2Text(string)
Return a text approximation of html content
public abstract string ConvertHTML2Text(string Source)
Parameters
Sourcestring
Returns
ConvertLinkToShortLink(string, string, string)
Deprecated
[Obsolete("Deprecated", false)]
public abstract string ConvertLinkToShortLink(string URL, string ServerHost, string ServerVirtualPath)
Parameters
Returns
ConvertShortLinkToLink(string, string)
Deprecated
[Obsolete("Deprecated", false)]
public abstract string ConvertShortLinkToLink(string URL, string PathPagePrefix)
Parameters
Returns
ConvertText2HTML(string)
Return an html approximation of text content
public abstract string ConvertText2HTML(string source)
Parameters
sourcestring
Returns
CreateGuid()
Return a new guid in system's format {...}
public abstract string CreateGuid()
Returns
DecodeGMTDate(string)
Deprecated
[Obsolete("Deprecated. Use native methods to convert date formats.", false)]
public abstract DateTime DecodeGMTDate(string GMTDate)
Parameters
GMTDatestring
Returns
DecodeHTML(string)
wrapped dotnet namespace for use in scripting
public abstract string DecodeHTML(string source)
Parameters
sourcestring
Returns
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
sourcestring
Returns
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
sourcestring
Returns
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
Urlstring
Returns
EncodeAppRootPath(string)
convert a file link (like /ccLibraryFiles/imageFilename/000001/this.png) to a full URL
public abstract string EncodeAppRootPath(string link)
Parameters
linkstring
Returns
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
expressionobject
Returns
EncodeContentForWeb(string)
public abstract string EncodeContentForWeb(string source)
Parameters
sourcestring
Returns
EncodeContentForWeb(string, string)
public abstract string EncodeContentForWeb(string source, string contextContentName)
Parameters
Returns
EncodeContentForWeb(string, string, int)
public abstract string EncodeContentForWeb(string source, string contextContentName, int contextRecordID)
Parameters
Returns
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
Returns
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
expressionobject
Returns
EncodeHTML(string)
wrapped dotnet namespace for use in scripting
public abstract string EncodeHTML(string source)
Parameters
sourcestring
Returns
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
sourcestring
Returns
EncodeInteger(object)
Convert to integer. If no valid rendition exists, returns 0.
public abstract int EncodeInteger(object expression)
Parameters
expressionobject
Returns
EncodeJavascript(string)
Deprecated
[Obsolete("Use System.Web.HttpUtility.JavaScriptStringEncode()", false)]
public abstract string EncodeJavascript(string source)
Parameters
sourcestring
Returns
EncodeNumber(object)
Convert to double. If no valid rendition exists, returns 0.
public abstract double EncodeNumber(object expression)
Parameters
expressionobject
Returns
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
Sourcestring
Returns
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
Sourcestring
Returns
EncodeText(object)
return an input argument as string, or empty string if it can not be converted.
public abstract string EncodeText(object expression)
Parameters
expressionobject
Returns
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
expressionobject
Returns
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
sourcestring
Returns
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
sourcestring
Returns
ExecuteAddon(string)
Deprecated. use cp.addon.execute()
[Obsolete("Deprecated. use cp.addon.execute()", false)]
public abstract string ExecuteAddon(string idGuidOrName)
Parameters
idGuidOrNamestring
Returns
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
IdGuidOrNamestringcontextCPUtilsBaseClass.addonContext
Returns
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
Returns
ExecuteAddonAsProcess(string)
Deprecated. use cp.addon.executeAsProcess()
[Obsolete("Deprecated. use cp.addon.executeAsProcess()", false)]
public abstract string ExecuteAddonAsProcess(string IdGuidOrName)
Parameters
IdGuidOrNamestring
Returns
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
SQLstringThe query to run, selecting the data to be exported.
exportNamestringThe name of the export data, used in the downloads table
filenamestringThe 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
Returns
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
Returns
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
Returns
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
UserIdint
Returns
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
Returns
GetDateTimeMockable()
Returns current DateTime.Now if cp.Mock.DateTime is not set, else returns Mock.DateTime
public abstract DateTime GetDateTimeMockable()
Returns
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
pathFilenamestring
Returns
GetFirstNonZeroDate(DateTime, DateTime)
Deprecated
[Obsolete("Deprecated", false)]
public abstract DateTime GetFirstNonZeroDate(DateTime Date0, DateTime Date1)
Parameters
Returns
GetFirstNonZeroInteger(int, int)
Deprecated
[Obsolete("Deprecated", false)]
public abstract int GetFirstNonZeroInteger(int Integer0, int Integer1)
Parameters
Returns
GetIntegerString(int, int)
Deprecated
[Obsolete("Use string.PadRight() and string.PadLeft()", false)]
public abstract string GetIntegerString(int Value, int DigitCount)
Parameters
Returns
GetLine(string)
Deprecated
[Obsolete("Use new StringReader(str).ReadLine()", false)]
public abstract string GetLine(string Body)
Parameters
Bodystring
Returns
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
Returns
GetPleaseWaitEnd()
Deprecated
[Obsolete("Deprecated", false)]
public abstract string GetPleaseWaitEnd()
Returns
GetPleaseWaitStart()
Deprecated
[Obsolete("Deprecated", false)]
public abstract string GetPleaseWaitStart()
Returns
GetProcessID()
Deprecated
[Obsolete("Use Process.GetCurrentProcess().Id", false)]
public abstract int GetProcessID()
Returns
GetRandomDouble()
Return a random double between 0.0 and 1.0
public abstract double GetRandomDouble()
Returns
GetRandomInteger()
Return a random integer
public abstract int GetRandomInteger()
Returns
GetRandomInteger(int)
Return a random integer between 0 and maxValue
public abstract int GetRandomInteger(int maxValue)
Parameters
maxValueint
Returns
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
lengthint
Returns
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
Returns
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
Returns
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
Returns
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
Returns
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
Returns
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
Returns
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
Returns
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
Returns
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
Returns
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
Returns
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
Returns
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
Returns
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
Returns
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
Returns
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
Returns
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
Returns
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
Returns
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
Returns
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
Returns
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
Returns
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
Returns
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
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
sourceUrlstringreturn_protocolstringreturn_domainstringreturn_pathstringreturn_pagestringreturn_queryStringstring
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
sourceUrlstringreturn_protocolstringreturn_domainstringreturn_portstringreturn_pathstringreturn_pagestringreturn_queryStringstring
Sleep(int)
Deprecated
[Obsolete("Use System.Threading.Thread.Sleep()", false)]
public abstract void Sleep(int timeMSec)
Parameters
timeMSecint
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
Returns
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
isNewAppbool
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
DirectoryInfoList<CPFileSystemBaseClass.FolderDetail>
Returns
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
DirectoryInfoList<CPFileSystemBaseClass.FileDetail>
Returns
hashMd5(string)
Deprecated
[Obsolete("Deprecated, some server audits fail if Md5 use detected.")]
public abstract string hashMd5(string source)
Parameters
sourcestring
Returns
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
privateFilestring
Returns
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
collectionGuidstring
Returns
installCollectionFromLink(string)
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
linkstring
Returns
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
privateFolderstring
Returns
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
Returns
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
guidstring
Returns
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)