Repository navigation
Expand file tree
/
Copy pathIRuntime.cs
More file actions
130 lines (99 loc) · 5.02 KB
/
Copy pathIRuntime.cs
File metadata and controls
130 lines (99 loc) · 5.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
using System;
using System.Collections.Generic;
namespace PayrollEngine.Client.Scripting.Runtime;
/// <summary>Runtime during the execution of a scripting function <see cref="Function"/></summary>
public interface IRuntime
{
#region Tenant
/// <summary>The tenant id</summary>
int TenantId { get; }
/// <summary>The tenant identifier</summary>
string TenantIdentifier { get; }
/// <summary>Get tenant attribute value</summary>
/// <param name="attributeName">Name of the attribute</param>
/// <returns>The tenant attribute value</returns>
object GetTenantAttribute(string attributeName);
#endregion
#region User
/// <summary>The user id</summary>
int UserId { get; }
/// <summary>The user identifier</summary>
string UserIdentifier { get; }
/// <summary>The user culture</summary>
string UserCulture { get; }
/// <summary>The user type</summary>
int UserType { get; }
/// <summary>Get user attribute value</summary>
/// <param name="attributeName">Name of the attribute</param>
/// <returns>The user attribute value</returns>
object GetUserAttribute(string attributeName);
#endregion
#region Culture and Calendar
/// <summary>Gets the derived culture name by priority:
/// - employee (optional)
/// - division (optional)
/// - tenant (fallback)</summary>
/// <param name="divisionId">The division id, use 0 to ignore the division culture (mandatory with employee id)</param>
/// <param name="employeeId">The employee id, use 0 to ignore the employee culture</param>
/// <returns>The most derived culture name</returns>
string GetDerivedCulture(int divisionId, int employeeId);
/// <summary>Gets the derived calendar name by priority:
/// - employee (optional)
/// - division (optional)
/// - tenant (fallback)</summary>
/// <param name="divisionId">The division id, use 0 to ignore the division calendar</param>
/// <param name="employeeId">The employee id, use 0 to ignore the employee calendar</param>
/// <returns>The most derived calendar name</returns>
string GetDerivedCalendar(int divisionId, int employeeId);
/// <summary>
/// Count the calendar days from a date period
/// </summary>
/// <param name="calendarName">The calendar name</param>
/// <param name="start">The period start date</param>
/// <param name="end">The period end date</param>
/// <param name="culture">The calendar culture</param>
int GetCalendarDayCount(string calendarName, DateTime start, DateTime end, string culture);
/// <summary>Test for calendar working day</summary>
/// <param name="calendarName">The calendar name</param>
/// <param name="moment">Test day</param>
bool IsCalendarWorkDay(string calendarName, DateTime moment);
/// <summary>Get previous working days</summary>
/// <param name="calendarName">The calendar name</param>
/// <param name="moment">The start moment (not included in results)</param>
List<DateTime> GetPreviousWorkDays(string calendarName, DateTime moment);
/// <summary>Get next working days</summary>
/// <param name="calendarName">The calendar name</param>
/// <param name="moment">The start moment (not included in results)</param>
/// <returns>Returns true for valid time units</returns>
List<DateTime> GetNextWorkDays(string calendarName, DateTime moment);
/// <summary>Gets the calendar period</summary>
/// <param name="calendarName">The calendar name</param>
/// <param name="moment">Moment within the period</param>
/// <param name="offset">The period offset</param>
/// <param name="culture">The calendar culture</param>
Tuple<DateTime, DateTime> GetCalendarPeriod(string calendarName, DateTime moment, int offset, string culture);
#endregion
#region Log and Task
/// <summary>Add a log</summary>
/// <param name="level">The log level</param>
/// <param name="message">The log message</param>
/// <param name="error">The log error</param>
/// <param name="comment">The log comment</param>
void AddLog(int level, string message, string error = null, string comment = null);
/// <summary>Add task</summary>
/// <param name="name">The task name</param>
/// <param name="instruction">The task instruction</param>
/// <param name="scheduleDate">The task schedule date</param>
/// <param name="category">The task category</param>
/// <param name="attributes">The task attributes</param>
void AddTask(string name, string instruction, DateTime scheduleDate, string category,
Dictionary<string, object> attributes = null);
#endregion
#region Webhook
/// <summary>Invoke case relation webhook and receive the response JSON data</summary>
/// <param name="requestOperation">The request operation</param>
/// <param name="requestMessage">The JSON request message</param>
/// <returns>The webhook response object as JSON</returns>
string InvokeWebhook(string requestOperation, string requestMessage = null);
#endregion
}