Show / Hide Table of Contents

Class Function

Base class for any scripting function

Inheritance
object
Function
PayrollFunction
ReportFunction
Implements
IDisposable
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: PayrollEngine.Client.Scripting.Function
Assembly: PayrollEngine.Client.Scripting.dll
Syntax
public abstract class Function : IDisposable

Constructors

Function(object)

New function instance

Declaration
protected Function(object runtime)
Parameters
Type Name Description
object runtime

The function runtime

Function(string)

New function instance without runtime (scripting development)

Declaration
protected Function(string sourceFileName)
Parameters
Type Name Description
string sourceFileName

The name of the source file

Remarks

Use GetSourceFileName(string) in your constructor for the source file name

Properties

AdminUser

Test for user type

Declaration
public bool AdminUser { get; }
Property Value
Type Description
bool

Runtime

The function runtime

Declaration
protected dynamic Runtime { get; }
Property Value
Type Description
dynamic

SelfServiceUser

Test for self employee self-service (user is employee)

Declaration
[ActionProperty("Test for self service user", null)]
public bool SelfServiceUser { get; }
Property Value
Type Description
bool

SourceFileName

The name of the source file (scripting development)

Declaration
public string SourceFileName { get; }
Property Value
Type Description
string

The name of the source file

TenantId

The tenant id

Declaration
public int TenantId { get; }
Property Value
Type Description
int

TenantIdentifier

The tenant identifier

Declaration
public string TenantIdentifier { get; }
Property Value
Type Description
string

UserCulture

The user culture

Declaration
[ActionProperty("User culture", null)]
public string UserCulture { get; }
Property Value
Type Description
string

UserId

The user id

Declaration
public int UserId { get; }
Property Value
Type Description
int

UserIdentifier

The user identifier

Declaration
[ActionProperty("User identifier", null)]
public string UserIdentifier { get; }
Property Value
Type Description
string

UserType

The user type

Declaration
public UserType UserType { get; }
Property Value
Type Description
UserType

Methods

AddTask(string, string, DateTime, string, Dictionary<string, object>)

Add task

Declaration
public void AddTask(string name, string instruction, DateTime scheduleDate, string category = null, Dictionary<string, object> attributes = null)
Parameters
Type Name Description
string name

The task name

string instruction

The task instruction

DateTime scheduleDate

The task schedule date

string category

The task category

Dictionary<string, object> attributes

The task attributes

ChangeValueType<T>(object, T, IFormatProvider)

Change value type

Declaration
public T ChangeValueType<T>(object value, T defaultValue = default, IFormatProvider provider = null)
Parameters
Type Name Description
object value

Value to change

T defaultValue

Default value

IFormatProvider provider

Format provider (default InvariantCulture)

Returns
Type Description
T
Type Parameters
Name Description
T
Remarks

Supports json elements

Dispose()

Dispose the function

Declaration
public virtual void Dispose()

GetCalendarDayCount(DateTime, DateTime, string)

Count the calendar days from a date period

Declaration
public int GetCalendarDayCount(DateTime start, DateTime end, string culture = null)
Parameters
Type Name Description
DateTime start

The period start date

DateTime end

The period end date

string culture

The calendar culture

Returns
Type Description
int

GetCalendarDayCount(string, DateTime, DateTime, string)

Count the calendar days from a date period

Declaration
public int GetCalendarDayCount(string calendarName, DateTime start, DateTime end, string culture = null)
Parameters
Type Name Description
string calendarName

The calendar name

DateTime start

The period start date

DateTime end

The period end date

string culture

The calendar culture

Returns
Type Description
int

GetCalendarPeriod(DateTime?, int, int, int)

Gets the calendar period

Declaration
public DatePeriod GetCalendarPeriod(DateTime? moment = null, int divisionId = 0, int employeeId = 0, int offset = 0)
Parameters
Type Name Description
DateTime? moment

Moment within the period (default: today)

int divisionId

The division id, use 0 to ignore the division culture

int employeeId

The employee id, use 0 to ignore the employee culture

int offset

The period offset (default: 0/current)

Returns
Type Description
DatePeriod

The period start and end date

GetCalendarPeriod(string, DateTime?, int, string)

Gets the calendar period

Declaration
public DatePeriod GetCalendarPeriod(string calendarName, DateTime? moment = null, int offset = 0, string culture = null)
Parameters
Type Name Description
string calendarName

The calendar name

DateTime? moment

Moment within the period (default: today)

int offset

The period offset (default: 0/current)

string culture

The calendar culture (default: tenant culture)

Returns
Type Description
DatePeriod

The period start and end date

GetDerivedCalendar(int, int)

Gets the derived calendar name by priority: - employee (optional) - division (optional) - tenant (fallback)

Declaration
public string GetDerivedCalendar(int divisionId = 0, int employeeId = 0)
Parameters
Type Name Description
int divisionId

The division id, use 0 to ignore the division culture

int employeeId

The employee id, use 0 to ignore the employee culture

Returns
Type Description
string

The most derived calendar name

GetDerivedCulture(int, int)

Gets the derived culture name by priority: - employee (optional) - division (optional) - tenant (fallback)

Declaration
public string GetDerivedCulture(int divisionId = 0, int employeeId = 0)
Parameters
Type Name Description
int divisionId

The division id, use 0 to ignore the division culture (mandatory with employee id)

int employeeId

The employee id, use 0 to ignore the employee culture

Returns
Type Description
string

The most derived culture name

GetNextWorkDay(string, DateTime?)

Get next working day

Declaration
public DateTime GetNextWorkDay(string calendarName, DateTime? moment = null)
Parameters
Type Name Description
string calendarName

The calendar name

DateTime? moment

