Common Library¶
DirectoryServices¶
Methods¶
GetAllUsers(string)¶
Description
Get all domain users
Return Type : Collection
Static : Yes
Namespace : CommonLib.DirectoryServices
Parameters
Name | Data Type | Description |
---|---|---|
domain | string | Domain name |
GetAllUsers(string, string)¶
Description
Get all domain users that belong to a specific group
Return Type : Collection
Static : Yes
Namespace : CommonLib.DirectoryServices
Parameters
Name | Data Type | Description |
---|---|---|
domain | string | Domain name |
group | string | Group name |
Syntax
Collection[string] users = CommonLib.DirectoryServices.GetAllUsers("DEV-GR", "Domain Users");
GetCurrentUserProperty(string, string)¶
Description
Returns the value of a property from the current user
Return Type : string
Static : Yes
Namespace : CommonLib.DirectoryServices
Parameters
Name | Data Type | Description |
---|---|---|
domain | string | Domain name |
property | string | Property name |
GetUserProperty(string, string, string)¶
Description
Returns the value of a property from a username
Return Type : string
Static : Yes
Namespace : CommonLib.DirectoryServices
Parameters
Name | Data Type | Description |
---|---|---|
username | string | User to get property from |
domain | string | Domain name |
property | string | Property name |
GetUserProperties(string, string)¶
Description
Returns the properties and their values that belong to an Active Directory User
Return Type : Dictionary
Static : Yes
Namespace : CommonLib.DirectoryServices
Parameters
Name | Data Type | Description |
---|---|---|
username | string | User to get the properties from |
domain | string | Domain name |
Syntax
string domainName = "DEV-GR";
string userName = "AlphaGoldUser3";
Dictionary[string, Object] userProperties = CommonLib.DirectoryServices.GetUserProperties( userName, domainName );
foreach(string key in userProperties.GetKeys()){
DebugLib.Logger.WriteInfoLine("["+key+"] = ["+userProperties.Get(key)+"]");
}
GetUserProperties(string, string, Collection[string])¶
Description
Returns the, specified by the [keys] list representing their names, properties and their values that belong to an Active Directory User. If the keys collection is null or empty, all properties will be retrieved
Return Type : Dictionary
Static : Yes
Namespace : CommonLib.DirectoryServices
Parameters
Name | Data Type | Description |
---|---|---|
username | string | User to get the properties from |
domain | string | Domain name |
keys | Collection | A list of the property names to be retrieved. If empty or null, all properties will be fetched |
Syntax
string domainName = "DEV-GR";
string userName = "AlphaGoldUser3";
Collection[string] specificProperties = {"Description", "displayName", "sAMAccountName", "mail"};
Dictionary[string, Object] userProperties = CommonLib.DirectoryServices.GetUserProperties( userName, domainName, specificProperties );
foreach(string key in userProperties.GetKeys()){
DebugLib.Logger.WriteInfoLine("["+key+"] = ["+userProperties.Get(key)+"]");
}
GetCurrentUserGroups(string)¶
Description
Get current user groups
Return Type : Collection
Static : Yes
Namespace : CommonLib.DirectoryServices
Parameters
Name | Data Type | Description |
---|---|---|
domain | string | Domain name |
GetUserGroups(string, string)¶
Description
Get a user's groups
Return Type : Collection
Static : Yes
Namespace : CommonLib.DirectoryServices
Parameters
Name | Data Type | Description |
---|---|---|
username | string | User to get groups from |
domain | string | Domain name |
GetPasswordExpirationDate(string, string)¶
Description
Gets the user's Password Expiration Date
Return Type : DateTime
Static : Yes
Namespace : CommonLib.DirectoryServices
Parameters
Name | Data Type | Description |
---|---|---|
username | string | User to get groups from |
domain | string | Domain name |
Syntax
DateTime passwordExpirationDate = CommonLib.DirectoryServices.GetPasswordExpirationDate(Model.Username, Model.DomainName);
if(passwordExpirationDate != null){
ShowMessage(passwordExpirationDate);
}
ChangePassword(string, string, string, string)¶
Description
Changes the user's password
Return Type : bool
Static : Yes
Namespace : CommonLib.DirectoryServices
Parameters
Name | Data Type | Description |
---|---|---|
username | string | User to get groups from |
domain | string | Domain name |
oldPassword | string | The old (current) password of the User |
newPassword | string | New password to be set to the user's account |
Syntax
try
{
bool ok = CommonLib.DirectoryServices.ChangePassword("Administrator", "MyDomain", "oldPassword123!", "newPassword123!");
if(ok){
ShowMessage("Your password has been successfully changed!", AppLib.MessageType.Success);
}
else
{
ShowMessage("An error occurred while changing your password. Please, contact your Administrator", AppLib.MessageType.Warning);
}
}
catch Exception x
{
ShowMessage("Exception caught while changing your password: " + x.Message, AppLib.MessageType.Error);
}
Utilities¶
Description¶
Provides most commonly and widely used functionality for anything that is not included in all other namespaces and classes.
Methods¶
ValidateXmlAgainstXsd(string, string)¶
Description
Validates XML content against an XSD file and returns all errors, if any
Return Type : Collection
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
xmlContent | string | The xml content to be validated |
xsdPath | string | Path to the XSD file |
Syntax
Collection[string] xmlErrors = CommonLib.Utilities.ValidateXmlAgainstXsd(myXmlContent, xsdFilePath);
RunExecutable(string)¶
Description
Run an executable program.
Return Type : string
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
path | string | Path to executable program. |
Syntax
CommonLib.Utilities.RunExecutable("~/App_Data/Uploads/RestartBillingServer.exe");
RunExecutable(string, string)¶
Description
Run an executable program with specific arguments.
Return Type : string
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
path | string | Path to executable program. |
arguments | string | Any number of arguments, required to run the executable |
Syntax
CommonLib.Utilities.RunExecutable("~/App_Data/Uploads/RestartBillingServer.exe", 1, "Administrator");
GetNextExecutionTime(string, DateTime)¶
Description
Calculate next execution time of a scheduled job defined by a specific cron expression.
Return Type : DateTime
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
cronExpression | string | Cron expression |
lastExecution | DateTime | Last time this job was executed |
Syntax
CommonLib.Utilities.GetNextExecutionTime("* * * * *", DateTime.Now());
ExportFormToPdf(string, bool)¶
Description
Export current form to PDF Document with the provided filename.
Return Type : void
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
filename | string | Name of the pdf document |
usePrintMedia | bool | Use provided print media style |
Syntax
CommonLib.Utilities.ExportFormToPdf("file.pdf", true);
ExportFormToPdf(string)¶
Description
Export current form to PDF Document with the provided filename.
Return Type : void
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
filename | string | Name of the pdf document |
Syntax
CommonLib.Utilities.ExportFormToPdf("file.pdf");
ExportControlToPdf(string, string)¶
Description
Export a selected by name control to PDF Document with the provided filename.
Return Type : void
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
filename | string | Name of the pdf document |
controlName | string | Name of the selected control |
Syntax
CommonLib.Utilities.ExportControlToPdf("file.pdf", "Panel1");
ExportControlToPdf(string, string, bool)¶
Description
Export a selected by name control to PDF Document with the provided filename.
Return Type : void
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
filename | string | Name of the pdf document |
controlName | string | Name of the selected control |
usePrintMedia | bool | Use provided print media style |
Syntax
CommonLib.Utilities.ExportControlToPdf("file.pdf", "Panel1", true);
GetCrontabDescription(string)¶
Description
Get a description of a crontab.
Return Type : string
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
cronExpression | string | A crontab expression |
Syntax
string desc = CommonLib.Utilities.GetCrontabDescription("30 18 * * *");
IsCronExpressionValid(string)¶
Description
Validates a crontab expression.
Return Type : bool
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
cronExpression | string | A crontab expression |
Syntax
bool desc = CommonLib.Utilities.IsCronExpressionValid("30 18 * * *");
GetCrontabNextExecutionTime(string, DateTime)¶
Description
Get the next occurence of a crontab.
Return Type : DateTime
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
cronExpression | string | A crontab expression |
baseTime | DateTime | The base datetime to calculate the next occurence |
Syntax
DateTIme nextOccurance = CommonLib.Utilities.GetCrontabNextExecutionTime("30 18 * * *");
Sleep(int)¶
Description
Current thread waits for a specific amount of time.
Return Type : void
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
milliseconds | int | How many milliseconds is going to wait for |
Syntax
CommonLib.Utilities.Sleep(5); //Will wait for 5 msec
DownloadData(string)¶
Description
Download contents from a URL.
Return Type : Array
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
url | string | URL address of the downloaded data |
Syntax
Array[byte] downloadedData = CommonLib.Utilities.DownloadData("https://jsonplaceholder.typicode.com/posts/1");
GetDataPath(string)¶
Description
Get absolute path to a folder/file relative to data storage folder of the application
Return Type : string
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
relativePath | string | Relative path to the data storage folder |
Syntax
string dataPath = CommonLib.Utilities.GetDataPath("file.xml");
GetUploadsPath(string)¶
Description
Get absolute path to a folder/file relative to upload folder of the application
Return Type : string
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
relativePath | string | Relative path to the data storage folder |
Syntax
string uploadPath = CommonLib.Utilities.GetUploadsPath("pic");
GetServerPhysicalPath(string)¶
Description
Get absolute path to a folder/file relative to root folder of the application
Return Type : string
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
relativePath | string | Relative path to the data storage folder |
Syntax
string applicationPath = CommonLib.Utilities.GetServerPhysicalPath("pic");
CreateThumbnail(Collection[byte], int, int)¶
Description
Creates a thumbnail for an image.
Return Type : Collection
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
bytes | Collection | Image content |
width | int | Thumbnail Width |
height | int | Thumbnail Height |
Syntax
var thumb = CommonLib.Utilities.CreateThumbnail(Model.Customer.Avatar, 100, 100)
ResolveClientURL(string)¶
Description
Get url for a file saved at application filesystem.
Return Type : string
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
relativePath | string | Relative path to the data storage folder |
Syntax
var clientUrl = CommonLib.Utilities.ResolveClientURL("reports")
GetAttatchmentLink(string)¶
Description
Get url for an attachment saved at application filesystem.
Return Type : string
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
filename | string | Relative path to the data storage folder |
Syntax
string attachmentLink = CommonLib.Utilities.GetAttatchmentLink("reports/report.pdf");
GetAttatchmentPath(string)¶
Description
Get absolute path for an attachment saved at application filesystem.
Return Type : string
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
filename | string | Relative path to the data storage folder |
Syntax
string attachmentPath = CommonLib.Utilities.GetAttatchmentPath("reports");
VirtualPathToAbsolute(string)¶
Description
Get absolute path of an application virtual path.
Return Type : string
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
virtualPath | string | Your application's virtual path |
Syntax
string virtualPath = CommonLib.Utilities.VirtualPathToAbsolute("~/Uploads/reports");
ToDateTime(string)¶
Description
This operation converts a string into a DateTime.
Return Type : DateTime
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
text | string | Plain text, representing a date and/or time |
Syntax
DateTime myDate = CommonLib.Utilities.ToDateTime("2018-01-01");
ToLong(double)¶
Description
This operation converts a double number into a long, and rounds it if necessary.
Return Type : long
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
aDouble | double | The double number to be converted into a long |
Syntax
long x = CommonLib.Utilities.ToLong(2.3);
ToInt(string)¶
Description
This operation converts a text into an integer number.
Return Type : int
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
text | string | The double number to be converted into an integer |
Syntax
int x = CommonLib.Utilities.ToInt("1");
ToDecimal(string)¶
Description
This operation converts a text into an decimal number.
Return Type : decimal
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
text | string | The text represents the number you want to convert |
Syntax
decimal x = CommonLib.Utilities.ToDecimal("1.3");
ToGuid(string)¶
Description
This operation converts a text into a guid.
Return Type : Guid
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
text | string | The text you want to convert to a GUID |
Syntax
Guid g = CommonLib.Utilities.ToGuid("efcad23d-ed7b-44ef-a789-6dc0b72fe7b1")
ToDecimal(string, string)¶
Description
This operation converts a text into a decimal number, considering the separator.
Return Type : decimal
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
text | string | The text represents the number you want to convert |
separator | string | The separator of the decimal number |
Syntax
decimal x = CommonLib.Utilities.ToDecimal("2.3", ".");
ToDateTime(string, bool)¶
Description
This operation converts a text into a DateTime, with the option to not throw exception if the convertion is impossible.
Return Type : DateTime
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
text | string | The text represents a DateTime |
throwException | bool | The flag for throwing an exception or not |
Syntax
DateTime myDate = CommonLib.Utilities.ToDateTime("2018-01-01",false);
ToInt(string, bool)¶
Description
This operation converts a text into an integer number, with the option to not throw exception if the convertion is impossible.
Return Type : int
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
text | string | The text represents an integer number |
throwException | bool | The flag for throwing an exception or not |
Syntax
int x = CommonLib.Utilities.ToInt("1",false);
ToDecimal(string, bool)¶
Description
This operation converts a text into a decimal number, with the option to not throw exception if the convertion is impossible.
Return Type : decimal
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
text | string | The text represents an integer number |
throwException | bool | The flag for throwing an exception or not |
Syntax
decimal x = CommonLib.Utilities.ToDecimal("1.2",false);
ToGuid(string, bool)¶
Description
This operation converts a text into a guid, with the option to not throw exception if the convertion is impossible.
Return Type : Guid
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
text | string | The text you want to convert |
throwException | bool | The flag for throwing an exception or not |
Syntax
Guid g = CommonLib.Utilities.ToGuid("efcad23d-ed7b-44ef-a789-6dc0b72fe7b1",false);
EncodeUrl(string)¶
Description
Encodes a string to a URL encoded format.
Return Type : string
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
text | string | An arbitrary text |
Syntax
string encodedFormat = CommonLib.Utilities.EncodeUrl("https://github.com/trending");
DownloadFile(string, string)¶
Description
Downloads a file from a URL and saves it to FilePath
Return Type : void
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
url | string | A URL to the file |
filePath | string | A path to save the file |
Syntax
CommonLib.Utilities.DownloadFile("https://github.com/trending", CommonLib.Utilities.GetUploadsPath("data"));
SendEmail(CommonLib.EmailMessage)¶
Description
This operations sends an EmailMessage object.
Return Type : void
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
message | CommonLib.EmailMessage | The instance of the EmailMessage |
Syntax
CommonLib.Utilities.SendEmail(EmailInstance);
SendEmailAsync(CommonLib.EmailMessage)¶
Description
This operations sends an EmailMessage object asynchronously.
Return Type : void
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
message | CommonLib.EmailMessage | The instance of the EmailMessage |
Syntax
CommonLib.Utilities.SendEmailAsync(EmailInstance);
SendEmail(string, string, string)¶
Description
This operations takes as inputs the subject, and the body and it sends an email to the recipient.
Return Type : void
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
subject | string | The subject of the Email |
body | string | The body of the Email |
to | string | The recipient of the Email |
Syntax
CommonLib.Utilities.SendEmail("your-subject","the-body-of-the-email","example@mail.com");
SendEmail(string, string, string, string)¶
Description
This operations takes as inputs the subject, and the body and it sends an email to the recipient, it sends also a Carbon Copy to the specified mails.
Return Type : void
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
subject | string | The subject of the Email |
body | string | The body of the Email |
to | string | The recipient of the Email |
cc | string | The recipients of the Carbon Copy |
Syntax
CommonLib.Utilities.SendEmail("your-subject","the-body-of-the-email","example@mail.com","example2@mail.com");
SendEmail(string, string, string, string, string, string)¶
Description
This operations takes as inputs the subject, and the body and it sends an email to the recipient as well as the Carbon Copy and Blind Carbon Copy accounts.
Return Type : void
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
subject | string | The subject of the Email |
body | string | The body of the Email |
to | string | The recipient of the Email |
cc | string | The recipients of the Carbon Copy |
bcc | string | The recipients of the Blind Carbon Copy |
fromAddress | string | E-Mail address of the Sender. |
Syntax
string subject = "Order Receipt";
string body = "Greetings! I will send you your Receipt as soon as possible. Best regards, Dwight.";
string to = "michael@dundermifflin.com";
string cc = "angela@dundermifflin.com";
string bcc = "toby@dundermifflin.com"
string fromAddress = "dwight@dundermifflin.com"
CommonLib.Utilities.SendEmail(subject, body, to, cc, css, fromAddress);
Base64Encode(string)¶
Description
Converts a string to its equivalent string representation that is encoded with base-64 digits.
Return Type : string
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
plainText | string | The string to convert |
Syntax
var encodedToBase64Data = CommonLib.Utilities.Base64Encode("Test");
Base64Decode(string)¶
Description
Converts the specified string, which encodes binary data as base-64 digits, to an equivalent 8-bit unsigned
Return Type : string
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
base64EncodedData | string | The string to convert |
Syntax
var decodedString = CommonLib.Utilities.Base64Decode(encodedToBase64Data);
Base64Encode(Collection[byte])¶
Description
Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with base-64 digits.
Return Type : string
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
data | Collection | An array of 8-bit unsigned integers |
Syntax
Array[byte] encodedDataInputArray = CommonLib.Utilities.UTF8ToByteArray("Test");
var encodedToBase64Data = CommonLib.Utilities.Base64Encode(encodedDataInputArray.ToCollection());
Base64DecodeAsByteArray(string)¶
Description
Converts a string encoded with base-64 digits to an equivalent subset of a an 8-bit unsigned integer array.
Return Type : Collection
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
encodedData | string | An array of 8-bit unsigned integers |
Syntax
var base64DecodeAsByteArrayOutput = CommonLib.Utilities.Base64DecodeAsByteArray(encodedToBase64Data);
GetMD5Hash(string)¶
Description
Computes the hash value for the specified string.
Return Type : string
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
input | string | The input to compute the hash code for |
Syntax
string md5text = CommonLib.Utilities.GetMD5Hash("example text");
IsPropertyDirty(Object, string)¶
Description
Check if a property of an object is changed.
Return Type : bool
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
instance | Object | Instance of an object |
propertyName | string | Name of the property |
Syntax
var user = Domain.ApplicationUser.GetAll().First();
var isDirty = CommonLib.Utilities.IsPropertyDirty(user, "Name");
UTF8ToByteArray(string)¶
Description
Encodes all the characters in the specified string into a sequence of bytes.
Return Type : Array
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
data | string | The string to encode |
Syntax
var uTF8ToByteArrayOutput = CommonLib.Utilities.UTF8ToByteArray("example");
ByteArrayToUTF8(Array[byte])¶
Description
Decodes all the bytes in the specified byte array into a string.
Return Type : string
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
data | Array | The byte array containing the sequence of bytes to decode |
Syntax
var utf8ToByteArrayOutput = CommonLib.Utilities.UTF8ToByteArray("example");
var byteArrayToUTF8Output = CommonLib.Utilities.ByteArrayToUTF8(utf8ToByteArrayOutput);
StringToByteArray(string, string)¶
Description
Encodes all the characters in the specified string into a sequence of bytes.
Return Type : Array
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
data | string | The string to encode |
encoding | string | Specific encoding |
Syntax
var stringToByteArrayOutput = CommonLib.Utilities.StringToByteArray("example", "utf-8");
ByteArrayToString(Array[byte], string)¶
Description
Decodes a sequence of bytes in the specified string.
Return Type : string
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
data | Array | The byte array containing the sequence of bytes to encode |
encoding | string | Specific encoding |
Syntax
var stringToByteArrayOutput = CommonLib.Utilities.StringToByteArray("example", "utf-8");
var output = CommonLib.Utilities.ByteArrayToString(stringToByteArrayOutput, "utf-8");
UnicodeToByteArray(string)¶
Description
Encodes all the characters in the specified string into a sequence of bytes.
Return Type : Array
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
data | string | The string to encode |
Syntax
var unicodeToByteArrayOutput = CommonLib.Utilities.UnicodeToByteArray("example");
ByteArrayToUnicode(Array[byte])¶
Description
Decodes all the bytes in the specified byte array into a string.
Return Type : string
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
data | Array | The byte array containing the sequence of bytes to decode |
Syntax
var unicodeToByteArrayOutput = CommonLib.Utilities.UnicodeToByteArray("example")
var byteArrayToUnicodeOutput = CommonLib.Utilities.ByteArrayToUnicode(uTF8ToByteArrayOutput);
GetExcelFormat(Collection[string], Collection[Collection[Object]])¶
Description
Generate an EXCEL file with the provided data and then return it as a string.
Return Type : string
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
columnNames | Collection | Name of each column of the EXCEL document |
values | Collection | Values of the document as a 2D Array of objects |
Syntax
Collection[Collection[Object]] values;
Collection[string] cols;
for int j = 0; j < 4; j + 1 {
cols.Add("Name " + j);
}
for int i = 0; i < 10; i + 1 {
Collection[Object] row;
row.Add(DateTime.Now());
row.Add(decimal.GetRandom(-1, 1));
row.Add(decimal.GetRandom(-1000, 1000));
row.Add("test test");
values.Add(row);
}
string excelFormat = CommonLib.Utilities.GetExcelFormat(cols, values);
ExportExcelFile(CommonLib.ExcelExportConfiguration)¶
Description
Create an Excel file from the specific options.
Return Type : void
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
options | CommonLib.ExcelExportConfiguration | Options for generation of an EXCEL file |
Syntax
CommonLib.ExcelExportConfiguration options;
options.Author = "zAppDev";
options.Title = "Test excel";
options.NumberFormat = "0.##";
options.DateFormat = "yyyy-MM-ddTHH:mm:ssZ";
options.Path = CommonLib.Utilities.GetDataPath("Test.xlsx");
Collection[Collection[Object]] values;
Collection[Object] cols;
for int j = 0; j < 4; j + 1 {
cols.Add("Name " + j);
}
for int i = 0; i < 10; i + 1 {
Collection[Object] row;
row.Add(DateTime.Now());
row.Add(decimal.GetRandom(-1, 1));
row.Add(decimal.GetRandom(-1000, 1000));
row.Add("test test");
values.Add(row);
}
options.Columns = cols;
options.Values = values;
CommonLib.Utilities.ExportExcelFile(options);
GetExcelFileSheetNames(string)¶
Description
Gets the names of the sheets contained in an Excel file
Return Type : Collection
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
filePath | string | File path to the Excel file |
Syntax
string excelFilePath; //This is the filepath to the local Excel file
Collection[string] sheetNames = CommonLib.Utilities.GetExcelFileSheetNames(excelFilePath);
GetExcelTableContents(string, string, bool)¶
Description
Gets the table contents of the specified sheet name in the specified Excel file
Return Type : Collection
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
filePath | string | File path to the Excel file |
sheetname | string | Sheet name inside the Excel file |
hasHeaderRow | bool | Use first row for column names |
Syntax
string excelFilePath; //This is the filepath to the local Excel file
string sheetName; //This should contain the sheet name to get the contents from
//The last parameter dictates whether to use the first row for column names. If no column names are present genereic names like Column1, Column2 etc are used
Collection[Dictionary[string, string]] sheetNames = CommonLib.Utilities.GetExcelTableContents(excelFilePath, sheetName, true);
CreateTimeSpan(int, int, int, int, int)¶
Description
This operation initialize a new TimeSpan instance based on the parameters.
Return Type : TimeSpan
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
days | int | The days of the timespan |
hours | int | The hours of the timespan |
minutes | int | The minutes of the timespan |
seconds | int | The seconds of the timespan |
milliseconds | int | The milliseconds of the timespan |
Syntax
TimeSpan myTimeSpan = CommonLib.Utilities.CreateTimeSpan(0,0,1,1,100);
CreateTimeSpan(int, int, int, int)¶
Description
This operation initialize a new TimeSpan instance based on the parameters.
Return Type : TimeSpan
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
days | int | The days of the timespan |
hours | int | The hours of the timespan |
minutes | int | The minutes of the timespan |
seconds | int | The seconds of the timespan |
Syntax
TimeSpan myTimeSpan = CommonLib.Utilities.CreateTimeSpan(0,0,1,1);
CreateTimeSpan(int, int, int)¶
Description
This operation initialize a new TimeSpan instance based on the parameters.
Return Type : TimeSpan
Static : Yes
Namespace : CommonLib.Utilities
Parameters
Name | Data Type | Description |
---|---|---|
hours | int | The days of the timespan |
minutes | int | The hours of the timespan |
seconds | int | The minutes of the timespan |
Syntax
TimeSpan myTimeSpan = CommonLib.Utilities.CreateTimeSpan(0,0,1);
Stopwatch¶
Description¶
A class providing functionality and attributes to accuarely measure elapsed time
Methods¶
Start()¶
Description
Begins or continues (after a pause) measuring elapsed time
Return Type : void
Static : No
Namespace : CommonLib.Stopwatch
Syntax
CommonLib.Stopwatch stopwatch;
stopwatch.Start();
Stop()¶
Description
Aborts the time measuring.
Return Type : void
Static : No
Namespace : CommonLib.Stopwatch
Syntax
CommonLib.Stopwatch stopwatch;
stopwatch.Start();
//your code here
stopwatch.Stop();
Reset()¶
Description
Resets the elapsed time to zero. If stopwatch was already running, it will be stopped
Return Type : void
Static : No
Namespace : CommonLib.Stopwatch
Syntax
CommonLib.Stopwatch stopwatch;
stopwatch.Start();
//your code here
stopwatch.Stop();
stopwatch.Reset();
Restart()¶
Description
Stops the time measurement and starts measuring the time from the beginning (zero)
Return Type : void
Static : No
Namespace : CommonLib.Stopwatch
Syntax
CommonLib.Stopwatch stopwatch;
stopwatch.Start();
//your code here
stopwatch.Restart();
GetElapsed()¶
Description
Gets the total time interval measured by the current stopwatch
Return Type : TimeSpan
Static : No
Namespace : CommonLib.Stopwatch
Syntax
CommonLib.Stopwatch stopwatch;
stopwatch.Start();
//your code here
stopwatch.Stop();
Timespan myTimespan = stopwatch.GetElapsed();
GetElapsedMilliseconds()¶
Description
Gets the total time interval, in milliseconds, measured by the current stopwatch.
Return Type : long
Static : No
Namespace : CommonLib.Stopwatch
Syntax
CommonLib.Stopwatch stopwatch;
stopwatch.Start();
//your code here
stopwatch.Stop();
long elapseTimeInMilliseconds = stopwatch.GetElapsedMilliseconds();
EmailMessage¶
Description¶
Properties of an E-Mail Message
Properties¶
Name | Data Type | Static | Readonly | Description |
---|---|---|---|---|
Id | int | No | No | E-Mail Identifier |
From | string | No | No | E-Mail Account of the E-Mail Sender |
IsBodyHtml | bool | No | No | Defines/determines whether the E-Mail Message will be represented in an HTML format. False denotes a 'plain text' format |
Subject | string | No | No | E-Mail Subject or Title |
Body | string | No | No | The main content of the E-Mail |
To | Collection | No | No | Collection of recipient e-mail accounts |
CC | Collection | No | No | Collection of recipient Carbon Copy e-mail accounts |
BCC | Collection | No | No | Collection of recipient Blind Carbon Copy e-mail accounts |
Attachments | Collection | No | No | Collection of attached files |
Methods¶
GetCount()¶
Description
Returns the number of the unread e-mails in the Inbox
Return Type : int
Static : Yes
Namespace : CommonLib.EmailMessage
Syntax
var unreadMessages = CommonLib.EmailMessage.GetCount();
ShowMessage("You have " + unreadMessages + " unread messages in your Inbox!");
HasUnreadEmails()¶
Description
Returns true, if there are unread e-mails in the Inbox. False, otherwise
Return Type : bool
Static : Yes
Namespace : CommonLib.EmailMessage
Syntax
if(CommonLib.EmailMessage.HasUnreadEmails()){
DebugLib.Logger.WriteInfoLine("There are unread messages in your Inbox.");
}
Get(int, bool)¶
Description
Retrieves an e-mail, by ID, from the Inbox and leaves it in an 'unread' state
Return Type : CommonLib.EmailMessage
Static : Yes
Namespace : CommonLib.EmailMessage
Parameters
Name | Data Type | Description |
---|---|---|
id | int | The ID of the e-mail message to read (see CommonLib.EmailMessage.GetIDs()) |
readAll | bool | If true, all the contents of the e-mail will be returned (body, attachments, recipients etc.). If false, only the [From] and [Subject] properties will be set. |
Syntax
Collection[int] messageIDs = CommonLib.EmailMessage.GetIDs();
CommonLib.EmailMessage firstMessage = CommonLib.EmailMessage.Get(messageIDs.Get(0), false);
if(firstMessage.Subject.Contains("zAppDev")){
firstMessage = CommonLib.EmailMessage.Get(messageIDs.Get(0), true);
DebugLib.Logger.WriteInfoLine(firstMessage.Body);
}
Get(int, bool, bool)¶
Description
Retrieves an e-mail, by ID, from the Inbox and marks it as 'read' if required.
Return Type : CommonLib.EmailMessage
Static : Yes
Namespace : CommonLib.EmailMessage
Parameters
Name | Data Type | Description |
---|---|---|
id | int | The ID of the e-mail message to read (see CommonLib.EmailMessage.GetIDs()) |
readAll | bool | If true, all the contents of the e-mail will be returned (body, attachments, recipients etc.). If false, only the [From] and [Subject] properties will be set. |
markAsRead | bool | If true, the retrieved e-mail will be marked as 'read'. Otherwise, it will be left 'unread' |
Syntax
Collection[int] messageIDs = CommonLib.EmailMessage.GetIDs();
CommonLib.EmailMessage firstMessage = CommonLib.EmailMessage.Get(messageIDs.Get(0), false, false);
if(firstMessage.Subject.Contains("zAppDev")){
firstMessage = CommonLib.EmailMessage.Get(messageIDs.Get(0), true, true);
DebugLib.Logger.WriteInfoLine(firstMessage.Body);
}
GetIDs()¶
Description
Returns a list of IDs representing the unread messages in the Inbox
Return Type : Collection
Static : Yes
Namespace : CommonLib.EmailMessage
Syntax
Collection[int] messageIDs = CommonLib.EmailMessage.GetIDs();
GetAll(bool)¶
Description
Fetches all the unread e-mails from the Inbox, leaving then in an 'unread' state
Return Type : Collection
Static : Yes
Namespace : CommonLib.EmailMessage
Parameters
Name | Data Type | Description |
---|---|---|
readAll | bool | If true, all the contents of the e-mail will be returned (body, attachments, recipients etc.). If false, only the [From] and [Subject] properties will be set. |
Syntax
Collection[CommonLib.EmailMessage] messages = CommonLib.EmailMessage.GetAll(false);
if(messages.Any()){
messages = CommonLib.EmailMessage.GetAll(true);
}
GetAll(bool, bool)¶
Description
Fetches all the unread e-mails from the Inbox and marks them as 'read' if required.
Return Type : Collection
Static : Yes
Namespace : CommonLib.EmailMessage
Parameters
Name | Data Type | Description |
---|---|---|
readAll | bool | If true, all the contents of the e-mails will be returned (body, attachments, recipients etc.). If false, only the [From] and [Subject] properties will be set. |
markAsRead | bool | If true, the retrieved e-mails will be marked as 'read'. Otherwise, it will be left 'unread' |
Syntax
Collection[CommonLib.EmailMessage] messages = CommonLib.EmailMessage.GetAll(false);
if(messages.Any()){
messages = CommonLib.EmailMessage.GetAll(true, true);
}
GetAll(bool, bool, Collection[int])¶
Description
Fetches a filtered set of unread e-mails from the Inbox and marks then as 'read' if required
Return Type : Collection
Static : Yes
Namespace : CommonLib.EmailMessage
Parameters
Name | Data Type | Description |
---|---|---|
readAll | bool | If true, all the contents of the e-mails will be returned (body, attachments, recipients etc.). If false, only the [From] and [Subject] properties will be set. |
markAsRead | bool | If true, the retrieved e-mails will be marked as 'read'. Otherwise, it will be left 'unread' |
ids | Collection | The IDs of the e-mail messages to read (see CommonLib.EmailMessage.GetIDs()) |
Syntax
MAMBA_DOCUMENTATION_TODO
MarkAsRead(int)¶
Description
Sets a specific e-mail as 'read'
Return Type : void
Static : Yes
Namespace : CommonLib.EmailMessage
Parameters
Name | Data Type | Description |
---|---|---|
id | int | The ID of the message (see CommonLib.EmailMessage.GetIDs()) |
Syntax
Collection[int] messageIDs = CommonLib.EmailMessage.GetIDs();
//Mark the first message as read
CommonLib.EmailMessage.MarkAsRead(messageIDs.Get(0));
MarkAsRead(int, bool)¶
Description
Sets a specific e-mail as 'read' or 'unread', depending on the [isRead] parameter
Return Type : void
Static : Yes
Namespace : CommonLib.EmailMessage
Parameters
Name | Data Type | Description |
---|---|---|
id | int | The ID of the message (see CommonLib.EmailMessage.GetIDs()) |
isRead | bool | If true, the e-mail will be marked as 'read'. Otherwise, it will be marked as 'unread' |
Syntax
Collection[int] messageIDs = CommonLib.EmailMessage.GetIDs();
//Mark the first message as read
CommonLib.EmailMessage.MarkAsRead(messageIDs.Get(0));
//Mark the first message as read
CommonLib.EmailMessage.MarkAsRead(messageIDs.Get(0), true);
//Mark the second message as unread
CommonLib.EmailMessage.MarkAsRead(messageIDs.Get(1), false);
GetAttachment(int, string)¶
Description
Gets a byte array of the attached file specified
Return Type : Array
Static : Yes
Namespace : CommonLib.EmailMessage
Parameters
Name | Data Type | Description |
---|---|---|
mailId | int | The ID of the message (see CommonLib.EmailMessage.GetIDs()) |
attachmentName | string | The name of the attached file |
Syntax
var messageID = CommonLib.EmailMessage.GetIDs().First();
string attachmentName = "invoice.pdf";
//Get content of the attachment
Array[byte] attachmentContent = CommonLib.EmailMessage.GetAttachment(messageID, attachmentName);
EmailAttachment¶
Description¶
Represents a file, attached to an e-mail and exposes functionality to create it
Properties¶
Name | Data Type | Static | Readonly | Description |
---|---|---|---|---|
Name | string | No | No | Friendly name of the Attachment |
Methods¶
CreateFromFile(string, string, string)¶
Description
Creates a new Email Attachment instance by reading the contents of a file
Return Type : CommonLib.EmailAttachment
Static : Yes
Namespace : CommonLib.EmailAttachment
Parameters
Name | Data Type | Description |
---|---|---|
name | string | Attachment file name |
path | string | The path of the file containing the attachment contents |
mediaType | string | File media type |
Syntax
CommonLib.EmailMessage mail;
var file = CommonLib.EmailAttachment.CreateFromFile("readme.txt", "c:/template.txt", "plain/text");
mail.Attachments.Add(file);
CreateFromString(string, string, string)¶
Description
Creates a new Email Attachment instance from a string
Return Type : CommonLib.EmailAttachment
Static : Yes
Namespace : CommonLib.EmailAttachment
Parameters
Name | Data Type | Description |
---|---|---|
name | string | Attachment file name |
contents | string | Attachment string contents |
mediaType | string | File media type |
Syntax
CommonLib.EmailMessage mail;
var file = CommonLib.EmailAttachment.CreateFromFile("readme.txt", "This is an empty readme file!", "plain/text");
mail.Attachments.Add(file);
CreateFromBytes(string, Array[byte], string)¶
Description
Creates a new Email Attachment instance from a byte array
Return Type : CommonLib.EmailAttachment
Static : Yes
Namespace : CommonLib.EmailAttachment
Parameters
Name | Data Type | Description |
---|---|---|
name | string | Attachment file name |
contents | Array | Attachment byte contents |
mediaType | string | File media type |
Syntax
CommonLib.EmailMessage mail;
var file = CommonLib.EmailAttachment.CreateFromBytes("readme.pdf", FileIOLib.File.ReadAllBytesFrom("c:/template.pdf"), "application/pdf");
mail.Attachments.Add(file);
QueryResultSerializer¶
Description¶
Converts QueryResults (returned by CommonLib.DataContext.RunSqlQuery) to Classes
Generic Parameters¶
- T
Methods¶
Serialize(Collection[Dictionary[string, Object]])¶
Description
Converts QueryResults (returned by CommonLib.DataContext.RunSqlQuery) to Classes
Return Type : Collection
Static : No
Namespace : CommonLib.QueryResultSerializer
Parameters
Name | Data Type | Description |
---|---|---|
QueryResults | Collection | Query Results |
Syntax
Dictionary[string, Object] qParams;
qResults = CommonLib.DataContext.RunSqlQuery("SELECT * FROM Customers", qParams);
CommonLib.QueryResultSerializer[Domain.Customer] qSerializer;
customers = qSerializer.Serialize(qResults);
Serializer¶
Description¶
Converts XML, Json and Enum objects to and from plain strings
Generic Parameters¶
- T
Methods¶
ToXml(T)¶
Description
This function takes an object as input, and it returns it to an XML format.
Return Type : string
Static : No
Namespace : CommonLib.Serializer
Parameters
Name | Data Type | Description |
---|---|---|
instance | T | The instance for writting the xml |
Syntax
Domain.MyClass class;
CommonLib.Serializer[Domain.MyClass] serializer;
string classToXml = serializer.ToXml(class);
ToXml(T, bool)¶
Description
This function takes an object as input, and it returns it to an XML format, either in utf8 format or not.
Return Type : string
Static : No
Namespace : CommonLib.Serializer
Parameters
Name | Data Type | Description |
---|---|---|
instance | T | The instance for writting the xml |
utf8 | bool | True for utf8 format |
Syntax
Domain.MyClass class;
CommonLib.Serializer[Domain.MyClass] serializer;
string classToXml = serializer.ToXml(class,true);
ToJson(T)¶
Description
This funtion takes an object as input, and it returns it to a Json format
Return Type : string
Static : No
Namespace : CommonLib.Serializer
Parameters
Name | Data Type | Description |
---|---|---|
instance | T | The instance for writting the json |
Syntax
Domain.MyClass class;
CommonLib.Serializer[Domain.MyClass] serializer;
string classToJson = serializer.ToJson(class);
ToJson(T, bool)¶
Description
This funtion takes an object as input, and it returns it to a Json format. The preventCircles parameter is for not rewritting the assocciations that form a circle.
Return Type : string
Static : No
Namespace : CommonLib.Serializer
Parameters
Name | Data Type | Description |
---|---|---|
instance | T | The instance for writting the json |
preventCircles | bool | True for not have circles |
Syntax
Domain.MyClass class;
CommonLib.Serializer[Domain.MyClass] serializer;
string classToJson = serializer.ToJson(class,true);
FromXml(string)¶
Description
This function takes an xml representing an object and returns a new instance of that object.
Return Type : T
Static : No
Namespace : CommonLib.Serializer
Parameters
Name | Data Type | Description |
---|---|---|
input | string | The xml that represents the object |
Syntax
CommonLib.Serializer[Domain.MyClass] serializer;
Domain.MyClass myClass = serializer.FromXML(input);
FromJson(string)¶
Description
This function takes a json representing an object and returns a new instance of that object.
Return Type : T
Static : No
Namespace : CommonLib.Serializer
Parameters
Name | Data Type | Description |
---|---|---|
input | string | The json that represents the object |
Syntax
CommonLib.Serializer[Domain.MyClass] serializer;
Domain.MyClass myClass = serializer.FromJson(input);
ParseEnum(string)¶
Description
This function initialize an enumeration from a string instance.
Return Type : T
Static : No
Namespace : CommonLib.Serializer
Parameters
Name | Data Type | Description |
---|---|---|
instance | string | The string that represents the enumeration |
Syntax
CommonLib.Serializer[Domain.myEnum] ser;
Domain.Enum enum = ser.ParseEnum(instance);
NullableConverter¶
Description¶
Converts nullables to non nullables and vice-versa
Generic Parameters¶
- T
Methods¶
ToNonNullableArray(Array[T])¶
Description
Converts an array of nullables to array of non nullables.
Return Type : Array
Static : No
Namespace : CommonLib.NullableConverter
Parameters
Name | Data Type | Description |
---|---|---|
value | Array | The value to be converted |
Syntax
CommonLib.NullableConverter[long] converter;
ay[long] arrayOfNullables;
Array[long] arrayOfNonNullables = converter.ToNonNullableArray(arrayOfNullables);
ToNonNullableCollection(Collection[T])¶
Description
Converts a collection of nullables to collection of non nullables.
Return Type : Collection
Static : No
Namespace : CommonLib.NullableConverter
Parameters
Name | Data Type | Description |
---|---|---|
value | Collection | The collection to be converted |
Syntax
CommonLib.NullableConverter[long] converter;
lection[long] collectionOfNullables;
Collection[long] collectionOfNonNullables = converter.ToNonNullableArray(collectionOfNullables);
SFTPClient¶
Description¶
Connects as FTP over SSH to provide remote file handling
Properties¶
Name | Data Type | Static | Readonly | Description |
---|---|---|---|---|
Host | string | No | No | Remote host to connect |
Port | int | No | No | Remote port to connect |
Username | string | No | No | Username provided to connect |
Password | string | No | No | Password for the provided username |
ThrowErrors | bool | No | No | Throw SFTP related exceptions instead of just logging them |
Methods¶
ListDirectory(string)¶
Description
This function lists files and directories for the provided remote path. If the provided path is empty home directory is used
Return Type : Collection
Static : No
Namespace : CommonLib.SFTPClient
Parameters
Name | Data Type | Description |
---|---|---|
remoteDirectoryPath | string | Remote directory path to list |
Syntax
CommonLib.SFTP sftpClient;
sftpClient.Host = "ftp.clmsuk.com";
sftpClient.Username = "myuser";
sftpClient.Password = "mypass";
Collection[string] homeDirectoryResults = sftpClient.ListDirectory(""); // This will list the home directory
Collection[string] updateDirectoryResults = sftpClient.ListDirectory("/update/"); // This will list the provided update directory
SearchDirectory(string, string, bool, bool)¶
Description
This function search folders and directories for the provided value
Return Type : Collection
Static : No
Namespace : CommonLib.SFTPClient
Parameters
Name | Data Type | Description |
---|---|---|
remoteDirectoryPath | string | Remote directory to start searching |
pattern | string | What to search for |
includeDirectories | bool | Whether to include directories in the results |
recursive | bool | Whether to recursivly search all subdirectories |
Syntax
CommonLib.SFTP sftpClient;
sftpClient.Host = "ftp.clmsuk.com";
sftpClient.Username = "myuser";
sftpClient.Password = "mypass";
Collection[string] searchResults = sftpClient.SearchDirectory("", ".xlsx", false, true); // This will list recursively search for files containing ".xlsx" in their filename
DownloadFiles(Collection[string], string)¶
Description
This function downloads remote files into the specified local folder
Return Type : bool
Static : No
Namespace : CommonLib.SFTPClient
Parameters
Name | Data Type | Description |
---|---|---|
remoteFilePaths | Collection | Remote file paths |
localFolderPath | string | Where to save the files |
Syntax
Collection[string] remoteFilePaths; // This is filed probably with the use of the SearchDirectory function
string localDataFolder; // This is filled by the user. Probably the App_Data path
CommonLib.SFTP sftpClient;
sftpClient.Host = "ftp.clmsuk.com";
sftpClient.Username = "myuser";
sftpClient.Password = "mypass";
if !sftpClient.DownloadFiles(remoteFilePaths, localDataFolder) {
//Check logs or set "sftpClient.ThrowErrors = true;" to handle exceptions in the code
}
UploadFiles(Collection[string], string)¶
Description
This function uploads local files into the specified remote filepath
Return Type : bool
Static : No
Namespace : CommonLib.SFTPClient
Parameters
Name | Data Type | Description |
---|---|---|
localFilePaths | Collection | Local file paths |
remoteFolder | string | Where to upload the files |
Syntax
Collection[string] localFilePaths; // This is filed with the local filepaths
string remoteFolder; // This is the remote folderpath to upload the files
CommonLib.SFTP sftpClient;
sftpClient.Host = "ftp.clmsuk.com";
sftpClient.Username = "myuser";
sftpClient.Password = "mypass";
if !sftpClient.UploadFiles(localFilePaths, remoteFolder) {
//Check logs or set "sftpClient.ThrowErrors = true;" to handle exceptions in the code
}
DeleteFilesAndFolders(Collection[string])¶
Description
This function deletes the specified remote file and folder paths
Return Type : bool
Static : No
Namespace : CommonLib.SFTPClient
Parameters
Name | Data Type | Description |
---|---|---|
remotePaths | Collection | Remote paths |
Syntax
Collection[string] remotePaths; // This is filed with the remote file and folder paths
CommonLib.SFTP sftpClient;
sftpClient.Host = "ftp.clmsuk.com";
sftpClient.Username = "myuser";
sftpClient.Password = "mypass";
if !sftpClient.DeleteFilesAndFolders(remotePaths) {
//Check logs or set "sftpClient.ThrowErrors = true;" to handle exceptions in the code
}
ExcelExportConfiguration¶
Description¶
A class structure representing the Configuration to use while exporting data into an Excel document
Properties¶
Name | Data Type | Static | Readonly | Description |
---|---|---|---|---|
Title | string | No | No | Document title |
Author | string | No | No | Document author |
Path | string | No | No | Document export path |
Columns | Collection | No | No | A collection of objects that is used to provide values for the Header Cells |
Values | Collection | No | No | A collection for each document Column, containing another collection of objects that is used to provide values for the Column Row Cells |
Formattings | Collection | No | No | A collection containing the formatting to be used for each column |
CsvTrimOptions¶
Description¶
Options for trimming of fields.
Properties¶
Name | Data Type | Static | Readonly | Description |
---|---|---|---|---|
InsideQuotes | CommonLib.CsvTrimOptions | No | Yes | Trims the whitespace inside of quotes around a field. |
None | CommonLib.CsvTrimOptions | No | Yes | No trimming. |
Trim | CommonLib.CsvTrimOptions | No | Yes | Trims the whitespace around a field. |
CsvConfiguration¶
Description¶
A class structure representing the way a CSV Document should be parsed
Properties¶
Name | Data Type | Static | Readonly | Description |
---|---|---|---|---|
Comment | char | No | No | Gets or sets the character used to denote a line that is commented out. Default is '#'. |
ShouldSkipRecord | Func | No | No | Gets or sets a value indicating whether empty rows should be skipped when reading |
IgnoreQuotes | bool | No | No | Gets or sets a value indicating if quotes should be ingored when parsing and treated like any other character |
IgnoreBlankLines | bool | No | No | Gets or sets a value indicating if blank lines should be ignored when reading. True to ignore, otherwise false. Default is true. |
Quote | char | No | No | Gets or sets the character used to quote fields. Default is '"'. |
DetectColumnCountChanges | bool | No | No | Gets or sets a value indicating whether changes in the column count should be detected. If true, a CsvHelper.CsvBadDataException will be thrown if a different column count is detected. |
HasHeaderRecord | bool | No | No | Gets or sets a value indicating if the CSV file has a header record. Default is true. |
PrepareHeaderForMatch | Func | No | No | Prepares the header field for matching against a member name. The header field and the member name are both ran through this function. You should do things like trimming, removing whitespace, removing underscores, and making casing changes to ignore case. |
TrimOptions | CommonLib.CsvTrimOptions | No | No | Gets or sets the field trimming options. |
Delimiter | string | No | No | Gets or sets the delimiter used to separate fields. Default is ',' |
CsvParser¶
Description¶
A reader that parses a CSV formatted file and fetches its contents
Methods¶
GetField(string)¶
Description
Gets value of column with header matching FieldName as string. Needs to be called within the anonymous function during the parser initialization.
Return Type : string
Static : No
Namespace : CommonLib.CsvParser
Parameters
Name | Data Type | Description |
---|---|---|
fieldName | string | The header of the column to get. |
Syntax
string csvfield = parser.GetField("Name"); //returns value of csv column with header "Name"
GetCurrentRow()¶
Description
Gets current csv raw row :)
Return Type : string
Static : No
Namespace : CommonLib.CsvParser
Syntax
string rawRow = parser.GetCurrentRow(); //returns something like "John;Holmes;30;MALE;Actor"
GetCurrentRecord()¶
Description
Gets current record values in an array of string
Return Type : Array
Static : No
Namespace : CommonLib.CsvParser
Syntax
Array[string] values = parser.GetCurrentRecord(); //returns an array like ['John','Holmes','30','MALE','Actor']
GetHeaders()¶
Description
Gets file's headers in an array of string
Return Type : Array
Static : No
Namespace : CommonLib.CsvParser
Syntax
Array[string] headers = parser.GetHeaders(); //returns an array like ['Name','Surname','Age','Gender','Job']
GetField(int)¶
Description
Gets the value of the field specified as a string. Needs to be called within the anonymous function during the parser initialization.
Return Type : string
Static : No
Namespace : CommonLib.CsvParser
Parameters
Name | Data Type | Description |
---|---|---|
fieldIndex | int | The index of the column to get. |
Syntax
string csvfield = parser.GetField(0); //returns value of first csv column
ParseFile(string, CommonLib.CsvConfiguration, bool, Func[Object, int, Object])¶
Description
Parses file located at filePath with options set at the configuration object. The extraction code allows for serial iteration through all the csv lines.
Return Type : void
Static : No
Namespace : CommonLib.CsvParser
Parameters
Name | Data Type | Description |
---|---|---|
filePath | string | The fully qualified path of the csv file. |
configuration | CommonLib.CsvConfiguration | The configuration object for the csv parser |
continueOnError | bool | If set on true, the parser will skip the rows which produce errors and continue to the next one. If set on false, the parser will stop parsing the csv file on the first error occurance. |
extractionCode | Func | Anonymous function which will iterate through all the rows. Needs to be returned. |
Syntax
CommonLib.CsvConfiguration config;
config.Delimiter=",";
CommonLib.CsvParser parser;
parser.ParseFile("C:\Users\test\test.csv", config, true, (x, idx) => {
string valueFromHeader = parser.GetField("Name");
string valueFromIndex = parser.GetField(0);
int index = idx;
return x;
});
ParseFile(string, CommonLib.CsvConfiguration, bool, Func[Object, int, Object], int)¶
Description
Parses file located at filePath, using the provided code page with options set at the configuration object. The extraction code allows for serial iteration through all the csv lines.
Return Type : void
Static : No
Namespace : CommonLib.CsvParser
Parameters
Name | Data Type | Description |
---|---|---|
filePath | string | The fully qualified path of the csv file. |
configuration | CommonLib.CsvConfiguration | The configuration object for the csv parser |
continueOnError | bool | If set on true, the parser will skip the rows which produce errors and continue to the next one. If set on false, the parser will stop parsing the csv file on the first error occurance. |
extractionCode | Func | Anonymous function which will iterate through all the rows. Needs to be returned. |
codePage | int | Defines the codepage used to read the file. See https://en.wikipedia.org/wiki/Windows_code_page for details |
Syntax
CommonLib.CsvConfiguration config;
config.Delimiter=",";
CommonLib.CsvParser parser;
parser.ParseFile("C:\Users\test\test-greek.csv", config, true, (x, idx) => {
string valueFromHeader = parser.GetField("Name");
string valueFromIndex = parser.GetField(0);
int index = idx;
return x;
}, 1252);
ParseString(string, CommonLib.CsvConfiguration, bool, Func[Object, int, Object])¶
Description
Parses a csv string with options set at the configuration object. The extraction code allows for serial iteration through all the csv lines.
Return Type : void
Static : No
Namespace : CommonLib.CsvParser
Parameters
Name | Data Type | Description |
---|---|---|
content | string | String, formatted using the CSV format |
configuration | CommonLib.CsvConfiguration | The configuration object for the csv parser |
continueOnError | bool | If set on true, the parser will skip the rows which produce errors and continue to the next one. If set on false, the parser will stop parsing the csv file on the first error occurance. |
extractionCode | Func | Anonymous function which will iterate through all the rows. Needs to be returned. |
Syntax
string csv = "Name,Address\nUserName,15th Street"
CommonLib.CsvConfiguration config;
config.Delimiter=",";
CommonLib.CsvParser parser;
parser.ParseFile(csv, config, true, (x, idx) => {
string valueFromHeader = parser.GetField("Name"); //UserName
string valueFromIndex = parser.GetField(0); // UserName
string addressstring= parser.GetField("Address"); //15th Street
string addressfromindex = parser.GetField(1);
int index = idx; // Current row of the file being parsed
return x;
});
PagedResults¶
Description¶
Object containing information regarding paged (limited) items in any collection
Generic Parameters¶
- T
Properties¶
Name | Data Type | Static | Readonly | Description |
---|---|---|---|---|
Results | Collection | No | No | Subset of the initial (full) collection |
TotalResults | int | No | No | Number of the total initial (non-paged) items |
DataAccessContext¶
Description¶
Exports semantics with which any Dataset can be accessed (filtering, paging, sorting options)
Generic Parameters¶
- T
Properties¶
Name | Data Type | Static | Readonly | Description |
---|---|---|---|---|
Filter | Func | No | No | User defined code that implements the way that the Dataset should be filtered |
SortByColumnName | Dictionary | No | No | Key/Value list representing the way that the Dataset must be sorted, as well as its sorted column |
PageIndex | int | No | No | Index of the page, in a paged collection |
PageSize | int | No | No | Number of items per page, in a paged collection |
DataContext¶
Description¶
Exposes methods that act on the Data Layer of the Application and its underlying Database
Methods¶
ExecuteWithoutAuditTrail(Func[Object, Object])¶
Description
This operation executes an operation disabling the audit trail. After the execution, it enables the audit trail again.
Return Type : void
Static : Yes
Namespace : CommonLib.DataContext
Parameters
Name | Data Type | Description |
---|---|---|
operation | Func | Your operation you want to execute without audit trail. |
Syntax
CommonLib.DataContext.ExecuteWithoutAuditTrail(manager => {
// here place your code
return manager;
});
ExecuteInUnitOfWork(Func[Object, Object])¶
Description
Executes an Operation in a single Unit of Work and performs a single Flush operation.
Return Type : Object
Static : Yes
Namespace : CommonLib.DataContext
Parameters
Name | Data Type | Description |
---|---|---|
operation | Func | Your operation you want to execute in a signle Unit of Work. |
Syntax
CommonLib.DataContext.ExecuteInUnitOfWork((manager => {
// here place your code
return manager;
});
ExecuteInTransaction(Func[Object, Object])¶
Description
Executes an Operation in a single Transaction.
Return Type : Object
Static : Yes
Namespace : CommonLib.DataContext
Parameters
Name | Data Type | Description |
---|---|---|
operation | Func | Your operation you want to execute in a signle Transaction. |
Syntax
CommonLib.DataContext.ExecuteInTransaction((manager => {
// here place your code
return manager;
});
Flush()¶
Description
Explicitly flushes the current database session, persisting any changes
Return Type : void
Static : Yes
Namespace : CommonLib.DataContext
Syntax
CommonLib.DataContext.Flush();
Clear()¶
Description
Clears the current database session, removing all entity instances from memory
Return Type : void
Static : Yes
Namespace : CommonLib.DataContext
Syntax
CommonLib.DataContext.Clear();
RunSqlQuery(string, Dictionary[string, Object])¶
Description
This operation runs an sql query directly to the database,and returns the results if there are any. The SQL Command's Timeout will be set using either the app's Configuration (SQLQueryTimeoutInSeconds configuration item) or 30 seconds if the latter is missing or invalid
Return Type : Collection
Static : Yes
Namespace : CommonLib.DataContext
Parameters
Name | Data Type | Description |
---|---|---|
query | string | The query you want to execute. |
parameters | Dictionary | The parameters for the query, if there are any. |
Syntax
CommonLib.DataContext.RunSqlQuery("UPDATE Computers SET CPUCores = 3 WHERE Id = 1",null);
RunSqlQuery(string, Dictionary[string, Object], int)¶
Description
This operation runs an sql query directly to the database,and returns the results if there are any.
Return Type : Collection
Static : Yes
Namespace : CommonLib.DataContext
Parameters
Name | Data Type | Description |
---|---|---|
query | string | The query you want to execute. |
parameters | Dictionary | The parameters for the query, if there are any. |
timeout | int | The SQL Command's Timeout, in seconds. A value of 0 denotes no limit; indefinite amount of time waiting for the command to execute. If null or invalid, the SQL Command's Timeout will be set using either the app's Configuration (SQLQueryTimeoutInSeconds configuration item) or 30 seconds if the latter is also missing or invalid |
Syntax
CommonLib.DataContext.RunSqlQuery("UPDATE Computers SET CPUCores = 3 WHERE Id = 1", null, 0);
RunSqlQuery(string, Dictionary[string, Object], string)¶
Description
This operation runs an sql query directly to the database,and returns the results if there are any.
Return Type : Collection
Static : Yes
Namespace : CommonLib.DataContext
Parameters
Name | Data Type | Description |
---|---|---|
query | string | The query you want to execute. |
parameters | Dictionary | The parameters for the query, if there are any. |
connectionString | string | The connection string to use for the query |
Syntax
CommonLib.DataContext.RunSqlQuery("UPDATE Computers SET CPUCores = 3 WHERE Id = 1", null, 0);
RunSqlQuery(string, Dictionary[string, Object], int, string)¶
Description
This operation runs an sql query directly to the database,and returns the results if there are any.
Return Type : Collection
Static : Yes
Namespace : CommonLib.DataContext
Parameters
Name | Data Type | Description |
---|---|---|
query | string | The query you want to execute. |
parameters | Dictionary | The parameters for the query, if there are any. |
timeout | int | The SQL Command's Timeout, in seconds. A value of 0 denotes no limit; indefinite amount of time waiting for the command to execute. If null or invalid, the SQL Command's Timeout will be set using either the app's Configuration (SQLQueryTimeoutInSeconds configuration item) or 30 seconds if the latter is also missing or invalid |
connectionString | string | The connection string to use for the query |
Syntax
CommonLib.DataContext.RunSqlQuery("UPDATE Computers SET CPUCores = 3 WHERE Id = 1", null, 0);
RunStoredProcedure(string, Dictionary[string, Object])¶
Description
This operation runs a stored procedure in the database.
Return Type : Collection
Static : Yes
Namespace : CommonLib.DataContext
Parameters
Name | Data Type | Description |
---|---|---|
procedureName | string | The name of the procedure you want to execute. |
parameters | Dictionary | The parameters for the procedure, if there are any. |
Syntax
CommonLib.DataContext.RunStoredProcedure("sp_SeedSecurityTables", null);
RunStoredProcedure(string)¶
Description
Return Type : Collection
Static : Yes
Namespace : CommonLib.DataContext
Parameters
Name | Data Type | Description |
---|---|---|
procedureName | string | The name of the procedure you want to execute. |
Syntax
CommonLib.DataContext.RunStoredProcedure("sp_SeedSecurityTables");
RunStoredProcedure(string, Dictionary[string, Object], string)¶
Description
This operation runs a stored procedure in the database.
Return Type : Collection
Static : Yes
Namespace : CommonLib.DataContext
Parameters
Name | Data Type | Description |
---|---|---|
procedureName | string | The name of the procedure you want to execute. |
parameters | Dictionary | The parameters for the procedure, if there are any. |
connectionString | string | The connection string to use for the procedure |
Syntax
CommonLib.DataContext.RunStoredProcedure("sp_SeedSecurityTables", null);
RunStoredProcedure(string, Dictionary[string, Object], string, Collection[string])¶
Description
This operation runs a stored procedure in the database.
Return Type : Collection
Static : Yes
Namespace : CommonLib.DataContext
Parameters
Name | Data Type | Description |
---|---|---|
procedureName | string | The name of the procedure you want to execute. |
parameters | Dictionary | The parameters for the procedure, if there are any. |
connectionString | string | The connection string to use for the procedure |
OutputParameters | Collection | The names of the output parameters |
Syntax
CommonLib.DataContext.RunStoredProcedure("sp_SeedSecurityTables", null);
RunStoredProcedure(string, string)¶
Description
Return Type : Collection
Static : Yes
Namespace : CommonLib.DataContext
Parameters
Name | Data Type | Description |
---|---|---|
procedureName | string | The name of the procedure you want to execute. |
connectionString | string | The connection string to use for the procedure |
Syntax
CommonLib.DataContext.RunStoredProcedure("sp_SeedSecurityTables");
Evict(Object)¶
Description
Explicity removes an entity instance from the current database session
Return Type : void
Static : Yes
Namespace : CommonLib.DataContext
Parameters
Name | Data Type | Description |
---|---|---|
instance | Object | The entity instance to be removed from the session |
Syntax
Domain.ApplicationUser user = Domain.ApplicationUser.GetByKey("admin");
string oldName = user.Name;
user.Name = "New Name";
CommonLib.DataContext.Evict(user);
user = Domain.ApplicationUser.GetByKey("admin");
bool nameWasReset = user.Name == oldName; // true
Math¶
Description¶
Exposes static functions implementing mathematical operations
Methods¶
Round(decimal, int)¶
Description
Rounds a value to a specified number of fractional digits.
Return Type : decimal
Static : Yes
Namespace : CommonLib.Math
Parameters
Name | Data Type | Description |
---|---|---|
number | decimal | The number for rounding. |
digits | int | The fractional digits of the number. |
Syntax
decimal pi = 3.14159265;
decimal piRounded = CommonLib.Math.Round(pi,2);
//piRounded = 3.14
Round(double, int)¶
Description
Rounds a value to a specified number of fractional digits.
Return Type : double
Static : Yes
Namespace : CommonLib.Math
Parameters
Name | Data Type | Description |
---|---|---|
number | double | The number for rounding. |
digits | int | The fractional digits of the number. |
Syntax
double pi = 3.14159265;
double piRounded = CommonLib.Math.Round(pi,2);
//piRounded = 3.14
Ceil(double)¶
Description
Returns the smallest integral value that is greater than or equal to the specified double number.
Return Type : double
Static : Yes
Namespace : CommonLib.Math
Parameters
Name | Data Type | Description |
---|---|---|
number | double | The number for ceiling |
Syntax
double x = 7.03;
double xCeil = CommonLib.Math.Ceil(x);
//xCeil = 8
Ceil(decimal)¶
Description
Returns the smallest integral value that is greater than or equal to the specified decimal number.
Return Type : decimal
Static : Yes
Namespace : CommonLib.Math
Parameters
Name | Data Type | Description |
---|---|---|
number | decimal | The number for ceiling |
Syntax
decimal x = 7.03;
decimal xCeil = CommonLib.Math.Ceil(x);
//xCeil = 8
Floor(double)¶
Description
Returns the largest integer less than or equal to the specified decimal number.
Return Type : double
Static : Yes
Namespace : CommonLib.Math
Parameters
Name | Data Type | Description |
---|---|---|
number | double | The number for floor |
Syntax
double x = 7.03;
double xFloor = CommonLib.Math.Floor(x);
//xFloor = 7
Floor(decimal)¶
Description
Returns the largest integer less than or equal to the specified decimal number.
Return Type : decimal
Static : Yes
Namespace : CommonLib.Math
Parameters
Name | Data Type | Description |
---|---|---|
number | decimal | The number for floor |
Syntax
decimal x = 7.03;
decimal xFloor = CommonLib.Math.Floor(x);
//xFloor = 7
Abs(decimal)¶
Description
Returns the absolute value of a decimal number.
Return Type : decimal
Static : Yes
Namespace : CommonLib.Math
Parameters
Name | Data Type | Description |
---|---|---|
number | decimal | The number to return its absolute value. |
Syntax
decimal x = CommonLib.Math.Abs(-1.0)
//x = 1
Abs(float)¶
Description
Returns the absolute value of a float number.
Return Type : float
Static : Yes
Namespace : CommonLib.Math
Parameters
Name | Data Type | Description |
---|---|---|
number | float | The number to return its absolute value. |
Syntax
float x = CommonLib.Math.Abs(-1.0)
//x = 1
Abs(double)¶
Description
Returns the absolute value of a double number.
Return Type : double
Static : Yes
Namespace : CommonLib.Math
Parameters
Name | Data Type | Description |
---|---|---|
number | double | The number to return its absolute value. |
Syntax
double x = CommonLib.Math.Abs(-1.0)
//x = 1
Abs(int)¶
Description
Returns the absolute value of a int number.
Return Type : int
Static : Yes
Namespace : CommonLib.Math
Parameters
Name | Data Type | Description |
---|---|---|
number | int | The number to return its absolute value. |
Syntax
int x = CommonLib.Math.Abs(-1)
//x = 1
Min(decimal, decimal)¶
Description
Returns the smaller of two decimal numbers.
Return Type : decimal
Static : Yes
Namespace : CommonLib.Math
Parameters
Name | Data Type | Description |
---|---|---|
number1 | decimal | The first number |
number2 | decimal | The second number |
Syntax
decimal smaller = CommonLib.Min(2.1, 3.5);
Min(int, int)¶
Description
Returns the smaller of two integer numbers.
Return Type : int
Static : Yes
Namespace : CommonLib.Math
Parameters
Name | Data Type | Description |
---|---|---|
number1 | int | The first number |
number2 | int | The second number |
Syntax
int smaller = CommonLib.Min(5, 10);
Pi()¶
Description
Return Type : double
Static : Yes
Namespace : CommonLib.Math
Cos(double)¶
Description
Returns the cosine of the specified angle.
Return Type : double
Static : Yes
Namespace : CommonLib.Math
Parameters
Name | Data Type | Description |
---|---|---|
number | double | The angle. |
Syntax
double cosine = CommonLib.Math.Cos(30.0)
Sin(double)¶
Description
Returns the sine of the specified angle.
Return Type : double
Static : Yes
Namespace : CommonLib.Math
Parameters
Name | Data Type | Description |
---|---|---|
number | double | The angle. |
Syntax
double sine = CommonLib.Math.Sin(30.0)
Acos(double)¶
Description
Returns the angle whose cosine is the specified number.
Return Type : double
Static : Yes
Namespace : CommonLib.Math
Parameters
Name | Data Type | Description |
---|---|---|
number | double | The cosine |
Syntax
double angle = CommonLib.Math.Acos(1.0);
Asin(double)¶
Description
Returns the angle whose sine is the specified number.
Return Type : double
Static : Yes
Namespace : CommonLib.Math
Parameters
Name | Data Type | Description |
---|---|---|
number | double | The sine |
Syntax
double sine = CommonLib.Math.Asin(1.0);
Tan(double)¶
Description
Returns the tangent of the specified angle.
Return Type : double
Static : Yes
Namespace : CommonLib.Math
Parameters
Name | Data Type | Description |
---|---|---|
number | double | The angle |
Syntax
double tangent = CommonLib.Math.Tan(30.0);
Atan2(double, double)¶
Description
Returns the angle whose tangent is the quotient of two specified numbers.
Return Type : double
Static : Yes
Namespace : CommonLib.Math
Parameters
Name | Data Type | Description |
---|---|---|
number1 | double | The first tangent |
number2 | double | The second tangent |
Syntax
double angle = CommonLib.Math.Atan2(1.0,2.0);
Atan(double)¶
Description
Returns the angle whose tangent is the specified number.
Return Type : double
Static : Yes
Namespace : CommonLib.Math
Parameters
Name | Data Type | Description |
---|---|---|
number | double | The tangent |
Syntax
double angle = CommonLib.Math.Atan(1.0);
Pow(double, double)¶
Description
Returns a specified number raised to the specified power.
Return Type : double
Static : Yes
Namespace : CommonLib.Math
Parameters
Name | Data Type | Description |
---|---|---|
number1 | double | The number for raising to the power |
number2 | double | The power for raising the number |
Syntax
double power = CommonLib.Math.Pow(5.0,2.0);
Sqrt(double)¶
Description
Returns the square root of a specified number.
Return Type : double
Static : Yes
Namespace : CommonLib.Math
Parameters
Name | Data Type | Description |
---|---|---|
number | double | The number |
Syntax
double sqrt = CommonLib.Math.Sqrt(9.0);
Max(decimal, decimal)¶
Description
Returns the larger of two decimal numbers.
Return Type : decimal
Static : Yes
Namespace : CommonLib.Math
Parameters
Name | Data Type | Description |
---|---|---|
number1 | decimal | The first Number |
number2 | decimal | The second Number |
Syntax
decimal larger = CommonLib.Math.Max(3.0,5.0);
Max(int, int)¶
Description
Returns the larger of two integer numbers.
Return Type : int
Static : Yes
Namespace : CommonLib.Math
Parameters
Name | Data Type | Description |
---|---|---|
number1 | int | The first Number |
number2 | int | The second Number |
Syntax
CommonLib.Math.Max(3,5);
ServiceResponse¶
Description¶
Structured representation of a Response received from or sent to a remote Service
Properties¶
Name | Data Type | Static | Readonly | Description |
---|---|---|---|---|
Data | Object | No | No | The data received from the remote Serivce Call |
Status | string | No | No | The request HTTP Status Message Code (200, 403, 404, 501 etc.) See https://www.w3schools.com/tags/ref_httpmessages.asp for details. |
StatusText | string | No | No | Status code representing the status of the request's output (eg. 200 (OK) ) |
Headers | Object | No | No | The headers that the server responded with |
Config | Object | No | No | The config that was provided to the remote Service request |
Week¶
Description¶
A class that represents a week
Properties¶
Name | Data Type | Static | Readonly | Description |
---|---|---|---|---|
Sunday | CommonLib.WeekDay | No | Yes | WeekDay class instance for Sunday |
Monday | CommonLib.WeekDay | No | Yes | WeekDay class instance for Monday |
Tuesday | CommonLib.WeekDay | No | Yes | WeekDay class instance for Tuesday |
Wednesday | CommonLib.WeekDay | No | Yes | WeekDay class instance for Wednesday |
Thursday | CommonLib.WeekDay | No | Yes | WeekDay class instance for Thursday |
Friday | CommonLib.WeekDay | No | Yes | WeekDay class instance for Friday |
Saturday | CommonLib.WeekDay | No | Yes | WeekDay class instance for Saturday |
Methods¶
GetDays()¶
Description
Returns an array containing 7 WeekDay instances, one for each day, with Sunday first.
Return Type : Array
Static : No
Namespace : CommonLib.Week
Syntax
CommonLib.Week week;
Array[CommonLib.WeekDay] days = week.GetDays();
GetDaysStartingWith(CommonLib.WeekDay)¶
Description
Returns an array containing 7 WeekDay instances, one for each day, with provided day first.
Return Type : Array
Static : No
Namespace : CommonLib.Week
Parameters
Name | Data Type | Description |
---|---|---|
day | CommonLib.WeekDay | The first day of the week |
Syntax
CommonLib.Week week;
Array[CommonLib.WeekDay] days = week.GetDaysStartingWith(week.Monday);
WeekDay¶
Description¶
A class that represents a week day, exposing related methods and properties
Properties¶
Name | Data Type | Static | Readonly | Description |
---|---|---|---|---|
Index | int | No | Yes | The order of the day in a week. Sunday is 0, Monday is 1 etc. |
IsWeekEnd | bool | No | Yes | True for Sunday and Monday |
Methods¶
GetEnglishName()¶
Description
Gets the English name of the day.
Return Type : string
Static : No
Namespace : CommonLib.WeekDay
Syntax
CommonLib.Week week;
CommonLib.WeekDay sunday = week.Sunday;
string name = sunday.GetEnglishName();
GetLocalizedName()¶
Description
Gets the name of the day, according to current user locale settings.
Return Type : string
Static : No
Namespace : CommonLib.WeekDay
Syntax
CommonLib.Week week;
CommonLib.WeekDay sunday = week.Sunday;
string localizedName = sunday.GetLocalizedName();
GetShortEnglishName()¶
Description
Gets the abbreviated English name of the day.
Return Type : string
Static : No
Namespace : CommonLib.WeekDay
Syntax
CommonLib.Week week;
CommonLib.WeekDay sunday = week.Sunday;
string shortName = sunday.GetShortEnglishName();
GetShortLocalizedName()¶
Description
Gets the abbreviated name of the day, according to current user locale settings.
Return Type : string
Static : No
Namespace : CommonLib.WeekDay
Syntax
CommonLib.Week week;
CommonLib.WeekDay sunday = week.Sunday;
string shortLocalizedName = sunday.GetShortLocalizedName();
FromIndex(int)¶
Description
Creates a WeekDay instance based on the provided index. Sunday is 0, Monday is 1 etc.
Return Type : CommonLib.WeekDay
Static : Yes
Namespace : CommonLib.WeekDay
Parameters
Name | Data Type | Description |
---|---|---|
index | int | Day index. From 0 to 6 |
Syntax
CommonLib.WeekDay sundayFromIndex = CommonLib.WeekDay.FromIndex(0);
FromEnglishName(string)¶
Description
Creates a WeekDay instance based on the provided string.
Return Type : CommonLib.WeekDay
Static : Yes
Namespace : CommonLib.WeekDay
Parameters
Name | Data Type | Description |
---|---|---|
name | string | Day name (Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday) |
Syntax
CommonLib.WeekDay sundayFromName = CommonLib.WeekDay.FromIndex("Sunday");
FromShortEnglishName(string)¶
Description
Creates a WeekDay instance based on the provided string.
Return Type : CommonLib.WeekDay
Static : Yes
Namespace : CommonLib.WeekDay
Parameters
Name | Data Type | Description |
---|---|---|
name | string | Day name (Sun, Mon, Tue, Wed, Thu, Fri, Sat) |
Syntax
CommonLib.WeekDay sundayFromShortName = CommonLib.WeekDay.FromIndex("Sun");
FromDateTime(DateTime)¶
Description
Creates a WeekDay instance based on the provided DateTime value.
Return Type : CommonLib.WeekDay
Static : Yes
Namespace : CommonLib.WeekDay
Parameters
Name | Data Type | Description |
---|---|---|
date | DateTime | A DateTime instance |
Syntax
CommonLib.WeekDay sundayFromDateTime = CommonLib.WeekDay.FromDateTime(DateTime.Create(2018, 5, 6));