The start moment (default: today)

Returns
Type Description
DateTime

GetNextWorkDays(string, DateTime?, int)

Get next working days

Declaration
public List<DateTime> GetNextWorkDays(string calendarName, DateTime? moment = null, int count = 1)
Parameters
Type Name Description
string calendarName

The calendar name

DateTime? moment

The start moment (default: today, not included in results)

int count

The number of days (default: 1)

Returns
Type Description
List<DateTime>

GetPreviousWorkDay(string, DateTime?)

Get previous working day

Declaration
public DateTime GetPreviousWorkDay(string calendarName, DateTime? moment = null)
Parameters
Type Name Description
string calendarName

The calendar name

DateTime? moment

The start moment (default: today)

Returns
Type Description
DateTime

GetPreviousWorkDays(string, DateTime?, int)

Get previous working days

Declaration
public List<DateTime> GetPreviousWorkDays(string calendarName, DateTime? moment = null, int count = 1)
Parameters
Type Name Description
string calendarName

The calendar name

DateTime? moment

The start moment (default: today, not included in results)

int count

The number of days (default: 1)

Returns
Type Description
List<DateTime>

GetSourceFileName(string)

Initialize the source file path (scripting development)

Declaration
protected static string GetSourceFileName(string sourceFilePath = "")
Parameters
Type Name Description
string sourceFilePath

The source file path (do not provide a value)

Returns
Type Description
string

Source code file name

GetTenantAttribute(string)

Get tenant attribute value

Declaration
public object GetTenantAttribute(string attributeName)
Parameters
Type Name Description
string attributeName
Returns
Type Description
object

GetTenantAttribute<T>(string, T)

Get tenant attribute typed value

Declaration
public T GetTenantAttribute<T>(string attributeName, T defaultValue = default)
Parameters
Type Name Description
string attributeName
T defaultValue
Returns
Type Description
T
Type Parameters
Name Description
T

GetUserAttribute(string)

Get user attribute value

Declaration
public object GetUserAttribute(string attributeName)
Parameters
Type Name Description
string attributeName
Returns
Type Description
object

GetUserAttribute<T>(string, T)

Get user attribute typed value

Declaration
public T GetUserAttribute<T>(string attributeName, T defaultValue = default)
Parameters
Type Name Description
string attributeName
T defaultValue
Returns
Type Description
T
Type Parameters
Name Description
T

InvokeWebhook<T>(string, object)

Invoke report webhook

Declaration
public T InvokeWebhook<T>(string requestOperation, object requestMessage = null)
Parameters
Type Name Description
string requestOperation

The request operation

object requestMessage

The webhook request message

Returns
Type Description
T

The webhook response object

Type Parameters
Name Description
T

IsCalendarWorkDay(DateTime?)

Test for calendar working day

Declaration
public bool IsCalendarWorkDay(DateTime? moment = null)
Parameters
Type Name Description
DateTime? moment

Work date (default: today)

Returns
Type Description
bool

IsCalendarWorkDay(string, DateTime?)

Test for calendar working day

Declaration
public bool IsCalendarWorkDay(string calendarName, DateTime? moment = null)
Parameters
Type Name Description
string calendarName

The calendar name

DateTime? moment

Test day (default: today)

Returns
Type Description
bool

Log(LogLevel, string, string, string)

Add a log

Declaration
public void Log(LogLevel level, string message, string error = null, string comment = null)
Parameters
Type Name Description
LogLevel level

The log level

string message

The log message

string error

The log error

string comment

The log comment

LogDebug(string, string, string)

Add a debug log

Declaration
public void LogDebug(string message, string error = null, string comment = null)
Parameters
Type Name Description
string message

The log message

string error

The log error

string comment

The log comment

LogError(Exception, string, string)

Add an error log using an exception

Declaration
public void LogError(Exception exception, string message = null, string comment = null)
Parameters
Type Name Description
Exception exception

The exception

string message

The log message, default is the exception message

string comment

The log comment

LogError(string, string, string)

Add error log

Declaration
public void LogError(string message, string error = null, string comment = null)
Parameters
Type Name Description
string message

The log message

string error

The log error

string comment

The log comment

LogFatal(Exception, string, string)

Add a fatal log using an exception

Declaration
public void LogFatal(Exception exception, string message = null, string comment = null)
Parameters
Type Name Description
Exception exception

The exception

string message

The log message, default is the exception message

string comment

The log comment

LogFatal(string, string, string)

Add a fatal log

Declaration
public void LogFatal(string message, string error = null, string comment = null)
Parameters
Type Name Description
string message

The log message

string error

The log error

string comment

The log comment

LogInformation(string, string, string)

Add an information log

Declaration
public void LogInformation(string message, string error = null, string comment = null)
Parameters
Type Name Description
string message

The log message

string error

The log error

string comment

The log comment

LogVerbose(string, string, string)

Add a verbose log

Declaration
public void LogVerbose(string message, string error = null, string comment = null)
Parameters
Type Name Description
string message

The log message

string error

The log error

string comment

The log comment

LogWarning(string, string, string)

Add a warning log

Declaration
public void LogWarning(string message, string error = null, string comment = null)
Parameters
Type Name Description
string message

The log message

string error

The log error

string comment

The log comment

Implements

IDisposable

Extension Methods

ConsoleExtensions.WriteProperties(object, bool)
ValueTypeExtensions.GetValueType(object)
ObjectInfo.GetPropertyValue(object, string)
ObjectInfo.GetPropertyValue<T>(object, string, T)
ObjectInfo.ResolvePropertyValue(object, string)
ObjectInfo.SetPropertyValue(object, string, object)
☀
☾
Back to top Generated by DocFX